Context
stringlengths
285
6.98k
file_name
stringlengths
21
79
start
int64
14
184
end
int64
18
184
theorem
stringlengths
25
1.34k
proof
stringlengths
5
3.43k
/- Copyright (c) 2022 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.MonoidAlgebra.Basic #align_import algebra.monoid_algebra.division from "leanprover-community/mathlib"@"72c366d0475675f1309d3027d3d7d47ee4423951" /-! # Division of `AddMonoidAlgebra` by monomials This file is most important for when `G = ℕ` (polynomials) or `G = σ →₀ ℕ` (multivariate polynomials). In order to apply in maximal generality (such as for `LaurentPolynomial`s), this uses `∃ d, g' = g + d` in many places instead of `g ≤ g'`. ## Main definitions * `AddMonoidAlgebra.divOf x g`: divides `x` by the monomial `AddMonoidAlgebra.of k G g` * `AddMonoidAlgebra.modOf x g`: the remainder upon dividing `x` by the monomial `AddMonoidAlgebra.of k G g`. ## Main results * `AddMonoidAlgebra.divOf_add_modOf`, `AddMonoidAlgebra.modOf_add_divOf`: `divOf` and `modOf` are well-behaved as quotient and remainder operators. ## Implementation notes `∃ d, g' = g + d` is used as opposed to some other permutation up to commutativity in order to match the definition of `semigroupDvd`. The results in this file could be duplicated for `MonoidAlgebra` by using `g ∣ g'`, but this can't be done automatically, and in any case is not likely to be very useful. -/ variable {k G : Type*} [Semiring k] namespace AddMonoidAlgebra section variable [AddCancelCommMonoid G] /-- Divide by `of' k G g`, discarding terms not divisible by this. -/ noncomputable def divOf (x : k[G]) (g : G) : k[G] := -- note: comapping by `+ g` has the effect of subtracting `g` from every element in -- the support, and discarding the elements of the support from which `g` can't be subtracted. -- If `G` is an additive group, such as `ℤ` when used for `LaurentPolynomial`, -- then no discarding occurs. @Finsupp.comapDomain.addMonoidHom _ _ _ _ (g + ·) (add_right_injective g) x #align add_monoid_algebra.div_of AddMonoidAlgebra.divOf local infixl:70 " /ᵒᶠ " => divOf @[simp] theorem divOf_apply (g : G) (x : k[G]) (g' : G) : (x /ᵒᶠ g) g' = x (g + g') := rfl #align add_monoid_algebra.div_of_apply AddMonoidAlgebra.divOf_apply @[simp] theorem support_divOf (g : G) (x : k[G]) : (x /ᵒᶠ g).support = x.support.preimage (g + ·) (Function.Injective.injOn (add_right_injective g)) := rfl #align add_monoid_algebra.support_div_of AddMonoidAlgebra.support_divOf @[simp] theorem zero_divOf (g : G) : (0 : k[G]) /ᵒᶠ g = 0 := map_zero (Finsupp.comapDomain.addMonoidHom _) #align add_monoid_algebra.zero_div_of AddMonoidAlgebra.zero_divOf @[simp] theorem divOf_zero (x : k[G]) : x /ᵒᶠ 0 = x := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work simp only [AddMonoidAlgebra.divOf_apply, zero_add] #align add_monoid_algebra.div_of_zero AddMonoidAlgebra.divOf_zero theorem add_divOf (x y : k[G]) (g : G) : (x + y) /ᵒᶠ g = x /ᵒᶠ g + y /ᵒᶠ g := map_add (Finsupp.comapDomain.addMonoidHom _) _ _ #align add_monoid_algebra.add_div_of AddMonoidAlgebra.add_divOf theorem divOf_add (x : k[G]) (a b : G) : x /ᵒᶠ (a + b) = x /ᵒᶠ a /ᵒᶠ b := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work simp only [AddMonoidAlgebra.divOf_apply, add_assoc] #align add_monoid_algebra.div_of_add AddMonoidAlgebra.divOf_add /-- A bundled version of `AddMonoidAlgebra.divOf`. -/ @[simps] noncomputable def divOfHom : Multiplicative G →* AddMonoid.End k[G] where toFun g := { toFun := fun x => divOf x (Multiplicative.toAdd g) map_zero' := zero_divOf _ map_add' := fun x y => add_divOf x y (Multiplicative.toAdd g) } map_one' := AddMonoidHom.ext divOf_zero map_mul' g₁ g₂ := AddMonoidHom.ext fun _x => (congr_arg _ (add_comm (Multiplicative.toAdd g₁) (Multiplicative.toAdd g₂))).trans (divOf_add _ _ _) #align add_monoid_algebra.div_of_hom AddMonoidAlgebra.divOfHom theorem of'_mul_divOf (a : G) (x : k[G]) : of' k G a * x /ᵒᶠ a = x := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work rw [AddMonoidAlgebra.divOf_apply, of'_apply, single_mul_apply_aux, one_mul] intro c exact add_right_inj _ #align add_monoid_algebra.of'_mul_div_of AddMonoidAlgebra.of'_mul_divOf theorem mul_of'_divOf (x : k[G]) (a : G) : x * of' k G a /ᵒᶠ a = x := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work rw [AddMonoidAlgebra.divOf_apply, of'_apply, mul_single_apply_aux, mul_one] intro c rw [add_comm] exact add_right_inj _ #align add_monoid_algebra.mul_of'_div_of AddMonoidAlgebra.mul_of'_divOf
Mathlib/Algebra/MonoidAlgebra/Division.lean
120
121
theorem of'_divOf (a : G) : of' k G a /ᵒᶠ a = 1 := by
simpa only [one_mul] using mul_of'_divOf (1 : k[G]) a
/- 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.Matrix.Reindex import Mathlib.LinearAlgebra.Matrix.ToLin #align_import linear_algebra.matrix.basis from "leanprover-community/mathlib"@"6c263e4bfc2e6714de30f22178b4d0ca4d149a76" /-! # Bases and matrices This file defines the map `Basis.toMatrix` that sends a family of vectors to the matrix of their coordinates with respect to some basis. ## Main definitions * `Basis.toMatrix e v` is the matrix whose `i, j`th entry is `e.repr (v j) i` * `basis.toMatrixEquiv` is `Basis.toMatrix` bundled as a linear equiv ## Main results * `LinearMap.toMatrix_id_eq_basis_toMatrix`: `LinearMap.toMatrix b c id` is equal to `Basis.toMatrix b c` * `Basis.toMatrix_mul_toMatrix`: multiplying `Basis.toMatrix` with another `Basis.toMatrix` gives a `Basis.toMatrix` ## Tags matrix, basis -/ noncomputable section open LinearMap Matrix Set Submodule open Matrix section BasisToMatrix variable {ι ι' κ κ' : Type*} variable {R M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] variable {R₂ M₂ : Type*} [CommRing R₂] [AddCommGroup M₂] [Module R₂ M₂] open Function Matrix /-- From a basis `e : ι → M` and a family of vectors `v : ι' → M`, make the matrix whose columns are the vectors `v i` written in the basis `e`. -/ def Basis.toMatrix (e : Basis ι R M) (v : ι' → M) : Matrix ι ι' R := fun i j => e.repr (v j) i #align basis.to_matrix Basis.toMatrix variable (e : Basis ι R M) (v : ι' → M) (i : ι) (j : ι') namespace Basis theorem toMatrix_apply : e.toMatrix v i j = e.repr (v j) i := rfl #align basis.to_matrix_apply Basis.toMatrix_apply theorem toMatrix_transpose_apply : (e.toMatrix v)ᵀ j = e.repr (v j) := funext fun _ => rfl #align basis.to_matrix_transpose_apply Basis.toMatrix_transpose_apply theorem toMatrix_eq_toMatrix_constr [Fintype ι] [DecidableEq ι] (v : ι → M) : e.toMatrix v = LinearMap.toMatrix e e (e.constr ℕ v) := by ext rw [Basis.toMatrix_apply, LinearMap.toMatrix_apply, Basis.constr_basis] #align basis.to_matrix_eq_to_matrix_constr Basis.toMatrix_eq_toMatrix_constr -- TODO (maybe) Adjust the definition of `Basis.toMatrix` to eliminate the transpose.
Mathlib/LinearAlgebra/Matrix/Basis.lean
73
76
theorem coePiBasisFun.toMatrix_eq_transpose [Finite ι] : ((Pi.basisFun R ι).toMatrix : Matrix ι ι R → Matrix ι ι R) = Matrix.transpose := by
ext M i j rfl
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Nilpotent import Mathlib.Algebra.Lie.Normalizer #align_import algebra.lie.engel from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90" /-! # Engel's theorem This file contains a proof of Engel's theorem providing necessary and sufficient conditions for Lie algebras and Lie modules to be nilpotent. The key result `LieModule.isNilpotent_iff_forall` says that if `M` is a Lie module of a Noetherian Lie algebra `L`, then `M` is nilpotent iff the image of `L → End(M)` consists of nilpotent elements. In the special case that we have the adjoint representation `M = L`, this says that a Lie algebra is nilpotent iff `ad x : End(L)` is nilpotent for all `x : L`. Engel's theorem is true for any coefficients (i.e., it is really a theorem about Lie rings) and so we work with coefficients in any commutative ring `R` throughout. On the other hand, Engel's theorem is not true for infinite-dimensional Lie algebras and so a finite-dimensionality assumption is required. We prove the theorem subject to the assumption that the Lie algebra is Noetherian as an `R`-module, though actually we only need the slightly weaker property that the relation `>` is well-founded on the complete lattice of Lie subalgebras. ## Remarks about the proof Engel's theorem is usually proved in the special case that the coefficients are a field, and uses an inductive argument on the dimension of the Lie algebra. One begins by choosing either a maximal proper Lie subalgebra (in some proofs) or a maximal nilpotent Lie subalgebra (in other proofs, at the cost of obtaining a weaker end result). Since we work with general coefficients, we cannot induct on dimension and an alternate approach must be taken. The key ingredient is the concept of nilpotency, not just for Lie algebras, but for Lie modules. Using this concept, we define an _Engelian Lie algebra_ `LieAlgebra.IsEngelian` to be one for which a Lie module is nilpotent whenever the action consists of nilpotent endomorphisms. The argument then proceeds by selecting a maximal Engelian Lie subalgebra and showing that it cannot be proper. The first part of the traditional statement of Engel's theorem consists of the statement that if `M` is a non-trivial `R`-module and `L ⊆ End(M)` is a finite-dimensional Lie subalgebra of nilpotent elements, then there exists a non-zero element `m : M` that is annihilated by every element of `L`. This follows trivially from the result established here `LieModule.isNilpotent_iff_forall`, that `M` is a nilpotent Lie module over `L`, since the last non-zero term in the lower central series will consist of such elements `m` (see: `LieModule.nontrivial_max_triv_of_isNilpotent`). It seems that this result has not previously been established at this level of generality. The second part of the traditional statement of Engel's theorem concerns nilpotency of the Lie algebra and a proof of this for general coefficients appeared in the literature as long ago [as 1937](zorn1937). This also follows trivially from `LieModule.isNilpotent_iff_forall` simply by taking `M = L`. It is pleasing that the two parts of the traditional statements of Engel's theorem are thus unified into a single statement about nilpotency of Lie modules. This is not usually emphasised. ## Main definitions * `LieAlgebra.IsEngelian` * `LieAlgebra.isEngelian_of_isNoetherian` * `LieModule.isNilpotent_iff_forall` * `LieAlgebra.isNilpotent_iff_forall` -/ universe u₁ u₂ u₃ u₄ variable {R : Type u₁} {L : Type u₂} {L₂ : Type u₃} {M : Type u₄} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L₂] [LieAlgebra R L₂] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieSubmodule open LieModule variable {I : LieIdeal R L} {x : L} (hxI : (R ∙ x) ⊔ I = ⊤)
Mathlib/Algebra/Lie/Engel.lean
82
86
theorem exists_smul_add_of_span_sup_eq_top (y : L) : ∃ t : R, ∃ z ∈ I, y = t • x + z := by
have hy : y ∈ (⊤ : Submodule R L) := Submodule.mem_top simp only [← hxI, Submodule.mem_sup, Submodule.mem_span_singleton] at hy obtain ⟨-, ⟨t, rfl⟩, z, hz, rfl⟩ := hy exact ⟨t, z, hz, rfl⟩
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.Deriv.Slope import Mathlib.MeasureTheory.Covering.OneDim import Mathlib.Order.Monotone.Extension #align_import analysis.calculus.monotone from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Differentiability of monotone functions We show that a monotone function `f : ℝ → ℝ` is differentiable almost everywhere, in `Monotone.ae_differentiableAt`. (We also give a version for a function monotone on a set, in `MonotoneOn.ae_differentiableWithinAt`.) If the function `f` is continuous, this follows directly from general differentiation of measure theorems. Let `μ` be the Stieltjes measure associated to `f`. Then, almost everywhere, `μ [x, y] / Leb [x, y]` (resp. `μ [y, x] / Leb [y, x]`) converges to the Radon-Nikodym derivative of `μ` with respect to Lebesgue when `y` tends to `x` in `(x, +∞)` (resp. `(-∞, x)`), by `VitaliFamily.ae_tendsto_rnDeriv`. As `μ [x, y] = f y - f x` and `Leb [x, y] = y - x`, this gives differentiability right away. When `f` is only monotone, the same argument works up to small adjustments, as the associated Stieltjes measure satisfies `μ [x, y] = f (y^+) - f (x^-)` (the right and left limits of `f` at `y` and `x` respectively). One argues that `f (x^-) = f x` almost everywhere (in fact away from a countable set), and moreover `f ((y - (y-x)^2)^+) ≤ f y ≤ f (y^+)`. This is enough to deduce the limit of `(f y - f x) / (y - x)` by a lower and upper approximation argument from the known behavior of `μ [x, y]`. -/ open Set Filter Function Metric MeasureTheory MeasureTheory.Measure IsUnifLocDoublingMeasure open scoped Topology /-- If `(f y - f x) / (y - x)` converges to a limit as `y` tends to `x`, then the same goes if `y` is shifted a little bit, i.e., `f (y + (y-x)^2) - f x) / (y - x)` converges to the same limit. This lemma contains a slightly more general version of this statement (where one considers convergence along some subfilter, typically `𝓝[<] x` or `𝓝[>] x`) tailored to the application to almost everywhere differentiability of monotone functions. -/
Mathlib/Analysis/Calculus/Monotone.lean
44
62
theorem tendsto_apply_add_mul_sq_div_sub {f : ℝ → ℝ} {x a c d : ℝ} {l : Filter ℝ} (hl : l ≤ 𝓝[≠] x) (hf : Tendsto (fun y => (f y - d) / (y - x)) l (𝓝 a)) (h' : Tendsto (fun y => y + c * (y - x) ^ 2) l l) : Tendsto (fun y => (f (y + c * (y - x) ^ 2) - d) / (y - x)) l (𝓝 a) := by
have L : Tendsto (fun y => (y + c * (y - x) ^ 2 - x) / (y - x)) l (𝓝 1) := by have : Tendsto (fun y => 1 + c * (y - x)) l (𝓝 (1 + c * (x - x))) := by apply Tendsto.mono_left _ (hl.trans nhdsWithin_le_nhds) exact ((tendsto_id.sub_const x).const_mul c).const_add 1 simp only [_root_.sub_self, add_zero, mul_zero] at this apply Tendsto.congr' (Eventually.filter_mono hl _) this filter_upwards [self_mem_nhdsWithin] with y hy field_simp [sub_ne_zero.2 hy] ring have Z := (hf.comp h').mul L rw [mul_one] at Z apply Tendsto.congr' _ Z have : ∀ᶠ y in l, y + c * (y - x) ^ 2 ≠ x := by apply Tendsto.mono_right h' hl self_mem_nhdsWithin filter_upwards [this] with y hy field_simp [sub_ne_zero.2 hy]
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Data.Multiset.Bind #align_import data.multiset.pi from "leanprover-community/mathlib"@"b2c89893177f66a48daf993b7ba5ef7cddeff8c9" /-! # The cartesian product of multisets -/ namespace Multiset section Pi variable {α : Type*} open Function /-- Given `δ : α → Type*`, `Pi.empty δ` is the trivial dependent function out of the empty multiset. -/ def Pi.empty (δ : α → Sort*) : ∀ a ∈ (0 : Multiset α), δ a := nofun #align multiset.pi.empty Multiset.Pi.empty universe u v variable [DecidableEq α] {β : α → Type u} {δ : α → Sort v} /-- Given `δ : α → Type*`, a multiset `m` and a term `a`, as well as a term `b : δ a` and a function `f` such that `f a' : δ a'` for all `a'` in `m`, `Pi.cons m a b f` is a function `g` such that `g a'' : δ a''` for all `a''` in `a ::ₘ m`. -/ def Pi.cons (m : Multiset α) (a : α) (b : δ a) (f : ∀ a ∈ m, δ a) : ∀ a' ∈ a ::ₘ m, δ a' := fun a' ha' => if h : a' = a then Eq.ndrec b h.symm else f a' <| (mem_cons.1 ha').resolve_left h #align multiset.pi.cons Multiset.Pi.cons theorem Pi.cons_same {m : Multiset α} {a : α} {b : δ a} {f : ∀ a ∈ m, δ a} (h : a ∈ a ::ₘ m) : Pi.cons m a b f a h = b := dif_pos rfl #align multiset.pi.cons_same Multiset.Pi.cons_same theorem Pi.cons_ne {m : Multiset α} {a a' : α} {b : δ a} {f : ∀ a ∈ m, δ a} (h' : a' ∈ a ::ₘ m) (h : a' ≠ a) : Pi.cons m a b f a' h' = f a' ((mem_cons.1 h').resolve_left h) := dif_neg h #align multiset.pi.cons_ne Multiset.Pi.cons_ne theorem Pi.cons_swap {a a' : α} {b : δ a} {b' : δ a'} {m : Multiset α} {f : ∀ a ∈ m, δ a} (h : a ≠ a') : HEq (Pi.cons (a' ::ₘ m) a b (Pi.cons m a' b' f)) (Pi.cons (a ::ₘ m) a' b' (Pi.cons m a b f)) := by apply hfunext rfl simp only [heq_iff_eq] rintro a'' _ rfl refine hfunext (by rw [Multiset.cons_swap]) fun ha₁ ha₂ _ => ?_ rcases ne_or_eq a'' a with (h₁ | rfl) on_goal 1 => rcases eq_or_ne a'' a' with (rfl | h₂) all_goals simp [*, Pi.cons_same, Pi.cons_ne] #align multiset.pi.cons_swap Multiset.Pi.cons_swap @[simp, nolint simpNF] -- Porting note: false positive, this lemma can prove itself
Mathlib/Data/Multiset/Pi.lean
62
68
theorem pi.cons_eta {m : Multiset α} {a : α} (f : ∀ a' ∈ a ::ₘ m, δ a') : (Pi.cons m a (f _ (mem_cons_self _ _)) fun a' ha' => f a' (mem_cons_of_mem ha')) = f := by
ext a' h' by_cases h : a' = a · subst h rw [Pi.cons_same] · rw [Pi.cons_ne _ 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 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] /-- The **rank-nullity theorem** for commutative domains. Also see `rank_quotient_add_rank`. -/
Mathlib/LinearAlgebra/Dimension/Localization.lean
96
102
theorem rank_quotient_add_rank_of_isDomain [IsDomain R] (M' : Submodule R M) : Module.rank R (M ⧸ M') + Module.rank R M' = Module.rank R M := by
apply lift_injective.{max u v} rw [lift_add, ← IsLocalizedModule.lift_rank_eq (FractionRing R) R⁰ (M'.toLocalized R⁰) le_rfl, ← IsLocalizedModule.lift_rank_eq (FractionRing R) R⁰ (LocalizedModule.mkLinearMap R⁰ M) le_rfl, ← IsLocalizedModule.lift_rank_eq (FractionRing R) R⁰ (M'.toLocalizedQuotient R⁰) le_rfl, ← lift_add, rank_quotient_add_rank_of_divisionRing]
/- Copyright (c) 2023 Mark Andrew Gerads. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mark Andrew Gerads, Junyan Xu, Eric Wieser -/ import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Tactic.Ring #align_import data.nat.hyperoperation from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Hyperoperation sequence This file defines the Hyperoperation sequence. `hyperoperation 0 m k = k + 1` `hyperoperation 1 m k = m + k` `hyperoperation 2 m k = m * k` `hyperoperation 3 m k = m ^ k` `hyperoperation (n + 3) m 0 = 1` `hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k)` ## References * <https://en.wikipedia.org/wiki/Hyperoperation> ## Tags hyperoperation -/ /-- Implementation of the hyperoperation sequence where `hyperoperation n m k` is the `n`th hyperoperation between `m` and `k`. -/ def hyperoperation : ℕ → ℕ → ℕ → ℕ | 0, _, k => k + 1 | 1, m, 0 => m | 2, _, 0 => 0 | _ + 3, _, 0 => 1 | n + 1, m, k + 1 => hyperoperation n m (hyperoperation (n + 1) m k) #align hyperoperation hyperoperation -- Basic hyperoperation lemmas @[simp] theorem hyperoperation_zero (m : ℕ) : hyperoperation 0 m = Nat.succ := funext fun k => by rw [hyperoperation, Nat.succ_eq_add_one] #align hyperoperation_zero hyperoperation_zero theorem hyperoperation_ge_three_eq_one (n m : ℕ) : hyperoperation (n + 3) m 0 = 1 := by rw [hyperoperation] #align hyperoperation_ge_three_eq_one hyperoperation_ge_three_eq_one
Mathlib/Data/Nat/Hyperoperation.lean
53
55
theorem hyperoperation_recursion (n m k : ℕ) : hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k) := by
rw [hyperoperation]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Nat import Mathlib.Data.Set.Basic import Mathlib.Tactic.Common #align_import data.set.enumerate from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" /-! # Set enumeration This file allows enumeration of sets given a choice function. The definition does not assume `sel` actually is a choice function, i.e. `sel s ∈ s` and `sel s = none ↔ s = ∅`. These assumptions are added to the lemmas needing them. -/ noncomputable section open Function namespace Set section Enumerate /- Porting note: The original used parameters -/ variable {α : Type*} (sel : Set α → Option α) /-- Given a choice function `sel`, enumerates the elements of a set in the order `a 0 = sel s`, `a 1 = sel (s \ {a 0})`, `a 2 = sel (s \ {a 0, a 1})`, ... and stops when `sel (s \ {a 0, ..., a n}) = none`. Note that we don't require `sel` to be a choice function. -/ def enumerate : Set α → ℕ → Option α | s, 0 => sel s | s, n + 1 => do let a ← sel s enumerate (s \ {a}) n #align set.enumerate Set.enumerate theorem enumerate_eq_none_of_sel {s : Set α} (h : sel s = none) : ∀ {n}, enumerate sel s n = none | 0 => by simp [h, enumerate] | n + 1 => by simp [h, enumerate] #align set.enumerate_eq_none_of_sel Set.enumerate_eq_none_of_sel theorem enumerate_eq_none : ∀ {s n₁ n₂}, enumerate sel s n₁ = none → n₁ ≤ n₂ → enumerate sel s n₂ = none | s, 0, m => fun h _ ↦ enumerate_eq_none_of_sel sel h | s, n + 1, m => fun h hm ↦ by cases hs : sel s · exact enumerate_eq_none_of_sel sel hs · cases m with | zero => contradiction | succ m' => simp? [hs, enumerate] at h ⊢ says simp only [enumerate, hs, Option.bind_eq_bind, Option.some_bind] at h ⊢ have hm : n ≤ m' := Nat.le_of_succ_le_succ hm exact enumerate_eq_none h hm #align set.enumerate_eq_none Set.enumerate_eq_none theorem enumerate_mem (h_sel : ∀ s a, sel s = some a → a ∈ s) : ∀ {s n a}, enumerate sel s n = some a → a ∈ s | s, 0, a => h_sel s a | s, n + 1, a => by cases h : sel s with | none => simp [enumerate_eq_none_of_sel, h] | some a' => simp only [enumerate, h, Nat.add_eq, add_zero] exact fun h' : enumerate sel (s \ {a'}) n = some a ↦ have : a ∈ s \ {a'} := enumerate_mem h_sel h' this.left #align set.enumerate_mem Set.enumerate_mem
Mathlib/Data/Set/Enumerate.lean
75
101
theorem enumerate_inj {n₁ n₂ : ℕ} {a : α} {s : Set α} (h_sel : ∀ s a, sel s = some a → a ∈ s) (h₁ : enumerate sel s n₁ = some a) (h₂ : enumerate sel s n₂ = some a) : n₁ = n₂ := by
/- Porting note: The `rcase, on_goal, all_goals` has been used instead of the not-yet-ported `wlog` -/ rcases le_total n₁ n₂ with (hn|hn) on_goal 2 => swap_var n₁ ↔ n₂, h₁ ↔ h₂ all_goals rcases Nat.le.dest hn with ⟨m, rfl⟩ clear hn induction n₁ generalizing s with | zero => cases m with | zero => rfl | succ m => have h' : enumerate sel (s \ {a}) m = some a := by simp_all only [enumerate, Nat.zero_eq, Nat.add_eq, zero_add]; exact h₂ have : a ∈ s \ {a} := enumerate_mem sel h_sel h' simp_all [Set.mem_diff_singleton] | succ k ih => cases h : sel s with /- Porting note: The original covered both goals with just `simp_all <;> tauto` -/ | none => simp_all only [add_comm, self_eq_add_left, Nat.add_succ, enumerate_eq_none_of_sel _ h] | some => simp_all only [add_comm, self_eq_add_left, enumerate, Option.some.injEq, Nat.add_succ, Nat.succ.injEq] exact ih h₁ h₂
/- 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, Yaël Dillies -/ import Mathlib.Order.PartialSups #align_import order.disjointed from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Consecutive differences of sets This file defines the way to make a sequence of elements into a sequence of disjoint elements with the same partial sups. For a sequence `f : ℕ → α`, this new sequence will be `f 0`, `f 1 \ f 0`, `f 2 \ (f 0 ⊔ f 1)`. It is actually unique, as `disjointed_unique` shows. ## Main declarations * `disjointed f`: The sequence `f 0`, `f 1 \ f 0`, `f 2 \ (f 0 ⊔ f 1)`, .... * `partialSups_disjointed`: `disjointed f` has the same partial sups as `f`. * `disjoint_disjointed`: The elements of `disjointed f` are pairwise disjoint. * `disjointed_unique`: `disjointed f` is the only pairwise disjoint sequence having the same partial sups as `f`. * `iSup_disjointed`: `disjointed f` has the same supremum as `f`. Limiting case of `partialSups_disjointed`. We also provide set notation variants of some lemmas. ## TODO Find a useful statement of `disjointedRec_succ`. One could generalize `disjointed` to any locally finite bot preorder domain, in place of `ℕ`. Related to the TODO in the module docstring of `Mathlib.Order.PartialSups`. -/ variable {α β : Type*} section GeneralizedBooleanAlgebra variable [GeneralizedBooleanAlgebra α] /-- If `f : ℕ → α` is a sequence of elements, then `disjointed f` is the sequence formed by subtracting each element from the nexts. This is the unique disjoint sequence whose partial sups are the same as the original sequence. -/ def disjointed (f : ℕ → α) : ℕ → α | 0 => f 0 | n + 1 => f (n + 1) \ partialSups f n #align disjointed disjointed @[simp] theorem disjointed_zero (f : ℕ → α) : disjointed f 0 = f 0 := rfl #align disjointed_zero disjointed_zero theorem disjointed_succ (f : ℕ → α) (n : ℕ) : disjointed f (n + 1) = f (n + 1) \ partialSups f n := rfl #align disjointed_succ disjointed_succ
Mathlib/Order/Disjointed.lean
63
67
theorem disjointed_le_id : disjointed ≤ (id : (ℕ → α) → ℕ → α) := by
rintro f n cases n · rfl · exact sdiff_le
/- Copyright (c) 2020 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker, Alexey Soloyev, Junyan Xu, Kamila Szewczyk -/ import Mathlib.Data.Real.Irrational import Mathlib.Data.Nat.Fib.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Algebra.LinearRecurrence import Mathlib.Tactic.NormNum.NatFib import Mathlib.Tactic.NormNum.Prime #align_import data.real.golden_ratio from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # The golden ratio and its conjugate This file defines the golden ratio `φ := (1 + √5)/2` and its conjugate `ψ := (1 - √5)/2`, which are the two real roots of `X² - X - 1`. Along with various computational facts about them, we prove their irrationality, and we link them to the Fibonacci sequence by proving Binet's formula. -/ noncomputable section open Polynomial /-- The golden ratio `φ := (1 + √5)/2`. -/ abbrev goldenRatio : ℝ := (1 + √5) / 2 #align golden_ratio goldenRatio /-- The conjugate of the golden ratio `ψ := (1 - √5)/2`. -/ abbrev goldenConj : ℝ := (1 - √5) / 2 #align golden_conj goldenConj @[inherit_doc goldenRatio] scoped[goldenRatio] notation "φ" => goldenRatio @[inherit_doc goldenConj] scoped[goldenRatio] notation "ψ" => goldenConj open Real goldenRatio /-- The inverse of the golden ratio is the opposite of its conjugate. -/ theorem inv_gold : φ⁻¹ = -ψ := by have : 1 + √5 ≠ 0 := ne_of_gt (add_pos (by norm_num) <| Real.sqrt_pos.mpr (by norm_num)) field_simp [sub_mul, mul_add] norm_num #align inv_gold inv_gold /-- The opposite of the golden ratio is the inverse of its conjugate. -/ theorem inv_goldConj : ψ⁻¹ = -φ := by rw [inv_eq_iff_eq_inv, ← neg_inv, ← neg_eq_iff_eq_neg] exact inv_gold.symm #align inv_gold_conj inv_goldConj @[simp] theorem gold_mul_goldConj : φ * ψ = -1 := by field_simp rw [← sq_sub_sq] norm_num #align gold_mul_gold_conj gold_mul_goldConj @[simp] theorem goldConj_mul_gold : ψ * φ = -1 := by rw [mul_comm] exact gold_mul_goldConj #align gold_conj_mul_gold goldConj_mul_gold @[simp] theorem gold_add_goldConj : φ + ψ = 1 := by rw [goldenRatio, goldenConj] ring #align gold_add_gold_conj gold_add_goldConj theorem one_sub_goldConj : 1 - φ = ψ := by linarith [gold_add_goldConj] #align one_sub_gold_conj one_sub_goldConj theorem one_sub_gold : 1 - ψ = φ := by linarith [gold_add_goldConj] #align one_sub_gold one_sub_gold @[simp] theorem gold_sub_goldConj : φ - ψ = √5 := by ring #align gold_sub_gold_conj gold_sub_goldConj theorem gold_pow_sub_gold_pow (n : ℕ) : φ ^ (n + 2) - φ ^ (n + 1) = φ ^ n := by rw [goldenRatio]; ring_nf; norm_num; ring @[simp 1200] theorem gold_sq : φ ^ 2 = φ + 1 := by rw [goldenRatio, ← sub_eq_zero] ring_nf rw [Real.sq_sqrt] <;> norm_num #align gold_sq gold_sq @[simp 1200] theorem goldConj_sq : ψ ^ 2 = ψ + 1 := by rw [goldenConj, ← sub_eq_zero] ring_nf rw [Real.sq_sqrt] <;> norm_num #align gold_conj_sq goldConj_sq theorem gold_pos : 0 < φ := mul_pos (by apply add_pos <;> norm_num) <| inv_pos.2 zero_lt_two #align gold_pos gold_pos theorem gold_ne_zero : φ ≠ 0 := ne_of_gt gold_pos #align gold_ne_zero gold_ne_zero theorem one_lt_gold : 1 < φ := by refine lt_of_mul_lt_mul_left ?_ (le_of_lt gold_pos) simp [← sq, gold_pos, zero_lt_one, - div_pow] -- Porting note: Added `- div_pow` #align one_lt_gold one_lt_gold
Mathlib/Data/Real/GoldenRatio.lean
117
119
theorem gold_lt_two : φ < 2 := by
calc (1 + sqrt 5) / 2 < (1 + 3) / 2 := by gcongr; rw [sqrt_lt'] <;> norm_num _ = 2 := by norm_num
/- 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.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Star.Unitary import Mathlib.Data.Nat.ModEq import Mathlib.NumberTheory.Zsqrtd.Basic import Mathlib.Tactic.Monotonicity #align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"795b501869b9fa7aa716d5fdadd00c03f983a605" /-! # Pell's equation and Matiyasevic's theorem This file solves Pell's equation, i.e. integer solutions to `x ^ 2 - d * y ^ 2 = 1` *in the special case that `d = a ^ 2 - 1`*. This is then applied to prove Matiyasevic's theorem that the power function is Diophantine, which is the last key ingredient in the solution to Hilbert's tenth problem. For the definition of Diophantine function, see `NumberTheory.Dioph`. For results on Pell's equation for arbitrary (positive, non-square) `d`, see `NumberTheory.Pell`. ## Main definition * `pell` is a function assigning to a natural number `n` the `n`-th solution to Pell's equation constructed recursively from the initial solution `(0, 1)`. ## Main statements * `eq_pell` shows that every solution to Pell's equation is recursively obtained using `pell` * `matiyasevic` shows that a certain system of Diophantine equations has a solution if and only if the first variable is the `x`-component in a solution to Pell's equation - the key step towards Hilbert's tenth problem in Davis' version of Matiyasevic's theorem. * `eq_pow_of_pell` shows that the power function is Diophantine. ## Implementation notes The proof of Matiyasevic's theorem doesn't follow Matiyasevic's original account of using Fibonacci numbers but instead Davis' variant of using solutions to Pell's equation. ## References * [M. Carneiro, _A Lean formalization of Matiyasevič's theorem_][carneiro2018matiyasevic] * [M. Davis, _Hilbert's tenth problem is unsolvable_][MR317916] ## Tags Pell's equation, Matiyasevic's theorem, Hilbert's tenth problem -/ namespace Pell open Nat section variable {d : ℤ} /-- The property of being a solution to the Pell equation, expressed as a property of elements of `ℤ√d`. -/ def IsPell : ℤ√d → Prop | ⟨x, y⟩ => x * x - d * y * y = 1 #align pell.is_pell Pell.IsPell theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1 | ⟨x, y⟩ => by simp [Zsqrtd.ext_iff, IsPell, mul_comm]; ring_nf #align pell.is_pell_norm Pell.isPell_norm theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d) | ⟨x, y⟩ => by rw [unitary.mem_iff, isPell_norm, mul_comm (star _), and_self_iff] #align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary theorem isPell_mul {b c : ℤ√d} (hb : IsPell b) (hc : IsPell c) : IsPell (b * c) := isPell_norm.2 (by simp [mul_comm, mul_left_comm c, mul_assoc, star_mul, isPell_norm.1 hb, isPell_norm.1 hc]) #align pell.is_pell_mul Pell.isPell_mul theorem isPell_star : ∀ {b : ℤ√d}, IsPell b ↔ IsPell (star b) | ⟨x, y⟩ => by simp [IsPell, Zsqrtd.star_mk] #align pell.is_pell_star Pell.isPell_star end section -- Porting note: was parameter in Lean3 variable {a : ℕ} (a1 : 1 < a) private def d (_a1 : 1 < a) := a * a - 1 @[simp] theorem d_pos : 0 < d a1 := tsub_pos_of_lt (mul_lt_mul a1 (le_of_lt a1) (by decide) (Nat.zero_le _) : 1 * 1 < a * a) #align pell.d_pos Pell.d_pos -- TODO(lint): Fix double namespace issue /-- The Pell sequences, i.e. the sequence of integer solutions to `x ^ 2 - d * y ^ 2 = 1`, where `d = a ^ 2 - 1`, defined together in mutual recursion. -/ --@[nolint dup_namespace] def pell : ℕ → ℕ × ℕ -- Porting note: used pattern matching because `Nat.recOn` is noncomputable | 0 => (1, 0) | n+1 => ((pell n).1 * a + d a1 * (pell n).2, (pell n).1 + (pell n).2 * a) #align pell.pell Pell.pell /-- The Pell `x` sequence. -/ def xn (n : ℕ) : ℕ := (pell a1 n).1 #align pell.xn Pell.xn /-- The Pell `y` sequence. -/ def yn (n : ℕ) : ℕ := (pell a1 n).2 #align pell.yn Pell.yn @[simp] theorem pell_val (n : ℕ) : pell a1 n = (xn a1 n, yn a1 n) := show pell a1 n = ((pell a1 n).1, (pell a1 n).2) from match pell a1 n with | (_, _) => rfl #align pell.pell_val Pell.pell_val @[simp] theorem xn_zero : xn a1 0 = 1 := rfl #align pell.xn_zero Pell.xn_zero @[simp] theorem yn_zero : yn a1 0 = 0 := rfl #align pell.yn_zero Pell.yn_zero @[simp] theorem xn_succ (n : ℕ) : xn a1 (n + 1) = xn a1 n * a + d a1 * yn a1 n := rfl #align pell.xn_succ Pell.xn_succ @[simp] theorem yn_succ (n : ℕ) : yn a1 (n + 1) = xn a1 n + yn a1 n * a := rfl #align pell.yn_succ Pell.yn_succ --@[simp] Porting note (#10618): `simp` can prove it theorem xn_one : xn a1 1 = a := by simp #align pell.xn_one Pell.xn_one --@[simp] Porting note (#10618): `simp` can prove it
Mathlib/NumberTheory/PellMatiyasevic.lean
155
155
theorem yn_one : yn a1 1 = 1 := by
simp
/- Copyright (c) 2022 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.Analysis.Calculus.BumpFunction.Basic import Mathlib.MeasureTheory.Integral.SetIntegral import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar #align_import analysis.calculus.bump_function_inner from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Normed bump function In this file we define `ContDiffBump.normed f μ` to be the bump function `f` normalized so that `∫ x, f.normed μ x ∂μ = 1` and prove some properties of this function. -/ noncomputable section open Function Filter Set Metric MeasureTheory FiniteDimensional Measure open scoped Topology namespace ContDiffBump variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [HasContDiffBump E] [MeasurableSpace E] {c : E} (f : ContDiffBump c) {x : E} {n : ℕ∞} {μ : Measure E} /-- A bump function normed so that `∫ x, f.normed μ x ∂μ = 1`. -/ protected def normed (μ : Measure E) : E → ℝ := fun x => f x / ∫ x, f x ∂μ #align cont_diff_bump.normed ContDiffBump.normed theorem normed_def {μ : Measure E} (x : E) : f.normed μ x = f x / ∫ x, f x ∂μ := rfl #align cont_diff_bump.normed_def ContDiffBump.normed_def theorem nonneg_normed (x : E) : 0 ≤ f.normed μ x := div_nonneg f.nonneg <| integral_nonneg f.nonneg' #align cont_diff_bump.nonneg_normed ContDiffBump.nonneg_normed theorem contDiff_normed {n : ℕ∞} : ContDiff ℝ n (f.normed μ) := f.contDiff.div_const _ #align cont_diff_bump.cont_diff_normed ContDiffBump.contDiff_normed theorem continuous_normed : Continuous (f.normed μ) := f.continuous.div_const _ #align cont_diff_bump.continuous_normed ContDiffBump.continuous_normed theorem normed_sub (x : E) : f.normed μ (c - x) = f.normed μ (c + x) := by simp_rw [f.normed_def, f.sub] #align cont_diff_bump.normed_sub ContDiffBump.normed_sub theorem normed_neg (f : ContDiffBump (0 : E)) (x : E) : f.normed μ (-x) = f.normed μ x := by simp_rw [f.normed_def, f.neg] #align cont_diff_bump.normed_neg ContDiffBump.normed_neg variable [BorelSpace E] [FiniteDimensional ℝ E] [IsLocallyFiniteMeasure μ] protected theorem integrable : Integrable f μ := f.continuous.integrable_of_hasCompactSupport f.hasCompactSupport #align cont_diff_bump.integrable ContDiffBump.integrable protected theorem integrable_normed : Integrable (f.normed μ) μ := f.integrable.div_const _ #align cont_diff_bump.integrable_normed ContDiffBump.integrable_normed variable [μ.IsOpenPosMeasure] theorem integral_pos : 0 < ∫ x, f x ∂μ := by refine (integral_pos_iff_support_of_nonneg f.nonneg' f.integrable).mpr ?_ rw [f.support_eq] exact measure_ball_pos μ c f.rOut_pos #align cont_diff_bump.integral_pos ContDiffBump.integral_pos theorem integral_normed : ∫ x, f.normed μ x ∂μ = 1 := by simp_rw [ContDiffBump.normed, div_eq_mul_inv, mul_comm (f _), ← smul_eq_mul, integral_smul] exact inv_mul_cancel f.integral_pos.ne' #align cont_diff_bump.integral_normed ContDiffBump.integral_normed
Mathlib/Analysis/Calculus/BumpFunction/Normed.lean
80
82
theorem support_normed_eq : Function.support (f.normed μ) = Metric.ball c f.rOut := by
unfold ContDiffBump.normed rw [support_div, f.support_eq, support_const f.integral_pos.ne', inter_univ]
/- Copyright (c) 2024 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Batteries.Data.List.Lemmas /-! # Basic properties of `List.eraseIdx` `List.eraseIdx l k` erases `k`-th element of `l : List α`. If `k ≥ length l`, then it returns `l`. -/ namespace List universe u v variable {α : Type u} {β : Type v} @[simp] theorem eraseIdx_zero (l : List α) : eraseIdx l 0 = tail l := by cases l <;> rfl theorem eraseIdx_eq_take_drop_succ : ∀ (l : List α) (i : Nat), l.eraseIdx i = l.take i ++ l.drop (i + 1) | nil, _ => by simp | a::l, 0 => by simp | a::l, i + 1 => by simp [eraseIdx_eq_take_drop_succ l i] theorem eraseIdx_sublist : ∀ (l : List α) (k : Nat), eraseIdx l k <+ l | [], _ => by simp | a::l, 0 => by simp | a::l, k + 1 => by simp [eraseIdx_sublist l k] theorem eraseIdx_subset (l : List α) (k : Nat) : eraseIdx l k ⊆ l := (eraseIdx_sublist l k).subset @[simp] theorem eraseIdx_eq_self : ∀ {l : List α} {k : Nat}, eraseIdx l k = l ↔ length l ≤ k | [], _ => by simp | a::l, 0 => by simp [(cons_ne_self _ _).symm] | a::l, k + 1 => by simp [eraseIdx_eq_self] alias ⟨_, eraseIdx_of_length_le⟩ := eraseIdx_eq_self theorem eraseIdx_append_of_lt_length {l : List α} {k : Nat} (hk : k < length l) (l' : List α) : eraseIdx (l ++ l') k = eraseIdx l k ++ l' := by rw [eraseIdx_eq_take_drop_succ, take_append_of_le_length, drop_append_of_le_length, eraseIdx_eq_take_drop_succ, append_assoc] all_goals omega
.lake/packages/batteries/Batteries/Data/List/EraseIdx.lean
49
55
theorem eraseIdx_append_of_length_le {l : List α} {k : Nat} (hk : length l ≤ k) (l' : List α) : eraseIdx (l ++ l') k = l ++ eraseIdx l' (k - length l) := by
rw [eraseIdx_eq_take_drop_succ, eraseIdx_eq_take_drop_succ, take_append_eq_append_take, drop_append_eq_append_drop, take_all_of_le hk, drop_eq_nil_of_le (by omega), nil_append, append_assoc] congr omega
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Finset.Image import Mathlib.Data.List.FinRange #align_import data.fintype.basic from "leanprover-community/mathlib"@"d78597269638367c3863d40d45108f52207e03cf" /-! # Finite types This file defines a typeclass to state that a type is finite. ## Main declarations * `Fintype α`: Typeclass saying that a type is finite. It takes as fields a `Finset` and a proof that all terms of type `α` are in it. * `Finset.univ`: The finset of all elements of a fintype. See `Data.Fintype.Card` for the cardinality of a fintype, the equivalence with `Fin (Fintype.card α)`, and pigeonhole principles. ## Instances Instances for `Fintype` for * `{x // p x}` are in this file as `Fintype.subtype` * `Option α` are in `Data.Fintype.Option` * `α × β` are in `Data.Fintype.Prod` * `α ⊕ β` are in `Data.Fintype.Sum` * `Σ (a : α), β a` are in `Data.Fintype.Sigma` These files also contain appropriate `Infinite` instances for these types. `Infinite` instances for `ℕ`, `ℤ`, `Multiset α`, and `List α` are in `Data.Fintype.Lattice`. Types which have a surjection from/an injection to a `Fintype` are themselves fintypes. See `Fintype.ofInjective` and `Fintype.ofSurjective`. -/ assert_not_exists MonoidWithZero assert_not_exists MulAction open Function open Nat universe u v variable {α β γ : Type*} /-- `Fintype α` means that `α` is finite, i.e. there are only finitely many distinct elements of type `α`. The evidence of this is a finset `elems` (a list up to permutation without duplicates), together with a proof that everything of type `α` is in the list. -/ class Fintype (α : Type*) where /-- The `Finset` containing all elements of a `Fintype` -/ elems : Finset α /-- A proof that `elems` contains every element of the type -/ complete : ∀ x : α, x ∈ elems #align fintype Fintype namespace Finset variable [Fintype α] {s t : Finset α} /-- `univ` is the universal finite set of type `Finset α` implied from the assumption `Fintype α`. -/ def univ : Finset α := @Fintype.elems α _ #align finset.univ Finset.univ @[simp] theorem mem_univ (x : α) : x ∈ (univ : Finset α) := Fintype.complete x #align finset.mem_univ Finset.mem_univ -- Porting note: removing @[simp], simp can prove it theorem mem_univ_val : ∀ x, x ∈ (univ : Finset α).1 := mem_univ #align finset.mem_univ_val Finset.mem_univ_val theorem eq_univ_iff_forall : s = univ ↔ ∀ x, x ∈ s := by simp [ext_iff] #align finset.eq_univ_iff_forall Finset.eq_univ_iff_forall theorem eq_univ_of_forall : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2 #align finset.eq_univ_of_forall Finset.eq_univ_of_forall @[simp, norm_cast] theorem coe_univ : ↑(univ : Finset α) = (Set.univ : Set α) := by ext; simp #align finset.coe_univ Finset.coe_univ @[simp, norm_cast]
Mathlib/Data/Fintype/Basic.lean
96
96
theorem coe_eq_univ : (s : Set α) = Set.univ ↔ s = univ := by
rw [← coe_univ, coe_inj]
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Topology.MetricSpace.IsometricSMul #align_import topology.metric_space.hausdorff_distance from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156" /-! # Hausdorff distance The Hausdorff distance on subsets of a metric (or emetric) space. Given two subsets `s` and `t` of a metric space, their Hausdorff distance is the smallest `d` such that any point `s` is within `d` of a point in `t`, and conversely. This quantity is often infinite (think of `s` bounded and `t` unbounded), and therefore better expressed in the setting of emetric spaces. ## Main definitions This files introduces: * `EMetric.infEdist x s`, the infimum edistance of a point `x` to a set `s` in an emetric space * `EMetric.hausdorffEdist s t`, the Hausdorff edistance of two sets in an emetric space * Versions of these notions on metric spaces, called respectively `Metric.infDist` and `Metric.hausdorffDist` ## Main results * `infEdist_closure`: the edistance to a set and its closure coincide * `EMetric.mem_closure_iff_infEdist_zero`: a point `x` belongs to the closure of `s` iff `infEdist x s = 0` * `IsCompact.exists_infEdist_eq_edist`: if `s` is compact and non-empty, there exists a point `y` which attains this edistance * `IsOpen.exists_iUnion_isClosed`: every open set `U` can be written as the increasing union of countably many closed subsets of `U` * `hausdorffEdist_closure`: replacing a set by its closure does not change the Hausdorff edistance * `hausdorffEdist_zero_iff_closure_eq_closure`: two sets have Hausdorff edistance zero iff their closures coincide * the Hausdorff edistance is symmetric and satisfies the triangle inequality * in particular, closed sets in an emetric space are an emetric space (this is shown in `EMetricSpace.closeds.emetricspace`) * versions of these notions on metric spaces * `hausdorffEdist_ne_top_of_nonempty_of_bounded`: if two sets in a metric space are nonempty and bounded in a metric space, they are at finite Hausdorff edistance. ## Tags metric space, Hausdorff distance -/ noncomputable section open NNReal ENNReal Topology Set Filter Pointwise Bornology universe u v w variable {ι : Sort*} {α : Type u} {β : Type v} namespace EMetric section InfEdist variable [PseudoEMetricSpace α] [PseudoEMetricSpace β] {x y : α} {s t : Set α} {Φ : α → β} /-! ### Distance of a point to a set as a function into `ℝ≥0∞`. -/ /-- The minimal edistance of a point to a set -/ def infEdist (x : α) (s : Set α) : ℝ≥0∞ := ⨅ y ∈ s, edist x y #align emetric.inf_edist EMetric.infEdist @[simp] theorem infEdist_empty : infEdist x ∅ = ∞ := iInf_emptyset #align emetric.inf_edist_empty EMetric.infEdist_empty theorem le_infEdist {d} : d ≤ infEdist x s ↔ ∀ y ∈ s, d ≤ edist x y := by simp only [infEdist, le_iInf_iff] #align emetric.le_inf_edist EMetric.le_infEdist /-- The edist to a union is the minimum of the edists -/ @[simp] theorem infEdist_union : infEdist x (s ∪ t) = infEdist x s ⊓ infEdist x t := iInf_union #align emetric.inf_edist_union EMetric.infEdist_union @[simp] theorem infEdist_iUnion (f : ι → Set α) (x : α) : infEdist x (⋃ i, f i) = ⨅ i, infEdist x (f i) := iInf_iUnion f _ #align emetric.inf_edist_Union EMetric.infEdist_iUnion lemma infEdist_biUnion {ι : Type*} (f : ι → Set α) (I : Set ι) (x : α) : infEdist x (⋃ i ∈ I, f i) = ⨅ i ∈ I, infEdist x (f i) := by simp only [infEdist_iUnion] /-- The edist to a singleton is the edistance to the single point of this singleton -/ @[simp] theorem infEdist_singleton : infEdist x {y} = edist x y := iInf_singleton #align emetric.inf_edist_singleton EMetric.infEdist_singleton /-- The edist to a set is bounded above by the edist to any of its points -/ theorem infEdist_le_edist_of_mem (h : y ∈ s) : infEdist x s ≤ edist x y := iInf₂_le y h #align emetric.inf_edist_le_edist_of_mem EMetric.infEdist_le_edist_of_mem /-- If a point `x` belongs to `s`, then its edist to `s` vanishes -/ theorem infEdist_zero_of_mem (h : x ∈ s) : infEdist x s = 0 := nonpos_iff_eq_zero.1 <| @edist_self _ _ x ▸ infEdist_le_edist_of_mem h #align emetric.inf_edist_zero_of_mem EMetric.infEdist_zero_of_mem /-- The edist is antitone with respect to inclusion. -/ theorem infEdist_anti (h : s ⊆ t) : infEdist x t ≤ infEdist x s := iInf_le_iInf_of_subset h #align emetric.inf_edist_anti EMetric.infEdist_anti /-- The edist to a set is `< r` iff there exists a point in the set at edistance `< r` -/
Mathlib/Topology/MetricSpace/HausdorffDistance.lean
120
121
theorem infEdist_lt_iff {r : ℝ≥0∞} : infEdist x s < r ↔ ∃ y ∈ s, edist x y < r := by
simp_rw [infEdist, iInf_lt_iff, exists_prop]
/- Copyright (c) 2022 Eric Rodriguez. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Rodriguez, Eric Wieser -/ import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" /-! # Destuttering of Lists This file proves theorems about `List.destutter` (in `Data.List.Defs`), which greedily removes all non-related items that are adjacent in a list, e.g. `[2, 2, 3, 3, 2].destutter (≠) = [2, 3, 2]`. Note that we make no guarantees of being the longest sublist with this property; e.g., `[123, 1, 2, 5, 543, 1000].destutter (<) = [123, 543, 1000]`, but a longer ascending chain could be `[1, 2, 5, 543, 1000]`. ## Main statements * `List.destutter_sublist`: `l.destutter` is a sublist of `l`. * `List.destutter_is_chain'`: `l.destutter` satisfies `Chain' R`. * Analogies of these theorems for `List.destutter'`, which is the `destutter` equivalent of `Chain`. ## Tags adjacent, chain, duplicates, remove, list, stutter, destutter -/ variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp] theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by rw [destutter', if_pos h] #align list.destutter'_cons_pos List.destutter'_cons_pos @[simp]
Mathlib/Data/List/Destutter.lean
53
54
theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by
rw [destutter', if_neg h]
/- Copyright (c) 2020 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Data.Nat.Cast.WithTop import Mathlib.RingTheory.Prime import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.Ideal.Quotient #align_import ring_theory.eisenstein_criterion from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" /-! # Eisenstein's criterion A proof of a slight generalisation of Eisenstein's criterion for the irreducibility of a polynomial over an integral domain. -/ open Polynomial Ideal.Quotient variable {R : Type*} [CommRing R] namespace Polynomial open Polynomial namespace EisensteinCriterionAux -- Section for auxiliary lemmas used in the proof of `irreducible_of_eisenstein_criterion` theorem map_eq_C_mul_X_pow_of_forall_coeff_mem {f : R[X]} {P : Ideal R} (hfP : ∀ n : ℕ, ↑n < f.degree → f.coeff n ∈ P) : map (mk P) f = C ((mk P) f.leadingCoeff) * X ^ f.natDegree := Polynomial.ext fun n => by by_cases hf0 : f = 0 · simp [hf0] rcases lt_trichotomy (n : WithBot ℕ) (degree f) with (h | h | h) · erw [coeff_map, eq_zero_iff_mem.2 (hfP n h), coeff_C_mul, coeff_X_pow, if_neg, mul_zero] rintro rfl exact not_lt_of_ge degree_le_natDegree h · have : natDegree f = n := natDegree_eq_of_degree_eq_some h.symm rw [coeff_C_mul, coeff_X_pow, if_pos this.symm, mul_one, leadingCoeff, this, coeff_map] · rw [coeff_eq_zero_of_degree_lt, coeff_eq_zero_of_degree_lt] · refine lt_of_le_of_lt (degree_C_mul_X_pow_le _ _) ?_ rwa [← degree_eq_natDegree hf0] · exact lt_of_le_of_lt (degree_map_le _ _) h set_option linter.uppercaseLean3 false in #align polynomial.eisenstein_criterion_aux.map_eq_C_mul_X_pow_of_forall_coeff_mem Polynomial.EisensteinCriterionAux.map_eq_C_mul_X_pow_of_forall_coeff_mem theorem le_natDegree_of_map_eq_mul_X_pow {n : ℕ} {P : Ideal R} (hP : P.IsPrime) {q : R[X]} {c : Polynomial (R ⧸ P)} (hq : map (mk P) q = c * X ^ n) (hc0 : c.degree = 0) : n ≤ q.natDegree := Nat.cast_le.1 (calc ↑n = degree (q.map (mk P)) := by rw [hq, degree_mul, hc0, zero_add, degree_pow, degree_X, nsmul_one] _ ≤ degree q := degree_map_le _ _ _ ≤ natDegree q := degree_le_natDegree ) set_option linter.uppercaseLean3 false in #align polynomial.eisenstein_criterion_aux.le_nat_degree_of_map_eq_mul_X_pow Polynomial.EisensteinCriterionAux.le_natDegree_of_map_eq_mul_X_pow
Mathlib/RingTheory/EisensteinCriterion.lean
65
68
theorem eval_zero_mem_ideal_of_eq_mul_X_pow {n : ℕ} {P : Ideal R} {q : R[X]} {c : Polynomial (R ⧸ P)} (hq : map (mk P) q = c * X ^ n) (hn0 : n ≠ 0) : eval 0 q ∈ P := by
rw [← coeff_zero_eq_eval_zero, ← eq_zero_iff_mem, ← coeff_map, hq, coeff_zero_eq_eval_zero, eval_mul, eval_pow, eval_X, zero_pow hn0, mul_zero]
/- Copyright (c) 2018 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Algebra.Defs import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Algebra.Order.Field.Canonical.Basic import Mathlib.Algebra.Order.Nonneg.Field import Mathlib.Algebra.Order.Nonneg.Floor import Mathlib.Data.Real.Pointwise import Mathlib.Order.ConditionallyCompleteLattice.Group import Mathlib.Tactic.GCongr.Core #align_import data.real.nnreal from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010" /-! # Nonnegative real numbers In this file we define `NNReal` (notation: `ℝ≥0`) to be the type of non-negative real numbers, a.k.a. the interval `[0, ∞)`. We also define the following operations and structures on `ℝ≥0`: * the order on `ℝ≥0` is the restriction of the order on `ℝ`; these relations define a conditionally complete linear order with a bottom element, `ConditionallyCompleteLinearOrderBot`; * `a + b` and `a * b` are the restrictions of addition and multiplication of real numbers to `ℝ≥0`; these operations together with `0 = ⟨0, _⟩` and `1 = ⟨1, _⟩` turn `ℝ≥0` into a conditionally complete linear ordered archimedean commutative semifield; we have no typeclass for this in `mathlib` yet, so we define the following instances instead: - `LinearOrderedSemiring ℝ≥0`; - `OrderedCommSemiring ℝ≥0`; - `CanonicallyOrderedCommSemiring ℝ≥0`; - `LinearOrderedCommGroupWithZero ℝ≥0`; - `CanonicallyLinearOrderedAddCommMonoid ℝ≥0`; - `Archimedean ℝ≥0`; - `ConditionallyCompleteLinearOrderBot ℝ≥0`. These instances are derived from corresponding instances about the type `{x : α // 0 ≤ x}` in an appropriate ordered field/ring/group/monoid `α`, see `Mathlib.Algebra.Order.Nonneg.Ring`. * `Real.toNNReal x` is defined as `⟨max x 0, _⟩`, i.e. `↑(Real.toNNReal x) = x` when `0 ≤ x` and `↑(Real.toNNReal x) = 0` otherwise. We also define an instance `CanLift ℝ ℝ≥0`. This instance can be used by the `lift` tactic to replace `x : ℝ` and `hx : 0 ≤ x` in the proof context with `x : ℝ≥0` while replacing all occurrences of `x` with `↑x`. This tactic also works for a function `f : α → ℝ` with a hypothesis `hf : ∀ x, 0 ≤ f x`. ## Notations This file defines `ℝ≥0` as a localized notation for `NNReal`. -/ open Function -- to ensure these instances are computable /-- Nonnegative real numbers. -/ def NNReal := { r : ℝ // 0 ≤ r } deriving Zero, One, Semiring, StrictOrderedSemiring, CommMonoidWithZero, CommSemiring, SemilatticeInf, SemilatticeSup, DistribLattice, OrderedCommSemiring, CanonicallyOrderedCommSemiring, Inhabited #align nnreal NNReal namespace NNReal scoped notation "ℝ≥0" => NNReal noncomputable instance : FloorSemiring ℝ≥0 := Nonneg.floorSemiring instance instDenselyOrdered : DenselyOrdered ℝ≥0 := Nonneg.instDenselyOrdered instance : OrderBot ℝ≥0 := inferInstance instance : Archimedean ℝ≥0 := Nonneg.archimedean noncomputable instance : Sub ℝ≥0 := Nonneg.sub noncomputable instance : OrderedSub ℝ≥0 := Nonneg.orderedSub noncomputable instance : CanonicallyLinearOrderedSemifield ℝ≥0 := Nonneg.canonicallyLinearOrderedSemifield /-- Coercion `ℝ≥0 → ℝ`. -/ @[coe] def toReal : ℝ≥0 → ℝ := Subtype.val instance : Coe ℝ≥0 ℝ := ⟨toReal⟩ -- Simp lemma to put back `n.val` into the normal form given by the coercion. @[simp] theorem val_eq_coe (n : ℝ≥0) : n.val = n := rfl #align nnreal.val_eq_coe NNReal.val_eq_coe instance canLift : CanLift ℝ ℝ≥0 toReal fun r => 0 ≤ r := Subtype.canLift _ #align nnreal.can_lift NNReal.canLift @[ext] protected theorem eq {n m : ℝ≥0} : (n : ℝ) = (m : ℝ) → n = m := Subtype.eq #align nnreal.eq NNReal.eq protected theorem eq_iff {n m : ℝ≥0} : (n : ℝ) = (m : ℝ) ↔ n = m := Subtype.ext_iff.symm #align nnreal.eq_iff NNReal.eq_iff theorem ne_iff {x y : ℝ≥0} : (x : ℝ) ≠ (y : ℝ) ↔ x ≠ y := not_congr <| NNReal.eq_iff #align nnreal.ne_iff NNReal.ne_iff protected theorem «forall» {p : ℝ≥0 → Prop} : (∀ x : ℝ≥0, p x) ↔ ∀ (x : ℝ) (hx : 0 ≤ x), p ⟨x, hx⟩ := Subtype.forall #align nnreal.forall NNReal.forall protected theorem «exists» {p : ℝ≥0 → Prop} : (∃ x : ℝ≥0, p x) ↔ ∃ (x : ℝ) (hx : 0 ≤ x), p ⟨x, hx⟩ := Subtype.exists #align nnreal.exists NNReal.exists /-- Reinterpret a real number `r` as a non-negative real number. Returns `0` if `r < 0`. -/ noncomputable def _root_.Real.toNNReal (r : ℝ) : ℝ≥0 := ⟨max r 0, le_max_right _ _⟩ #align real.to_nnreal Real.toNNReal theorem _root_.Real.coe_toNNReal (r : ℝ) (hr : 0 ≤ r) : (Real.toNNReal r : ℝ) = r := max_eq_left hr #align real.coe_to_nnreal Real.coe_toNNReal
Mathlib/Data/Real/NNReal.lean
125
126
theorem _root_.Real.toNNReal_of_nonneg {r : ℝ} (hr : 0 ≤ r) : r.toNNReal = ⟨r, hr⟩ := by
simp_rw [Real.toNNReal, max_eq_left hr]
/- 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.Logic.Function.Conjugate #align_import logic.function.iterate from "leanprover-community/mathlib"@"792a2a264169d64986541c6f8f7e3bbb6acb6295" /-! # Iterations of a function In this file we prove simple properties of `Nat.iterate f n` a.k.a. `f^[n]`: * `iterate_zero`, `iterate_succ`, `iterate_succ'`, `iterate_add`, `iterate_mul`: formulas for `f^[0]`, `f^[n+1]` (two versions), `f^[n+m]`, and `f^[n*m]`; * `iterate_id` : `id^[n]=id`; * `Injective.iterate`, `Surjective.iterate`, `Bijective.iterate` : iterates of an injective/surjective/bijective function belong to the same class; * `LeftInverse.iterate`, `RightInverse.iterate`, `Commute.iterate_left`, `Commute.iterate_right`, `Commute.iterate_iterate`: some properties of pairs of functions survive under iterations * `iterate_fixed`, `Function.Semiconj.iterate_*`, `Function.Semiconj₂.iterate`: if `f` fixes a point (resp., semiconjugates unary/binary operations), then so does `f^[n]`. -/ universe u v variable {α : Type u} {β : Type v} /-- Iterate a function. -/ def Nat.iterate {α : Sort u} (op : α → α) : ℕ → α → α | 0, a => a | succ k, a => iterate op k (op a) #align nat.iterate Nat.iterate @[inherit_doc Nat.iterate] notation:max f "^["n"]" => Nat.iterate f n namespace Function open Function (Commute) variable (f : α → α) @[simp] theorem iterate_zero : f^[0] = id := rfl #align function.iterate_zero Function.iterate_zero theorem iterate_zero_apply (x : α) : f^[0] x = x := rfl #align function.iterate_zero_apply Function.iterate_zero_apply @[simp] theorem iterate_succ (n : ℕ) : f^[n.succ] = f^[n] ∘ f := rfl #align function.iterate_succ Function.iterate_succ theorem iterate_succ_apply (n : ℕ) (x : α) : f^[n.succ] x = f^[n] (f x) := rfl #align function.iterate_succ_apply Function.iterate_succ_apply @[simp] theorem iterate_id (n : ℕ) : (id : α → α)^[n] = id := Nat.recOn n rfl fun n ihn ↦ by rw [iterate_succ, ihn, id_comp] #align function.iterate_id Function.iterate_id theorem iterate_add (m : ℕ) : ∀ n : ℕ, f^[m + n] = f^[m] ∘ f^[n] | 0 => rfl | Nat.succ n => by rw [Nat.add_succ, iterate_succ, iterate_succ, iterate_add m n]; rfl #align function.iterate_add Function.iterate_add
Mathlib/Logic/Function/Iterate.lean
80
82
theorem iterate_add_apply (m n : ℕ) (x : α) : f^[m + n] x = f^[m] (f^[n] x) := by
rw [iterate_add f m n] 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.Algebra.BigOperators.Group.Finset import Mathlib.Data.List.MinMax import Mathlib.Algebra.Tropical.Basic import Mathlib.Order.ConditionallyCompleteLattice.Finset #align_import algebra.tropical.big_operators from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce" /-! # Tropicalization of finitary operations This file provides the "big-op" or notation-based finitary operations on tropicalized types. This allows easy conversion between sums to Infs and prods to sums. Results here are important for expressing that evaluation of tropical polynomials are the minimum over a finite piecewise collection of linear functions. ## Main declarations * `untrop_sum` ## Implementation notes No concrete (semi)ring is used here, only ones with inferrable order/lattice structure, to support `Real`, `Rat`, `EReal`, and others (`ERat` is not yet defined). Minima over `List α` are defined as producing a value in `WithTop α` so proofs about lists do not directly transfer to minima over multisets or finsets. -/ variable {R S : Type*} open Tropical Finset theorem List.trop_sum [AddMonoid R] (l : List R) : trop l.sum = List.prod (l.map trop) := by induction' l with hd tl IH · simp · simp [← IH] #align list.trop_sum List.trop_sum theorem Multiset.trop_sum [AddCommMonoid R] (s : Multiset R) : trop s.sum = Multiset.prod (s.map trop) := Quotient.inductionOn s (by simpa using List.trop_sum) #align multiset.trop_sum Multiset.trop_sum theorem trop_sum [AddCommMonoid R] (s : Finset S) (f : S → R) : trop (∑ i ∈ s, f i) = ∏ i ∈ s, trop (f i) := by convert Multiset.trop_sum (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl #align trop_sum trop_sum theorem List.untrop_prod [AddMonoid R] (l : List (Tropical R)) : untrop l.prod = List.sum (l.map untrop) := by induction' l with hd tl IH · simp · simp [← IH] #align list.untrop_prod List.untrop_prod theorem Multiset.untrop_prod [AddCommMonoid R] (s : Multiset (Tropical R)) : untrop s.prod = Multiset.sum (s.map untrop) := Quotient.inductionOn s (by simpa using List.untrop_prod) #align multiset.untrop_prod Multiset.untrop_prod theorem untrop_prod [AddCommMonoid R] (s : Finset S) (f : S → Tropical R) : untrop (∏ i ∈ s, f i) = ∑ i ∈ s, untrop (f i) := by convert Multiset.untrop_prod (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl #align untrop_prod untrop_prod -- Porting note: replaced `coe` with `WithTop.some` in statement theorem List.trop_minimum [LinearOrder R] (l : List R) : trop l.minimum = List.sum (l.map (trop ∘ WithTop.some)) := by induction' l with hd tl IH · simp · simp [List.minimum_cons, ← IH] #align list.trop_minimum List.trop_minimum theorem Multiset.trop_inf [LinearOrder R] [OrderTop R] (s : Multiset R) : trop s.inf = Multiset.sum (s.map trop) := by induction' s using Multiset.induction with s x IH · simp · simp [← IH] #align multiset.trop_inf Multiset.trop_inf theorem Finset.trop_inf [LinearOrder R] [OrderTop R] (s : Finset S) (f : S → R) : trop (s.inf f) = ∑ i ∈ s, trop (f i) := by convert Multiset.trop_inf (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl #align finset.trop_inf Finset.trop_inf theorem trop_sInf_image [ConditionallyCompleteLinearOrder R] (s : Finset S) (f : S → WithTop R) : trop (sInf (f '' s)) = ∑ i ∈ s, trop (f i) := by rcases s.eq_empty_or_nonempty with (rfl | h) · simp only [Set.image_empty, coe_empty, sum_empty, WithTop.sInf_empty, trop_top] rw [← inf'_eq_csInf_image _ h, inf'_eq_inf, s.trop_inf] #align trop_Inf_image trop_sInf_image theorem trop_iInf [ConditionallyCompleteLinearOrder R] [Fintype S] (f : S → WithTop R) : trop (⨅ i : S, f i) = ∑ i : S, trop (f i) := by rw [iInf, ← Set.image_univ, ← coe_univ, trop_sInf_image] #align trop_infi trop_iInf
Mathlib/Algebra/Tropical/BigOperators.lean
111
116
theorem Multiset.untrop_sum [LinearOrder R] [OrderTop R] (s : Multiset (Tropical R)) : untrop s.sum = Multiset.inf (s.map untrop) := by
induction' s using Multiset.induction with s x IH · simp · simp only [sum_cons, ge_iff_le, untrop_add, untrop_le_iff, map_cons, inf_cons, ← IH] rfl
/- Copyright (c) 2019 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov Some proofs and docs came from `algebra/commute` (c) Neil Strickland -/ import Mathlib.Algebra.Group.Defs import Mathlib.Init.Logic import Mathlib.Tactic.Cases #align_import algebra.group.semiconj from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64" /-! # Semiconjugate elements of a semigroup ## Main definitions We say that `x` is semiconjugate to `y` by `a` (`SemiconjBy a x y`), if `a * x = y * a`. In this file we provide operations on `SemiconjBy _ _ _`. In the names of these operations, we treat `a` as the “left” argument, and both `x` and `y` as “right” arguments. This way most names in this file agree with the names of the corresponding lemmas for `Commute a b = SemiconjBy a b b`. As a side effect, some lemmas have only `_right` version. Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like `rw [(h.pow_right 5).eq]` rather than just `rw [h.pow_right 5]`. This file provides only basic operations (`mul_left`, `mul_right`, `inv_right` etc). Other operations (`pow_right`, field inverse etc) are in the files that define corresponding notions. -/ assert_not_exists MonoidWithZero assert_not_exists DenselyOrdered variable {S M G : Type*} /-- `x` is semiconjugate to `y` by `a`, if `a * x = y * a`. -/ @[to_additive "`x` is additive semiconjugate to `y` by `a` if `a + x = y + a`"] def SemiconjBy [Mul M] (a x y : M) : Prop := a * x = y * a #align semiconj_by SemiconjBy #align add_semiconj_by AddSemiconjBy namespace SemiconjBy /-- Equality behind `SemiconjBy a x y`; useful for rewriting. -/ @[to_additive "Equality behind `AddSemiconjBy a x y`; useful for rewriting."] protected theorem eq [Mul S] {a x y : S} (h : SemiconjBy a x y) : a * x = y * a := h #align semiconj_by.eq SemiconjBy.eq #align add_semiconj_by.eq AddSemiconjBy.eq section Semigroup variable [Semigroup S] {a b x y z x' y' : S} /-- If `a` semiconjugates `x` to `y` and `x'` to `y'`, then it semiconjugates `x * x'` to `y * y'`. -/ @[to_additive (attr := simp) "If `a` semiconjugates `x` to `y` and `x'` to `y'`, then it semiconjugates `x + x'` to `y + y'`."] theorem mul_right (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x * x') (y * y') := by unfold SemiconjBy -- TODO this could be done using `assoc_rw` if/when this is ported to mathlib4 rw [← mul_assoc, h.eq, mul_assoc, h'.eq, ← mul_assoc] #align semiconj_by.mul_right SemiconjBy.mul_right #align add_semiconj_by.add_right AddSemiconjBy.add_right /-- If `b` semiconjugates `x` to `y` and `a` semiconjugates `y` to `z`, then `a * b` semiconjugates `x` to `z`. -/ @[to_additive "If `b` semiconjugates `x` to `y` and `a` semiconjugates `y` to `z`, then `a + b` semiconjugates `x` to `z`."] theorem mul_left (ha : SemiconjBy a y z) (hb : SemiconjBy b x y) : SemiconjBy (a * b) x z := by unfold SemiconjBy rw [mul_assoc, hb.eq, ← mul_assoc, ha.eq, mul_assoc] #align semiconj_by.mul_left SemiconjBy.mul_left #align add_semiconj_by.add_left AddSemiconjBy.add_left /-- The relation “there exists an element that semiconjugates `a` to `b`” on a semigroup is transitive. -/ @[to_additive "The relation “there exists an element that semiconjugates `a` to `b`” on an additive semigroup is transitive."] protected theorem transitive : Transitive fun a b : S ↦ ∃ c, SemiconjBy c a b | _, _, _, ⟨x, hx⟩, ⟨y, hy⟩ => ⟨y * x, hy.mul_left hx⟩ #align semiconj_by.transitive SemiconjBy.transitive #align add_semiconj_by.transitive SemiconjBy.transitive end Semigroup section MulOneClass variable [MulOneClass M] /-- Any element semiconjugates `1` to `1`. -/ @[to_additive (attr := simp) "Any element semiconjugates `0` to `0`."] theorem one_right (a : M) : SemiconjBy a 1 1 := by rw [SemiconjBy, mul_one, one_mul] #align semiconj_by.one_right SemiconjBy.one_right #align add_semiconj_by.zero_right AddSemiconjBy.zero_right /-- One semiconjugates any element to itself. -/ @[to_additive (attr := simp) "Zero semiconjugates any element to itself."] theorem one_left (x : M) : SemiconjBy 1 x x := Eq.symm <| one_right x #align semiconj_by.one_left SemiconjBy.one_left #align add_semiconj_by.zero_left AddSemiconjBy.zero_left /-- The relation “there exists an element that semiconjugates `a` to `b`” on a monoid (or, more generally, on `MulOneClass` type) is reflexive. -/ @[to_additive "The relation “there exists an element that semiconjugates `a` to `b`” on an additive monoid (or, more generally, on an `AddZeroClass` type) is reflexive."] protected theorem reflexive : Reflexive fun a b : M ↦ ∃ c, SemiconjBy c a b | a => ⟨1, one_left a⟩ #align semiconj_by.reflexive SemiconjBy.reflexive #align add_semiconj_by.reflexive AddSemiconjBy.reflexive end MulOneClass section Monoid variable [Monoid M] @[to_additive (attr := simp)]
Mathlib/Algebra/Group/Semiconj/Defs.lean
124
129
theorem pow_right {a x y : M} (h : SemiconjBy a x y) (n : ℕ) : SemiconjBy a (x ^ n) (y ^ n) := by
induction' n with n ih · rw [pow_zero, pow_zero] exact SemiconjBy.one_right _ · rw [pow_succ, pow_succ] exact ih.mul_right h
/- Copyright (c) 2021 Paul Lezeau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen, Paul Lezeau -/ import Mathlib.Algebra.IsPrimePow import Mathlib.Algebra.Squarefree.Basic import Mathlib.Order.Hom.Bounded import Mathlib.Algebra.GCDMonoid.Basic #align_import ring_theory.chain_of_divisors from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # Chains of divisors The results in this file show that in the monoid `Associates M` of a `UniqueFactorizationMonoid` `M`, an element `a` is an n-th prime power iff its set of divisors is a strictly increasing chain of length `n + 1`, meaning that we can find a strictly increasing bijection between `Fin (n + 1)` and the set of factors of `a`. ## Main results - `DivisorChain.exists_chain_of_prime_pow` : existence of a chain for prime powers. - `DivisorChain.is_prime_pow_of_has_chain` : elements that have a chain are prime powers. - `multiplicity_prime_eq_multiplicity_image_by_factor_orderIso` : if there is a monotone bijection `d` between the set of factors of `a : Associates M` and the set of factors of `b : Associates N` then for any prime `p ∣ a`, `multiplicity p a = multiplicity (d p) b`. - `multiplicity_eq_multiplicity_factor_dvd_iso_of_mem_normalizedFactors` : if there is a bijection between the set of factors of `a : M` and `b : N` then for any prime `p ∣ a`, `multiplicity p a = multiplicity (d p) b` ## Todo - Create a structure for chains of divisors. - Simplify proof of `mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors` using `mem_normalizedFactors_factor_order_iso_of_mem_normalizedFactors` or vice versa. -/ variable {M : Type*} [CancelCommMonoidWithZero M] theorem Associates.isAtom_iff {p : Associates M} (h₁ : p ≠ 0) : IsAtom p ↔ Irreducible p := ⟨fun hp => ⟨by simpa only [Associates.isUnit_iff_eq_one] using hp.1, fun a b h => (hp.le_iff.mp ⟨_, h⟩).casesOn (fun ha => Or.inl (a.isUnit_iff_eq_one.mpr ha)) fun ha => Or.inr (show IsUnit b by rw [ha] at h apply isUnit_of_associated_mul (show Associated (p * b) p by conv_rhs => rw [h]) h₁)⟩, fun hp => ⟨by simpa only [Associates.isUnit_iff_eq_one, Associates.bot_eq_one] using hp.1, fun b ⟨⟨a, hab⟩, hb⟩ => (hp.isUnit_or_isUnit hab).casesOn (fun hb => show b = ⊥ by rwa [Associates.isUnit_iff_eq_one, ← Associates.bot_eq_one] at hb) fun ha => absurd (show p ∣ b from ⟨(ha.unit⁻¹ : Units _), by rw [hab, mul_assoc, IsUnit.mul_val_inv ha, mul_one]⟩) hb⟩⟩ #align associates.is_atom_iff Associates.isAtom_iff open UniqueFactorizationMonoid multiplicity Irreducible Associates namespace DivisorChain
Mathlib/RingTheory/ChainOfDivisors.lean
66
81
theorem exists_chain_of_prime_pow {p : Associates M} {n : ℕ} (hn : n ≠ 0) (hp : Prime p) : ∃ c : Fin (n + 1) → Associates M, c 1 = p ∧ StrictMono c ∧ ∀ {r : Associates M}, r ≤ p ^ n ↔ ∃ i, r = c i := by
refine ⟨fun i => p ^ (i : ℕ), ?_, fun n m h => ?_, @fun y => ⟨fun h => ?_, ?_⟩⟩ · dsimp only rw [Fin.val_one', Nat.mod_eq_of_lt, pow_one] exact Nat.lt_succ_of_le (Nat.one_le_iff_ne_zero.mpr hn) · exact Associates.dvdNotUnit_iff_lt.mp ⟨pow_ne_zero n hp.ne_zero, p ^ (m - n : ℕ), not_isUnit_of_not_isUnit_dvd hp.not_unit (dvd_pow dvd_rfl (Nat.sub_pos_of_lt h).ne'), (pow_mul_pow_sub p h.le).symm⟩ · obtain ⟨i, i_le, hi⟩ := (dvd_prime_pow hp n).1 h rw [associated_iff_eq] at hi exact ⟨⟨i, Nat.lt_succ_of_le i_le⟩, hi⟩ · rintro ⟨i, rfl⟩ exact ⟨p ^ (n - i : ℕ), (pow_mul_pow_sub p (Nat.succ_le_succ_iff.mp i.2)).symm⟩
/- 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'
Mathlib/Algebra/Polynomial/Taylor.lean
62
62
theorem taylor_zero (f : R[X]) : taylor 0 f = f := by
rw [taylor_zero', LinearMap.id_apply]
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.MonoidAlgebra.Ideal import Mathlib.Algebra.MvPolynomial.Division #align_import ring_theory.mv_polynomial.ideal from "leanprover-community/mathlib"@"72c366d0475675f1309d3027d3d7d47ee4423951" /-! # Lemmas about ideals of `MvPolynomial` Notably this contains results about monomial ideals. ## Main results * `MvPolynomial.mem_ideal_span_monomial_image` * `MvPolynomial.mem_ideal_span_X_image` -/ variable {σ R : Type*} namespace MvPolynomial variable [CommSemiring R] /-- `x` is in a monomial ideal generated by `s` iff every element of its support dominates one of the generators. Note that `si ≤ xi` is analogous to saying that the monomial corresponding to `si` divides the monomial corresponding to `xi`. -/ theorem mem_ideal_span_monomial_image {x : MvPolynomial σ R} {s : Set (σ →₀ ℕ)} : x ∈ Ideal.span ((fun s => monomial s (1 : R)) '' s) ↔ ∀ xi ∈ x.support, ∃ si ∈ s, si ≤ xi := by refine AddMonoidAlgebra.mem_ideal_span_of'_image.trans ?_ simp_rw [le_iff_exists_add, add_comm] rfl #align mv_polynomial.mem_ideal_span_monomial_image MvPolynomial.mem_ideal_span_monomial_image
Mathlib/RingTheory/MvPolynomial/Ideal.lean
39
43
theorem mem_ideal_span_monomial_image_iff_dvd {x : MvPolynomial σ R} {s : Set (σ →₀ ℕ)} : x ∈ Ideal.span ((fun s => monomial s (1 : R)) '' s) ↔ ∀ xi ∈ x.support, ∃ si ∈ s, monomial si 1 ∣ monomial xi (x.coeff xi) := by
refine mem_ideal_span_monomial_image.trans (forall₂_congr fun xi hxi => ?_) simp_rw [monomial_dvd_monomial, one_dvd, and_true_iff, mem_support_iff.mp hxi, false_or_iff]
/- 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 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 #align polynomial.content_dvd_coeff Polynomial.content_dvd_coeff @[simp] theorem content_C {r : R} : (C r).content = normalize r := by rw [content] by_cases h0 : r = 0 · simp [h0] have h : (C r).support = {0} := support_monomial _ h0 simp [h] set_option linter.uppercaseLean3 false in #align polynomial.content_C Polynomial.content_C @[simp]
Mathlib/RingTheory/Polynomial/Content.lean
102
102
theorem content_zero : content (0 : R[X]) = 0 := by
rw [← C_0, content_C, normalize_zero]
/- 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.Filtered.Basic import Mathlib.CategoryTheory.Limits.HasLimits import Mathlib.CategoryTheory.Limits.Types #align_import category_theory.limits.filtered from "leanprover-community/mathlib"@"e4ee4e30418efcb8cf304ba76ad653aeec04ba6e" /-! # Filtered categories and limits In this file , we show that `C` is filtered if and only if for every functor `F : J ⥤ C` from a finite category there is some `X : C` such that `lim Hom(F·, X)` is nonempty. Furthermore, we define the type classes `HasCofilteredLimitsOfSize` and `HasFilteredColimitsOfSize`. -/ universe w' w v u noncomputable section open CategoryTheory variable {C : Type u} [Category.{v} C] namespace CategoryTheory section NonemptyLimit open CategoryTheory.Limits Opposite /-- `C` is filtered if and only if for every functor `F : J ⥤ C` from a finite category there is some `X : C` such that `lim Hom(F·, X)` is nonempty. Lemma 3.1.2 of [Kashiwara2006] -/ theorem IsFiltered.iff_nonempty_limit : IsFiltered C ↔ ∀ {J : Type v} [SmallCategory J] [FinCategory J] (F : J ⥤ C), ∃ (X : C), Nonempty (limit (F.op ⋙ yoneda.obj X)) := by rw [IsFiltered.iff_cocone_nonempty.{v}] refine ⟨fun h J _ _ F => ?_, fun h J _ _ F => ?_⟩ · obtain ⟨c⟩ := h F exact ⟨c.pt, ⟨(limitCompYonedaIsoCocone F c.pt).inv c.ι⟩⟩ · obtain ⟨pt, ⟨ι⟩⟩ := h F exact ⟨⟨pt, (limitCompYonedaIsoCocone F pt).hom ι⟩⟩ /-- `C` is cofiltered if and only if for every functor `F : J ⥤ C` from a finite category there is some `X : C` such that `lim Hom(X, F·)` is nonempty. -/
Mathlib/CategoryTheory/Limits/Filtered.lean
52
60
theorem IsCofiltered.iff_nonempty_limit : IsCofiltered C ↔ ∀ {J : Type v} [SmallCategory J] [FinCategory J] (F : J ⥤ C), ∃ (X : C), Nonempty (limit (F ⋙ coyoneda.obj (op X))) := by
rw [IsCofiltered.iff_cone_nonempty.{v}] refine ⟨fun h J _ _ F => ?_, fun h J _ _ F => ?_⟩ · obtain ⟨c⟩ := h F exact ⟨c.pt, ⟨(limitCompCoyonedaIsoCone F c.pt).inv c.π⟩⟩ · obtain ⟨pt, ⟨π⟩⟩ := h F exact ⟨⟨pt, (limitCompCoyonedaIsoCone F pt).hom π⟩⟩
/- 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 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 #align rat_mul_continuous_lemma rat_mul_continuous_lemma
Mathlib/Algebra/Order/CauSeq/Basic.lean
74
85
theorem rat_inv_continuous_lemma {β : Type*} [DivisionRing β] (abv : β → α) [IsAbsoluteValue abv] {ε K : α} (ε0 : 0 < ε) (K0 : 0 < K) : ∃ δ > 0, ∀ {a b : β}, K ≤ abv a → K ≤ abv b → abv (a - b) < δ → abv (a⁻¹ - b⁻¹) < ε := by
refine ⟨K * ε * K, mul_pos (mul_pos K0 ε0) K0, fun {a b} ha hb h => ?_⟩ have a0 := K0.trans_le ha have b0 := K0.trans_le hb rw [inv_sub_inv' ((abv_pos abv).1 a0) ((abv_pos abv).1 b0), abv_mul abv, abv_mul abv, abv_inv abv, abv_inv abv, abv_sub abv] refine lt_of_mul_lt_mul_left (lt_of_mul_lt_mul_right ?_ b0.le) a0.le rw [mul_assoc, inv_mul_cancel_right₀ b0.ne', ← mul_assoc, mul_inv_cancel a0.ne', one_mul] refine h.trans_le ?_ gcongr
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Jens Wagemaker, Aaron Anderson -/ import Mathlib.Algebra.EuclideanDomain.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Algebra.GCDMonoid.Nat #align_import ring_theory.int.basic from "leanprover-community/mathlib"@"e655e4ea5c6d02854696f97494997ba4c31be802" /-! # Divisibility over ℕ and ℤ This file collects results for the integers and natural numbers that use ring theory in their proofs or cases of ℕ and ℤ being examples of structures in ring theory. ## Main statements * `Nat.factors_eq`: the multiset of elements of `Nat.factors` is equal to the factors given by the `UniqueFactorizationMonoid` instance ## Tags prime, irreducible, natural numbers, integers, normalization monoid, gcd monoid, greatest common divisor, prime factorization, prime factors, unique factorization, unique factors -/ namespace Int
Mathlib/RingTheory/Int/Basic.lean
33
46
theorem gcd_eq_one_iff_coprime {a b : ℤ} : Int.gcd a b = 1 ↔ IsCoprime a b := by
constructor · intro hg obtain ⟨ua, -, ha⟩ := exists_unit_of_abs a obtain ⟨ub, -, hb⟩ := exists_unit_of_abs b use Nat.gcdA (Int.natAbs a) (Int.natAbs b) * ua, Nat.gcdB (Int.natAbs a) (Int.natAbs b) * ub rw [mul_assoc, ← ha, mul_assoc, ← hb, mul_comm, mul_comm _ (Int.natAbs b : ℤ), ← Nat.gcd_eq_gcd_ab, ← gcd_eq_natAbs, hg, Int.ofNat_one] · rintro ⟨r, s, h⟩ by_contra hg obtain ⟨p, ⟨hp, ha, hb⟩⟩ := Nat.Prime.not_coprime_iff_dvd.mp hg apply Nat.Prime.not_dvd_one hp rw [← natCast_dvd_natCast, Int.ofNat_one, ← h] exact dvd_add ((natCast_dvd.mpr ha).mul_left _) ((natCast_dvd.mpr hb).mul_left _)
/- Copyright (c) 2019 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.Algebra.Algebra.Operations import Mathlib.Algebra.Algebra.Subalgebra.Prod import Mathlib.Algebra.Algebra.Subalgebra.Tower import Mathlib.LinearAlgebra.Basis import Mathlib.LinearAlgebra.Prod import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.Prod #align_import ring_theory.adjoin.basic from "leanprover-community/mathlib"@"a35ddf20601f85f78cd57e7f5b09ed528d71b7af" /-! # Adjoining elements to form subalgebras This file develops the basic theory of subalgebras of an R-algebra generated by a set of elements. A basic interface for `adjoin` is set up. ## Tags adjoin, algebra -/ universe uR uS uA uB open Pointwise open Submodule Subsemiring variable {R : Type uR} {S : Type uS} {A : Type uA} {B : Type uB} namespace Algebra section Semiring variable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B] variable [Algebra R S] [Algebra R A] [Algebra S A] [Algebra R B] [IsScalarTower R S A] variable {s t : Set A} @[aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_adjoin : s ⊆ adjoin R s := Algebra.gc.le_u_l s #align algebra.subset_adjoin Algebra.subset_adjoin theorem adjoin_le {S : Subalgebra R A} (H : s ⊆ S) : adjoin R s ≤ S := Algebra.gc.l_le H #align algebra.adjoin_le Algebra.adjoin_le theorem adjoin_eq_sInf : adjoin R s = sInf { p : Subalgebra R A | s ⊆ p } := le_antisymm (le_sInf fun _ h => adjoin_le h) (sInf_le subset_adjoin) #align algebra.adjoin_eq_Inf Algebra.adjoin_eq_sInf theorem adjoin_le_iff {S : Subalgebra R A} : adjoin R s ≤ S ↔ s ⊆ S := Algebra.gc _ _ #align algebra.adjoin_le_iff Algebra.adjoin_le_iff theorem adjoin_mono (H : s ⊆ t) : adjoin R s ≤ adjoin R t := Algebra.gc.monotone_l H #align algebra.adjoin_mono Algebra.adjoin_mono theorem adjoin_eq_of_le (S : Subalgebra R A) (h₁ : s ⊆ S) (h₂ : S ≤ adjoin R s) : adjoin R s = S := le_antisymm (adjoin_le h₁) h₂ #align algebra.adjoin_eq_of_le Algebra.adjoin_eq_of_le theorem adjoin_eq (S : Subalgebra R A) : adjoin R ↑S = S := adjoin_eq_of_le _ (Set.Subset.refl _) subset_adjoin #align algebra.adjoin_eq Algebra.adjoin_eq theorem adjoin_iUnion {α : Type*} (s : α → Set A) : adjoin R (Set.iUnion s) = ⨆ i : α, adjoin R (s i) := (@Algebra.gc R A _ _ _).l_iSup #align algebra.adjoin_Union Algebra.adjoin_iUnion theorem adjoin_attach_biUnion [DecidableEq A] {α : Type*} {s : Finset α} (f : s → Finset A) : adjoin R (s.attach.biUnion f : Set A) = ⨆ x, adjoin R (f x) := by simp [adjoin_iUnion] #align algebra.adjoin_attach_bUnion Algebra.adjoin_attach_biUnion @[elab_as_elim] theorem adjoin_induction {p : A → Prop} {x : A} (h : x ∈ adjoin R s) (mem : ∀ x ∈ s, p x) (algebraMap : ∀ r, p (algebraMap R A r)) (add : ∀ x y, p x → p y → p (x + y)) (mul : ∀ x y, p x → p y → p (x * y)) : p x := let S : Subalgebra R A := { carrier := p mul_mem' := mul _ _ add_mem' := add _ _ algebraMap_mem' := algebraMap } adjoin_le (show s ≤ S from mem) h #align algebra.adjoin_induction Algebra.adjoin_induction /-- Induction principle for the algebra generated by a set `s`: show that `p x y` holds for any `x y ∈ adjoin R s` given that it holds for `x y ∈ s` and that it satisfies a number of natural properties. -/ @[elab_as_elim]
Mathlib/RingTheory/Adjoin/Basic.lean
99
113
theorem adjoin_induction₂ {p : A → A → Prop} {a b : A} (ha : a ∈ adjoin R s) (hb : b ∈ adjoin R s) (Hs : ∀ x ∈ s, ∀ y ∈ s, p x y) (Halg : ∀ r₁ r₂, p (algebraMap R A r₁) (algebraMap R A r₂)) (Halg_left : ∀ (r), ∀ x ∈ s, p (algebraMap R A r) x) (Halg_right : ∀ (r), ∀ x ∈ s, p x (algebraMap R A r)) (Hadd_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y) (Hadd_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂)) (Hmul_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ * x₂) y) (Hmul_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ * y₂)) : p a b := by
refine adjoin_induction hb ?_ (fun r => ?_) (Hadd_right a) (Hmul_right a) · exact adjoin_induction ha Hs Halg_left (fun x y Hx Hy z hz => Hadd_left x y z (Hx z hz) (Hy z hz)) fun x y Hx Hy z hz => Hmul_left x y z (Hx z hz) (Hy z hz) · exact adjoin_induction ha (Halg_right r) (fun r' => Halg r' r) (fun x y => Hadd_left x y ((algebraMap R A) r)) fun x y => Hmul_left x y ((algebraMap R A) r)
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.MeasurableSpace.Basic import Mathlib.MeasureTheory.Measure.MeasureSpaceDef #align_import measure_theory.function.ae_measurable_sequence from "leanprover-community/mathlib"@"d003c55042c3cd08aefd1ae9a42ef89441cdaaf3" /-! # Sequence of measurable functions associated to a sequence of a.e.-measurable functions We define here tools to prove statements about limits (infi, supr...) of sequences of `AEMeasurable` functions. Given a sequence of a.e.-measurable functions `f : ι → α → β` with hypothesis `hf : ∀ i, AEMeasurable (f i) μ`, and a pointwise property `p : α → (ι → β) → Prop` such that we have `hp : ∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, we define a sequence of measurable functions `aeSeq hf p` and a measurable set `aeSeqSet hf p`, such that * `μ (aeSeqSet hf p)ᶜ = 0` * `x ∈ aeSeqSet hf p → ∀ i : ι, aeSeq hf hp i x = f i x` * `x ∈ aeSeqSet hf p → p x (fun n ↦ f n x)` -/ open MeasureTheory open scoped Classical variable {ι : Sort*} {α β γ : Type*} [MeasurableSpace α] [MeasurableSpace β] {f : ι → α → β} {μ : Measure α} {p : α → (ι → β) → Prop} /-- If we have the additional hypothesis `∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, this is a measurable set whose complement has measure 0 such that for all `x ∈ aeSeqSet`, `f i x` is equal to `(hf i).mk (f i) x` for all `i` and we have the pointwise property `p x (fun n ↦ f n x)`. -/ def aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : Set α := (toMeasurable μ { x | (∀ i, f i x = (hf i).mk (f i) x) ∧ p x fun n => f n x }ᶜ)ᶜ #align ae_seq_set aeSeqSet /-- A sequence of measurable functions that are equal to `f` and verify property `p` on the measurable set `aeSeqSet hf p`. -/ noncomputable def aeSeq (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : ι → α → β := fun i x => ite (x ∈ aeSeqSet hf p) ((hf i).mk (f i) x) (⟨f i x⟩ : Nonempty β).some #align ae_seq aeSeq namespace aeSeq section MemAESeqSet theorem mk_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : (hf i).mk (f i) x = f i x := haveI h_ss : aeSeqSet hf p ⊆ { x | ∀ i, f i x = (hf i).mk (f i) x } := by rw [aeSeqSet, ← compl_compl { x | ∀ i, f i x = (hf i).mk (f i) x }, Set.compl_subset_compl] refine Set.Subset.trans (Set.compl_subset_compl.mpr fun x h => ?_) (subset_toMeasurable _ _) exact h.1 (h_ss hx i).symm #align ae_seq.mk_eq_fun_of_mem_ae_seq_set aeSeq.mk_eq_fun_of_mem_aeSeqSet theorem aeSeq_eq_mk_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = (hf i).mk (f i) x := by simp only [aeSeq, hx, if_true] #align ae_seq.ae_seq_eq_mk_of_mem_ae_seq_set aeSeq.aeSeq_eq_mk_of_mem_aeSeqSet theorem aeSeq_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = f i x := by simp only [aeSeq_eq_mk_of_mem_aeSeqSet hf hx i, mk_eq_fun_of_mem_aeSeqSet hf hx i] #align ae_seq.ae_seq_eq_fun_of_mem_ae_seq_set aeSeq.aeSeq_eq_fun_of_mem_aeSeqSet
Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean
69
78
theorem prop_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) : p x fun n => aeSeq hf p n x := by
simp only [aeSeq, hx, if_true] rw [funext fun n => mk_eq_fun_of_mem_aeSeqSet hf hx n] have h_ss : aeSeqSet hf p ⊆ { x | p x fun n => f n x } := by rw [← compl_compl { x | p x fun n => f n x }, aeSeqSet, Set.compl_subset_compl] refine Set.Subset.trans (Set.compl_subset_compl.mpr ?_) (subset_toMeasurable _ _) exact fun x hx => hx.2 have hx' := Set.mem_of_subset_of_mem h_ss hx exact hx'
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen, Devon Tuma -/ import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.RingTheory.Coprime.Basic import Mathlib.Tactic.AdaptationNote #align_import ring_theory.polynomial.scale_roots from "leanprover-community/mathlib"@"40ac1b258344e0c2b4568dc37bfad937ec35a727" /-! # Scaling the roots of a polynomial This file defines `scaleRoots p s` for a polynomial `p` in one variable and a ring element `s` to be the polynomial with root `r * s` for each root `r` of `p` and proves some basic results about it. -/ variable {R S A K : Type*} namespace Polynomial open Polynomial section Semiring variable [Semiring R] [Semiring S] /-- `scaleRoots p s` is a polynomial with root `r * s` for each root `r` of `p`. -/ noncomputable def scaleRoots (p : R[X]) (s : R) : R[X] := ∑ i ∈ p.support, monomial i (p.coeff i * s ^ (p.natDegree - i)) #align polynomial.scale_roots Polynomial.scaleRoots @[simp] theorem coeff_scaleRoots (p : R[X]) (s : R) (i : ℕ) : (scaleRoots p s).coeff i = coeff p i * s ^ (p.natDegree - i) := by simp (config := { contextual := true }) [scaleRoots, coeff_monomial] #align polynomial.coeff_scale_roots Polynomial.coeff_scaleRoots theorem coeff_scaleRoots_natDegree (p : R[X]) (s : R) : (scaleRoots p s).coeff p.natDegree = p.leadingCoeff := by rw [leadingCoeff, coeff_scaleRoots, tsub_self, pow_zero, mul_one] #align polynomial.coeff_scale_roots_nat_degree Polynomial.coeff_scaleRoots_natDegree @[simp] theorem zero_scaleRoots (s : R) : scaleRoots 0 s = 0 := by ext simp #align polynomial.zero_scale_roots Polynomial.zero_scaleRoots theorem scaleRoots_ne_zero {p : R[X]} (hp : p ≠ 0) (s : R) : scaleRoots p s ≠ 0 := by intro h have : p.coeff p.natDegree ≠ 0 := mt leadingCoeff_eq_zero.mp hp have : (scaleRoots p s).coeff p.natDegree = 0 := congr_fun (congr_arg (coeff : R[X] → ℕ → R) h) p.natDegree rw [coeff_scaleRoots_natDegree] at this contradiction #align polynomial.scale_roots_ne_zero Polynomial.scaleRoots_ne_zero theorem support_scaleRoots_le (p : R[X]) (s : R) : (scaleRoots p s).support ≤ p.support := by intro simpa using left_ne_zero_of_mul #align polynomial.support_scale_roots_le Polynomial.support_scaleRoots_le theorem support_scaleRoots_eq (p : R[X]) {s : R} (hs : s ∈ nonZeroDivisors R) : (scaleRoots p s).support = p.support := le_antisymm (support_scaleRoots_le p s) (by intro i simp only [coeff_scaleRoots, Polynomial.mem_support_iff] intro p_ne_zero ps_zero have := pow_mem hs (p.natDegree - i) _ ps_zero contradiction) #align polynomial.support_scale_roots_eq Polynomial.support_scaleRoots_eq @[simp]
Mathlib/RingTheory/Polynomial/ScaleRoots.lean
78
86
theorem degree_scaleRoots (p : R[X]) {s : R} : degree (scaleRoots p s) = degree p := by
haveI := Classical.propDecidable by_cases hp : p = 0 · rw [hp, zero_scaleRoots] refine le_antisymm (Finset.sup_mono (support_scaleRoots_le p s)) (degree_le_degree ?_) rw [coeff_scaleRoots_natDegree] intro h have := leadingCoeff_eq_zero.mp h contradiction
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Integrals import Mathlib.MeasureTheory.Integral.PeakFunction #align_import analysis.special_functions.trigonometric.euler_sine_prod from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Euler's infinite product for the sine function This file proves the infinite product formula $$ \sin \pi z = \pi z \prod_{n = 1}^\infty \left(1 - \frac{z ^ 2}{n ^ 2}\right) $$ for any real or complex `z`. Our proof closely follows the article [Salwinski, *Euler's Sine Product Formula: An Elementary Proof*][salwinski2018]: the basic strategy is to prove a recurrence relation for the integrals `∫ x in 0..π/2, cos 2 z x * cos x ^ (2 * n)`, generalising the arguments used to prove Wallis' limit formula for `π`. -/ open scoped Real Topology open Real Set Filter intervalIntegral MeasureTheory.MeasureSpace namespace EulerSine section IntegralRecursion /-! ## Recursion formula for the integral of `cos (2 * z * x) * cos x ^ n` We evaluate the integral of `cos (2 * z * x) * cos x ^ n`, for any complex `z` and even integers `n`, via repeated integration by parts. -/ variable {z : ℂ} {n : ℕ}
Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean
39
46
theorem antideriv_cos_comp_const_mul (hz : z ≠ 0) (x : ℝ) : HasDerivAt (fun y : ℝ => Complex.sin (2 * z * y) / (2 * z)) (Complex.cos (2 * z * x)) x := by
have a : HasDerivAt (fun y : ℂ => y * (2 * z)) _ x := hasDerivAt_mul_const _ have b : HasDerivAt (fun y : ℂ => Complex.sin (y * (2 * z))) _ x := HasDerivAt.comp (x : ℂ) (Complex.hasDerivAt_sin (x * (2 * z))) a have c := b.comp_ofReal.div_const (2 * z) field_simp at c; simp only [fun y => mul_comm y (2 * z)] at c exact c
/- Copyright (c) 2023 Moritz Firsching. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.Polynomial.Monic import Mathlib.Data.Nat.Factorial.Basic import Mathlib.LinearAlgebra.Vandermonde import Mathlib.RingTheory.Polynomial.Pochhammer /-! # Superfactorial This file defines the [superfactorial](https://en.wikipedia.org/wiki/Superfactorial) `sf n = 1! * 2! * 3! * ... * n!`. ## Main declarations * `Nat.superFactorial`: The superfactorial, denoted by `sf`. -/ namespace Nat /-- `Nat.superFactorial n` is the superfactorial of `n`. -/ def superFactorial : ℕ → ℕ | 0 => 1 | succ n => factorial n.succ * superFactorial n /-- `sf` notation for superfactorial -/ scoped notation "sf" n:60 => Nat.superFactorial n section SuperFactorial variable {n : ℕ} @[simp] theorem superFactorial_zero : sf 0 = 1 := rfl theorem superFactorial_succ (n : ℕ) : (sf n.succ) = (n + 1)! * sf n := rfl @[simp] theorem superFactorial_one : sf 1 = 1 := rfl @[simp] theorem superFactorial_two : sf 2 = 2 := rfl open Finset @[simp] theorem prod_Icc_factorial : ∀ n : ℕ, ∏ x ∈ Icc 1 n, x ! = sf n | 0 => rfl | n + 1 => by rw [← Ico_succ_right 1 n.succ, prod_Ico_succ_top <| Nat.succ_le_succ <| Nat.zero_le n, Nat.factorial_succ, Ico_succ_right 1 n, prod_Icc_factorial n, superFactorial, factorial, Nat.succ_eq_add_one, mul_comm] @[simp] theorem prod_range_factorial_succ (n : ℕ) : ∏ x ∈ range n, (x + 1)! = sf n := (prod_Icc_factorial n) ▸ range_eq_Ico ▸ Finset.prod_Ico_add' _ _ _ _ @[simp] theorem prod_range_succ_factorial : ∀ n : ℕ, ∏ x ∈ range (n + 1), x ! = sf n | 0 => rfl | n + 1 => by rw [prod_range_succ, prod_range_succ_factorial n, mul_comm, superFactorial] variable {R : Type*} [CommRing R] theorem det_vandermonde_id_eq_superFactorial (n : ℕ) : (Matrix.vandermonde (fun (i : Fin (n + 1)) ↦ (i : R))).det = Nat.superFactorial n := by induction' n with n hn · simp [Matrix.det_vandermonde] · rw [Nat.superFactorial, Matrix.det_vandermonde, Fin.prod_univ_succAbove _ 0] push_cast congr · simp only [Fin.val_zero, Nat.cast_zero, sub_zero] norm_cast simp [Fin.prod_univ_eq_prod_range (fun i ↦ (↑i + 1)) (n + 1)] · rw [Matrix.det_vandermonde] at hn simp [hn] theorem superFactorial_two_mul : ∀ n : ℕ, sf (2 * n) = (∏ i ∈ range n, (2 * i + 1) !) ^ 2 * 2 ^ n * n ! | 0 => rfl | (n + 1) => by simp only [prod_range_succ, mul_pow, mul_add, mul_one, superFactorial_succ, superFactorial_two_mul n, factorial_succ] ring theorem superFactorial_four_mul (n : ℕ) : sf (4 * n) = ((∏ i ∈ range (2 * n), (2 * i + 1) !) * 2 ^ n) ^ 2 * (2 * n) ! := calc sf (4 * n) = (∏ i ∈ range (2 * n), (2 * i + 1) !) ^ 2 * 2 ^ (2 * n) * (2 * n) ! := by rw [← superFactorial_two_mul, ← mul_assoc, Nat.mul_two] _ = ((∏ i ∈ range (2 * n), (2 * i + 1) !) * 2 ^ n) ^ 2 * (2 * n) ! := by rw [pow_mul', mul_pow] private theorem matrixOf_eval_descPochhammer_eq_mul_matrixOf_choose {n : ℕ} (v : Fin n → ℕ) : (Matrix.of (fun (i j : Fin n) => (descPochhammer ℤ j).eval (v i : ℤ))).det = (∏ i : Fin n, Nat.factorial i) * (Matrix.of (fun (i j : Fin n) => (Nat.choose (v i) (j : ℕ) : ℤ))).det := by convert Matrix.det_mul_row (fun (i : Fin n) => ((Nat.factorial (i : ℕ)):ℤ)) _ · rw [Matrix.of_apply, descPochhammer_eval_eq_descFactorial ℤ _ _] congr exact Nat.descFactorial_eq_factorial_mul_choose _ _ · rw [Nat.cast_prod]
Mathlib/Data/Nat/Factorial/SuperFactorial.lean
114
125
theorem superFactorial_dvd_vandermonde_det {n : ℕ} (v : Fin (n + 1) → ℤ) : ↑(Nat.superFactorial n) ∣ (Matrix.vandermonde v).det := by
let m := inf' univ ⟨0, mem_univ _⟩ v let w' := fun i ↦ (v i - m).toNat have hw' : ∀ i, (w' i : ℤ) = v i - m := fun i ↦ Int.toNat_sub_of_le (inf'_le _ (mem_univ _)) have h := Matrix.det_eval_matrixOfPolynomials_eq_det_vandermonde (fun i ↦ ↑(w' i)) (fun i => descPochhammer ℤ i) (fun i => descPochhammer_natDegree ℤ i) (fun i => monic_descPochhammer ℤ i) conv_lhs at h => simp only [hw', Matrix.det_vandermonde_sub] use (Matrix.of (fun (i j : Fin (n + 1)) => (Nat.choose (w' i) (j : ℕ) : ℤ))).det simp [h, matrixOf_eval_descPochhammer_eq_mul_matrixOf_choose w', Fin.prod_univ_eq_prod_range]
/- Copyright (c) 2019 Neil Strickland. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Neil Strickland -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Algebra.Order.Field.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Ring.Opposite import Mathlib.Tactic.Abel #align_import algebra.geom_sum from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" /-! # Partial sums of geometric series This file determines the values of the geometric series $\sum_{i=0}^{n-1} x^i$ and $\sum_{i=0}^{n-1} x^i y^{n-1-i}$ and variants thereof. We also provide some bounds on the "geometric" sum of `a/b^i` where `a b : ℕ`. ## Main statements * `geom_sum_Ico` proves that $\sum_{i=m}^{n-1} x^i=\frac{x^n-x^m}{x-1}$ in a division ring. * `geom_sum₂_Ico` proves that $\sum_{i=m}^{n-1} x^iy^{n - 1 - i}=\frac{x^n-y^{n-m}x^m}{x-y}$ in a field. Several variants are recorded, generalising in particular to the case of a noncommutative ring in which `x` and `y` commute. Even versions not using division or subtraction, valid in each semiring, are recorded. -/ -- Porting note: corrected type in the description of `geom_sum₂_Ico` (in the doc string only). universe u variable {α : Type u} open Finset MulOpposite section Semiring variable [Semiring α] theorem geom_sum_succ {x : α} {n : ℕ} : ∑ i ∈ range (n + 1), x ^ i = (x * ∑ i ∈ range n, x ^ i) + 1 := by simp only [mul_sum, ← pow_succ', sum_range_succ', pow_zero] #align geom_sum_succ geom_sum_succ theorem geom_sum_succ' {x : α} {n : ℕ} : ∑ i ∈ range (n + 1), x ^ i = x ^ n + ∑ i ∈ range n, x ^ i := (sum_range_succ _ _).trans (add_comm _ _) #align geom_sum_succ' geom_sum_succ' theorem geom_sum_zero (x : α) : ∑ i ∈ range 0, x ^ i = 0 := rfl #align geom_sum_zero geom_sum_zero theorem geom_sum_one (x : α) : ∑ i ∈ range 1, x ^ i = 1 := by simp [geom_sum_succ'] #align geom_sum_one geom_sum_one @[simp] theorem geom_sum_two {x : α} : ∑ i ∈ range 2, x ^ i = x + 1 := by simp [geom_sum_succ'] #align geom_sum_two geom_sum_two @[simp] theorem zero_geom_sum : ∀ {n}, ∑ i ∈ range n, (0 : α) ^ i = if n = 0 then 0 else 1 | 0 => by simp | 1 => by simp | n + 2 => by rw [geom_sum_succ'] simp [zero_geom_sum] #align zero_geom_sum zero_geom_sum theorem one_geom_sum (n : ℕ) : ∑ i ∈ range n, (1 : α) ^ i = n := by simp #align one_geom_sum one_geom_sum -- porting note (#10618): simp can prove this -- @[simp]
Mathlib/Algebra/GeomSum.lean
81
82
theorem op_geom_sum (x : α) (n : ℕ) : op (∑ i ∈ range n, x ^ i) = ∑ i ∈ range n, op x ^ i := by
simp
/- Copyright (c) 2020 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri, Sebastien Gouezel, Heather Macbeth, Patrick Massot, Floris van Doorn -/ import Mathlib.Analysis.NormedSpace.BoundedLinearMaps import Mathlib.Topology.FiberBundle.Basic #align_import topology.vector_bundle.basic from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Vector bundles In this file we define (topological) vector bundles. Let `B` be the base space, let `F` be a normed space over a normed field `R`, and let `E : B → Type*` be a `FiberBundle` with fiber `F`, in which, for each `x`, the fiber `E x` is a topological vector space over `R`. To have a vector bundle structure on `Bundle.TotalSpace F E`, one should additionally have the following properties: * The bundle trivializations in the trivialization atlas should be continuous linear equivs in the fibers; * For any two trivializations `e`, `e'` in the atlas the transition function considered as a map from `B` into `F →L[R] F` is continuous on `e.baseSet ∩ e'.baseSet` with respect to the operator norm topology on `F →L[R] F`. If these conditions are satisfied, we register the typeclass `VectorBundle R F E`. We define constructions on vector bundles like pullbacks and direct sums in other files. ## Main Definitions * `Trivialization.IsLinear`: a class stating that a trivialization is fiberwise linear on its base set. * `Trivialization.linearEquivAt` and `Trivialization.continuousLinearMapAt` are the (continuous) linear fiberwise equivalences a trivialization induces. * They have forward maps `Trivialization.linearMapAt` / `Trivialization.continuousLinearMapAt` and inverses `Trivialization.symmₗ` / `Trivialization.symmL`. Note that these are all defined everywhere, since they are extended using the zero function. * `Trivialization.coordChangeL` is the coordinate change induced by two trivializations. It only makes sense on the intersection of their base sets, but is extended outside it using the identity. * Given a continuous (semi)linear map between `E x` and `E' y` where `E` and `E'` are bundles over possibly different base sets, `ContinuousLinearMap.inCoordinates` turns this into a continuous (semi)linear map between the chosen fibers of those bundles. ## Implementation notes The implementation choices in the vector bundle definition are discussed in the "Implementation notes" section of `Mathlib.Topology.FiberBundle.Basic`. ## Tags Vector bundle -/ noncomputable section open scoped Classical open Bundle Set open scoped Topology variable (R : Type*) {B : Type*} (F : Type*) (E : B → Type*) section TopologicalVectorSpace variable {F E} variable [Semiring R] [TopologicalSpace F] [TopologicalSpace B] /-- A mixin class for `Pretrivialization`, stating that a pretrivialization is fiberwise linear with respect to given module structures on its fibers and the model fiber. -/ protected class Pretrivialization.IsLinear [AddCommMonoid F] [Module R F] [∀ x, AddCommMonoid (E x)] [∀ x, Module R (E x)] (e : Pretrivialization F (π F E)) : Prop where linear : ∀ b ∈ e.baseSet, IsLinearMap R fun x : E b => (e ⟨b, x⟩).2 #align pretrivialization.is_linear Pretrivialization.IsLinear namespace Pretrivialization variable (e : Pretrivialization F (π F E)) {x : TotalSpace F E} {b : B} {y : E b} theorem linear [AddCommMonoid F] [Module R F] [∀ x, AddCommMonoid (E x)] [∀ x, Module R (E x)] [e.IsLinear R] {b : B} (hb : b ∈ e.baseSet) : IsLinearMap R fun x : E b => (e ⟨b, x⟩).2 := Pretrivialization.IsLinear.linear b hb #align pretrivialization.linear Pretrivialization.linear variable [AddCommMonoid F] [Module R F] [∀ x, AddCommMonoid (E x)] [∀ x, Module R (E x)] /-- A fiberwise linear inverse to `e`. -/ @[simps!] protected def symmₗ (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) : F →ₗ[R] E b := by refine IsLinearMap.mk' (e.symm b) ?_ by_cases hb : b ∈ e.baseSet · exact (((e.linear R hb).mk' _).inverse (e.symm b) (e.symm_apply_apply_mk hb) fun v ↦ congr_arg Prod.snd <| e.apply_mk_symm hb v).isLinear · rw [e.coe_symm_of_not_mem hb] exact (0 : F →ₗ[R] E b).isLinear #align pretrivialization.symmₗ Pretrivialization.symmₗ /-- A pretrivialization for a vector bundle defines linear equivalences between the fibers and the model space. -/ @[simps (config := .asFn)] def linearEquivAt (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) (hb : b ∈ e.baseSet) : E b ≃ₗ[R] F where toFun y := (e ⟨b, y⟩).2 invFun := e.symm b left_inv := e.symm_apply_apply_mk hb right_inv v := by simp_rw [e.apply_mk_symm hb v] map_add' v w := (e.linear R hb).map_add v w map_smul' c v := (e.linear R hb).map_smul c v #align pretrivialization.linear_equiv_at Pretrivialization.linearEquivAt /-- A fiberwise linear map equal to `e` on `e.baseSet`. -/ protected def linearMapAt (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) : E b →ₗ[R] F := if hb : b ∈ e.baseSet then e.linearEquivAt R b hb else 0 #align pretrivialization.linear_map_at Pretrivialization.linearMapAt variable {R}
Mathlib/Topology/VectorBundle/Basic.lean
120
123
theorem coe_linearMapAt (e : Pretrivialization F (π F E)) [e.IsLinear R] (b : B) : ⇑(e.linearMapAt R b) = fun y => if b ∈ e.baseSet then (e ⟨b, y⟩).2 else 0 := by
rw [Pretrivialization.linearMapAt] split_ifs <;> rfl
/- Copyright (c) 2023 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.MonoidAlgebra.Ideal import Mathlib.Algebra.MvPolynomial.Division #align_import ring_theory.mv_polynomial.ideal from "leanprover-community/mathlib"@"72c366d0475675f1309d3027d3d7d47ee4423951" /-! # Lemmas about ideals of `MvPolynomial` Notably this contains results about monomial ideals. ## Main results * `MvPolynomial.mem_ideal_span_monomial_image` * `MvPolynomial.mem_ideal_span_X_image` -/ variable {σ R : Type*} namespace MvPolynomial variable [CommSemiring R] /-- `x` is in a monomial ideal generated by `s` iff every element of its support dominates one of the generators. Note that `si ≤ xi` is analogous to saying that the monomial corresponding to `si` divides the monomial corresponding to `xi`. -/ theorem mem_ideal_span_monomial_image {x : MvPolynomial σ R} {s : Set (σ →₀ ℕ)} : x ∈ Ideal.span ((fun s => monomial s (1 : R)) '' s) ↔ ∀ xi ∈ x.support, ∃ si ∈ s, si ≤ xi := by refine AddMonoidAlgebra.mem_ideal_span_of'_image.trans ?_ simp_rw [le_iff_exists_add, add_comm] rfl #align mv_polynomial.mem_ideal_span_monomial_image MvPolynomial.mem_ideal_span_monomial_image theorem mem_ideal_span_monomial_image_iff_dvd {x : MvPolynomial σ R} {s : Set (σ →₀ ℕ)} : x ∈ Ideal.span ((fun s => monomial s (1 : R)) '' s) ↔ ∀ xi ∈ x.support, ∃ si ∈ s, monomial si 1 ∣ monomial xi (x.coeff xi) := by refine mem_ideal_span_monomial_image.trans (forall₂_congr fun xi hxi => ?_) simp_rw [monomial_dvd_monomial, one_dvd, and_true_iff, mem_support_iff.mp hxi, false_or_iff] #align mv_polynomial.mem_ideal_span_monomial_image_iff_dvd MvPolynomial.mem_ideal_span_monomial_image_iff_dvd /-- `x` is in a monomial ideal generated by variables `X` iff every element of its support has a component in `s`. -/
Mathlib/RingTheory/MvPolynomial/Ideal.lean
48
54
theorem mem_ideal_span_X_image {x : MvPolynomial σ R} {s : Set σ} : x ∈ Ideal.span (MvPolynomial.X '' s : Set (MvPolynomial σ R)) ↔ ∀ m ∈ x.support, ∃ i ∈ s, (m : σ →₀ ℕ) i ≠ 0 := by
have := @mem_ideal_span_monomial_image σ R _ x ((fun i => Finsupp.single i 1) '' s) rw [Set.image_image] at this refine this.trans ?_ simp [Nat.one_le_iff_ne_zero]
/- 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, Bryan Gin-ge Chen -/ import Mathlib.Order.Heyting.Basic #align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4" /-! # (Generalized) Boolean algebras A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras generalize the (classical) logic of propositions and the lattice of subsets of a set. Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary (not-necessarily-finite) type `α`. `GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`). For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra` so that it is also bundled with a `\` operator. (A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do not yet have relative complements for arbitrary intervals, as we do not even have lattice intervals.) ## Main declarations * `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras * `BooleanAlgebra`: a type class for Boolean algebras. * `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop` ## Implementation notes The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in `GeneralizedBooleanAlgebra` are taken from [Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations). [Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution `x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`. ## References * <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations> * [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935] * [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011] ## Tags generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl -/ open Function OrderDual universe u v variable {α : Type u} {β : Type*} {w x y z : α} /-! ### Generalized Boolean algebras Some of the lemmas in this section are from: * [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011] * <https://ncatlab.org/nlab/show/relative+complement> * <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf> -/ /-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and `(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`. This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary (not-necessarily-`Fintype`) `α`. -/ class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where /-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/ sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a /-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/ inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥ #align generalized_boolean_algebra GeneralizedBooleanAlgebra -- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`, -- however we'd need another type class for lattices with bot, and all the API for that. section GeneralizedBooleanAlgebra variable [GeneralizedBooleanAlgebra α] @[simp] theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x := GeneralizedBooleanAlgebra.sup_inf_sdiff _ _ #align sup_inf_sdiff sup_inf_sdiff @[simp] theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ := GeneralizedBooleanAlgebra.inf_inf_sdiff _ _ #align inf_inf_sdiff inf_inf_sdiff @[simp] theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff] #align sup_sdiff_inf sup_sdiff_inf @[simp]
Mathlib/Order/BooleanAlgebra.lean
111
111
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by
rw [inf_comm, inf_inf_sdiff]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Morenikeji Neri -/ import Mathlib.Algebra.EuclideanDomain.Instances import Mathlib.RingTheory.Ideal.Colon import Mathlib.RingTheory.UniqueFactorizationDomain #align_import ring_theory.principal_ideal_domain from "leanprover-community/mathlib"@"6010cf523816335f7bae7f8584cb2edaace73940" /-! # Principal ideal rings, principal ideal domains, and Bézout rings A principal ideal ring (PIR) is a ring in which all left ideals are principal. A principal ideal domain (PID) is an integral domain which is a principal ideal ring. # Main definitions Note that for principal ideal domains, one should use `[IsDomain R] [IsPrincipalIdealRing R]`. There is no explicit definition of a PID. Theorems about PID's are in the `principal_ideal_ring` namespace. - `IsPrincipalIdealRing`: a predicate on rings, saying that every left ideal is principal. - `IsBezout`: the predicate saying that every finitely generated left ideal is principal. - `generator`: a generator of a principal ideal (or more generally submodule) - `to_unique_factorization_monoid`: a PID is a unique factorization domain # Main results - `to_maximal_ideal`: a non-zero prime ideal in a PID is maximal. - `EuclideanDomain.to_principal_ideal_domain` : a Euclidean domain is a PID. - `IsBezout.nonemptyGCDMonoid`: Every Bézout domain is a GCD domain. -/ universe u v variable {R : Type u} {M : Type v} open Set Function open Submodule section variable [Ring R] [AddCommGroup M] [Module R M] instance bot_isPrincipal : (⊥ : Submodule R M).IsPrincipal := ⟨⟨0, by simp⟩⟩ #align bot_is_principal bot_isPrincipal instance top_isPrincipal : (⊤ : Submodule R R).IsPrincipal := ⟨⟨1, Ideal.span_singleton_one.symm⟩⟩ #align top_is_principal top_isPrincipal variable (R) /-- A Bézout ring is a ring whose finitely generated ideals are principal. -/ class IsBezout : Prop where /-- Any finitely generated ideal is principal. -/ isPrincipal_of_FG : ∀ I : Ideal R, I.FG → I.IsPrincipal #align is_bezout IsBezout instance (priority := 100) IsBezout.of_isPrincipalIdealRing [IsPrincipalIdealRing R] : IsBezout R := ⟨fun I _ => IsPrincipalIdealRing.principal I⟩ #align is_bezout.of_is_principal_ideal_ring IsBezout.of_isPrincipalIdealRing instance (priority := 100) DivisionRing.isPrincipalIdealRing (K : Type u) [DivisionRing K] : IsPrincipalIdealRing K where principal S := by rcases Ideal.eq_bot_or_top S with (rfl | rfl) · apply bot_isPrincipal · apply top_isPrincipal #align division_ring.is_principal_ideal_ring DivisionRing.isPrincipalIdealRing end namespace Submodule.IsPrincipal variable [AddCommGroup M] section Ring variable [Ring R] [Module R M] /-- `generator I`, if `I` is a principal submodule, is an `x ∈ M` such that `span R {x} = I` -/ noncomputable def generator (S : Submodule R M) [S.IsPrincipal] : M := Classical.choose (principal S) #align submodule.is_principal.generator Submodule.IsPrincipal.generator theorem span_singleton_generator (S : Submodule R M) [S.IsPrincipal] : span R {generator S} = S := Eq.symm (Classical.choose_spec (principal S)) #align submodule.is_principal.span_singleton_generator Submodule.IsPrincipal.span_singleton_generator @[simp] theorem _root_.Ideal.span_singleton_generator (I : Ideal R) [I.IsPrincipal] : Ideal.span ({generator I} : Set R) = I := Eq.symm (Classical.choose_spec (principal I)) #align ideal.span_singleton_generator Ideal.span_singleton_generator @[simp] theorem generator_mem (S : Submodule R M) [S.IsPrincipal] : generator S ∈ S := by conv_rhs => rw [← span_singleton_generator S] exact subset_span (mem_singleton _) #align submodule.is_principal.generator_mem Submodule.IsPrincipal.generator_mem theorem mem_iff_eq_smul_generator (S : Submodule R M) [S.IsPrincipal] {x : M} : x ∈ S ↔ ∃ s : R, x = s • generator S := by simp_rw [@eq_comm _ x, ← mem_span_singleton, span_singleton_generator] #align submodule.is_principal.mem_iff_eq_smul_generator Submodule.IsPrincipal.mem_iff_eq_smul_generator
Mathlib/RingTheory/PrincipalIdealDomain.lean
114
115
theorem eq_bot_iff_generator_eq_zero (S : Submodule R M) [S.IsPrincipal] : S = ⊥ ↔ generator S = 0 := by
rw [← @span_singleton_eq_bot R M, span_singleton_generator]
/- Copyright (c) 2023 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Order.SuccPred.LinearLocallyFinite import Mathlib.Probability.Martingale.Basic #align_import probability.martingale.optional_sampling from "leanprover-community/mathlib"@"ba074af83b6cf54c3104e59402b39410ddbd6dca" /-! # Optional sampling theorem If `τ` is a bounded stopping time and `σ` is another stopping time, then the value of a martingale `f` at the stopping time `min τ σ` is almost everywhere equal to `μ[stoppedValue f τ | hσ.measurableSpace]`. ## Main results * `stoppedValue_ae_eq_condexp_of_le_const`: the value of a martingale `f` at a stopping time `τ` bounded by `n` is the conditional expectation of `f n` with respect to the σ-algebra generated by `τ`. * `stoppedValue_ae_eq_condexp_of_le`: if `τ` and `σ` are two stopping times with `σ ≤ τ` and `τ` is bounded, then the value of a martingale `f` at `σ` is the conditional expectation of its value at `τ` with respect to the σ-algebra generated by `σ`. * `stoppedValue_min_ae_eq_condexp`: the optional sampling theorem. If `τ` is a bounded stopping time and `σ` is another stopping time, then the value of a martingale `f` at the stopping time `min τ σ` is almost everywhere equal to the conditional expectation of `f` stopped at `τ` with respect to the σ-algebra generated by `σ`. -/ open scoped MeasureTheory ENNReal open TopologicalSpace namespace MeasureTheory namespace Martingale variable {Ω E : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] section FirstCountableTopology variable {ι : Type*} [LinearOrder ι] [TopologicalSpace ι] [OrderTopology ι] [FirstCountableTopology ι] {ℱ : Filtration ι m} [SigmaFiniteFiltration μ ℱ] {τ σ : Ω → ι} {f : ι → Ω → E} {i n : ι} theorem condexp_stopping_time_ae_eq_restrict_eq_const [(Filter.atTop : Filter ι).IsCountablyGenerated] (h : Martingale f ℱ μ) (hτ : IsStoppingTime ℱ τ) [SigmaFinite (μ.trim hτ.measurableSpace_le)] (hin : i ≤ n) : μ[f n|hτ.measurableSpace] =ᵐ[μ.restrict {x | τ x = i}] f i := by refine Filter.EventuallyEq.trans ?_ (ae_restrict_of_ae (h.condexp_ae_eq hin)) refine condexp_ae_eq_restrict_of_measurableSpace_eq_on hτ.measurableSpace_le (ℱ.le i) (hτ.measurableSet_eq' i) fun t => ?_ rw [Set.inter_comm _ t, IsStoppingTime.measurableSet_inter_eq_iff] #align measure_theory.martingale.condexp_stopping_time_ae_eq_restrict_eq_const MeasureTheory.Martingale.condexp_stopping_time_ae_eq_restrict_eq_const
Mathlib/Probability/Martingale/OptionalSampling.lean
61
74
theorem condexp_stopping_time_ae_eq_restrict_eq_const_of_le_const (h : Martingale f ℱ μ) (hτ : IsStoppingTime ℱ τ) (hτ_le : ∀ x, τ x ≤ n) [SigmaFinite (μ.trim (hτ.measurableSpace_le_of_le hτ_le))] (i : ι) : μ[f n|hτ.measurableSpace] =ᵐ[μ.restrict {x | τ x = i}] f i := by
by_cases hin : i ≤ n · refine Filter.EventuallyEq.trans ?_ (ae_restrict_of_ae (h.condexp_ae_eq hin)) refine condexp_ae_eq_restrict_of_measurableSpace_eq_on (hτ.measurableSpace_le_of_le hτ_le) (ℱ.le i) (hτ.measurableSet_eq' i) fun t => ?_ rw [Set.inter_comm _ t, IsStoppingTime.measurableSet_inter_eq_iff] · suffices {x : Ω | τ x = i} = ∅ by simp [this]; norm_cast ext1 x simp only [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false_iff] rintro rfl exact hin (hτ_le x)
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Data.Complex.Abs /-! # The partial order on the complex numbers This order is defined by `z ≤ w ↔ z.re ≤ w.re ∧ z.im = w.im`. This is a natural order on `ℂ` because, as is well-known, there does not exist an order on `ℂ` making it into a `LinearOrderedField`. However, the order described above is the canonical order stemming from the structure of `ℂ` as a ⋆-ring (i.e., it becomes a `StarOrderedRing`). Moreover, with this order `ℂ` is a `StrictOrderedCommRing` and the coercion `(↑) : ℝ → ℂ` is an order embedding. This file only provides `Complex.partialOrder` and lemmas about it. Further structural classes are provided by `Mathlib/Data/RCLike/Basic.lean` as * `RCLike.toStrictOrderedCommRing` * `RCLike.toStarOrderedRing` * `RCLike.toOrderedSMul` These are all only available with `open scoped ComplexOrder`. -/ namespace Complex /-- We put a partial order on ℂ so that `z ≤ w` exactly if `w - z` is real and nonnegative. Complex numbers with different imaginary parts are incomparable. -/ protected def partialOrder : PartialOrder ℂ where le z w := z.re ≤ w.re ∧ z.im = w.im lt z w := z.re < w.re ∧ z.im = w.im lt_iff_le_not_le z w := by dsimp rw [lt_iff_le_not_le] tauto le_refl x := ⟨le_rfl, rfl⟩ le_trans x y z h₁ h₂ := ⟨h₁.1.trans h₂.1, h₁.2.trans h₂.2⟩ le_antisymm z w h₁ h₂ := ext (h₁.1.antisymm h₂.1) h₁.2 #align complex.partial_order Complex.partialOrder namespace _root_.ComplexOrder -- Porting note: made section into namespace to allow scoping scoped[ComplexOrder] attribute [instance] Complex.partialOrder end _root_.ComplexOrder open ComplexOrder theorem le_def {z w : ℂ} : z ≤ w ↔ z.re ≤ w.re ∧ z.im = w.im := Iff.rfl #align complex.le_def Complex.le_def theorem lt_def {z w : ℂ} : z < w ↔ z.re < w.re ∧ z.im = w.im := Iff.rfl #align complex.lt_def Complex.lt_def theorem nonneg_iff {z : ℂ} : 0 ≤ z ↔ 0 ≤ z.re ∧ 0 = z.im := le_def theorem pos_iff {z : ℂ} : 0 < z ↔ 0 < z.re ∧ 0 = z.im := lt_def @[simp, norm_cast] theorem real_le_real {x y : ℝ} : (x : ℂ) ≤ (y : ℂ) ↔ x ≤ y := by simp [le_def, ofReal'] #align complex.real_le_real Complex.real_le_real @[simp, norm_cast] theorem real_lt_real {x y : ℝ} : (x : ℂ) < (y : ℂ) ↔ x < y := by simp [lt_def, ofReal'] #align complex.real_lt_real Complex.real_lt_real @[simp, norm_cast] theorem zero_le_real {x : ℝ} : (0 : ℂ) ≤ (x : ℂ) ↔ 0 ≤ x := real_le_real #align complex.zero_le_real Complex.zero_le_real @[simp, norm_cast] theorem zero_lt_real {x : ℝ} : (0 : ℂ) < (x : ℂ) ↔ 0 < x := real_lt_real #align complex.zero_lt_real Complex.zero_lt_real
Mathlib/Data/Complex/Order.lean
87
88
theorem not_le_iff {z w : ℂ} : ¬z ≤ w ↔ w.re < z.re ∨ z.im ≠ w.im := by
rw [le_def, not_and_or, not_le]
/- 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.Algebra.CharP.Invertible import Mathlib.Analysis.NormedSpace.LinearIsometry import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Analysis.NormedSpace.Basic import Mathlib.LinearAlgebra.AffineSpace.Restrict import Mathlib.Tactic.FailIfNoProgress #align_import analysis.normed_space.affine_isometry from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Affine isometries In this file we define `AffineIsometry 𝕜 P P₂` to be an affine isometric embedding of normed add-torsors `P` into `P₂` over normed `𝕜`-spaces and `AffineIsometryEquiv` to be an affine isometric equivalence between `P` and `P₂`. We also prove basic lemmas and provide convenience constructors. The choice of these lemmas and constructors is closely modelled on those for the `LinearIsometry` and `AffineMap` theories. Since many elementary properties don't require `‖x‖ = 0 → x = 0` we initially set up the theory for `SeminormedAddCommGroup` and specialize to `NormedAddCommGroup` only when needed. ## Notation We introduce the notation `P →ᵃⁱ[𝕜] P₂` for `AffineIsometry 𝕜 P P₂`, and `P ≃ᵃⁱ[𝕜] P₂` for `AffineIsometryEquiv 𝕜 P P₂`. In contrast with the notation `→ₗᵢ` for linear isometries, `≃ᵢ` for isometric equivalences, etc., the "i" here is a superscript. This is for aesthetic reasons to match the superscript "a" (note that in mathlib `→ᵃ` is an affine map, since `→ₐ` has been taken by algebra-homomorphisms.) -/ open Function Set variable (𝕜 : Type*) {V V₁ V₁' V₂ V₃ V₄ : Type*} {P₁ P₁' : Type*} (P P₂ : Type*) {P₃ P₄ : Type*} [NormedField 𝕜] [SeminormedAddCommGroup V] [NormedSpace 𝕜 V] [PseudoMetricSpace P] [NormedAddTorsor V P] [SeminormedAddCommGroup V₁] [NormedSpace 𝕜 V₁] [PseudoMetricSpace P₁] [NormedAddTorsor V₁ P₁] [SeminormedAddCommGroup V₁'] [NormedSpace 𝕜 V₁'] [MetricSpace P₁'] [NormedAddTorsor V₁' P₁'] [SeminormedAddCommGroup V₂] [NormedSpace 𝕜 V₂] [PseudoMetricSpace P₂] [NormedAddTorsor V₂ P₂] [SeminormedAddCommGroup V₃] [NormedSpace 𝕜 V₃] [PseudoMetricSpace P₃] [NormedAddTorsor V₃ P₃] [SeminormedAddCommGroup V₄] [NormedSpace 𝕜 V₄] [PseudoMetricSpace P₄] [NormedAddTorsor V₄ P₄] /-- A `𝕜`-affine isometric embedding of one normed add-torsor over a normed `𝕜`-space into another. -/ structure AffineIsometry extends P →ᵃ[𝕜] P₂ where norm_map : ∀ x : V, ‖linear x‖ = ‖x‖ #align affine_isometry AffineIsometry variable {𝕜 P P₂} @[inherit_doc] notation:25 -- `→ᵃᵢ` would be more consistent with the linear isometry notation, but it is uglier P " →ᵃⁱ[" 𝕜:25 "] " P₂:0 => AffineIsometry 𝕜 P P₂ namespace AffineIsometry variable (f : P →ᵃⁱ[𝕜] P₂) /-- The underlying linear map of an affine isometry is in fact a linear isometry. -/ protected def linearIsometry : V →ₗᵢ[𝕜] V₂ := { f.linear with norm_map' := f.norm_map } #align affine_isometry.linear_isometry AffineIsometry.linearIsometry @[simp]
Mathlib/Analysis/NormedSpace/AffineIsometry.lean
72
74
theorem linear_eq_linearIsometry : f.linear = f.linearIsometry.toLinearMap := by
ext rfl
/- 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 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 #align complex.integral_circle_transform Complex.integral_circleTransform theorem continuous_circleTransform {R : ℝ} (hR : 0 < R) {f : ℂ → E} {z w : ℂ} (hf : ContinuousOn f <| sphere z R) (hw : w ∈ ball z R) : Continuous (circleTransform R z w f) := by apply_rules [Continuous.smul, continuous_const] · simp_rw [deriv_circleMap] apply_rules [Continuous.mul, continuous_circleMap 0 R, continuous_const] · exact continuous_circleMap_inv hw · apply ContinuousOn.comp_continuous hf (continuous_circleMap z R) exact fun _ => (circleMap_mem_sphere _ hR.le) _ #align complex.continuous_circle_transform Complex.continuous_circleTransform theorem continuous_circleTransformDeriv {R : ℝ} (hR : 0 < R) {f : ℂ → E} {z w : ℂ} (hf : ContinuousOn f (sphere z R)) (hw : w ∈ ball z R) : Continuous (circleTransformDeriv R z w f) := by rw [circleTransformDeriv_eq] exact (continuous_circleMap_inv hw).smul (continuous_circleTransform hR hf hw) #align complex.continuous_circle_transform_deriv Complex.continuous_circleTransformDeriv /-- A useful bound for circle integrals (with complex codomain)-/ def circleTransformBoundingFunction (R : ℝ) (z : ℂ) (w : ℂ × ℝ) : ℂ := circleTransformDeriv R z w.1 (fun _ => 1) w.2 #align complex.circle_transform_bounding_function Complex.circleTransformBoundingFunction theorem continuousOn_prod_circle_transform_function {R r : ℝ} (hr : r < R) {z : ℂ} : ContinuousOn (fun w : ℂ × ℝ => (circleMap z R w.snd - w.fst)⁻¹ ^ 2) (closedBall z r ×ˢ univ) := by simp_rw [← one_div] apply_rules [ContinuousOn.pow, ContinuousOn.div, continuousOn_const] · exact ((continuous_circleMap z R).comp_continuousOn continuousOn_snd).sub continuousOn_fst · rintro ⟨a, b⟩ ⟨ha, -⟩ have ha2 : a ∈ ball z R := closedBall_subset_ball hr ha exact sub_ne_zero.2 (circleMap_ne_mem_ball ha2 b) #align complex.continuous_on_prod_circle_transform_function Complex.continuousOn_prod_circle_transform_function
Mathlib/MeasureTheory/Integral/CircleTransform.lean
109
117
theorem continuousOn_abs_circleTransformBoundingFunction {R r : ℝ} (hr : r < R) (z : ℂ) : ContinuousOn (abs ∘ circleTransformBoundingFunction R z) (closedBall z r ×ˢ univ) := by
have : ContinuousOn (circleTransformBoundingFunction R z) (closedBall z r ×ˢ univ) := by apply_rules [ContinuousOn.smul, continuousOn_const] · simp only [deriv_circleMap] apply_rules [ContinuousOn.mul, (continuous_circleMap 0 R).comp_continuousOn continuousOn_snd, continuousOn_const] · simpa only [inv_pow] using continuousOn_prod_circle_transform_function hr exact this.norm
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Nat.Lattice import Mathlib.Logic.Denumerable import Mathlib.Logic.Function.Iterate import Mathlib.Order.Hom.Basic import Mathlib.Data.Set.Subsingleton #align_import order.order_iso_nat from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90" /-! # Relation embeddings from the naturals This file allows translation from monotone functions `ℕ → α` to order embeddings `ℕ ↪ α` and defines the limit value of an eventually-constant sequence. ## Main declarations * `natLT`/`natGT`: Make an order embedding `Nat ↪ α` from an increasing/decreasing function `Nat → α`. * `monotonicSequenceLimit`: The limit of an eventually-constant monotone sequence `Nat →o α`. * `monotonicSequenceLimitIndex`: The index of the first occurrence of `monotonicSequenceLimit` in the sequence. -/ variable {α : Type*} namespace RelEmbedding variable {r : α → α → Prop} [IsStrictOrder α r] /-- If `f` is a strictly `r`-increasing sequence, then this returns `f` as an order embedding. -/ def natLT (f : ℕ → α) (H : ∀ n : ℕ, r (f n) (f (n + 1))) : ((· < ·) : ℕ → ℕ → Prop) ↪r r := ofMonotone f <| Nat.rel_of_forall_rel_succ_of_lt r H #align rel_embedding.nat_lt RelEmbedding.natLT @[simp] theorem coe_natLT {f : ℕ → α} {H : ∀ n : ℕ, r (f n) (f (n + 1))} : ⇑(natLT f H) = f := rfl #align rel_embedding.coe_nat_lt RelEmbedding.coe_natLT /-- If `f` is a strictly `r`-decreasing sequence, then this returns `f` as an order embedding. -/ def natGT (f : ℕ → α) (H : ∀ n : ℕ, r (f (n + 1)) (f n)) : ((· > ·) : ℕ → ℕ → Prop) ↪r r := haveI := IsStrictOrder.swap r RelEmbedding.swap (natLT f H) #align rel_embedding.nat_gt RelEmbedding.natGT @[simp] theorem coe_natGT {f : ℕ → α} {H : ∀ n : ℕ, r (f (n + 1)) (f n)} : ⇑(natGT f H) = f := rfl #align rel_embedding.coe_nat_gt RelEmbedding.coe_natGT theorem exists_not_acc_lt_of_not_acc {a : α} {r} (h : ¬Acc r a) : ∃ b, ¬Acc r b ∧ r b a := by contrapose! h refine ⟨_, fun b hr => ?_⟩ by_contra hb exact h b hb hr #align rel_embedding.exists_not_acc_lt_of_not_acc RelEmbedding.exists_not_acc_lt_of_not_acc /-- A value is accessible iff it isn't contained in any infinite decreasing sequence. -/ theorem acc_iff_no_decreasing_seq {x} : Acc r x ↔ IsEmpty { f : ((· > ·) : ℕ → ℕ → Prop) ↪r r // x ∈ Set.range f } := by constructor · refine fun h => h.recOn fun x _ IH => ?_ constructor rintro ⟨f, k, hf⟩ exact IsEmpty.elim' (IH (f (k + 1)) (hf ▸ f.map_rel_iff.2 (lt_add_one k))) ⟨f, _, rfl⟩ · have : ∀ x : { a // ¬Acc r a }, ∃ y : { a // ¬Acc r a }, r y.1 x.1 := by rintro ⟨x, hx⟩ cases exists_not_acc_lt_of_not_acc hx with | intro w h => exact ⟨⟨w, h.1⟩, h.2⟩ choose f h using this refine fun E => by_contradiction fun hx => E.elim' ⟨natGT (fun n => (f^[n] ⟨x, hx⟩).1) fun n => ?_, 0, rfl⟩ simp only [Function.iterate_succ'] apply h #align rel_embedding.acc_iff_no_decreasing_seq RelEmbedding.acc_iff_no_decreasing_seq theorem not_acc_of_decreasing_seq (f : ((· > ·) : ℕ → ℕ → Prop) ↪r r) (k : ℕ) : ¬Acc r (f k) := by rw [acc_iff_no_decreasing_seq, not_isEmpty_iff] exact ⟨⟨f, k, rfl⟩⟩ #align rel_embedding.not_acc_of_decreasing_seq RelEmbedding.not_acc_of_decreasing_seq /-- A relation is well-founded iff it doesn't have any infinite decreasing sequence. -/
Mathlib/Order/OrderIsoNat.lean
90
96
theorem wellFounded_iff_no_descending_seq : WellFounded r ↔ IsEmpty (((· > ·) : ℕ → ℕ → Prop) ↪r r) := by
constructor · rintro ⟨h⟩ exact ⟨fun f => not_acc_of_decreasing_seq f 0 (h _)⟩ · intro h exact ⟨fun x => acc_iff_no_decreasing_seq.2 inferInstance⟩
/- 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.Polynomial.FieldDivision import Mathlib.Algebra.Polynomial.Lifts import Mathlib.Data.List.Prime #align_import data.polynomial.splits from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # Split polynomials A polynomial `f : K[X]` splits over a field extension `L` of `K` if it is zero or all of its irreducible factors over `L` have degree `1`. ## Main definitions * `Polynomial.Splits i f`: A predicate on a homomorphism `i : K →+* L` from a commutative ring to a field and a polynomial `f` saying that `f.map i` is zero or all of its irreducible factors over `L` have degree `1`. -/ noncomputable section open Polynomial universe u v w variable {R : Type*} {F : Type u} {K : Type v} {L : Type w} namespace Polynomial open Polynomial section Splits section CommRing variable [CommRing K] [Field L] [Field F] variable (i : K →+* L) /-- A polynomial `Splits` iff it is zero or all of its irreducible factors have `degree` 1. -/ def Splits (f : K[X]) : Prop := f.map i = 0 ∨ ∀ {g : L[X]}, Irreducible g → g ∣ f.map i → degree g = 1 #align polynomial.splits Polynomial.Splits @[simp] theorem splits_zero : Splits i (0 : K[X]) := Or.inl (Polynomial.map_zero i) #align polynomial.splits_zero Polynomial.splits_zero theorem splits_of_map_eq_C {f : K[X]} {a : L} (h : f.map i = C a) : Splits i f := letI := Classical.decEq L if ha : a = 0 then Or.inl (h.trans (ha.symm ▸ C_0)) else Or.inr fun hg ⟨p, hp⟩ => absurd hg.1 <| Classical.not_not.2 <| isUnit_iff_degree_eq_zero.2 <| by have := congr_arg degree hp rw [h, degree_C ha, degree_mul, @eq_comm (WithBot ℕ) 0, Nat.WithBot.add_eq_zero_iff] at this exact this.1 set_option linter.uppercaseLean3 false in #align polynomial.splits_of_map_eq_C Polynomial.splits_of_map_eq_C @[simp] theorem splits_C (a : K) : Splits i (C a) := splits_of_map_eq_C i (map_C i) set_option linter.uppercaseLean3 false in #align polynomial.splits_C Polynomial.splits_C theorem splits_of_map_degree_eq_one {f : K[X]} (hf : degree (f.map i) = 1) : Splits i f := Or.inr fun hg ⟨p, hp⟩ => by have := congr_arg degree hp simp [Nat.WithBot.add_eq_one_iff, hf, @eq_comm (WithBot ℕ) 1, mt isUnit_iff_degree_eq_zero.2 hg.1] at this tauto #align polynomial.splits_of_map_degree_eq_one Polynomial.splits_of_map_degree_eq_one theorem splits_of_degree_le_one {f : K[X]} (hf : degree f ≤ 1) : Splits i f := if hif : degree (f.map i) ≤ 0 then splits_of_map_eq_C i (degree_le_zero_iff.mp hif) else by push_neg at hif rw [← Order.succ_le_iff, ← WithBot.coe_zero, WithBot.succ_coe, Nat.succ_eq_succ] at hif exact splits_of_map_degree_eq_one i (le_antisymm ((degree_map_le i _).trans hf) hif) #align polynomial.splits_of_degree_le_one Polynomial.splits_of_degree_le_one theorem splits_of_degree_eq_one {f : K[X]} (hf : degree f = 1) : Splits i f := splits_of_degree_le_one i hf.le #align polynomial.splits_of_degree_eq_one Polynomial.splits_of_degree_eq_one theorem splits_of_natDegree_le_one {f : K[X]} (hf : natDegree f ≤ 1) : Splits i f := splits_of_degree_le_one i (degree_le_of_natDegree_le hf) #align polynomial.splits_of_nat_degree_le_one Polynomial.splits_of_natDegree_le_one theorem splits_of_natDegree_eq_one {f : K[X]} (hf : natDegree f = 1) : Splits i f := splits_of_natDegree_le_one i (le_of_eq hf) #align polynomial.splits_of_nat_degree_eq_one Polynomial.splits_of_natDegree_eq_one theorem splits_mul {f g : K[X]} (hf : Splits i f) (hg : Splits i g) : Splits i (f * g) := letI := Classical.decEq L if h : (f * g).map i = 0 then Or.inl h else Or.inr @fun p hp hpf => ((irreducible_iff_prime.1 hp).2.2 _ _ (show p ∣ map i f * map i g by convert hpf; rw [Polynomial.map_mul])).elim (hf.resolve_left (fun hf => by simp [hf] at h) hp) (hg.resolve_left (fun hg => by simp [hg] at h) hp) #align polynomial.splits_mul Polynomial.splits_mul theorem splits_of_splits_mul' {f g : K[X]} (hfg : (f * g).map i ≠ 0) (h : Splits i (f * g)) : Splits i f ∧ Splits i g := ⟨Or.inr @fun g hgi hg => Or.resolve_left h hfg hgi (by rw [Polynomial.map_mul]; exact hg.trans (dvd_mul_right _ _)), Or.inr @fun g hgi hg => Or.resolve_left h hfg hgi (by rw [Polynomial.map_mul]; exact hg.trans (dvd_mul_left _ _))⟩ #align polynomial.splits_of_splits_mul' Polynomial.splits_of_splits_mul'
Mathlib/Algebra/Polynomial/Splits.lean
124
125
theorem splits_map_iff (j : L →+* F) {f : K[X]} : Splits j (f.map i) ↔ Splits (j.comp i) f := by
simp [Splits, Polynomial.map_map]
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Homology.HomologicalComplex import Mathlib.CategoryTheory.DifferentialObject #align_import algebra.homology.differential_object from "leanprover-community/mathlib"@"b535c2d5d996acd9b0554b76395d9c920e186f4f" /-! # Homological complexes are differential graded objects. We verify that a `HomologicalComplex` indexed by an `AddCommGroup` is essentially the same thing as a differential graded object. This equivalence is probably not particularly useful in practice; it's here to check that definitions match up as expected. -/ open CategoryTheory CategoryTheory.Limits open scoped Classical noncomputable section /-! We first prove some results about differential graded objects. Porting note: after the port, move these to their own file. -/ namespace CategoryTheory.DifferentialObject variable {β : Type*} [AddCommGroup β] {b : β} variable {V : Type*} [Category V] [HasZeroMorphisms V] variable (X : DifferentialObject ℤ (GradedObjectWithShift b V)) /-- Since `eqToHom` only preserves the fact that `X.X i = X.X j` but not `i = j`, this definition is used to aid the simplifier. -/ abbrev objEqToHom {i j : β} (h : i = j) : X.obj i ⟶ X.obj j := eqToHom (congr_arg X.obj h) set_option linter.uppercaseLean3 false in #align category_theory.differential_object.X_eq_to_hom CategoryTheory.DifferentialObject.objEqToHom @[simp] theorem objEqToHom_refl (i : β) : X.objEqToHom (refl i) = 𝟙 _ := rfl set_option linter.uppercaseLean3 false in #align category_theory.differential_object.X_eq_to_hom_refl CategoryTheory.DifferentialObject.objEqToHom_refl @[reassoc (attr := simp)] theorem objEqToHom_d {x y : β} (h : x = y) : X.objEqToHom h ≫ X.d y = X.d x ≫ X.objEqToHom (by cases h; rfl) := by cases h; dsimp; simp #align homological_complex.eq_to_hom_d CategoryTheory.DifferentialObject.objEqToHom_d @[reassoc (attr := simp)] theorem d_squared_apply {x : β} : X.d x ≫ X.d _ = 0 := congr_fun X.d_squared _ @[reassoc (attr := simp)]
Mathlib/Algebra/Homology/DifferentialObject.lean
61
62
theorem eqToHom_f' {X Y : DifferentialObject ℤ (GradedObjectWithShift b V)} (f : X ⟶ Y) {x y : β} (h : x = y) : X.objEqToHom h ≫ f.f y = f.f x ≫ Y.objEqToHom h := by
cases h; simp
/- 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.PFunctor.Univariate.M #align_import data.qpf.univariate.basic from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7" /-! # Quotients of Polynomial Functors We assume the following: * `P`: a polynomial functor * `W`: its W-type * `M`: its M-type * `F`: a functor We define: * `q`: `QPF` data, representing `F` as a quotient of `P` The main goal is to construct: * `Fix`: the initial algebra with structure map `F Fix → Fix`. * `Cofix`: the final coalgebra with structure map `Cofix → F Cofix` We also show that the composition of qpfs is a qpf, and that the quotient of a qpf is a qpf. The present theory focuses on the univariate case for qpfs ## References * [Jeremy Avigad, Mario M. Carneiro and Simon Hudon, *Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019] -/ universe u /-- Quotients of polynomial functors. Roughly speaking, saying that `F` is a quotient of a polynomial functor means that for each `α`, elements of `F α` are represented by pairs `⟨a, f⟩`, where `a` is the shape of the object and `f` indexes the relevant elements of `α`, in a suitably natural manner. -/ class QPF (F : Type u → Type u) [Functor F] where P : PFunctor.{u} abs : ∀ {α}, P α → F α repr : ∀ {α}, F α → P α abs_repr : ∀ {α} (x : F α), abs (repr x) = x abs_map : ∀ {α β} (f : α → β) (p : P α), abs (P.map f p) = f <$> abs p #align qpf QPF namespace QPF variable {F : Type u → Type u} [Functor F] [q : QPF F] open Functor (Liftp Liftr) /- Show that every qpf is a lawful functor. Note: every functor has a field, `map_const`, and `lawfulFunctor` has the defining characterization. We can only propagate the assumption. -/ theorem id_map {α : Type _} (x : F α) : id <$> x = x := by rw [← abs_repr x] cases' repr x with a f rw [← abs_map] rfl #align qpf.id_map QPF.id_map
Mathlib/Data/QPF/Univariate/Basic.lean
78
83
theorem comp_map {α β γ : Type _} (f : α → β) (g : β → γ) (x : F α) : (g ∘ f) <$> x = g <$> f <$> x := by
rw [← abs_repr x] cases' repr x with a f rw [← abs_map, ← abs_map, ← abs_map] rfl
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou -/ import Mathlib.Order.Filter.AtTopBot import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.LinearCombination import Mathlib.Tactic.Linarith.Frontend #align_import algebra.quadratic_discriminant from "leanprover-community/mathlib"@"e085d1df33274f4b32f611f483aae678ba0b42df" /-! # Quadratic discriminants and roots of a quadratic This file defines the discriminant of a quadratic and gives the solution to a quadratic equation. ## Main definition - `discrim a b c`: the discriminant of a quadratic `a * x * x + b * x + c` is `b * b - 4 * a * c`. ## Main statements - `quadratic_eq_zero_iff`: roots of a quadratic can be written as `(-b + s) / (2 * a)` or `(-b - s) / (2 * a)`, where `s` is a square root of the discriminant. - `quadratic_ne_zero_of_discrim_ne_sq`: if the discriminant has no square root, then the corresponding quadratic has no root. - `discrim_le_zero`: if a quadratic is always non-negative, then its discriminant is non-positive. - `discrim_le_zero_of_nonpos`, `discrim_lt_zero`, `discrim_lt_zero_of_neg`: versions of this statement with other inequalities. ## Tags polynomial, quadratic, discriminant, root -/ open Filter section Ring variable {R : Type*} /-- Discriminant of a quadratic -/ def discrim [Ring R] (a b c : R) : R := b ^ 2 - 4 * a * c #align discrim discrim @[simp] lemma discrim_neg [Ring R] (a b c : R) : discrim (-a) (-b) (-c) = discrim a b c := by simp [discrim] #align discrim_neg discrim_neg variable [CommRing R] {a b c : R} lemma discrim_eq_sq_of_quadratic_eq_zero {x : R} (h : a * x * x + b * x + c = 0) : discrim a b c = (2 * a * x + b) ^ 2 := by rw [discrim] linear_combination -4 * a * h #align discrim_eq_sq_of_quadratic_eq_zero discrim_eq_sq_of_quadratic_eq_zero /-- A quadratic has roots if and only if its discriminant equals some square. -/ theorem quadratic_eq_zero_iff_discrim_eq_sq [NeZero (2 : R)] [NoZeroDivisors R] (ha : a ≠ 0) (x : R) : a * x * x + b * x + c = 0 ↔ discrim a b c = (2 * a * x + b) ^ 2 := by refine ⟨discrim_eq_sq_of_quadratic_eq_zero, fun h ↦ ?_⟩ rw [discrim] at h have ha : 2 * 2 * a ≠ 0 := mul_ne_zero (mul_ne_zero (NeZero.ne _) (NeZero.ne _)) ha apply mul_left_cancel₀ ha linear_combination -h #align quadratic_eq_zero_iff_discrim_eq_sq quadratic_eq_zero_iff_discrim_eq_sq /-- A quadratic has no root if its discriminant has no square root. -/ theorem quadratic_ne_zero_of_discrim_ne_sq (h : ∀ s : R, discrim a b c ≠ s^2) (x : R) : a * x * x + b * x + c ≠ 0 := mt discrim_eq_sq_of_quadratic_eq_zero (h _) #align quadratic_ne_zero_of_discrim_ne_sq quadratic_ne_zero_of_discrim_ne_sq end Ring section Field variable {K : Type*} [Field K] [NeZero (2 : K)] {a b c x : K} /-- Roots of a quadratic equation. -/ theorem quadratic_eq_zero_iff (ha : a ≠ 0) {s : K} (h : discrim a b c = s * s) (x : K) : a * x * x + b * x + c = 0 ↔ x = (-b + s) / (2 * a) ∨ x = (-b - s) / (2 * a) := by rw [quadratic_eq_zero_iff_discrim_eq_sq ha, h, sq, mul_self_eq_mul_self_iff] field_simp apply or_congr · constructor <;> intro h' <;> linear_combination -h' · constructor <;> intro h' <;> linear_combination h' #align quadratic_eq_zero_iff quadratic_eq_zero_iff /-- A quadratic has roots if its discriminant has square roots -/
Mathlib/Algebra/QuadraticDiscriminant.lean
96
101
theorem exists_quadratic_eq_zero (ha : a ≠ 0) (h : ∃ s, discrim a b c = s * s) : ∃ x, a * x * x + b * x + c = 0 := by
rcases h with ⟨s, hs⟩ use (-b + s) / (2 * a) rw [quadratic_eq_zero_iff ha hs] 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.RingTheory.PrincipalIdealDomain #align_import ring_theory.bezout from "leanprover-community/mathlib"@"6623e6af705e97002a9054c1c05a980180276fc1" /-! # Bézout rings A Bézout ring (Bezout ring) is a ring whose finitely generated ideals are principal. Notable examples include principal ideal rings, valuation rings, and the ring of algebraic integers. ## Main results - `IsBezout.iff_span_pair_isPrincipal`: It suffices to verify every `span {x, y}` is principal. - `IsBezout.TFAE`: For a Bézout domain, noetherian ↔ PID ↔ UFD ↔ ACCP -/ universe u v variable {R : Type u} [CommRing R] namespace IsBezout theorem iff_span_pair_isPrincipal : IsBezout R ↔ ∀ x y : R, (Ideal.span {x, y} : Ideal R).IsPrincipal := by classical constructor · intro H x y; infer_instance · intro H constructor apply Submodule.fg_induction · exact fun _ => ⟨⟨_, rfl⟩⟩ · rintro _ _ ⟨⟨x, rfl⟩⟩ ⟨⟨y, rfl⟩⟩; rw [← Submodule.span_insert]; exact H _ _ #align is_bezout.iff_span_pair_is_principal IsBezout.iff_span_pair_isPrincipal theorem _root_.Function.Surjective.isBezout {S : Type v} [CommRing S] (f : R →+* S) (hf : Function.Surjective f) [IsBezout R] : IsBezout S := by rw [iff_span_pair_isPrincipal] intro x y obtain ⟨⟨x, rfl⟩, ⟨y, rfl⟩⟩ := hf x, hf y use f (gcd x y) trans Ideal.map f (Ideal.span {gcd x y}) · rw [span_gcd, Ideal.map_span, Set.image_insert_eq, Set.image_singleton] · rw [Ideal.map_span, Set.image_singleton]; rfl #align function.surjective.is_bezout Function.Surjective.isBezout
Mathlib/RingTheory/Bezout.lean
53
78
theorem TFAE [IsBezout R] [IsDomain R] : List.TFAE [IsNoetherianRing R, IsPrincipalIdealRing R, UniqueFactorizationMonoid R, WfDvdMonoid R] := by
classical tfae_have 1 → 2 · intro H; exact ⟨fun I => isPrincipal_of_FG _ (IsNoetherian.noetherian _)⟩ tfae_have 2 → 3 · intro; infer_instance tfae_have 3 → 4 · intro; infer_instance tfae_have 4 → 1 · rintro ⟨h⟩ rw [isNoetherianRing_iff, isNoetherian_iff_fg_wellFounded] apply RelEmbedding.wellFounded _ h have : ∀ I : { J : Ideal R // J.FG }, ∃ x : R, (I : Ideal R) = Ideal.span {x} := fun ⟨I, hI⟩ => (IsBezout.isPrincipal_of_FG I hI).1 choose f hf using this exact { toFun := f inj' := fun x y e => by ext1; rw [hf, hf, e] map_rel_iff' := by dsimp intro a b rw [← Ideal.span_singleton_lt_span_singleton, ← hf, ← hf] rfl } tfae_finish
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.Order.LeftRight import Mathlib.Topology.Order.Monotone #align_import topology.algebra.order.left_right_lim from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" /-! # Left and right limits We define the (strict) left and right limits of a function. * `leftLim f x` is the strict left limit of `f` at `x` (using `f x` as a garbage value if `x` is isolated to its left). * `rightLim f x` is the strict right limit of `f` at `x` (using `f x` as a garbage value if `x` is isolated to its right). We develop a comprehensive API for monotone functions. Notably, * `Monotone.continuousAt_iff_leftLim_eq_rightLim` states that a monotone function is continuous at a point if and only if its left and right limits coincide. * `Monotone.countable_not_continuousAt` asserts that a monotone function taking values in a second-countable space has at most countably many discontinuity points. We also port the API to antitone functions. ## TODO Prove corresponding stronger results for `StrictMono` and `StrictAnti` functions. -/ open Set Filter open Topology section variable {α β : Type*} [LinearOrder α] [TopologicalSpace β] /-- Let `f : α → β` be a function from a linear order `α` to a topological space `β`, and let `a : α`. The limit strictly to the left of `f` at `a`, denoted with `leftLim f a`, is defined by using the order topology on `α`. If `a` is isolated to its left or the function has no left limit, we use `f a` instead to guarantee a good behavior in most cases. -/ noncomputable def Function.leftLim (f : α → β) (a : α) : β := by classical haveI : Nonempty β := ⟨f a⟩ letI : TopologicalSpace α := Preorder.topology α exact if 𝓝[<] a = ⊥ ∨ ¬∃ y, Tendsto f (𝓝[<] a) (𝓝 y) then f a else limUnder (𝓝[<] a) f #align function.left_lim Function.leftLim /-- Let `f : α → β` be a function from a linear order `α` to a topological space `β`, and let `a : α`. The limit strictly to the right of `f` at `a`, denoted with `rightLim f a`, is defined by using the order topology on `α`. If `a` is isolated to its right or the function has no right limit, , we use `f a` instead to guarantee a good behavior in most cases. -/ noncomputable def Function.rightLim (f : α → β) (a : α) : β := @Function.leftLim αᵒᵈ β _ _ f a #align function.right_lim Function.rightLim open Function theorem leftLim_eq_of_tendsto [hα : TopologicalSpace α] [h'α : OrderTopology α] [T2Space β] {f : α → β} {a : α} {y : β} (h : 𝓝[<] a ≠ ⊥) (h' : Tendsto f (𝓝[<] a) (𝓝 y)) : leftLim f a = y := by have h'' : ∃ y, Tendsto f (𝓝[<] a) (𝓝 y) := ⟨y, h'⟩ rw [h'α.topology_eq_generate_intervals] at h h' h'' simp only [leftLim, h, h'', not_true, or_self_iff, if_false] haveI := neBot_iff.2 h exact lim_eq h' #align left_lim_eq_of_tendsto leftLim_eq_of_tendsto theorem leftLim_eq_of_eq_bot [hα : TopologicalSpace α] [h'α : OrderTopology α] (f : α → β) {a : α} (h : 𝓝[<] a = ⊥) : leftLim f a = f a := by rw [h'α.topology_eq_generate_intervals] at h simp [leftLim, ite_eq_left_iff, h] #align left_lim_eq_of_eq_bot leftLim_eq_of_eq_bot theorem rightLim_eq_of_tendsto [TopologicalSpace α] [OrderTopology α] [T2Space β] {f : α → β} {a : α} {y : β} (h : 𝓝[>] a ≠ ⊥) (h' : Tendsto f (𝓝[>] a) (𝓝 y)) : Function.rightLim f a = y := @leftLim_eq_of_tendsto αᵒᵈ _ _ _ _ _ _ f a y h h' #align right_lim_eq_of_tendsto rightLim_eq_of_tendsto theorem rightLim_eq_of_eq_bot [TopologicalSpace α] [OrderTopology α] (f : α → β) {a : α} (h : 𝓝[>] a = ⊥) : rightLim f a = f a := @leftLim_eq_of_eq_bot αᵒᵈ _ _ _ _ _ f a h end open Function namespace Monotone variable {α β : Type*} [LinearOrder α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : Monotone f) {x y : α} theorem leftLim_eq_sSup [TopologicalSpace α] [OrderTopology α] (h : 𝓝[<] x ≠ ⊥) : leftLim f x = sSup (f '' Iio x) := leftLim_eq_of_tendsto h (hf.tendsto_nhdsWithin_Iio x) #align monotone.left_lim_eq_Sup Monotone.leftLim_eq_sSup theorem rightLim_eq_sInf [TopologicalSpace α] [OrderTopology α] (h : 𝓝[>] x ≠ ⊥) : rightLim f x = sInf (f '' Ioi x) := rightLim_eq_of_tendsto h (hf.tendsto_nhdsWithin_Ioi x) #align right_lim_eq_Inf Monotone.rightLim_eq_sInf
Mathlib/Topology/Order/LeftRightLim.lean
110
122
theorem leftLim_le (h : x ≤ y) : leftLim f x ≤ f y := by
letI : TopologicalSpace α := Preorder.topology α haveI : OrderTopology α := ⟨rfl⟩ rcases eq_or_ne (𝓝[<] x) ⊥ with (h' | h') · simpa [leftLim, h'] using hf h haveI A : NeBot (𝓝[<] x) := neBot_iff.2 h' rw [leftLim_eq_sSup hf h'] refine csSup_le ?_ ?_ · simp only [image_nonempty] exact (forall_mem_nonempty_iff_neBot.2 A) _ self_mem_nhdsWithin · simp only [mem_image, mem_Iio, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro z hz exact hf (hz.le.trans h)
/- Copyright (c) 2021 Bolton Bailey. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bolton Bailey -/ import Mathlib.Analysis.SpecialFunctions.Pow.Real #align_import analysis.special_functions.log.monotone from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8" /-! # Logarithm Tonality In this file we describe the tonality of the logarithm function when multiplied by functions of the form `x ^ a`. ## Tags logarithm, tonality -/ open Set Filter Function open Topology noncomputable section namespace Real variable {x y : ℝ} theorem log_mul_self_monotoneOn : MonotoneOn (fun x : ℝ => log x * x) { x | 1 ≤ x } := by -- TODO: can be strengthened to exp (-1) ≤ x simp only [MonotoneOn, mem_setOf_eq] intro x hex y hey hxy have y_pos : 0 < y := lt_of_lt_of_le zero_lt_one hey gcongr rwa [le_log_iff_exp_le y_pos, Real.exp_zero] #align real.log_mul_self_monotone_on Real.log_mul_self_monotoneOn
Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean
41
53
theorem log_div_self_antitoneOn : AntitoneOn (fun x : ℝ => log x / x) { x | exp 1 ≤ x } := by
simp only [AntitoneOn, mem_setOf_eq] intro x hex y hey hxy have x_pos : 0 < x := (exp_pos 1).trans_le hex have y_pos : 0 < y := (exp_pos 1).trans_le hey have hlogx : 1 ≤ log x := by rwa [le_log_iff_exp_le x_pos] have hyx : 0 ≤ y / x - 1 := by rwa [le_sub_iff_add_le, le_div_iff x_pos, zero_add, one_mul] rw [div_le_iff y_pos, ← sub_le_sub_iff_right (log x)] calc log y - log x = log (y / x) := by rw [log_div y_pos.ne' x_pos.ne'] _ ≤ y / x - 1 := log_le_sub_one_of_pos (div_pos y_pos x_pos) _ ≤ log x * (y / x - 1) := le_mul_of_one_le_left hyx hlogx _ = log x / x * y - log x := by ring
/- Copyright (c) 2022 Moritz Doll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Doll -/ import Mathlib.Analysis.Calculus.ContDiff.Bounds import Mathlib.Analysis.Calculus.IteratedDeriv.Defs import Mathlib.Analysis.Calculus.LineDeriv.Basic import Mathlib.Analysis.LocallyConvex.WithSeminorms import Mathlib.Analysis.Normed.Group.ZeroAtInfty import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Analysis.SpecialFunctions.JapaneseBracket import Mathlib.Topology.Algebra.UniformFilterBasis import Mathlib.Tactic.MoveAdd #align_import analysis.schwartz_space from "leanprover-community/mathlib"@"e137999b2c6f2be388f4cd3bbf8523de1910cd2b" /-! # Schwartz space This file defines the Schwartz space. Usually, the Schwartz space is defined as the set of smooth functions $f : ℝ^n → ℂ$ such that there exists $C_{αβ} > 0$ with $$|x^α ∂^β f(x)| < C_{αβ}$$ for all $x ∈ ℝ^n$ and for all multiindices $α, β$. In mathlib, we use a slightly different approach and define the Schwartz space as all smooth functions `f : E → F`, where `E` and `F` are real normed vector spaces such that for all natural numbers `k` and `n` we have uniform bounds `‖x‖^k * ‖iteratedFDeriv ℝ n f x‖ < C`. This approach completely avoids using partial derivatives as well as polynomials. We construct the topology on the Schwartz space by a family of seminorms, which are the best constants in the above estimates. The abstract theory of topological vector spaces developed in `SeminormFamily.moduleFilterBasis` and `WithSeminorms.toLocallyConvexSpace` turns the Schwartz space into a locally convex topological vector space. ## Main definitions * `SchwartzMap`: The Schwartz space is the space of smooth functions such that all derivatives decay faster than any power of `‖x‖`. * `SchwartzMap.seminorm`: The family of seminorms as described above * `SchwartzMap.fderivCLM`: The differential as a continuous linear map `𝓢(E, F) →L[𝕜] 𝓢(E, E →L[ℝ] F)` * `SchwartzMap.derivCLM`: The one-dimensional derivative as a continuous linear map `𝓢(ℝ, F) →L[𝕜] 𝓢(ℝ, F)` * `SchwartzMap.integralCLM`: Integration as a continuous linear map `𝓢(ℝ, F) →L[ℝ] F` ## Main statements * `SchwartzMap.instUniformAddGroup` and `SchwartzMap.instLocallyConvexSpace`: The Schwartz space is a locally convex topological vector space. * `SchwartzMap.one_add_le_sup_seminorm_apply`: For a Schwartz function `f` there is a uniform bound on `(1 + ‖x‖) ^ k * ‖iteratedFDeriv ℝ n f x‖`. ## Implementation details The implementation of the seminorms is taken almost literally from `ContinuousLinearMap.opNorm`. ## Notation * `𝓢(E, F)`: The Schwartz space `SchwartzMap E F` localized in `SchwartzSpace` ## Tags Schwartz space, tempered distributions -/ noncomputable section open scoped Nat NNReal variable {𝕜 𝕜' D E F G V : Type*} variable [NormedAddCommGroup E] [NormedSpace ℝ E] variable [NormedAddCommGroup F] [NormedSpace ℝ F] variable (E F) /-- A function is a Schwartz function if it is smooth and all derivatives decay faster than any power of `‖x‖`. -/ structure SchwartzMap where toFun : E → F smooth' : ContDiff ℝ ⊤ toFun decay' : ∀ k n : ℕ, ∃ C : ℝ, ∀ x, ‖x‖ ^ k * ‖iteratedFDeriv ℝ n toFun x‖ ≤ C #align schwartz_map SchwartzMap /-- A function is a Schwartz function if it is smooth and all derivatives decay faster than any power of `‖x‖`. -/ scoped[SchwartzMap] notation "𝓢(" E ", " F ")" => SchwartzMap E F variable {E F} namespace SchwartzMap -- Porting note: removed -- instance : Coe 𝓢(E, F) (E → F) := ⟨toFun⟩ instance instFunLike : FunLike 𝓢(E, F) E F where coe f := f.toFun coe_injective' f g h := by cases f; cases g; congr #align schwartz_map.fun_like SchwartzMap.instFunLike /-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`. -/ instance instCoeFun : CoeFun 𝓢(E, F) fun _ => E → F := DFunLike.hasCoeToFun #align schwartz_map.has_coe_to_fun SchwartzMap.instCoeFun /-- All derivatives of a Schwartz function are rapidly decaying. -/
Mathlib/Analysis/Distribution/SchwartzSpace.lean
103
106
theorem decay (f : 𝓢(E, F)) (k n : ℕ) : ∃ C : ℝ, 0 < C ∧ ∀ x, ‖x‖ ^ k * ‖iteratedFDeriv ℝ n f x‖ ≤ C := by
rcases f.decay' k n with ⟨C, hC⟩ exact ⟨max C 1, by positivity, fun x => (hC x).trans (le_max_left _ _)⟩
/- Copyright (c) 2022 Moritz Doll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Doll -/ import Mathlib.Analysis.SpecialFunctions.Integrals import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.MeasureTheory.Integral.Layercake #align_import analysis.special_functions.japanese_bracket from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Japanese Bracket In this file, we show that Japanese bracket $(1 + \|x\|^2)^{1/2}$ can be estimated from above and below by $1 + \|x\|$. The functions $(1 + \|x\|^2)^{-r/2}$ and $(1 + |x|)^{-r}$ are integrable provided that `r` is larger than the dimension. ## Main statements * `integrable_one_add_norm`: the function $(1 + |x|)^{-r}$ is integrable * `integrable_jap` the Japanese bracket is integrable -/ noncomputable section open scoped NNReal Filter Topology ENNReal open Asymptotics Filter Set Real MeasureTheory FiniteDimensional variable {E : Type*} [NormedAddCommGroup E] theorem sqrt_one_add_norm_sq_le (x : E) : √((1 : ℝ) + ‖x‖ ^ 2) ≤ 1 + ‖x‖ := by rw [sqrt_le_left (by positivity)] simp [add_sq] #align sqrt_one_add_norm_sq_le sqrt_one_add_norm_sq_le
Mathlib/Analysis/SpecialFunctions/JapaneseBracket.lean
41
46
theorem one_add_norm_le_sqrt_two_mul_sqrt (x : E) : (1 : ℝ) + ‖x‖ ≤ √2 * √(1 + ‖x‖ ^ 2) := by
rw [← sqrt_mul zero_le_two] have := sq_nonneg (‖x‖ - 1) apply le_sqrt_of_sq_le linarith
/- Copyright (c) 2020 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon, Yaël Dillies -/ import Mathlib.Data.Nat.Defs import Mathlib.Order.Interval.Set.Basic import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.log from "leanprover-community/mathlib"@"3e00d81bdcbf77c8188bbd18f5524ddc3ed8cac6" /-! # Natural number logarithms This file defines two `ℕ`-valued analogs of the logarithm of `n` with base `b`: * `log b n`: Lower logarithm, or floor **log**. Greatest `k` such that `b^k ≤ n`. * `clog b n`: Upper logarithm, or **c**eil **log**. Least `k` such that `n ≤ b^k`. These are interesting because, for `1 < b`, `Nat.log b` and `Nat.clog b` are respectively right and left adjoints of `Nat.pow b`. See `pow_le_iff_le_log` and `le_pow_iff_clog_le`. -/ namespace Nat /-! ### Floor logarithm -/ /-- `log b n`, is the logarithm of natural number `n` in base `b`. It returns the largest `k : ℕ` such that `b^k ≤ n`, so if `b^k = n`, it returns exactly `k`. -/ --@[pp_nodot] porting note: unknown attribute def log (b : ℕ) : ℕ → ℕ | n => if h : b ≤ n ∧ 1 < b then log b (n / b) + 1 else 0 decreasing_by -- putting this in the def triggers the `unusedHavesSuffices` linter: -- https://github.com/leanprover-community/batteries/issues/428 have : n / b < n := div_lt_self ((Nat.zero_lt_one.trans h.2).trans_le h.1) h.2 decreasing_trivial #align nat.log Nat.log @[simp] theorem log_eq_zero_iff {b n : ℕ} : log b n = 0 ↔ n < b ∨ b ≤ 1 := by rw [log, dite_eq_right_iff] simp only [Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, imp_false, not_and_or, not_le, not_lt] #align nat.log_eq_zero_iff Nat.log_eq_zero_iff theorem log_of_lt {b n : ℕ} (hb : n < b) : log b n = 0 := log_eq_zero_iff.2 (Or.inl hb) #align nat.log_of_lt Nat.log_of_lt theorem log_of_left_le_one {b : ℕ} (hb : b ≤ 1) (n) : log b n = 0 := log_eq_zero_iff.2 (Or.inr hb) #align nat.log_of_left_le_one Nat.log_of_left_le_one @[simp] theorem log_pos_iff {b n : ℕ} : 0 < log b n ↔ b ≤ n ∧ 1 < b := by rw [Nat.pos_iff_ne_zero, Ne, log_eq_zero_iff, not_or, not_lt, not_le] #align nat.log_pos_iff Nat.log_pos_iff theorem log_pos {b n : ℕ} (hb : 1 < b) (hbn : b ≤ n) : 0 < log b n := log_pos_iff.2 ⟨hbn, hb⟩ #align nat.log_pos Nat.log_pos
Mathlib/Data/Nat/Log.lean
64
66
theorem log_of_one_lt_of_le {b n : ℕ} (h : 1 < b) (hn : b ≤ n) : log b n = log b (n / b) + 1 := by
rw [log] exact if_pos ⟨hn, h⟩
/- 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]
Mathlib/Topology/ContinuousFunction/Units.lean
70
79
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)
/- Copyright (c) 2020 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.FieldTheory.Normal import Mathlib.FieldTheory.Perfect import Mathlib.RingTheory.Localization.Integral #align_import field_theory.is_alg_closed.basic from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a" /-! # Algebraically Closed Field In this file we define the typeclass for algebraically closed fields and algebraic closures, and prove some of their properties. ## Main Definitions - `IsAlgClosed k` is the typeclass saying `k` is an algebraically closed field, i.e. every polynomial in `k` splits. - `IsAlgClosure R K` is the typeclass saying `K` is an algebraic closure of `R`, where `R` is a commutative ring. This means that the map from `R` to `K` is injective, and `K` is algebraically closed and algebraic over `R` - `IsAlgClosed.lift` is a map from an algebraic extension `L` of `R`, into any algebraically closed extension of `R`. - `IsAlgClosure.equiv` is a proof that any two algebraic closures of the same field are isomorphic. ## Tags algebraic closure, algebraically closed ## TODO - Prove that if `K / k` is algebraic, and any monic irreducible polynomial over `k` has a root in `K`, then `K` is algebraically closed (in fact an algebraic closure of `k`). Reference: <https://kconrad.math.uconn.edu/blurbs/galoistheory/algclosure.pdf>, Theorem 2 -/ universe u v w open scoped Classical Polynomial open Polynomial variable (k : Type u) [Field k] /-- Typeclass for algebraically closed fields. To show `Polynomial.Splits p f` for an arbitrary ring homomorphism `f`, see `IsAlgClosed.splits_codomain` and `IsAlgClosed.splits_domain`. -/ class IsAlgClosed : Prop where splits : ∀ p : k[X], p.Splits <| RingHom.id k #align is_alg_closed IsAlgClosed /-- Every polynomial splits in the field extension `f : K →+* k` if `k` is algebraically closed. See also `IsAlgClosed.splits_domain` for the case where `K` is algebraically closed. -/ theorem IsAlgClosed.splits_codomain {k K : Type*} [Field k] [IsAlgClosed k] [Field K] {f : K →+* k} (p : K[X]) : p.Splits f := by convert IsAlgClosed.splits (p.map f); simp [splits_map_iff] #align is_alg_closed.splits_codomain IsAlgClosed.splits_codomain /-- Every polynomial splits in the field extension `f : K →+* k` if `K` is algebraically closed. See also `IsAlgClosed.splits_codomain` for the case where `k` is algebraically closed. -/ theorem IsAlgClosed.splits_domain {k K : Type*} [Field k] [IsAlgClosed k] [Field K] {f : k →+* K} (p : k[X]) : p.Splits f := Polynomial.splits_of_splits_id _ <| IsAlgClosed.splits _ #align is_alg_closed.splits_domain IsAlgClosed.splits_domain namespace IsAlgClosed variable {k} theorem exists_root [IsAlgClosed k] (p : k[X]) (hp : p.degree ≠ 0) : ∃ x, IsRoot p x := exists_root_of_splits _ (IsAlgClosed.splits p) hp #align is_alg_closed.exists_root IsAlgClosed.exists_root theorem exists_pow_nat_eq [IsAlgClosed k] (x : k) {n : ℕ} (hn : 0 < n) : ∃ z, z ^ n = x := by have : degree (X ^ n - C x) ≠ 0 := by rw [degree_X_pow_sub_C hn x] exact ne_of_gt (WithBot.coe_lt_coe.2 hn) obtain ⟨z, hz⟩ := exists_root (X ^ n - C x) this use z simp only [eval_C, eval_X, eval_pow, eval_sub, IsRoot.def] at hz exact sub_eq_zero.1 hz #align is_alg_closed.exists_pow_nat_eq IsAlgClosed.exists_pow_nat_eq
Mathlib/FieldTheory/IsAlgClosed/Basic.lean
99
101
theorem exists_eq_mul_self [IsAlgClosed k] (x : k) : ∃ z, x = z * z := by
rcases exists_pow_nat_eq x zero_lt_two with ⟨z, rfl⟩ exact ⟨z, sq z⟩
/- Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura -/ import Mathlib.Init.Order.Defs #align_import init.algebra.functions from "leanprover-community/lean"@"c2bcdbcbe741ed37c361a30d38e179182b989f76" /-! # Basic lemmas about linear orders. The contents of this file came from `init.algebra.functions` in Lean 3, and it would be good to find everything a better home. -/ universe u section open Decidable variable {α : Type u} [LinearOrder α] theorem min_def (a b : α) : min a b = if a ≤ b then a else b := by rw [LinearOrder.min_def a] #align min_def min_def theorem max_def (a b : α) : max a b = if a ≤ b then b else a := by rw [LinearOrder.max_def a] #align max_def max_def theorem min_le_left (a b : α) : min a b ≤ a := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h, le_refl] else simp [min_def, if_neg h]; exact le_of_not_le h #align min_le_left min_le_left theorem min_le_right (a b : α) : min a b ≤ b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h]; exact h else simp [min_def, if_neg h, le_refl] #align min_le_right min_le_right theorem le_min {a b c : α} (h₁ : c ≤ a) (h₂ : c ≤ b) : c ≤ min a b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h]; exact h₁ else simp [min_def, if_neg h]; exact h₂ #align le_min le_min theorem le_max_left (a b : α) : a ≤ max a b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [max_def, if_pos h]; exact h else simp [max_def, if_neg h, le_refl] #align le_max_left le_max_left theorem le_max_right (a b : α) : b ≤ max a b := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [max_def, if_pos h, le_refl] else simp [max_def, if_neg h]; exact le_of_not_le h #align le_max_right le_max_right
Mathlib/Init/Order/LinearOrder.lean
68
72
theorem max_le {a b c : α} (h₁ : a ≤ c) (h₂ : b ≤ c) : max a b ≤ c := by
-- Porting note: no `min_tac` tactic if h : a ≤ b then simp [max_def, if_pos h]; exact h₂ else simp [max_def, if_neg h]; exact h₁
/- 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, Sébastien Gouëzel, Patrick Massot -/ import Mathlib.Topology.UniformSpace.Cauchy import Mathlib.Topology.UniformSpace.Separation import Mathlib.Topology.DenseEmbedding #align_import topology.uniform_space.uniform_embedding from "leanprover-community/mathlib"@"195fcd60ff2bfe392543bceb0ec2adcdb472db4c" /-! # Uniform embeddings of uniform spaces. Extension of uniform continuous functions. -/ open Filter Function Set Uniformity Topology section universe u v w variable {α : Type u} {β : Type v} {γ : Type w} [UniformSpace α] [UniformSpace β] [UniformSpace γ] /-! ### Uniform inducing maps -/ /-- A map `f : α → β` between uniform spaces is called *uniform inducing* if the uniformity filter on `α` is the pullback of the uniformity filter on `β` under `Prod.map f f`. If `α` is a separated space, then this implies that `f` is injective, hence it is a `UniformEmbedding`. -/ @[mk_iff] structure UniformInducing (f : α → β) : Prop where /-- The uniformity filter on the domain is the pullback of the uniformity filter on the codomain under `Prod.map f f`. -/ comap_uniformity : comap (fun x : α × α => (f x.1, f x.2)) (𝓤 β) = 𝓤 α #align uniform_inducing UniformInducing #align uniform_inducing_iff uniformInducing_iff lemma uniformInducing_iff_uniformSpace {f : α → β} : UniformInducing f ↔ ‹UniformSpace β›.comap f = ‹UniformSpace α› := by rw [uniformInducing_iff, UniformSpace.ext_iff, Filter.ext_iff] rfl protected alias ⟨UniformInducing.comap_uniformSpace, _⟩ := uniformInducing_iff_uniformSpace #align uniform_inducing.comap_uniform_space UniformInducing.comap_uniformSpace lemma uniformInducing_iff' {f : α → β} : UniformInducing f ↔ UniformContinuous f ∧ comap (Prod.map f f) (𝓤 β) ≤ 𝓤 α := by rw [uniformInducing_iff, UniformContinuous, tendsto_iff_comap, le_antisymm_iff, and_comm]; rfl #align uniform_inducing_iff' uniformInducing_iff' protected lemma Filter.HasBasis.uniformInducing_iff {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'} (h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} : UniformInducing f ↔ (∀ i, p' i → ∃ j, p j ∧ ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ s' i) ∧ (∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by simp [uniformInducing_iff', h.uniformContinuous_iff h', (h'.comap _).le_basis_iff h, subset_def] #align filter.has_basis.uniform_inducing_iff Filter.HasBasis.uniformInducing_iff theorem UniformInducing.mk' {f : α → β} (h : ∀ s, s ∈ 𝓤 α ↔ ∃ t ∈ 𝓤 β, ∀ x y : α, (f x, f y) ∈ t → (x, y) ∈ s) : UniformInducing f := ⟨by simp [eq_comm, Filter.ext_iff, subset_def, h]⟩ #align uniform_inducing.mk' UniformInducing.mk' theorem uniformInducing_id : UniformInducing (@id α) := ⟨by rw [← Prod.map_def, Prod.map_id, comap_id]⟩ #align uniform_inducing_id uniformInducing_id theorem UniformInducing.comp {g : β → γ} (hg : UniformInducing g) {f : α → β} (hf : UniformInducing f) : UniformInducing (g ∘ f) := ⟨by rw [← hf.1, ← hg.1, comap_comap]; rfl⟩ #align uniform_inducing.comp UniformInducing.comp
Mathlib/Topology/UniformSpace/UniformEmbedding.lean
76
80
theorem UniformInducing.of_comp_iff {g : β → γ} (hg : UniformInducing g) {f : α → β} : UniformInducing (g ∘ f) ↔ UniformInducing f := by
refine ⟨fun h ↦ ?_, hg.comp⟩ rw [uniformInducing_iff, ← hg.comap_uniformity, comap_comap, ← h.comap_uniformity, Function.comp, Function.comp]
/- 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
Mathlib/Algebra/RingQuot.lean
62
64
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
/- 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.Multiset.FinsetOps import Mathlib.Data.Multiset.Fold #align_import data.multiset.lattice from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Lattice operations on multisets -/ namespace Multiset variable {α : Type*} /-! ### sup -/ section Sup -- can be defined with just `[Bot α]` where some lemmas hold without requiring `[OrderBot α]` variable [SemilatticeSup α] [OrderBot α] /-- Supremum of a multiset: `sup {a, b, c} = a ⊔ b ⊔ c` -/ def sup (s : Multiset α) : α := s.fold (· ⊔ ·) ⊥ #align multiset.sup Multiset.sup @[simp] theorem sup_coe (l : List α) : sup (l : Multiset α) = l.foldr (· ⊔ ·) ⊥ := rfl #align multiset.sup_coe Multiset.sup_coe @[simp] theorem sup_zero : (0 : Multiset α).sup = ⊥ := fold_zero _ _ #align multiset.sup_zero Multiset.sup_zero @[simp] theorem sup_cons (a : α) (s : Multiset α) : (a ::ₘ s).sup = a ⊔ s.sup := fold_cons_left _ _ _ _ #align multiset.sup_cons Multiset.sup_cons @[simp] theorem sup_singleton {a : α} : ({a} : Multiset α).sup = a := sup_bot_eq _ #align multiset.sup_singleton Multiset.sup_singleton @[simp] theorem sup_add (s₁ s₂ : Multiset α) : (s₁ + s₂).sup = s₁.sup ⊔ s₂.sup := Eq.trans (by simp [sup]) (fold_add _ _ _ _ _) #align multiset.sup_add Multiset.sup_add @[simp] theorem sup_le {s : Multiset α} {a : α} : s.sup ≤ a ↔ ∀ b ∈ s, b ≤ a := Multiset.induction_on s (by simp) (by simp (config := { contextual := true }) [or_imp, forall_and]) #align multiset.sup_le Multiset.sup_le theorem le_sup {s : Multiset α} {a : α} (h : a ∈ s) : a ≤ s.sup := sup_le.1 le_rfl _ h #align multiset.le_sup Multiset.le_sup theorem sup_mono {s₁ s₂ : Multiset α} (h : s₁ ⊆ s₂) : s₁.sup ≤ s₂.sup := sup_le.2 fun _ hb => le_sup (h hb) #align multiset.sup_mono Multiset.sup_mono variable [DecidableEq α] @[simp] theorem sup_dedup (s : Multiset α) : (dedup s).sup = s.sup := fold_dedup_idem _ _ _ #align multiset.sup_dedup Multiset.sup_dedup @[simp] theorem sup_ndunion (s₁ s₂ : Multiset α) : (ndunion s₁ s₂).sup = s₁.sup ⊔ s₂.sup := by rw [← sup_dedup, dedup_ext.2, sup_dedup, sup_add]; simp #align multiset.sup_ndunion Multiset.sup_ndunion @[simp] theorem sup_union (s₁ s₂ : Multiset α) : (s₁ ∪ s₂).sup = s₁.sup ⊔ s₂.sup := by rw [← sup_dedup, dedup_ext.2, sup_dedup, sup_add]; simp #align multiset.sup_union Multiset.sup_union @[simp]
Mathlib/Data/Multiset/Lattice.lean
89
90
theorem sup_ndinsert (a : α) (s : Multiset α) : (ndinsert a s).sup = a ⊔ s.sup := by
rw [← sup_dedup, dedup_ext.2, sup_dedup, sup_cons]; simp
/- Copyright (c) 2021 Nicolò Cavalleri. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nicolò Cavalleri -/ import Mathlib.Data.Set.Basic #align_import data.bundle from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" /-! # Bundle Basic data structure to implement fiber bundles, vector bundles (maybe fibrations?), etc. This file should contain all possible results that do not involve any topology. We represent a bundle `E` over a base space `B` as a dependent type `E : B → Type*`. We define `Bundle.TotalSpace F E` to be the type of pairs `⟨b, x⟩`, where `b : B` and `x : E b`. This type is isomorphic to `Σ x, E x` and uses an extra argument `F` for reasons explained below. In general, the constructions of fiber bundles we will make will be of this form. ## Main Definitions * `Bundle.TotalSpace` the total space of a bundle. * `Bundle.TotalSpace.proj` the projection from the total space to the base space. * `Bundle.TotalSpace.mk` the constructor for the total space. ## Implementation Notes - We use a custom structure for the total space of a bundle instead of using a type synonym for the canonical disjoint union `Σ x, E x` because the total space usually has a different topology and Lean 4 `simp` fails to apply lemmas about `Σ x, E x` to elements of the total space. - The definition of `Bundle.TotalSpace` has an unused argument `F`. The reason is that in some constructions (e.g., `Bundle.ContinuousLinearMap.vectorBundle`) we need access to the atlas of trivializations of original fiber bundles to construct the topology on the total space of the new fiber bundle. ## References - https://en.wikipedia.org/wiki/Bundle_(mathematics) -/ open Function Set namespace Bundle variable {B F : Type*} (E : B → Type*) /-- `Bundle.TotalSpace F E` is the total space of the bundle. It consists of pairs `(proj : B, snd : E proj)`. -/ @[ext] structure TotalSpace (F : Type*) (E : B → Type*) where /-- `Bundle.TotalSpace.proj` is the canonical projection `Bundle.TotalSpace F E → B` from the total space to the base space. -/ proj : B snd : E proj #align bundle.total_space Bundle.TotalSpace instance [Inhabited B] [Inhabited (E default)] : Inhabited (TotalSpace F E) := ⟨⟨default, default⟩⟩ variable {E} @[inherit_doc] scoped notation:max "π" F':max E':max => Bundle.TotalSpace.proj (F := F') (E := E') abbrev TotalSpace.mk' (F : Type*) (x : B) (y : E x) : TotalSpace F E := ⟨x, y⟩
Mathlib/Data/Bundle.lean
69
70
theorem TotalSpace.mk_cast {x x' : B} (h : x = x') (b : E x) : .mk' F x' (cast (congr_arg E h) b) = TotalSpace.mk x b := by
subst h; rfl
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Simon Hudon -/ import Mathlib.Data.PFunctor.Multivariate.W import Mathlib.Data.QPF.Multivariate.Basic #align_import data.qpf.multivariate.constructions.fix from "leanprover-community/mathlib"@"28aa996fc6fb4317f0083c4e6daf79878d81be33" /-! # The initial algebra of a multivariate qpf is again a qpf. For an `(n+1)`-ary QPF `F (α₀,..,αₙ)`, we take the least fixed point of `F` with regards to its last argument `αₙ`. The result is an `n`-ary functor: `Fix F (α₀,..,αₙ₋₁)`. Making `Fix F` into a functor allows us to take the fixed point, compose with other functors and take a fixed point again. ## Main definitions * `Fix.mk` - constructor * `Fix.dest` - destructor * `Fix.rec` - recursor: basis for defining functions by structural recursion on `Fix F α` * `Fix.drec` - dependent recursor: generalization of `Fix.rec` where the result type of the function is allowed to depend on the `Fix F α` value * `Fix.rec_eq` - defining equation for `recursor` * `Fix.ind` - induction principle for `Fix F α` ## Implementation notes For `F` a `QPF`, we define `Fix F α` in terms of the W-type of the polynomial functor `P` of `F`. We define the relation `WEquiv` and take its quotient as the definition of `Fix F α`. See [avigad-carneiro-hudon2019] for more details. ## Reference * Jeremy Avigad, Mario M. Carneiro and Simon Hudon. [*Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019] -/ universe u v namespace MvQPF open TypeVec open MvFunctor (LiftP LiftR) open MvFunctor variable {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [MvFunctor F] [q : MvQPF F] /-- `recF` is used as a basis for defining the recursor on `Fix F α`. `recF` traverses recursively the W-type generated by `q.P` using a function on `F` as a recursive step -/ def recF {α : TypeVec n} {β : Type u} (g : F (α.append1 β) → β) : q.P.W α → β := q.P.wRec fun a f' _f rec => g (abs ⟨a, splitFun f' rec⟩) set_option linter.uppercaseLean3 false in #align mvqpf.recF MvQPF.recF theorem recF_eq {α : TypeVec n} {β : Type u} (g : F (α.append1 β) → β) (a : q.P.A) (f' : q.P.drop.B a ⟹ α) (f : q.P.last.B a → q.P.W α) : recF g (q.P.wMk a f' f) = g (abs ⟨a, splitFun f' (recF g ∘ f)⟩) := by rw [recF, MvPFunctor.wRec_eq]; rfl set_option linter.uppercaseLean3 false in #align mvqpf.recF_eq MvQPF.recF_eq theorem recF_eq' {α : TypeVec n} {β : Type u} (g : F (α.append1 β) → β) (x : q.P.W α) : recF g x = g (abs (appendFun id (recF g) <$$> q.P.wDest' x)) := by apply q.P.w_cases _ x intro a f' f rw [recF_eq, q.P.wDest'_wMk, MvPFunctor.map_eq, appendFun_comp_splitFun, TypeVec.id_comp] set_option linter.uppercaseLean3 false in #align mvqpf.recF_eq' MvQPF.recF_eq' /-- Equivalence relation on W-types that represent the same `Fix F` value -/ inductive WEquiv {α : TypeVec n} : q.P.W α → q.P.W α → Prop | ind (a : q.P.A) (f' : q.P.drop.B a ⟹ α) (f₀ f₁ : q.P.last.B a → q.P.W α) : (∀ x, WEquiv (f₀ x) (f₁ x)) → WEquiv (q.P.wMk a f' f₀) (q.P.wMk a f' f₁) | abs (a₀ : q.P.A) (f'₀ : q.P.drop.B a₀ ⟹ α) (f₀ : q.P.last.B a₀ → q.P.W α) (a₁ : q.P.A) (f'₁ : q.P.drop.B a₁ ⟹ α) (f₁ : q.P.last.B a₁ → q.P.W α) : abs ⟨a₀, q.P.appendContents f'₀ f₀⟩ = abs ⟨a₁, q.P.appendContents f'₁ f₁⟩ → WEquiv (q.P.wMk a₀ f'₀ f₀) (q.P.wMk a₁ f'₁ f₁) | trans (u v w : q.P.W α) : WEquiv u v → WEquiv v w → WEquiv u w set_option linter.uppercaseLean3 false in #align mvqpf.Wequiv MvQPF.WEquiv
Mathlib/Data/QPF/Multivariate/Constructions/Fix.lean
92
104
theorem recF_eq_of_wEquiv (α : TypeVec n) {β : Type u} (u : F (α.append1 β) → β) (x y : q.P.W α) : WEquiv x y → recF u x = recF u y := by
apply q.P.w_cases _ x intro a₀ f'₀ f₀ apply q.P.w_cases _ y intro a₁ f'₁ f₁ intro h -- Porting note: induction on h doesn't work. refine @WEquiv.recOn _ _ _ _ _ (fun a a' _ ↦ recF u a = recF u a') _ _ h ?_ ?_ ?_ · intros a f' f₀ f₁ _h ih; simp only [recF_eq, Function.comp] congr; funext; congr; funext; apply ih · intros a₀ f'₀ f₀ a₁ f'₁ f₁ h; simp only [recF_eq', abs_map, MvPFunctor.wDest'_wMk, h] · intros x y z _e₁ _e₂ ih₁ ih₂; exact Eq.trans ih₁ ih₂
/- 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.NumberTheory.Liouville.Basic import Mathlib.Topology.Baire.Lemmas import Mathlib.Topology.Baire.LocallyCompactRegular import Mathlib.Topology.Instances.Irrational #align_import number_theory.liouville.residual from "leanprover-community/mathlib"@"32b08ef840dd25ca2e47e035c5da03ce16d2dc3c" /-! # Density of Liouville numbers In this file we prove that the set of Liouville numbers form a dense `Gδ` set. We also prove a similar statement about irrational numbers. -/ open scoped Filter open Filter Set Metric theorem setOf_liouville_eq_iInter_iUnion : { x | Liouville x } = ⋂ n : ℕ, ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b), ball ((a : ℝ) / b) (1 / (b : ℝ) ^ n) \ {(a : ℝ) / b} := by ext x simp only [mem_iInter, mem_iUnion, Liouville, mem_setOf_eq, exists_prop, mem_diff, mem_singleton_iff, mem_ball, Real.dist_eq, and_comm] #align set_of_liouville_eq_Inter_Union setOf_liouville_eq_iInter_iUnion
Mathlib/NumberTheory/Liouville/Residual.lean
34
38
theorem IsGδ.setOf_liouville : IsGδ { x | Liouville x } := by
rw [setOf_liouville_eq_iInter_iUnion] refine .iInter fun n => IsOpen.isGδ ?_ refine isOpen_iUnion fun a => isOpen_iUnion fun b => isOpen_iUnion fun _hb => ?_ exact isOpen_ball.inter isClosed_singleton.isOpen_compl
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky, Chris Hughes -/ import Mathlib.Data.List.Nodup #align_import data.list.duplicate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # List duplicates ## Main definitions * `List.Duplicate x l : Prop` is an inductive property that holds when `x` is a duplicate in `l` ## Implementation details In this file, `x ∈+ l` notation is shorthand for `List.Duplicate x l`. -/ variable {α : Type*} namespace List /-- Property that an element `x : α` of `l : List α` can be found in the list more than once. -/ inductive Duplicate (x : α) : List α → Prop | cons_mem {l : List α} : x ∈ l → Duplicate x (x :: l) | cons_duplicate {y : α} {l : List α} : Duplicate x l → Duplicate x (y :: l) #align list.duplicate List.Duplicate local infixl:50 " ∈+ " => List.Duplicate variable {l : List α} {x : α} theorem Mem.duplicate_cons_self (h : x ∈ l) : x ∈+ x :: l := Duplicate.cons_mem h #align list.mem.duplicate_cons_self List.Mem.duplicate_cons_self theorem Duplicate.duplicate_cons (h : x ∈+ l) (y : α) : x ∈+ y :: l := Duplicate.cons_duplicate h #align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons theorem Duplicate.mem (h : x ∈+ l) : x ∈ l := by induction' h with l' _ y l' _ hm · exact mem_cons_self _ _ · exact mem_cons_of_mem _ hm #align list.duplicate.mem List.Duplicate.mem theorem Duplicate.mem_cons_self (h : x ∈+ x :: l) : x ∈ l := by cases' h with _ h _ _ h · exact h · exact h.mem #align list.duplicate.mem_cons_self List.Duplicate.mem_cons_self @[simp] theorem duplicate_cons_self_iff : x ∈+ x :: l ↔ x ∈ l := ⟨Duplicate.mem_cons_self, Mem.duplicate_cons_self⟩ #align list.duplicate_cons_self_iff List.duplicate_cons_self_iff theorem Duplicate.ne_nil (h : x ∈+ l) : l ≠ [] := fun H => (mem_nil_iff x).mp (H ▸ h.mem) #align list.duplicate.ne_nil List.Duplicate.ne_nil @[simp] theorem not_duplicate_nil (x : α) : ¬x ∈+ [] := fun H => H.ne_nil rfl #align list.not_duplicate_nil List.not_duplicate_nil theorem Duplicate.ne_singleton (h : x ∈+ l) (y : α) : l ≠ [y] := by induction' h with l' h z l' h _ · simp [ne_nil_of_mem h] · simp [ne_nil_of_mem h.mem] #align list.duplicate.ne_singleton List.Duplicate.ne_singleton @[simp] theorem not_duplicate_singleton (x y : α) : ¬x ∈+ [y] := fun H => H.ne_singleton _ rfl #align list.not_duplicate_singleton List.not_duplicate_singleton theorem Duplicate.elim_nil (h : x ∈+ []) : False := not_duplicate_nil x h #align list.duplicate.elim_nil List.Duplicate.elim_nil theorem Duplicate.elim_singleton {y : α} (h : x ∈+ [y]) : False := not_duplicate_singleton x y h #align list.duplicate.elim_singleton List.Duplicate.elim_singleton theorem duplicate_cons_iff {y : α} : x ∈+ y :: l ↔ y = x ∧ x ∈ l ∨ x ∈+ l := by refine ⟨fun h => ?_, fun h => ?_⟩ · cases' h with _ hm _ _ hm · exact Or.inl ⟨rfl, hm⟩ · exact Or.inr hm · rcases h with (⟨rfl | h⟩ | h) · simpa · exact h.cons_duplicate #align list.duplicate_cons_iff List.duplicate_cons_iff theorem Duplicate.of_duplicate_cons {y : α} (h : x ∈+ y :: l) (hx : x ≠ y) : x ∈+ l := by simpa [duplicate_cons_iff, hx.symm] using h #align list.duplicate.of_duplicate_cons List.Duplicate.of_duplicate_cons theorem duplicate_cons_iff_of_ne {y : α} (hne : x ≠ y) : x ∈+ y :: l ↔ x ∈+ l := by simp [duplicate_cons_iff, hne.symm] #align list.duplicate_cons_iff_of_ne List.duplicate_cons_iff_of_ne theorem Duplicate.mono_sublist {l' : List α} (hx : x ∈+ l) (h : l <+ l') : x ∈+ l' := by induction' h with l₁ l₂ y _ IH l₁ l₂ y h IH · exact hx · exact (IH hx).duplicate_cons _ · rw [duplicate_cons_iff] at hx ⊢ rcases hx with (⟨rfl, hx⟩ | hx) · simp [h.subset hx] · simp [IH hx] #align list.duplicate.mono_sublist List.Duplicate.mono_sublist /-- The contrapositive of `List.nodup_iff_sublist`. -/ theorem duplicate_iff_sublist : x ∈+ l ↔ [x, x] <+ l := by induction' l with y l IH · simp · by_cases hx : x = y · simp [hx, cons_sublist_cons, singleton_sublist] · rw [duplicate_cons_iff_of_ne hx, IH] refine ⟨sublist_cons_of_sublist y, fun h => ?_⟩ cases h · assumption · contradiction #align list.duplicate_iff_sublist List.duplicate_iff_sublist
Mathlib/Data/List/Duplicate.lean
129
130
theorem nodup_iff_forall_not_duplicate : Nodup l ↔ ∀ x : α, ¬x ∈+ l := by
simp_rw [nodup_iff_sublist, duplicate_iff_sublist]
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Heather Macbeth -/ import Mathlib.Analysis.SpecialFunctions.Complex.Circle import Mathlib.Geometry.Euclidean.Angle.Oriented.Basic #align_import geometry.euclidean.angle.oriented.rotation from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Rotations by oriented angles. This file defines rotations by oriented angles in real inner product spaces. ## Main definitions * `Orientation.rotation` is the rotation by an oriented angle with respect to an orientation. -/ noncomputable section open FiniteDimensional Complex open scoped Real RealInnerProductSpace ComplexConjugate namespace Orientation attribute [local instance] Complex.finrank_real_complex_fact variable {V V' : Type*} variable [NormedAddCommGroup V] [NormedAddCommGroup V'] variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V'] variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2)) local notation "J" => o.rightAngleRotation /-- Auxiliary construction to build a rotation by the oriented angle `θ`. -/ def rotationAux (θ : Real.Angle) : V →ₗᵢ[ℝ] V := LinearMap.isometryOfInner (Real.Angle.cos θ • LinearMap.id + Real.Angle.sin θ • (LinearIsometryEquiv.toLinearEquiv J).toLinearMap) (by intro x y simp only [RCLike.conj_to_real, id, LinearMap.smul_apply, LinearMap.add_apply, LinearMap.id_coe, LinearEquiv.coe_coe, LinearIsometryEquiv.coe_toLinearEquiv, Orientation.areaForm_rightAngleRotation_left, Orientation.inner_rightAngleRotation_left, Orientation.inner_rightAngleRotation_right, inner_add_left, inner_smul_left, inner_add_right, inner_smul_right] linear_combination inner (𝕜 := ℝ) x y * θ.cos_sq_add_sin_sq) #align orientation.rotation_aux Orientation.rotationAux @[simp] theorem rotationAux_apply (θ : Real.Angle) (x : V) : o.rotationAux θ x = Real.Angle.cos θ • x + Real.Angle.sin θ • J x := rfl #align orientation.rotation_aux_apply Orientation.rotationAux_apply /-- A rotation by the oriented angle `θ`. -/ def rotation (θ : Real.Angle) : V ≃ₗᵢ[ℝ] V := LinearIsometryEquiv.ofLinearIsometry (o.rotationAux θ) (Real.Angle.cos θ • LinearMap.id - Real.Angle.sin θ • (LinearIsometryEquiv.toLinearEquiv J).toLinearMap) (by ext x convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 · simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply, Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap, LinearIsometryEquiv.coe_toLinearEquiv, map_smul, map_sub, LinearMap.coe_comp, LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, ← mul_smul, add_smul, smul_add, smul_neg, smul_sub, mul_comm, sq] abel · simp) (by ext x convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 · simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply, Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap, LinearIsometryEquiv.coe_toLinearEquiv, map_add, map_smul, LinearMap.coe_comp, LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, add_smul, smul_neg, smul_sub, smul_smul] ring_nf abel · simp) #align orientation.rotation Orientation.rotation theorem rotation_apply (θ : Real.Angle) (x : V) : o.rotation θ x = Real.Angle.cos θ • x + Real.Angle.sin θ • J x := rfl #align orientation.rotation_apply Orientation.rotation_apply theorem rotation_symm_apply (θ : Real.Angle) (x : V) : (o.rotation θ).symm x = Real.Angle.cos θ • x - Real.Angle.sin θ • J x := rfl #align orientation.rotation_symm_apply Orientation.rotation_symm_apply theorem rotation_eq_matrix_toLin (θ : Real.Angle) {x : V} (hx : x ≠ 0) : (o.rotation θ).toLinearMap = Matrix.toLin (o.basisRightAngleRotation x hx) (o.basisRightAngleRotation x hx) !![θ.cos, -θ.sin; θ.sin, θ.cos] := by apply (o.basisRightAngleRotation x hx).ext intro i fin_cases i · rw [Matrix.toLin_self] simp [rotation_apply, Fin.sum_univ_succ] · rw [Matrix.toLin_self] simp [rotation_apply, Fin.sum_univ_succ, add_comm] #align orientation.rotation_eq_matrix_to_lin Orientation.rotation_eq_matrix_toLin /-- The determinant of `rotation` (as a linear map) is equal to `1`. -/ @[simp] theorem det_rotation (θ : Real.Angle) : LinearMap.det (o.rotation θ).toLinearMap = 1 := by haveI : Nontrivial V := FiniteDimensional.nontrivial_of_finrank_eq_succ (@Fact.out (finrank ℝ V = 2) _) obtain ⟨x, hx⟩ : ∃ x, x ≠ (0 : V) := exists_ne (0 : V) rw [o.rotation_eq_matrix_toLin θ hx] simpa [sq] using θ.cos_sq_add_sin_sq #align orientation.det_rotation Orientation.det_rotation /-- The determinant of `rotation` (as a linear equiv) is equal to `1`. -/ @[simp] theorem linearEquiv_det_rotation (θ : Real.Angle) : LinearEquiv.det (o.rotation θ).toLinearEquiv = 1 := Units.ext <| by -- Porting note: Lean can't see through `LinearEquiv.coe_det` and needed the rewrite -- in mathlib3 this was just `units.ext <| o.det_rotation θ` simpa only [LinearEquiv.coe_det, Units.val_one] using o.det_rotation θ #align orientation.linear_equiv_det_rotation Orientation.linearEquiv_det_rotation /-- The inverse of `rotation` is rotation by the negation of the angle. -/ @[simp]
Mathlib/Geometry/Euclidean/Angle/Oriented/Rotation.lean
134
135
theorem rotation_symm (θ : Real.Angle) : (o.rotation θ).symm = o.rotation (-θ) := by
ext; simp [o.rotation_apply, o.rotation_symm_apply, sub_eq_add_neg]
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Measure.Typeclasses /-! # Restriction of a measure to a sub-σ-algebra ## Main definitions * `MeasureTheory.Measure.trim`: restriction of a measure to a sub-sigma algebra. -/ open scoped ENNReal namespace MeasureTheory variable {α : Type*} /-- Restriction of a measure to a sub-σ-algebra. It is common to see a measure `μ` on a measurable space structure `m0` as being also a measure on any `m ≤ m0`. Since measures in mathlib have to be trimmed to the measurable space, `μ` itself cannot be a measure on `m`, hence the definition of `μ.trim hm`. This notion is related to `OuterMeasure.trim`, see the lemma `toOuterMeasure_trim_eq_trim_toOuterMeasure`. -/ noncomputable def Measure.trim {m m0 : MeasurableSpace α} (μ : @Measure α m0) (hm : m ≤ m0) : @Measure α m := @OuterMeasure.toMeasure α m μ.toOuterMeasure (hm.trans (le_toOuterMeasure_caratheodory μ)) #align measure_theory.measure.trim MeasureTheory.Measure.trim @[simp] theorem trim_eq_self [MeasurableSpace α] {μ : Measure α} : μ.trim le_rfl = μ := by simp [Measure.trim] #align measure_theory.trim_eq_self MeasureTheory.trim_eq_self variable {m m0 : MeasurableSpace α} {μ : Measure α} {s : Set α}
Mathlib/MeasureTheory/Measure/Trim.lean
43
45
theorem toOuterMeasure_trim_eq_trim_toOuterMeasure (μ : Measure α) (hm : m ≤ m0) : @Measure.toOuterMeasure _ m (μ.trim hm) = @OuterMeasure.trim _ m μ.toOuterMeasure := by
rw [Measure.trim, toMeasure_toOuterMeasure (ms := m)]
/- Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Data.Set.Equitable import Mathlib.Logic.Equiv.Fin import Mathlib.Order.Partition.Finpartition #align_import order.partition.equipartition from "leanprover-community/mathlib"@"b363547b3113d350d053abdf2884e9850a56b205" /-! # Finite equipartitions This file defines finite equipartitions, the partitions whose parts all are the same size up to a difference of `1`. ## Main declarations * `Finpartition.IsEquipartition`: Predicate for a `Finpartition` to be an equipartition. * `Finpartition.IsEquipartition.exists_partPreservingEquiv`: part-preserving enumeration of a finset equipped with an equipartition. Indices of elements in the same part are congruent modulo the number of parts. -/ open Finset Fintype namespace Finpartition variable {α : Type*} [DecidableEq α] {s t : Finset α} (P : Finpartition s) /-- An equipartition is a partition whose parts are all the same size, up to a difference of `1`. -/ def IsEquipartition : Prop := (P.parts : Set (Finset α)).EquitableOn card #align finpartition.is_equipartition Finpartition.IsEquipartition theorem isEquipartition_iff_card_parts_eq_average : P.IsEquipartition ↔ ∀ a : Finset α, a ∈ P.parts → a.card = s.card / P.parts.card ∨ a.card = s.card / P.parts.card + 1 := by simp_rw [IsEquipartition, Finset.equitableOn_iff, P.sum_card_parts] #align finpartition.is_equipartition_iff_card_parts_eq_average Finpartition.isEquipartition_iff_card_parts_eq_average variable {P} lemma not_isEquipartition : ¬P.IsEquipartition ↔ ∃ a ∈ P.parts, ∃ b ∈ P.parts, b.card + 1 < a.card := Set.not_equitableOn theorem _root_.Set.Subsingleton.isEquipartition (h : (P.parts : Set (Finset α)).Subsingleton) : P.IsEquipartition := Set.Subsingleton.equitableOn h _ #align finpartition.set.subsingleton.is_equipartition Set.Subsingleton.isEquipartition theorem IsEquipartition.card_parts_eq_average (hP : P.IsEquipartition) (ht : t ∈ P.parts) : t.card = s.card / P.parts.card ∨ t.card = s.card / P.parts.card + 1 := P.isEquipartition_iff_card_parts_eq_average.1 hP _ ht #align finpartition.is_equipartition.card_parts_eq_average Finpartition.IsEquipartition.card_parts_eq_average theorem IsEquipartition.card_part_eq_average_iff (hP : P.IsEquipartition) (ht : t ∈ P.parts) : t.card = s.card / P.parts.card ↔ t.card ≠ s.card / P.parts.card + 1 := by have a := hP.card_parts_eq_average ht have b : ¬(t.card = s.card / P.parts.card ∧ t.card = s.card / P.parts.card + 1) := by by_contra h; exact absurd (h.1 ▸ h.2) (lt_add_one _).ne tauto theorem IsEquipartition.average_le_card_part (hP : P.IsEquipartition) (ht : t ∈ P.parts) : s.card / P.parts.card ≤ t.card := by rw [← P.sum_card_parts] exact Finset.EquitableOn.le hP ht #align finpartition.is_equipartition.average_le_card_part Finpartition.IsEquipartition.average_le_card_part
Mathlib/Order/Partition/Equipartition.lean
74
77
theorem IsEquipartition.card_part_le_average_add_one (hP : P.IsEquipartition) (ht : t ∈ P.parts) : t.card ≤ s.card / P.parts.card + 1 := by
rw [← P.sum_card_parts] exact Finset.EquitableOn.le_add_one hP ht
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Manuel Candales -/ import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse #align_import geometry.euclidean.angle.unoriented.basic from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Angles between vectors This file defines unoriented angles in real inner product spaces. ## Main definitions * `InnerProductGeometry.angle` is the undirected angle between two vectors. ## TODO Prove the triangle inequality for the angle. -/ assert_not_exists HasFDerivAt assert_not_exists ConformalAt noncomputable section open Real Set open Real open RealInnerProductSpace namespace InnerProductGeometry variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] {x y : V} /-- The undirected angle between two vectors. If either vector is 0, this is π/2. See `Orientation.oangle` for the corresponding oriented angle definition. -/ def angle (x y : V) : ℝ := Real.arccos (⟪x, y⟫ / (‖x‖ * ‖y‖)) #align inner_product_geometry.angle InnerProductGeometry.angle theorem continuousAt_angle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) : ContinuousAt (fun y : V × V => angle y.1 y.2) x := Real.continuous_arccos.continuousAt.comp <| continuous_inner.continuousAt.div ((continuous_norm.comp continuous_fst).mul (continuous_norm.comp continuous_snd)).continuousAt (by simp [hx1, hx2]) #align inner_product_geometry.continuous_at_angle InnerProductGeometry.continuousAt_angle theorem angle_smul_smul {c : ℝ} (hc : c ≠ 0) (x y : V) : angle (c • x) (c • y) = angle x y := by have : c * c ≠ 0 := mul_ne_zero hc hc rw [angle, angle, real_inner_smul_left, inner_smul_right, norm_smul, norm_smul, Real.norm_eq_abs, mul_mul_mul_comm _ ‖x‖, abs_mul_abs_self, ← mul_assoc c c, mul_div_mul_left _ _ this] #align inner_product_geometry.angle_smul_smul InnerProductGeometry.angle_smul_smul @[simp] theorem _root_.LinearIsometry.angle_map {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] [InnerProductSpace ℝ E] [InnerProductSpace ℝ F] (f : E →ₗᵢ[ℝ] F) (u v : E) : angle (f u) (f v) = angle u v := by rw [angle, angle, f.inner_map_map, f.norm_map, f.norm_map] #align linear_isometry.angle_map LinearIsometry.angle_map @[simp, norm_cast] theorem _root_.Submodule.angle_coe {s : Submodule ℝ V} (x y : s) : angle (x : V) (y : V) = angle x y := s.subtypeₗᵢ.angle_map x y #align submodule.angle_coe Submodule.angle_coe /-- The cosine of the angle between two vectors. -/ theorem cos_angle (x y : V) : Real.cos (angle x y) = ⟪x, y⟫ / (‖x‖ * ‖y‖) := Real.cos_arccos (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).1 (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).2 #align inner_product_geometry.cos_angle InnerProductGeometry.cos_angle /-- The angle between two vectors does not depend on their order. -/ theorem angle_comm (x y : V) : angle x y = angle y x := by unfold angle rw [real_inner_comm, mul_comm] #align inner_product_geometry.angle_comm InnerProductGeometry.angle_comm /-- The angle between the negation of two vectors. -/ @[simp] theorem angle_neg_neg (x y : V) : angle (-x) (-y) = angle x y := by unfold angle rw [inner_neg_neg, norm_neg, norm_neg] #align inner_product_geometry.angle_neg_neg InnerProductGeometry.angle_neg_neg /-- The angle between two vectors is nonnegative. -/ theorem angle_nonneg (x y : V) : 0 ≤ angle x y := Real.arccos_nonneg _ #align inner_product_geometry.angle_nonneg InnerProductGeometry.angle_nonneg /-- The angle between two vectors is at most π. -/ theorem angle_le_pi (x y : V) : angle x y ≤ π := Real.arccos_le_pi _ #align inner_product_geometry.angle_le_pi InnerProductGeometry.angle_le_pi /-- The angle between a vector and the negation of another vector. -/ theorem angle_neg_right (x y : V) : angle x (-y) = π - angle x y := by unfold angle rw [← Real.arccos_neg, norm_neg, inner_neg_right, neg_div] #align inner_product_geometry.angle_neg_right InnerProductGeometry.angle_neg_right /-- The angle between the negation of a vector and another vector. -/
Mathlib/Geometry/Euclidean/Angle/Unoriented/Basic.lean
112
113
theorem angle_neg_left (x y : V) : angle (-x) y = π - angle x y := by
rw [← angle_neg_neg, neg_neg, angle_neg_right]
/- Copyright (c) 2022 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Batteries.Data.RBMap.Basic import Batteries.Tactic.SeqFocus /-! # Lemmas for Red-black trees The main theorem in this file is `WF_def`, which shows that the `RBNode.WF.mk` constructor subsumes the others, by showing that `insert` and `erase` satisfy the red-black invariants. -/ namespace Batteries namespace RBNode open RBColor attribute [simp] All theorem All.trivial (H : ∀ {x : α}, p x) : ∀ {t : RBNode α}, t.All p | nil => _root_.trivial | node .. => ⟨H, All.trivial H, All.trivial H⟩
.lake/packages/batteries/Batteries/Data/RBMap/WF.lean
27
28
theorem All_and {t : RBNode α} : t.All (fun a => p a ∧ q a) ↔ t.All p ∧ t.All q := by
induction t <;> simp [*, and_assoc, and_left_comm]
/- Copyright (c) 2020 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou -/ import Mathlib.Algebra.Group.Pi.Lemmas import Mathlib.Algebra.Group.Support #align_import algebra.indicator_function from "leanprover-community/mathlib"@"2445c98ae4b87eabebdde552593519b9b6dc350c" /-! # Indicator function - `Set.indicator (s : Set α) (f : α → β) (a : α)` is `f a` if `a ∈ s` and is `0` otherwise. - `Set.mulIndicator (s : Set α) (f : α → β) (a : α)` is `f a` if `a ∈ s` and is `1` otherwise. ## Implementation note In mathematics, an indicator function or a characteristic function is a function used to indicate membership of an element in a set `s`, having the value `1` for all elements of `s` and the value `0` otherwise. But since it is usually used to restrict a function to a certain set `s`, we let the indicator function take the value `f x` for some function `f`, instead of `1`. If the usual indicator function is needed, just set `f` to be the constant function `fun _ ↦ 1`. The indicator function is implemented non-computably, to avoid having to pass around `Decidable` arguments. This is in contrast with the design of `Pi.single` or `Set.piecewise`. ## Tags indicator, characteristic -/ assert_not_exists MonoidWithZero open Function variable {α β ι M N : Type*} namespace Set section One variable [One M] [One N] {s t : Set α} {f g : α → M} {a : α} /-- `Set.mulIndicator s f a` is `f a` if `a ∈ s`, `1` otherwise. -/ @[to_additive "`Set.indicator s f a` is `f a` if `a ∈ s`, `0` otherwise."] noncomputable def mulIndicator (s : Set α) (f : α → M) (x : α) : M := haveI := Classical.decPred (· ∈ s) if x ∈ s then f x else 1 #align set.mul_indicator Set.mulIndicator @[to_additive (attr := simp)] theorem piecewise_eq_mulIndicator [DecidablePred (· ∈ s)] : s.piecewise f 1 = s.mulIndicator f := funext fun _ => @if_congr _ _ _ _ (id _) _ _ _ _ Iff.rfl rfl rfl #align set.piecewise_eq_mul_indicator Set.piecewise_eq_mulIndicator #align set.piecewise_eq_indicator Set.piecewise_eq_indicator -- Porting note: needed unfold for mulIndicator @[to_additive] theorem mulIndicator_apply (s : Set α) (f : α → M) (a : α) [Decidable (a ∈ s)] : mulIndicator s f a = if a ∈ s then f a else 1 := by unfold mulIndicator congr #align set.mul_indicator_apply Set.mulIndicator_apply #align set.indicator_apply Set.indicator_apply @[to_additive (attr := simp)] theorem mulIndicator_of_mem (h : a ∈ s) (f : α → M) : mulIndicator s f a = f a := if_pos h #align set.mul_indicator_of_mem Set.mulIndicator_of_mem #align set.indicator_of_mem Set.indicator_of_mem @[to_additive (attr := simp)] theorem mulIndicator_of_not_mem (h : a ∉ s) (f : α → M) : mulIndicator s f a = 1 := if_neg h #align set.mul_indicator_of_not_mem Set.mulIndicator_of_not_mem #align set.indicator_of_not_mem Set.indicator_of_not_mem @[to_additive]
Mathlib/Algebra/Group/Indicator.lean
81
85
theorem mulIndicator_eq_one_or_self (s : Set α) (f : α → M) (a : α) : mulIndicator s f a = 1 ∨ mulIndicator s f a = f a := by
by_cases h : a ∈ s · exact Or.inr (mulIndicator_of_mem h f) · exact Or.inl (mulIndicator_of_not_mem h f)
/- Copyright (c) 2017 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura -/ import Mathlib.Init.Algebra.Classes import Mathlib.Init.Data.Ordering.Basic #align_import init.data.ordering.lemmas from "leanprover-community/lean"@"4bd314f7bd5e0c9e813fc201f1279a23f13f9f1d" /-! # Some `Ordering` lemmas -/ universe u namespace Ordering @[simp] theorem ite_eq_lt_distrib (c : Prop) [Decidable c] (a b : Ordering) : ((if c then a else b) = Ordering.lt) = if c then a = Ordering.lt else b = Ordering.lt := by by_cases c <;> simp [*] #align ordering.ite_eq_lt_distrib Ordering.ite_eq_lt_distrib @[simp] theorem ite_eq_eq_distrib (c : Prop) [Decidable c] (a b : Ordering) : ((if c then a else b) = Ordering.eq) = if c then a = Ordering.eq else b = Ordering.eq := by by_cases c <;> simp [*] #align ordering.ite_eq_eq_distrib Ordering.ite_eq_eq_distrib @[simp]
Mathlib/Init/Data/Ordering/Lemmas.lean
32
34
theorem ite_eq_gt_distrib (c : Prop) [Decidable c] (a b : Ordering) : ((if c then a else b) = Ordering.gt) = if c then a = Ordering.gt else b = Ordering.gt := by
by_cases c <;> simp [*]
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl -/ import Mathlib.Algebra.Order.Group.Abs import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax #align_import algebra.order.group.min_max from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" /-! # `min` and `max` in linearly ordered groups. -/ section variable {α : Type*} [Group α] [LinearOrder α] [CovariantClass α α (· * ·) (· ≤ ·)] -- TODO: This duplicates `oneLePart_div_leOnePart` @[to_additive (attr := simp)] theorem max_one_div_max_inv_one_eq_self (a : α) : max a 1 / max a⁻¹ 1 = a := by rcases le_total a 1 with (h | h) <;> simp [h] #align max_one_div_max_inv_one_eq_self max_one_div_max_inv_one_eq_self #align max_zero_sub_max_neg_zero_eq_self max_zero_sub_max_neg_zero_eq_self alias max_zero_sub_eq_self := max_zero_sub_max_neg_zero_eq_self #align max_zero_sub_eq_self max_zero_sub_eq_self @[to_additive] lemma max_inv_one (a : α) : max a⁻¹ 1 = a⁻¹ * max a 1 := by rw [eq_inv_mul_iff_mul_eq, ← eq_div_iff_mul_eq', max_one_div_max_inv_one_eq_self] end section LinearOrderedCommGroup variable {α : Type*} [LinearOrderedCommGroup α] {a b c : α} @[to_additive min_neg_neg] theorem min_inv_inv' (a b : α) : min a⁻¹ b⁻¹ = (max a b)⁻¹ := Eq.symm <| (@Monotone.map_max α αᵒᵈ _ _ Inv.inv a b) fun _ _ => -- Porting note: Explicit `α` necessary to infer `CovariantClass` instance (@inv_le_inv_iff α _ _ _).mpr #align min_inv_inv' min_inv_inv' #align min_neg_neg min_neg_neg @[to_additive max_neg_neg] theorem max_inv_inv' (a b : α) : max a⁻¹ b⁻¹ = (min a b)⁻¹ := Eq.symm <| (@Monotone.map_min α αᵒᵈ _ _ Inv.inv a b) fun _ _ => -- Porting note: Explicit `α` necessary to infer `CovariantClass` instance (@inv_le_inv_iff α _ _ _).mpr #align max_inv_inv' max_inv_inv' #align max_neg_neg max_neg_neg @[to_additive min_sub_sub_right] theorem min_div_div_right' (a b c : α) : min (a / c) (b / c) = min a b / c := by simpa only [div_eq_mul_inv] using min_mul_mul_right a b c⁻¹ #align min_div_div_right' min_div_div_right' #align min_sub_sub_right min_sub_sub_right @[to_additive max_sub_sub_right] theorem max_div_div_right' (a b c : α) : max (a / c) (b / c) = max a b / c := by simpa only [div_eq_mul_inv] using max_mul_mul_right a b c⁻¹ #align max_div_div_right' max_div_div_right' #align max_sub_sub_right max_sub_sub_right @[to_additive min_sub_sub_left] theorem min_div_div_left' (a b c : α) : min (a / b) (a / c) = a / max b c := by simp only [div_eq_mul_inv, min_mul_mul_left, min_inv_inv'] #align min_div_div_left' min_div_div_left' #align min_sub_sub_left min_sub_sub_left @[to_additive max_sub_sub_left] theorem max_div_div_left' (a b c : α) : max (a / b) (a / c) = a / min b c := by simp only [div_eq_mul_inv, max_mul_mul_left, max_inv_inv'] #align max_div_div_left' max_div_div_left' #align max_sub_sub_left max_sub_sub_left end LinearOrderedCommGroup section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] {a b c : α} theorem max_sub_max_le_max (a b c d : α) : max a b - max c d ≤ max (a - c) (b - d) := by simp only [sub_le_iff_le_add, max_le_iff]; constructor · calc a = a - c + c := (sub_add_cancel a c).symm _ ≤ max (a - c) (b - d) + max c d := add_le_add (le_max_left _ _) (le_max_left _ _) · calc b = b - d + d := (sub_add_cancel b d).symm _ ≤ max (a - c) (b - d) + max c d := add_le_add (le_max_right _ _) (le_max_right _ _) #align max_sub_max_le_max max_sub_max_le_max
Mathlib/Algebra/Order/Group/MinMax.lean
96
100
theorem abs_max_sub_max_le_max (a b c d : α) : |max a b - max c d| ≤ max |a - c| |b - d| := by
refine abs_sub_le_iff.2 ⟨?_, ?_⟩ · exact (max_sub_max_le_max _ _ _ _).trans (max_le_max (le_abs_self _) (le_abs_self _)) · rw [abs_sub_comm a c, abs_sub_comm b d] exact (max_sub_max_le_max _ _ _ _).trans (max_le_max (le_abs_self _) (le_abs_self _))
/- 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.SetTheory.Ordinal.Arithmetic import Mathlib.SetTheory.Ordinal.Exponential #align_import set_theory.ordinal.cantor_normal_form from "leanprover-community/mathlib"@"991ff3b5269848f6dd942ae8e9dd3c946035dc8b" /-! # Cantor Normal Form The Cantor normal form of an ordinal is generally defined as its base `ω` expansion, with its non-zero exponents in decreasing order. Here, we more generally define a base `b` expansion `Ordinal.CNF` in this manner, which is well-behaved for any `b ≥ 2`. # Implementation notes We implement `Ordinal.CNF` as an association list, where keys are exponents and values are coefficients. This is because this structure intrinsically reflects two key properties of the Cantor normal form: - It is ordered. - It has finitely many entries. # Todo - Add API for the coefficients of the Cantor normal form. - Prove the basic results relating the CNF to the arithmetic operations on ordinals. -/ noncomputable section universe u open List namespace Ordinal /-- Inducts on the base `b` expansion of an ordinal. -/ @[elab_as_elim] noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by by_cases h : o = 0 · rw [h]; exact H0 · exact H o h (CNFRec _ H0 H (o % b ^ log b o)) termination_by o => o decreasing_by exact mod_opow_log_lt_self b h set_option linter.uppercaseLean3 false in #align ordinal.CNF_rec Ordinal.CNFRec @[simp]
Mathlib/SetTheory/Ordinal/CantorNormalForm.lean
55
58
theorem CNFRec_zero {C : Ordinal → Sort*} (b : Ordinal) (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H 0 = H0 := by
rw [CNFRec, dif_pos rfl] rfl
/- Copyright (c) 2021 Benjamin Davidson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Benjamin Davidson, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.LocalExtr.Rolle import Mathlib.Analysis.Calculus.Deriv.Polynomial import Mathlib.Topology.Algebra.Polynomial #align_import analysis.calculus.local_extr from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Rolle's Theorem for polynomials In this file we use Rolle's Theorem to relate the number of real roots of a real polynomial and its derivative. Namely, we prove the following facts. * `Polynomial.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ`: the number of roots of a real polynomial `p` is at most the number of roots of its derivative that are not roots of `p` plus one. * `Polynomial.card_roots_toFinset_le_derivative`, `Polynomial.card_rootSet_le_derivative`: the number of roots of a real polynomial is at most the number of roots of its derivative plus one. * `Polynomial.card_roots_le_derivative`: same, but the roots are counted with multiplicities. ## Keywords polynomial, Rolle's Theorem, root -/ namespace Polynomial /-- The number of roots of a real polynomial `p` is at most the number of roots of its derivative that are not roots of `p` plus one. -/ theorem card_roots_toFinset_le_card_roots_derivative_diff_roots_succ (p : ℝ[X]) : p.roots.toFinset.card ≤ (p.derivative.roots.toFinset \ p.roots.toFinset).card + 1 := by rcases eq_or_ne (derivative p) 0 with hp' | hp' · rw [eq_C_of_derivative_eq_zero hp', roots_C, Multiset.toFinset_zero, Finset.card_empty] exact zero_le _ have hp : p ≠ 0 := ne_of_apply_ne derivative (by rwa [derivative_zero]) refine Finset.card_le_diff_of_interleaved fun x hx y hy hxy hxy' => ?_ rw [Multiset.mem_toFinset, mem_roots hp] at hx hy obtain ⟨z, hz1, hz2⟩ := exists_deriv_eq_zero hxy p.continuousOn (hx.trans hy.symm) refine ⟨z, ?_, hz1⟩ rwa [Multiset.mem_toFinset, mem_roots hp', IsRoot, ← p.deriv] #align polynomial.card_roots_to_finset_le_card_roots_derivative_diff_roots_succ Polynomial.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ /-- The number of roots of a real polynomial is at most the number of roots of its derivative plus one. -/ theorem card_roots_toFinset_le_derivative (p : ℝ[X]) : p.roots.toFinset.card ≤ p.derivative.roots.toFinset.card + 1 := p.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ.trans <| add_le_add_right (Finset.card_mono Finset.sdiff_subset) _ #align polynomial.card_roots_to_finset_le_derivative Polynomial.card_roots_toFinset_le_derivative /-- The number of roots of a real polynomial (counted with multiplicities) is at most the number of roots of its derivative (counted with multiplicities) plus one. -/
Mathlib/Analysis/Calculus/LocalExtr/Polynomial.lean
59
86
theorem card_roots_le_derivative (p : ℝ[X]) : Multiset.card p.roots ≤ Multiset.card (derivative p).roots + 1 := calc Multiset.card p.roots = ∑ x ∈ p.roots.toFinset, p.roots.count x := (Multiset.toFinset_sum_count_eq _).symm _ = ∑ x ∈ p.roots.toFinset, (p.roots.count x - 1 + 1) := (Eq.symm <| Finset.sum_congr rfl fun x hx => tsub_add_cancel_of_le <| Nat.succ_le_iff.2 <| Multiset.count_pos.2 <| Multiset.mem_toFinset.1 hx) _ = (∑ x ∈ p.roots.toFinset, (p.rootMultiplicity x - 1)) + p.roots.toFinset.card := by
simp only [Finset.sum_add_distrib, Finset.card_eq_sum_ones, count_roots] _ ≤ (∑ x ∈ p.roots.toFinset, p.derivative.rootMultiplicity x) + ((p.derivative.roots.toFinset \ p.roots.toFinset).card + 1) := (add_le_add (Finset.sum_le_sum fun x _ => rootMultiplicity_sub_one_le_derivative_rootMultiplicity _ _) p.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ) _ ≤ (∑ x ∈ p.roots.toFinset, p.derivative.roots.count x) + ((∑ x ∈ p.derivative.roots.toFinset \ p.roots.toFinset, p.derivative.roots.count x) + 1) := by simp only [← count_roots] refine add_le_add_left (add_le_add_right ((Finset.card_eq_sum_ones _).trans_le ?_) _) _ refine Finset.sum_le_sum fun x hx => Nat.succ_le_iff.2 <| ?_ rw [Multiset.count_pos, ← Multiset.mem_toFinset] exact (Finset.mem_sdiff.1 hx).1 _ = Multiset.card (derivative p).roots + 1 := by rw [← add_assoc, ← Finset.sum_union Finset.disjoint_sdiff, Finset.union_sdiff_self_eq_union, ← Multiset.toFinset_sum_count_eq, ← Finset.sum_subset Finset.subset_union_right] intro x _ hx₂ simpa only [Multiset.mem_toFinset, Multiset.count_eq_zero] using hx₂
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" /-! # Basis on a quaternion-like algebra ## Main definitions * `QuaternionAlgebra.Basis A c₁ c₂`: a basis for a subspace of an `R`-algebra `A` that has the same algebra structure as `ℍ[R,c₁,c₂]`. * `QuaternionAlgebra.Basis.self R`: the canonical basis for `ℍ[R,c₁,c₂]`. * `QuaternionAlgebra.Basis.compHom b f`: transform a basis `b` by an AlgHom `f`. * `QuaternionAlgebra.lift`: Define an `AlgHom` out of `ℍ[R,c₁,c₂]` by its action on the basis elements `i`, `j`, and `k`. In essence, this is a universal property. Analogous to `Complex.lift`, but takes a bundled `QuaternionAlgebra.Basis` instead of just a `Subtype` as the amount of data / proves is non-negligible. -/ open Quaternion namespace QuaternionAlgebra /-- A quaternion basis contains the information both sufficient and necessary to construct an `R`-algebra homomorphism from `ℍ[R,c₁,c₂]` to `A`; or equivalently, a surjective `R`-algebra homomorphism from `ℍ[R,c₁,c₂]` to an `R`-subalgebra of `A`. Note that for definitional convenience, `k` is provided as a field even though `i_mul_j` fully determines it. -/ structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis /-- Since `k` is redundant, it is not necessary to show `q₁.k = q₂.k` when showing `q₁ = q₂`. -/ @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) /-- There is a natural quaternionic basis for the `QuaternionAlgebra`. -/ @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp]
Mathlib/Algebra/QuaternionBasis.lean
94
95
theorem k_mul_j : q.k * q.j = c₂ • q.i := by
rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one]
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl -/ import Mathlib.Algebra.Group.Units.Equiv import Mathlib.Algebra.Order.Group.Defs import Mathlib.Order.Hom.Basic #align_import algebra.order.group.order_iso from "leanprover-community/mathlib"@"6632ca2081e55ff5cf228ca63011979a0efb495b" /-! # Inverse and multiplication as order isomorphisms in ordered groups -/ open Function universe u variable {α : Type u} section Group variable [Group α] section TypeclassesLeftRightLE variable [LE α] [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (swap (· * ·)) (· ≤ ·)] {a b c d : α} section variable (α) /-- `x ↦ x⁻¹` as an order-reversing equivalence. -/ @[to_additive (attr := simps!) "`x ↦ -x` as an order-reversing equivalence."] def OrderIso.inv : α ≃o αᵒᵈ where toEquiv := (Equiv.inv α).trans OrderDual.toDual map_rel_iff' {_ _} := @inv_le_inv_iff α _ _ _ _ _ _ #align order_iso.inv OrderIso.inv #align order_iso.neg OrderIso.neg #align order_iso.inv_apply OrderIso.inv_apply #align order_iso.inv_symm_apply OrderIso.inv_symm_apply end @[to_additive neg_le] theorem inv_le' : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := (OrderIso.inv α).symm_apply_le #align inv_le' inv_le' #align neg_le neg_le alias ⟨inv_le_of_inv_le', _⟩ := inv_le' #align inv_le_of_inv_le' inv_le_of_inv_le' attribute [to_additive neg_le_of_neg_le] inv_le_of_inv_le' #align neg_le_of_neg_le neg_le_of_neg_le @[to_additive le_neg] theorem le_inv' : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := (OrderIso.inv α).le_symm_apply #align le_inv' le_inv' #align le_neg le_neg /-- `x ↦ a / x` as an order-reversing equivalence. -/ @[to_additive (attr := simps!) "`x ↦ a - x` as an order-reversing equivalence."] def OrderIso.divLeft (a : α) : α ≃o αᵒᵈ where toEquiv := (Equiv.divLeft a).trans OrderDual.toDual map_rel_iff' {_ _} := @div_le_div_iff_left α _ _ _ _ _ _ _ #align order_iso.div_left OrderIso.divLeft #align order_iso.sub_left OrderIso.subLeft end TypeclassesLeftRightLE end Group alias ⟨le_inv_of_le_inv, _⟩ := le_inv' #align le_inv_of_le_inv le_inv_of_le_inv attribute [to_additive] le_inv_of_le_inv #align le_neg_of_le_neg le_neg_of_le_neg section Group variable [Group α] [LE α] section Right variable [CovariantClass α α (swap (· * ·)) (· ≤ ·)] {a b c d : α} /-- `Equiv.mulRight` as an `OrderIso`. See also `OrderEmbedding.mulRight`. -/ @[to_additive (attr := simps! (config := { simpRhs := true }) toEquiv apply) "`Equiv.addRight` as an `OrderIso`. See also `OrderEmbedding.addRight`."] def OrderIso.mulRight (a : α) : α ≃o α where map_rel_iff' {_ _} := mul_le_mul_iff_right a toEquiv := Equiv.mulRight a #align order_iso.mul_right OrderIso.mulRight #align order_iso.add_right OrderIso.addRight #align order_iso.mul_right_apply OrderIso.mulRight_apply #align order_iso.mul_right_to_equiv OrderIso.mulRight_toEquiv @[to_additive (attr := simp)] theorem OrderIso.mulRight_symm (a : α) : (OrderIso.mulRight a).symm = OrderIso.mulRight a⁻¹ := by ext x rfl #align order_iso.mul_right_symm OrderIso.mulRight_symm #align order_iso.add_right_symm OrderIso.addRight_symm /-- `x ↦ x / a` as an order isomorphism. -/ @[to_additive (attr := simps!) "`x ↦ x - a` as an order isomorphism."] def OrderIso.divRight (a : α) : α ≃o α where toEquiv := Equiv.divRight a map_rel_iff' {_ _} := div_le_div_iff_right a #align order_iso.div_right OrderIso.divRight #align order_iso.sub_right OrderIso.subRight end Right section Left variable [CovariantClass α α (· * ·) (· ≤ ·)] /-- `Equiv.mulLeft` as an `OrderIso`. See also `OrderEmbedding.mulLeft`. -/ @[to_additive (attr := simps! (config := { simpRhs := true }) toEquiv apply) "`Equiv.addLeft` as an `OrderIso`. See also `OrderEmbedding.addLeft`."] def OrderIso.mulLeft (a : α) : α ≃o α where map_rel_iff' {_ _} := mul_le_mul_iff_left a toEquiv := Equiv.mulLeft a #align order_iso.mul_left OrderIso.mulLeft #align order_iso.add_left OrderIso.addLeft #align order_iso.mul_left_apply OrderIso.mulLeft_apply #align order_iso.add_left_apply OrderIso.addLeft_apply #align order_iso.add_left_to_equiv OrderIso.addLeft_toEquiv @[to_additive (attr := simp)]
Mathlib/Algebra/Order/Group/OrderIso.lean
137
139
theorem OrderIso.mulLeft_symm (a : α) : (OrderIso.mulLeft a).symm = OrderIso.mulLeft a⁻¹ := by
ext x rfl
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho import Mathlib.LinearAlgebra.Orientation #align_import analysis.inner_product_space.orientation from "leanprover-community/mathlib"@"bd65478311e4dfd41f48bf38c7e3b02fb75d0163" /-! # Orientations of real inner product spaces. This file provides definitions and proves lemmas about orientations of real inner product spaces. ## Main definitions * `OrthonormalBasis.adjustToOrientation` takes an orthonormal basis and an orientation, and returns an orthonormal basis with that orientation: either the original orthonormal basis, or one constructed by negating a single (arbitrary) basis vector. * `Orientation.finOrthonormalBasis` is an orthonormal basis, indexed by `Fin n`, with the given orientation. * `Orientation.volumeForm` is a nonvanishing top-dimensional alternating form on an oriented real inner product space, uniquely defined by compatibility with the orientation and inner product structure. ## Main theorems * `Orientation.volumeForm_apply_le` states that the result of applying the volume form to a set of `n` vectors, where `n` is the dimension the inner product space, is bounded by the product of the lengths of the vectors. * `Orientation.abs_volumeForm_apply_of_pairwise_orthogonal` states that the result of applying the volume form to a set of `n` orthogonal vectors, where `n` is the dimension the inner product space, is equal up to sign to the product of the lengths of the vectors. -/ noncomputable section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] open FiniteDimensional open scoped RealInnerProductSpace namespace OrthonormalBasis variable {ι : Type*} [Fintype ι] [DecidableEq ι] [ne : Nonempty ι] (e f : OrthonormalBasis ι ℝ E) (x : Orientation ℝ E ι) /-- The change-of-basis matrix between two orthonormal bases with the same orientation has determinant 1. -/ theorem det_to_matrix_orthonormalBasis_of_same_orientation (h : e.toBasis.orientation = f.toBasis.orientation) : e.toBasis.det f = 1 := by apply (e.det_to_matrix_orthonormalBasis_real f).resolve_right have : 0 < e.toBasis.det f := by rw [e.toBasis.orientation_eq_iff_det_pos] at h simpa using h linarith #align orthonormal_basis.det_to_matrix_orthonormal_basis_of_same_orientation OrthonormalBasis.det_to_matrix_orthonormalBasis_of_same_orientation /-- The change-of-basis matrix between two orthonormal bases with the opposite orientations has determinant -1. -/ theorem det_to_matrix_orthonormalBasis_of_opposite_orientation (h : e.toBasis.orientation ≠ f.toBasis.orientation) : e.toBasis.det f = -1 := by contrapose! h simp [e.toBasis.orientation_eq_iff_det_pos, (e.det_to_matrix_orthonormalBasis_real f).resolve_right h] #align orthonormal_basis.det_to_matrix_orthonormal_basis_of_opposite_orientation OrthonormalBasis.det_to_matrix_orthonormalBasis_of_opposite_orientation variable {e f} /-- Two orthonormal bases with the same orientation determine the same "determinant" top-dimensional form on `E`, and conversely. -/ theorem same_orientation_iff_det_eq_det : e.toBasis.det = f.toBasis.det ↔ e.toBasis.orientation = f.toBasis.orientation := by constructor · intro h dsimp [Basis.orientation] congr · intro h rw [e.toBasis.det.eq_smul_basis_det f.toBasis] simp [e.det_to_matrix_orthonormalBasis_of_same_orientation f h] #align orthonormal_basis.same_orientation_iff_det_eq_det OrthonormalBasis.same_orientation_iff_det_eq_det variable (e f) /-- Two orthonormal bases with opposite orientations determine opposite "determinant" top-dimensional forms on `E`. -/ theorem det_eq_neg_det_of_opposite_orientation (h : e.toBasis.orientation ≠ f.toBasis.orientation) : e.toBasis.det = -f.toBasis.det := by rw [e.toBasis.det.eq_smul_basis_det f.toBasis] -- Porting note: added `neg_one_smul` with explicit type simp [e.det_to_matrix_orthonormalBasis_of_opposite_orientation f h, neg_one_smul ℝ (M := E [⋀^ι]→ₗ[ℝ] ℝ)] #align orthonormal_basis.det_eq_neg_det_of_opposite_orientation OrthonormalBasis.det_eq_neg_det_of_opposite_orientation section AdjustToOrientation /-- `OrthonormalBasis.adjustToOrientation`, applied to an orthonormal basis, preserves the property of orthonormality. -/
Mathlib/Analysis/InnerProductSpace/Orientation.lean
103
105
theorem orthonormal_adjustToOrientation : Orthonormal ℝ (e.toBasis.adjustToOrientation x) := by
apply e.orthonormal.orthonormal_of_forall_eq_or_eq_neg simpa using e.toBasis.adjustToOrientation_apply_eq_or_eq_neg x
/- 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.Algebra.Module.Equiv #align_import linear_algebra.general_linear_group from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" /-! # The general linear group of linear maps The general linear group is defined to be the group of invertible linear maps from `M` to itself. See also `Matrix.GeneralLinearGroup` ## Main definitions * `LinearMap.GeneralLinearGroup` -/ variable (R M : Type*) namespace LinearMap variable [Semiring R] [AddCommMonoid M] [Module R M] /-- The group of invertible linear maps from `M` to itself -/ abbrev GeneralLinearGroup := (M →ₗ[R] M)ˣ #align linear_map.general_linear_group LinearMap.GeneralLinearGroup namespace GeneralLinearGroup variable {R M} /-- An invertible linear map `f` determines an equivalence from `M` to itself. -/ def toLinearEquiv (f : GeneralLinearGroup R M) : M ≃ₗ[R] M := { f.val with invFun := f.inv.toFun left_inv := fun m ↦ show (f.inv * f.val) m = m by erw [f.inv_val]; simp right_inv := fun m ↦ show (f.val * f.inv) m = m by erw [f.val_inv]; simp } #align linear_map.general_linear_group.to_linear_equiv LinearMap.GeneralLinearGroup.toLinearEquiv /-- An equivalence from `M` to itself determines an invertible linear map. -/ def ofLinearEquiv (f : M ≃ₗ[R] M) : GeneralLinearGroup R M where val := f inv := (f.symm : M →ₗ[R] M) val_inv := LinearMap.ext fun _ ↦ f.apply_symm_apply _ inv_val := LinearMap.ext fun _ ↦ f.symm_apply_apply _ #align linear_map.general_linear_group.of_linear_equiv LinearMap.GeneralLinearGroup.ofLinearEquiv variable (R M) /-- The general linear group on `R` and `M` is multiplicatively equivalent to the type of linear equivalences between `M` and itself. -/ def generalLinearEquiv : GeneralLinearGroup R M ≃* M ≃ₗ[R] M where toFun := toLinearEquiv invFun := ofLinearEquiv left_inv f := by ext; rfl right_inv f := by ext; rfl map_mul' x y := by ext; rfl #align linear_map.general_linear_group.general_linear_equiv LinearMap.GeneralLinearGroup.generalLinearEquiv @[simp]
Mathlib/LinearAlgebra/GeneralLinearGroup.lean
68
69
theorem generalLinearEquiv_to_linearMap (f : GeneralLinearGroup R M) : (generalLinearEquiv R M f : M →ₗ[R] M) = f := by
ext; rfl
/- Copyright (c) 2020 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.MeasureTheory.Constructions.Prod.Basic import Mathlib.MeasureTheory.Group.Measure import Mathlib.Topology.Constructions #align_import measure_theory.constructions.pi from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Product measures In this file we define and prove properties about finite products of measures (and at some point, countable products of measures). ## Main definition * `MeasureTheory.Measure.pi`: The product of finitely many σ-finite measures. Given `μ : (i : ι) → Measure (α i)` for `[Fintype ι]` it has type `Measure ((i : ι) → α i)`. To apply Fubini's theorem or Tonelli's theorem along some subset, we recommend using the marginal construction `MeasureTheory.lmarginal` and (todo) `MeasureTheory.marginal`. This allows you to apply the theorems without any bookkeeping with measurable equivalences. ## Implementation Notes We define `MeasureTheory.OuterMeasure.pi`, the product of finitely many outer measures, as the maximal outer measure `n` with the property that `n (pi univ s) ≤ ∏ i, m i (s i)`, where `pi univ s` is the product of the sets `{s i | i : ι}`. We then show that this induces a product of measures, called `MeasureTheory.Measure.pi`. For a collection of σ-finite measures `μ` and a collection of measurable sets `s` we show that `Measure.pi μ (pi univ s) = ∏ i, m i (s i)`. To do this, we follow the following steps: * We know that there is some ordering on `ι`, given by an element of `[Countable ι]`. * Using this, we have an equivalence `MeasurableEquiv.piMeasurableEquivTProd` between `∀ ι, α i` and an iterated product of `α i`, called `List.tprod α l` for some list `l`. * On this iterated product we can easily define a product measure `MeasureTheory.Measure.tprod` by iterating `MeasureTheory.Measure.prod` * Using the previous two steps we construct `MeasureTheory.Measure.pi'` on `(i : ι) → α i` for countable `ι`. * We know that `MeasureTheory.Measure.pi'` sends products of sets to products of measures, and since `MeasureTheory.Measure.pi` is the maximal such measure (or at least, it comes from an outer measure which is the maximal such outer measure), we get the same rule for `MeasureTheory.Measure.pi`. ## Tags finitary product measure -/ noncomputable section open Function Set MeasureTheory.OuterMeasure Filter MeasurableSpace Encodable open scoped Classical Topology ENNReal universe u v variable {ι ι' : Type*} {α : ι → Type*} /-! We start with some measurability properties -/ /-- Boxes formed by π-systems form a π-system. -/ theorem IsPiSystem.pi {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsPiSystem (C i)) : IsPiSystem (pi univ '' pi univ C) := by rintro _ ⟨s₁, hs₁, rfl⟩ _ ⟨s₂, hs₂, rfl⟩ hst rw [← pi_inter_distrib] at hst ⊢; rw [univ_pi_nonempty_iff] at hst exact mem_image_of_mem _ fun i _ => hC i _ (hs₁ i (mem_univ i)) _ (hs₂ i (mem_univ i)) (hst i) #align is_pi_system.pi IsPiSystem.pi /-- Boxes form a π-system. -/ theorem isPiSystem_pi [∀ i, MeasurableSpace (α i)] : IsPiSystem (pi univ '' pi univ fun i => { s : Set (α i) | MeasurableSet s }) := IsPiSystem.pi fun _ => isPiSystem_measurableSet #align is_pi_system_pi isPiSystem_pi section Finite variable [Finite ι] [Finite ι'] /-- Boxes of countably spanning sets are countably spanning. -/ theorem IsCountablySpanning.pi {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsCountablySpanning (C i)) : IsCountablySpanning (pi univ '' pi univ C) := by choose s h1s h2s using hC cases nonempty_encodable (ι → ℕ) let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget refine ⟨fun n => Set.pi univ fun i => s i (e n i), fun n => mem_image_of_mem _ fun i _ => h1s i _, ?_⟩ simp_rw [(surjective_decode_iget (ι → ℕ)).iUnion_comp fun x => Set.pi univ fun i => s i (x i), iUnion_univ_pi s, h2s, pi_univ] #align is_countably_spanning.pi IsCountablySpanning.pi /-- The product of generated σ-algebras is the one generated by boxes, if both generating sets are countably spanning. -/
Mathlib/MeasureTheory/Constructions/Pi.lean
100
127
theorem generateFrom_pi_eq {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsCountablySpanning (C i)) : (@MeasurableSpace.pi _ _ fun i => generateFrom (C i)) = generateFrom (pi univ '' pi univ C) := by
cases nonempty_encodable ι apply le_antisymm · refine iSup_le ?_; intro i; rw [comap_generateFrom] apply generateFrom_le; rintro _ ⟨s, hs, rfl⟩; dsimp choose t h1t h2t using hC simp_rw [eval_preimage, ← h2t] rw [← @iUnion_const _ ℕ _ s] have : Set.pi univ (update (fun i' : ι => iUnion (t i')) i (⋃ _ : ℕ, s)) = Set.pi univ fun k => ⋃ j : ℕ, @update ι (fun i' => Set (α i')) _ (fun i' => t i' j) i s k := by ext; simp_rw [mem_univ_pi]; apply forall_congr'; intro i' by_cases h : i' = i · subst h; simp · rw [← Ne] at h; simp [h] rw [this, ← iUnion_univ_pi] apply MeasurableSet.iUnion intro n; apply measurableSet_generateFrom apply mem_image_of_mem; intro j _; dsimp only by_cases h : j = i · subst h; rwa [update_same] · rw [update_noteq h]; apply h1t · apply generateFrom_le; rintro _ ⟨s, hs, rfl⟩ rw [univ_pi_eq_iInter]; apply MeasurableSet.iInter; intro i apply @measurable_pi_apply _ _ (fun i => generateFrom (C i)) exact measurableSet_generateFrom (hs i (mem_univ i))
/- 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.Order.Ring.Nat import Mathlib.Algebra.Order.Monoid.WithTop #align_import data.nat.with_bot from "leanprover-community/mathlib"@"966e0cf0685c9cedf8a3283ac69eef4d5f2eaca2" /-! # `WithBot ℕ` Lemmas about the type of natural numbers with a bottom element adjoined. -/ namespace Nat namespace WithBot instance : WellFoundedRelation (WithBot ℕ) where rel := (· < ·) wf := IsWellFounded.wf theorem add_eq_zero_iff {n m : WithBot ℕ} : n + m = 0 ↔ n = 0 ∧ m = 0 := by rcases n, m with ⟨_ | _, _ | _⟩ repeat (· exact ⟨fun h => Option.noConfusion h, fun h => Option.noConfusion h.1⟩) · exact ⟨fun h => Option.noConfusion h, fun h => Option.noConfusion h.2⟩ repeat erw [WithBot.coe_eq_coe] exact add_eq_zero_iff' (zero_le _) (zero_le _) #align nat.with_bot.add_eq_zero_iff Nat.WithBot.add_eq_zero_iff theorem add_eq_one_iff {n m : WithBot ℕ} : n + m = 1 ↔ n = 0 ∧ m = 1 ∨ n = 1 ∧ m = 0 := by rcases n, m with ⟨_ | _, _ | _⟩ repeat refine ⟨fun h => Option.noConfusion h, fun h => ?_⟩; aesop (simp_config := { decide := true }) repeat erw [WithBot.coe_eq_coe] exact Nat.add_eq_one_iff #align nat.with_bot.add_eq_one_iff Nat.WithBot.add_eq_one_iff theorem add_eq_two_iff {n m : WithBot ℕ} : n + m = 2 ↔ n = 0 ∧ m = 2 ∨ n = 1 ∧ m = 1 ∨ n = 2 ∧ m = 0 := by rcases n, m with ⟨_ | _, _ | _⟩ repeat refine ⟨fun h => Option.noConfusion h, fun h => ?_⟩; aesop (simp_config := { decide := true }) repeat erw [WithBot.coe_eq_coe] exact Nat.add_eq_two_iff #align nat.with_bot.add_eq_two_iff Nat.WithBot.add_eq_two_iff theorem add_eq_three_iff {n m : WithBot ℕ} : n + m = 3 ↔ n = 0 ∧ m = 3 ∨ n = 1 ∧ m = 2 ∨ n = 2 ∧ m = 1 ∨ n = 3 ∧ m = 0 := by rcases n, m with ⟨_ | _, _ | _⟩ repeat refine ⟨fun h => Option.noConfusion h, fun h => ?_⟩; aesop (simp_config := { decide := true }) repeat erw [WithBot.coe_eq_coe] exact Nat.add_eq_three_iff #align nat.with_bot.add_eq_three_iff Nat.WithBot.add_eq_three_iff theorem coe_nonneg {n : ℕ} : 0 ≤ (n : WithBot ℕ) := by rw [← WithBot.coe_zero] exact WithBot.coe_le_coe.mpr (Nat.zero_le n) #align nat.with_bot.coe_nonneg Nat.WithBot.coe_nonneg @[simp] theorem lt_zero_iff {n : WithBot ℕ} : n < 0 ↔ n = ⊥ := WithBot.lt_coe_bot #align nat.with_bot.lt_zero_iff Nat.WithBot.lt_zero_iff
Mathlib/Data/Nat/WithBot.lean
70
74
theorem one_le_iff_zero_lt {x : WithBot ℕ} : 1 ≤ x ↔ 0 < x := by
refine ⟨fun h => lt_of_lt_of_le (WithBot.coe_lt_coe.mpr zero_lt_one) h, fun h => ?_⟩ induction x · exact (not_lt_bot h).elim · exact WithBot.coe_le_coe.mpr (Nat.succ_le_iff.mpr (WithBot.coe_lt_coe.mp h))
/- Copyright (c) 2019 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Simon Hudon, Alice Laroche, Frédéric Dupuis, Jireh Loreaux -/ import Lean.Elab.Tactic.Location import Mathlib.Logic.Basic import Mathlib.Init.Order.Defs import Mathlib.Tactic.Conv import Mathlib.Init.Set import Lean.Elab.Tactic.Location set_option autoImplicit true namespace Mathlib.Tactic.PushNeg open Lean Meta Elab.Tactic Parser.Tactic variable (p q : Prop) (s : α → Prop) theorem not_not_eq : (¬ ¬ p) = p := propext not_not theorem not_and_eq : (¬ (p ∧ q)) = (p → ¬ q) := propext not_and theorem not_and_or_eq : (¬ (p ∧ q)) = (¬ p ∨ ¬ q) := propext not_and_or theorem not_or_eq : (¬ (p ∨ q)) = (¬ p ∧ ¬ q) := propext not_or theorem not_forall_eq : (¬ ∀ x, s x) = (∃ x, ¬ s x) := propext not_forall theorem not_exists_eq : (¬ ∃ x, s x) = (∀ x, ¬ s x) := propext not_exists theorem not_implies_eq : (¬ (p → q)) = (p ∧ ¬ q) := propext Classical.not_imp theorem not_ne_eq (x y : α) : (¬ (x ≠ y)) = (x = y) := ne_eq x y ▸ not_not_eq _ theorem not_iff : (¬ (p ↔ q)) = ((p ∧ ¬ q) ∨ (¬ p ∧ q)) := propext <| _root_.not_iff.trans <| iff_iff_and_or_not_and_not.trans <| by rw [not_not, or_comm] variable {β : Type u} [LinearOrder β] theorem not_le_eq (a b : β) : (¬ (a ≤ b)) = (b < a) := propext not_le theorem not_lt_eq (a b : β) : (¬ (a < b)) = (b ≤ a) := propext not_lt theorem not_ge_eq (a b : β) : (¬ (a ≥ b)) = (a < b) := propext not_le theorem not_gt_eq (a b : β) : (¬ (a > b)) = (a ≤ b) := propext not_lt theorem not_nonempty_eq (s : Set γ) : (¬ s.Nonempty) = (s = ∅) := by have A : ∀ (x : γ), ¬(x ∈ (∅ : Set γ)) := fun x ↦ id simp only [Set.Nonempty, not_exists, eq_iff_iff] exact ⟨fun h ↦ Set.ext (fun x ↦ by simp only [h x, false_iff, A]), fun h ↦ by rwa [h]⟩
Mathlib/Tactic/PushNeg.lean
44
45
theorem ne_empty_eq_nonempty (s : Set γ) : (s ≠ ∅) = s.Nonempty := by
rw [ne_eq, ← not_nonempty_eq s, not_not]
/- Copyright (c) 2023 Peter Nelson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Peter Nelson -/ import Mathlib.SetTheory.Cardinal.Finite #align_import data.set.ncard from "leanprover-community/mathlib"@"74c2af38a828107941029b03839882c5c6f87a04" /-! # Noncomputable Set Cardinality We define the cardinality of set `s` as a term `Set.encard s : ℕ∞` and a term `Set.ncard s : ℕ`. The latter takes the junk value of zero if `s` is infinite. Both functions are noncomputable, and are defined in terms of `PartENat.card` (which takes a type as its argument); this file can be seen as an API for the same function in the special case where the type is a coercion of a `Set`, allowing for smoother interactions with the `Set` API. `Set.encard` never takes junk values, so is more mathematically natural than `Set.ncard`, even though it takes values in a less convenient type. It is probably the right choice in settings where one is concerned with the cardinalities of sets that may or may not be infinite. `Set.ncard` has a nicer codomain, but when using it, `Set.Finite` hypotheses are normally needed to make sure its values are meaningful. More generally, `Set.ncard` is intended to be used over the obvious alternative `Finset.card` when finiteness is 'propositional' rather than 'structural'. When working with sets that are finite by virtue of their definition, then `Finset.card` probably makes more sense. One setting where `Set.ncard` works nicely is in a type `α` with `[Finite α]`, where every set is automatically finite. In this setting, we use default arguments and a simple tactic so that finiteness goals are discharged automatically in `Set.ncard` theorems. ## Main Definitions * `Set.encard s` is the cardinality of the set `s` as an extended natural number, with value `⊤` if `s` is infinite. * `Set.ncard s` is the cardinality of the set `s` as a natural number, provided `s` is Finite. If `s` is Infinite, then `Set.ncard s = 0`. * `toFinite_tac` is a tactic that tries to synthesize a `Set.Finite s` argument with `Set.toFinite`. This will work for `s : Set α` where there is a `Finite α` instance. ## Implementation Notes The theorems in this file are very similar to those in `Data.Finset.Card`, but with `Set` operations instead of `Finset`. We first prove all the theorems for `Set.encard`, and then derive most of the `Set.ncard` results as a consequence. Things are done this way to avoid reliance on the `Finset` API for theorems about infinite sets, and to allow for a refactor that removes or modifies `Set.ncard` in the future. Nearly all the theorems for `Set.ncard` require finiteness of one or more of their arguments. We provide this assumption with a default argument of the form `(hs : s.Finite := by toFinite_tac)`, where `toFinite_tac` will find an `s.Finite` term in the cases where `s` is a set in a `Finite` type. Often, where there are two set arguments `s` and `t`, the finiteness of one follows from the other in the context of the theorem, in which case we only include the ones that are needed, and derive the other inside the proof. A few of the theorems, such as `ncard_union_le` do not require finiteness arguments; they are true by coincidence due to junk values. -/ namespace Set variable {α β : Type*} {s t : Set α} /-- The cardinality of a set as a term in `ℕ∞` -/ noncomputable def encard (s : Set α) : ℕ∞ := PartENat.withTopEquiv (PartENat.card s) @[simp] theorem encard_univ_coe (s : Set α) : encard (univ : Set s) = encard s := by rw [encard, encard, PartENat.card_congr (Equiv.Set.univ ↑s)] theorem encard_univ (α : Type*) : encard (univ : Set α) = PartENat.withTopEquiv (PartENat.card α) := by rw [encard, PartENat.card_congr (Equiv.Set.univ α)] theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by have := h.fintype rw [encard, PartENat.card_eq_coe_fintype_card, PartENat.withTopEquiv_natCast, toFinite_toFinset, toFinset_card] theorem encard_eq_coe_toFinset_card (s : Set α) [Fintype s] : encard s = s.toFinset.card := by have h := toFinite s rw [h.encard_eq_coe_toFinset_card, toFinite_toFinset] theorem encard_coe_eq_coe_finsetCard (s : Finset α) : encard (s : Set α) = s.card := by rw [Finite.encard_eq_coe_toFinset_card (Finset.finite_toSet s)]; simp theorem Infinite.encard_eq {s : Set α} (h : s.Infinite) : s.encard = ⊤ := by have := h.to_subtype rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply, PartENat.withTopEquiv_symm_top, PartENat.card_eq_top_of_infinite] @[simp] theorem encard_eq_zero : s.encard = 0 ↔ s = ∅ := by rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply, PartENat.withTopEquiv_symm_zero, PartENat.card_eq_zero_iff_empty, isEmpty_subtype, eq_empty_iff_forall_not_mem] @[simp] theorem encard_empty : (∅ : Set α).encard = 0 := by rw [encard_eq_zero]
Mathlib/Data/Set/Card.lean
98
99
theorem nonempty_of_encard_ne_zero (h : s.encard ≠ 0) : s.Nonempty := by
rwa [nonempty_iff_ne_empty, Ne, ← encard_eq_zero]
/- 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
Mathlib/Data/List/Cycle.lean
54
58
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
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Jujian Zhang -/ import Mathlib.Algebra.Algebra.Bilinear import Mathlib.RingTheory.Localization.Basic #align_import algebra.module.localized_module from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86" /-! # Localized Module Given a commutative semiring `R`, a multiplicative subset `S ⊆ R` and an `R`-module `M`, we can localize `M` by `S`. This gives us a `Localization S`-module. ## Main definitions * `LocalizedModule.r` : the equivalence relation defining this localization, namely `(m, s) ≈ (m', s')` if and only if there is some `u : S` such that `u • s' • m = u • s • m'`. * `LocalizedModule M S` : the localized module by `S`. * `LocalizedModule.mk` : the canonical map sending `(m, s) : M × S ↦ m/s : LocalizedModule M S` * `LocalizedModule.liftOn` : any well defined function `f : M × S → α` respecting `r` descents to a function `LocalizedModule M S → α` * `LocalizedModule.liftOn₂` : any well defined function `f : M × S → M × S → α` respecting `r` descents to a function `LocalizedModule M S → LocalizedModule M S` * `LocalizedModule.mk_add_mk` : in the localized module `mk m s + mk m' s' = mk (s' • m + s • m') (s * s')` * `LocalizedModule.mk_smul_mk` : in the localized module, for any `r : R`, `s t : S`, `m : M`, we have `mk r s • mk m t = mk (r • m) (s * t)` where `mk r s : Localization S` is localized ring by `S`. * `LocalizedModule.isModule` : `LocalizedModule M S` is a `Localization S`-module. ## Future work * Redefine `Localization` for monoids and rings to coincide with `LocalizedModule`. -/ namespace LocalizedModule universe u v variable {R : Type u} [CommSemiring R] (S : Submonoid R) variable (M : Type v) [AddCommMonoid M] [Module R M] variable (T : Type*) [CommSemiring T] [Algebra R T] [IsLocalization S T] /-- The equivalence relation on `M × S` where `(m1, s1) ≈ (m2, s2)` if and only if for some (u : S), u * (s2 • m1 - s1 • m2) = 0-/ /- Porting note: We use small letter `r` since `R` is used for a ring. -/ def r (a b : M × S) : Prop := ∃ u : S, u • b.2 • a.1 = u • a.2 • b.1 #align localized_module.r LocalizedModule.r theorem r.isEquiv : IsEquiv _ (r S M) := { refl := fun ⟨m, s⟩ => ⟨1, by rw [one_smul]⟩ trans := fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨m3, s3⟩ ⟨u1, hu1⟩ ⟨u2, hu2⟩ => by use u1 * u2 * s2 -- Put everything in the same shape, sorting the terms using `simp` have hu1' := congr_arg ((u2 * s3) • ·) hu1.symm have hu2' := congr_arg ((u1 * s1) • ·) hu2.symm simp only [← mul_smul, smul_assoc, mul_assoc, mul_comm, mul_left_comm] at hu1' hu2' ⊢ rw [hu2', hu1'] symm := fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨u, hu⟩ => ⟨u, hu.symm⟩ } #align localized_module.r.is_equiv LocalizedModule.r.isEquiv instance r.setoid : Setoid (M × S) where r := r S M iseqv := ⟨(r.isEquiv S M).refl, (r.isEquiv S M).symm _ _, (r.isEquiv S M).trans _ _ _⟩ #align localized_module.r.setoid LocalizedModule.r.setoid -- TODO: change `Localization` to use `r'` instead of `r` so that the two types are also defeq, -- `Localization S = LocalizedModule S R`. example {R} [CommSemiring R] (S : Submonoid R) : ⇑(Localization.r' S) = LocalizedModule.r S R := rfl /-- If `S` is a multiplicative subset of a ring `R` and `M` an `R`-module, then we can localize `M` by `S`. -/ -- Porting note(#5171): @[nolint has_nonempty_instance] def _root_.LocalizedModule : Type max u v := Quotient (r.setoid S M) #align localized_module LocalizedModule section variable {M S} /-- The canonical map sending `(m, s) ↦ m/s`-/ def mk (m : M) (s : S) : LocalizedModule S M := Quotient.mk' ⟨m, s⟩ #align localized_module.mk LocalizedModule.mk theorem mk_eq {m m' : M} {s s' : S} : mk m s = mk m' s' ↔ ∃ u : S, u • s' • m = u • s • m' := Quotient.eq' #align localized_module.mk_eq LocalizedModule.mk_eq @[elab_as_elim]
Mathlib/Algebra/Module/LocalizedModule.lean
99
102
theorem induction_on {β : LocalizedModule S M → Prop} (h : ∀ (m : M) (s : S), β (mk m s)) : ∀ x : LocalizedModule S M, β x := by
rintro ⟨⟨m, s⟩⟩ exact h m s
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky, Yury Kudryashov -/ import Mathlib.Data.Set.Image import Mathlib.Data.List.InsertNth import Mathlib.Init.Data.List.Lemmas #align_import data.list.lemmas from "leanprover-community/mathlib"@"2ec920d35348cb2d13ac0e1a2ad9df0fdf1a76b4" /-! # Some lemmas about lists involving sets Split out from `Data.List.Basic` to reduce its dependencies. -/ open List variable {α β γ : Type*} namespace List theorem injOn_insertNth_index_of_not_mem (l : List α) (x : α) (hx : x ∉ l) : Set.InjOn (fun k => insertNth k x l) { n | n ≤ l.length } := by induction' l with hd tl IH · intro n hn m hm _ simp only [Set.mem_singleton_iff, Set.setOf_eq_eq_singleton, length] at hn hm simp_all [hn, hm] · intro n hn m hm h simp only [length, Set.mem_setOf_eq] at hn hm simp only [mem_cons, not_or] at hx cases n <;> cases m · rfl · simp [hx.left] at h · simp [Ne.symm hx.left] at h · simp only [true_and_iff, eq_self_iff_true, insertNth_succ_cons] at h rw [Nat.succ_inj'] refine IH hx.right ?_ ?_ (by injection h) · simpa [Nat.succ_le_succ_iff] using hn · simpa [Nat.succ_le_succ_iff] using hm #align list.inj_on_insert_nth_index_of_not_mem List.injOn_insertNth_index_of_not_mem theorem foldr_range_subset_of_range_subset {f : β → α → α} {g : γ → α → α} (hfg : Set.range f ⊆ Set.range g) (a : α) : Set.range (foldr f a) ⊆ Set.range (foldr g a) := by rintro _ ⟨l, rfl⟩ induction' l with b l H · exact ⟨[], rfl⟩ · cases' hfg (Set.mem_range_self b) with c hgf cases' H with m hgf' rw [foldr_cons, ← hgf, ← hgf'] exact ⟨c :: m, rfl⟩ #align list.foldr_range_subset_of_range_subset List.foldr_range_subset_of_range_subset
Mathlib/Data/List/Lemmas.lean
55
66
theorem foldl_range_subset_of_range_subset {f : α → β → α} {g : α → γ → α} (hfg : (Set.range fun a c => f c a) ⊆ Set.range fun b c => g c b) (a : α) : Set.range (foldl f a) ⊆ Set.range (foldl g a) := by
change (Set.range fun l => _) ⊆ Set.range fun l => _ -- Porting note: This was simply `simp_rw [← foldr_reverse]` simp_rw [← foldr_reverse _ (fun z w => g w z), ← foldr_reverse _ (fun z w => f w z)] -- Porting note: This `change` was not necessary in mathlib3 change (Set.range (foldr (fun z w => f w z) a ∘ reverse)) ⊆ Set.range (foldr (fun z w => g w z) a ∘ reverse) simp_rw [Set.range_comp _ reverse, reverse_involutive.bijective.surjective.range_eq, Set.image_univ] exact foldr_range_subset_of_range_subset hfg a
/- Copyright (c) 2021 Yourong Zang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yourong Zang -/ import Mathlib.Analysis.Complex.Isometry import Mathlib.Analysis.NormedSpace.ConformalLinearMap import Mathlib.Analysis.NormedSpace.FiniteDimension #align_import analysis.complex.conformal from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" /-! # Conformal maps between complex vector spaces We prove the sufficient and necessary conditions for a real-linear map between complex vector spaces to be conformal. ## Main results * `isConformalMap_complex_linear`: a nonzero complex linear map into an arbitrary complex normed space is conformal. * `isConformalMap_complex_linear_conj`: the composition of a nonzero complex linear map with `conj` is complex linear. * `isConformalMap_iff_is_complex_or_conj_linear`: a real linear map between the complex plane is conformal iff it's complex linear or the composition of some complex linear map and `conj`. ## Warning Antiholomorphic functions such as the complex conjugate are considered as conformal functions in this file. -/ noncomputable section open Complex ContinuousLinearMap ComplexConjugate theorem isConformalMap_conj : IsConformalMap (conjLIE : ℂ →L[ℝ] ℂ) := conjLIE.toLinearIsometry.isConformalMap #align is_conformal_map_conj isConformalMap_conj section ConformalIntoComplexNormed variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace ℂ E] {z : ℂ} {g : ℂ →L[ℝ] E} {f : ℂ → E} theorem isConformalMap_complex_linear {map : ℂ →L[ℂ] E} (nonzero : map ≠ 0) : IsConformalMap (map.restrictScalars ℝ) := by have minor₁ : ‖map 1‖ ≠ 0 := by simpa only [ext_ring_iff, Ne, norm_eq_zero] using nonzero refine ⟨‖map 1‖, minor₁, ⟨‖map 1‖⁻¹ • ((map : ℂ →ₗ[ℂ] E) : ℂ →ₗ[ℝ] E), ?_⟩, ?_⟩ · intro x simp only [LinearMap.smul_apply] have : x = x • (1 : ℂ) := by rw [smul_eq_mul, mul_one] nth_rw 1 [this] rw [LinearMap.coe_restrictScalars] simp only [map.coe_coe, map.map_smul, norm_smul, norm_inv, norm_norm] field_simp only [one_mul] · ext1 -- porting note (#10745): was `simp`; explicitly supplied simp lemma simp [smul_inv_smul₀ minor₁] #align is_conformal_map_complex_linear isConformalMap_complex_linear theorem isConformalMap_complex_linear_conj {map : ℂ →L[ℂ] E} (nonzero : map ≠ 0) : IsConformalMap ((map.restrictScalars ℝ).comp (conjCLE : ℂ →L[ℝ] ℂ)) := (isConformalMap_complex_linear nonzero).comp isConformalMap_conj #align is_conformal_map_complex_linear_conj isConformalMap_complex_linear_conj end ConformalIntoComplexNormed section ConformalIntoComplexPlane open ContinuousLinearMap variable {f : ℂ → ℂ} {z : ℂ} {g : ℂ →L[ℝ] ℂ} theorem IsConformalMap.is_complex_or_conj_linear (h : IsConformalMap g) : (∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g) ∨ ∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g ∘L ↑conjCLE := by rcases h with ⟨c, -, li, rfl⟩ obtain ⟨li, rfl⟩ : ∃ li' : ℂ ≃ₗᵢ[ℝ] ℂ, li'.toLinearIsometry = li := ⟨li.toLinearIsometryEquiv rfl, by ext1; rfl⟩ rcases linear_isometry_complex li with ⟨a, rfl | rfl⟩ -- let rot := c • (a : ℂ) • ContinuousLinearMap.id ℂ ℂ, · refine Or.inl ⟨c • (a : ℂ) • ContinuousLinearMap.id ℂ ℂ, ?_⟩ ext1 simp · refine Or.inr ⟨c • (a : ℂ) • ContinuousLinearMap.id ℂ ℂ, ?_⟩ ext1 simp #align is_conformal_map.is_complex_or_conj_linear IsConformalMap.is_complex_or_conj_linear /-- A real continuous linear map on the complex plane is conformal if and only if the map or its conjugate is complex linear, and the map is nonvanishing. -/
Mathlib/Analysis/Complex/Conformal.lean
96
114
theorem isConformalMap_iff_is_complex_or_conj_linear : IsConformalMap g ↔ ((∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g) ∨ ∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g ∘L ↑conjCLE) ∧ g ≠ 0 := by
constructor · exact fun h => ⟨h.is_complex_or_conj_linear, h.ne_zero⟩ · rintro ⟨⟨map, rfl⟩ | ⟨map, hmap⟩, h₂⟩ · refine isConformalMap_complex_linear ?_ contrapose! h₂ with w simp only [w, restrictScalars_zero] · have minor₁ : g = map.restrictScalars ℝ ∘L ↑conjCLE := by ext1 simp only [hmap, coe_comp', ContinuousLinearEquiv.coe_coe, Function.comp_apply, conjCLE_apply, starRingEnd_self_apply] rw [minor₁] at h₂ ⊢ refine isConformalMap_complex_linear_conj ?_ contrapose! h₂ with w simp only [w, restrictScalars_zero, zero_comp]
/- Copyright (c) 2020 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Monic #align_import data.polynomial.lifts from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0" /-! # Polynomials that lift Given semirings `R` and `S` with a morphism `f : R →+* S`, we define a subsemiring `lifts` of `S[X]` by the image of `RingHom.of (map f)`. Then, we prove that a polynomial that lifts can always be lifted to a polynomial of the same degree and that a monic polynomial that lifts can be lifted to a monic polynomial (of the same degree). ## Main definition * `lifts (f : R →+* S)` : the subsemiring of polynomials that lift. ## Main results * `lifts_and_degree_eq` : A polynomial lifts if and only if it can be lifted to a polynomial of the same degree. * `lifts_and_degree_eq_and_monic` : A monic polynomial lifts if and only if it can be lifted to a monic polynomial of the same degree. * `lifts_iff_alg` : if `R` is commutative, a polynomial lifts if and only if it is in the image of `mapAlg`, where `mapAlg : R[X] →ₐ[R] S[X]` is the only `R`-algebra map that sends `X` to `X`. ## Implementation details In general `R` and `S` are semiring, so `lifts` is a semiring. In the case of rings, see `lifts_iff_lifts_ring`. Since we do not assume `R` to be commutative, we cannot say in general that the set of polynomials that lift is a subalgebra. (By `lift_iff` this is true if `R` is commutative.) -/ open Polynomial noncomputable section namespace Polynomial universe u v w section Semiring variable {R : Type u} [Semiring R] {S : Type v} [Semiring S] {f : R →+* S} /-- We define the subsemiring of polynomials that lifts as the image of `RingHom.of (map f)`. -/ def lifts (f : R →+* S) : Subsemiring S[X] := RingHom.rangeS (mapRingHom f) #align polynomial.lifts Polynomial.lifts theorem mem_lifts (p : S[X]) : p ∈ lifts f ↔ ∃ q : R[X], map f q = p := by simp only [coe_mapRingHom, lifts, RingHom.mem_rangeS] #align polynomial.mem_lifts Polynomial.mem_lifts theorem lifts_iff_set_range (p : S[X]) : p ∈ lifts f ↔ p ∈ Set.range (map f) := by simp only [coe_mapRingHom, lifts, Set.mem_range, RingHom.mem_rangeS] #align polynomial.lifts_iff_set_range Polynomial.lifts_iff_set_range theorem lifts_iff_ringHom_rangeS (p : S[X]) : p ∈ lifts f ↔ p ∈ (mapRingHom f).rangeS := by simp only [coe_mapRingHom, lifts, Set.mem_range, RingHom.mem_rangeS] #align polynomial.lifts_iff_ring_hom_srange Polynomial.lifts_iff_ringHom_rangeS theorem lifts_iff_coeff_lifts (p : S[X]) : p ∈ lifts f ↔ ∀ n : ℕ, p.coeff n ∈ Set.range f := by rw [lifts_iff_ringHom_rangeS, mem_map_rangeS f] rfl #align polynomial.lifts_iff_coeff_lifts Polynomial.lifts_iff_coeff_lifts /-- If `(r : R)`, then `C (f r)` lifts. -/ theorem C_mem_lifts (f : R →+* S) (r : R) : C (f r) ∈ lifts f := ⟨C r, by simp only [coe_mapRingHom, map_C, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true, and_self_iff]⟩ set_option linter.uppercaseLean3 false in #align polynomial.C_mem_lifts Polynomial.C_mem_lifts /-- If `(s : S)` is in the image of `f`, then `C s` lifts. -/ theorem C'_mem_lifts {f : R →+* S} {s : S} (h : s ∈ Set.range f) : C s ∈ lifts f := by obtain ⟨r, rfl⟩ := Set.mem_range.1 h use C r simp only [coe_mapRingHom, map_C, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true, and_self_iff] set_option linter.uppercaseLean3 false in #align polynomial.C'_mem_lifts Polynomial.C'_mem_lifts /-- The polynomial `X` lifts. -/ theorem X_mem_lifts (f : R →+* S) : (X : S[X]) ∈ lifts f := ⟨X, by simp only [coe_mapRingHom, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true, map_X, and_self_iff]⟩ set_option linter.uppercaseLean3 false in #align polynomial.X_mem_lifts Polynomial.X_mem_lifts /-- The polynomial `X ^ n` lifts. -/ theorem X_pow_mem_lifts (f : R →+* S) (n : ℕ) : (X ^ n : S[X]) ∈ lifts f := ⟨X ^ n, by simp only [coe_mapRingHom, map_pow, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true, map_X, and_self_iff]⟩ set_option linter.uppercaseLean3 false in #align polynomial.X_pow_mem_lifts Polynomial.X_pow_mem_lifts /-- If `p` lifts and `(r : R)` then `r * p` lifts. -/ theorem base_mul_mem_lifts {p : S[X]} (r : R) (hp : p ∈ lifts f) : C (f r) * p ∈ lifts f := by simp only [lifts, RingHom.mem_rangeS] at hp ⊢ obtain ⟨p₁, rfl⟩ := hp use C r * p₁ simp only [coe_mapRingHom, map_C, map_mul] #align polynomial.base_mul_mem_lifts Polynomial.base_mul_mem_lifts /-- If `(s : S)` is in the image of `f`, then `monomial n s` lifts. -/
Mathlib/Algebra/Polynomial/Lifts.lean
120
124
theorem monomial_mem_lifts {s : S} (n : ℕ) (h : s ∈ Set.range f) : monomial n s ∈ lifts f := by
obtain ⟨r, rfl⟩ := Set.mem_range.1 h use monomial n r simp only [coe_mapRingHom, Set.mem_univ, map_monomial, Subsemiring.coe_top, eq_self_iff_true, and_self_iff]
/- Copyright (c) 2021 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Riccardo Brasca -/ import Mathlib.Analysis.NormedSpace.Basic import Mathlib.Analysis.Normed.Group.Hom import Mathlib.Data.Real.Sqrt import Mathlib.RingTheory.Ideal.QuotientOperations import Mathlib.Topology.MetricSpace.HausdorffDistance #align_import analysis.normed.group.quotient from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # Quotients of seminormed groups For any `SeminormedAddCommGroup M` and any `S : AddSubgroup M`, we provide a `SeminormedAddCommGroup`, the group quotient `M ⧸ S`. If `S` is closed, we provide `NormedAddCommGroup (M ⧸ S)` (regardless of whether `M` itself is separated). The two main properties of these structures are the underlying topology is the quotient topology and the projection is a normed group homomorphism which is norm non-increasing (better, it has operator norm exactly one unless `S` is dense in `M`). The corresponding universal property is that every normed group hom defined on `M` which vanishes on `S` descends to a normed group hom defined on `M ⧸ S`. This file also introduces a predicate `IsQuotient` characterizing normed group homs that are isomorphic to the canonical projection onto a normed group quotient. In addition, this file also provides normed structures for quotients of modules by submodules, and of (commutative) rings by ideals. The `SeminormedAddCommGroup` and `NormedAddCommGroup` instances described above are transferred directly, but we also define instances of `NormedSpace`, `SeminormedCommRing`, `NormedCommRing` and `NormedAlgebra` under appropriate type class assumptions on the original space. Moreover, while `QuotientAddGroup.completeSpace` works out-of-the-box for quotients of `NormedAddCommGroup`s by `AddSubgroup`s, we need to transfer this instance in `Submodule.Quotient.completeSpace` so that it applies to these other quotients. ## Main definitions We use `M` and `N` to denote seminormed groups and `S : AddSubgroup M`. All the following definitions are in the `AddSubgroup` namespace. Hence we can access `AddSubgroup.normedMk S` as `S.normedMk`. * `seminormedAddCommGroupQuotient` : The seminormed group structure on the quotient by an additive subgroup. This is an instance so there is no need to explicitly use it. * `normedAddCommGroupQuotient` : The normed group structure on the quotient by a closed additive subgroup. This is an instance so there is no need to explicitly use it. * `normedMk S` : the normed group hom from `M` to `M ⧸ S`. * `lift S f hf`: implements the universal property of `M ⧸ S`. Here `(f : NormedAddGroupHom M N)`, `(hf : ∀ s ∈ S, f s = 0)` and `lift S f hf : NormedAddGroupHom (M ⧸ S) N`. * `IsQuotient`: given `f : NormedAddGroupHom M N`, `IsQuotient f` means `N` is isomorphic to a quotient of `M` by a subgroup, with projection `f`. Technically it asserts `f` is surjective and the norm of `f x` is the infimum of the norms of `x + m` for `m` in `f.ker`. ## Main results * `norm_normedMk` : the operator norm of the projection is `1` if the subspace is not dense. * `IsQuotient.norm_lift`: Provided `f : normed_hom M N` satisfies `IsQuotient f`, for every `n : N` and positive `ε`, there exists `m` such that `f m = n ∧ ‖m‖ < ‖n‖ + ε`. ## Implementation details For any `SeminormedAddCommGroup M` and any `S : AddSubgroup M` we define a norm on `M ⧸ S` by `‖x‖ = sInf (norm '' {m | mk' S m = x})`. This formula is really an implementation detail, it shouldn't be needed outside of this file setting up the theory. Since `M ⧸ S` is automatically a topological space (as any quotient of a topological space), one needs to be careful while defining the `SeminormedAddCommGroup` instance to avoid having two different topologies on this quotient. This is not purely a technological issue. Mathematically there is something to prove. The main point is proved in the auxiliary lemma `quotient_nhd_basis` that has no use beyond this verification and states that zero in the quotient admits as basis of neighborhoods in the quotient topology the sets `{x | ‖x‖ < ε}` for positive `ε`. Once this mathematical point is settled, we have two topologies that are propositionally equal. This is not good enough for the type class system. As usual we ensure *definitional* equality using forgetful inheritance, see Note [forgetful inheritance]. A (semi)-normed group structure includes a uniform space structure which includes a topological space structure, together with propositional fields asserting compatibility conditions. The usual way to define a `SeminormedAddCommGroup` is to let Lean build a uniform space structure using the provided norm, and then trivially build a proof that the norm and uniform structure are compatible. Here the uniform structure is provided using `TopologicalAddGroup.toUniformSpace` which uses the topological structure and the group structure to build the uniform structure. This uniform structure induces the correct topological structure by construction, but the fact that it is compatible with the norm is not obvious; this is where the mathematical content explained in the previous paragraph kicks in. -/ noncomputable section open QuotientAddGroup Metric Set Topology NNReal variable {M N : Type*} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] /-- The definition of the norm on the quotient by an additive subgroup. -/ noncomputable instance normOnQuotient (S : AddSubgroup M) : Norm (M ⧸ S) where norm x := sInf (norm '' { m | mk' S m = x }) #align norm_on_quotient normOnQuotient theorem AddSubgroup.quotient_norm_eq {S : AddSubgroup M} (x : M ⧸ S) : ‖x‖ = sInf (norm '' { m : M | (m : M ⧸ S) = x }) := rfl #align add_subgroup.quotient_norm_eq AddSubgroup.quotient_norm_eq
Mathlib/Analysis/Normed/Group/Quotient.lean
113
115
theorem QuotientAddGroup.norm_eq_infDist {S : AddSubgroup M} (x : M ⧸ S) : ‖x‖ = infDist 0 { m : M | (m : M ⧸ S) = x } := by
simp only [AddSubgroup.quotient_norm_eq, infDist_eq_iInf, sInf_image', dist_zero_left]
/- 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.MvPolynomial.PDeriv import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Sum import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.RingTheory.Polynomial.Pochhammer #align_import ring_theory.polynomial.bernstein from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821" /-! # Bernstein polynomials The definition of the Bernstein polynomials ``` bernsteinPolynomial (R : Type*) [CommRing R] (n ν : ℕ) : R[X] := (choose n ν) * X^ν * (1 - X)^(n - ν) ``` and the fact that for `ν : fin (n+1)` these are linearly independent over `ℚ`. We prove the basic identities * `(Finset.range (n + 1)).sum (fun ν ↦ bernsteinPolynomial R n ν) = 1` * `(Finset.range (n + 1)).sum (fun ν ↦ ν • bernsteinPolynomial R n ν) = n • X` * `(Finset.range (n + 1)).sum (fun ν ↦ (ν * (ν-1)) • bernsteinPolynomial R n ν) = (n * (n-1)) • X^2` ## Notes See also `Mathlib.Analysis.SpecialFunctions.Bernstein`, which defines the Bernstein approximations of a continuous function `f : C([0,1], ℝ)`, and shows that these converge uniformly to `f`. -/ noncomputable section open Nat (choose) open Polynomial (X) open scoped Polynomial variable (R : Type*) [CommRing R] /-- `bernsteinPolynomial R n ν` is `(choose n ν) * X^ν * (1 - X)^(n - ν)`. Although the coefficients are integers, it is convenient to work over an arbitrary commutative ring. -/ def bernsteinPolynomial (n ν : ℕ) : R[X] := (choose n ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) #align bernstein_polynomial bernsteinPolynomial example : bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3 := by norm_num [bernsteinPolynomial, choose] ring namespace bernsteinPolynomial theorem eq_zero_of_lt {n ν : ℕ} (h : n < ν) : bernsteinPolynomial R n ν = 0 := by simp [bernsteinPolynomial, Nat.choose_eq_zero_of_lt h] #align bernstein_polynomial.eq_zero_of_lt bernsteinPolynomial.eq_zero_of_lt section variable {R} {S : Type*} [CommRing S] @[simp] theorem map (f : R →+* S) (n ν : ℕ) : (bernsteinPolynomial R n ν).map f = bernsteinPolynomial S n ν := by simp [bernsteinPolynomial] #align bernstein_polynomial.map bernsteinPolynomial.map end theorem flip (n ν : ℕ) (h : ν ≤ n) : (bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν) := by simp [bernsteinPolynomial, h, tsub_tsub_assoc, mul_right_comm] #align bernstein_polynomial.flip bernsteinPolynomial.flip
Mathlib/RingTheory/Polynomial/Bernstein.lean
81
83
theorem flip' (n ν : ℕ) (h : ν ≤ n) : bernsteinPolynomial R n ν = (bernsteinPolynomial R n (n - ν)).comp (1 - X) := by
simp [← flip _ _ _ h, Polynomial.comp_assoc]
/- Copyright (c) 2023 Mohanad Ahmed. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mohanad Ahmed -/ import Mathlib.Algebra.Polynomial.Basic import Mathlib.FieldTheory.IsAlgClosed.Basic #align_import linear_algebra.matrix.charpoly.eigs from "leanprover-community/mathlib"@"48dc6abe71248bd6f4bffc9703dc87bdd4e37d0b" /-! # Eigenvalues are characteristic polynomial roots. In fields we show that: * `Matrix.det_eq_prod_roots_charpoly_of_splits`: the determinant (in the field of the matrix) is the product of the roots of the characteristic polynomial if the polynomial splits in the field of the matrix. * `Matrix.trace_eq_sum_roots_charpoly_of_splits`: the trace is the sum of the roots of the characteristic polynomial if the polynomial splits in the field of the matrix. In an algebraically closed field we show that: * `Matrix.det_eq_prod_roots_charpoly`: the determinant is the product of the roots of the characteristic polynomial. * `Matrix.trace_eq_sum_roots_charpoly`: the trace is the sum of the roots of the characteristic polynomial. Note that over other fields such as `ℝ`, these results can be used by using `A.map (algebraMap ℝ ℂ)` as the matrix, and then applying `RingHom.map_det`. The two lemmas `Matrix.det_eq_prod_roots_charpoly` and `Matrix.trace_eq_sum_roots_charpoly` are more commonly stated as trace is the sum of eigenvalues and determinant is the product of eigenvalues. Mathlib has already defined eigenvalues in `LinearAlgebra.Eigenspace` as the roots of the minimal polynomial of a linear endomorphism. These do not have correct multiplicity and cannot be used in the theorems above. Hence we express these theorems in terms of the roots of the characteristic polynomial directly. ## TODO The proofs of `det_eq_prod_roots_charpoly_of_splits` and `trace_eq_sum_roots_charpoly_of_splits` closely resemble `norm_gen_eq_prod_roots` and `trace_gen_eq_sum_roots` respectively, but the dependencies are not general enough to unify them. We should refactor `Polynomial.prod_roots_eq_coeff_zero_of_monic_of_split` and `Polynomial.sum_roots_eq_nextCoeff_of_monic_of_split` to assume splitting over an arbitrary map. -/ variable {n : Type*} [Fintype n] [DecidableEq n] variable {R : Type*} [Field R] variable {A : Matrix n n R} open Matrix Polynomial open scoped Matrix namespace Matrix
Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean
60
64
theorem det_eq_prod_roots_charpoly_of_splits (hAps : A.charpoly.Splits (RingHom.id R)) : A.det = (Matrix.charpoly A).roots.prod := by
rw [det_eq_sign_charpoly_coeff, ← charpoly_natDegree_eq_dim A, Polynomial.prod_roots_eq_coeff_zero_of_monic_of_split A.charpoly_monic hAps, ← mul_assoc, ← pow_two, pow_right_comm, neg_one_sq, one_pow, one_mul]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Fintype.Option import Mathlib.Data.Fintype.Sigma import Mathlib.Data.Fintype.Sum import Mathlib.Data.Fintype.Prod import Mathlib.Data.Fintype.Vector import Mathlib.Algebra.BigOperators.Option #align_import data.fintype.big_operators from "leanprover-community/mathlib"@"2445c98ae4b87eabebdde552593519b9b6dc350c" /-! Results about "big operations" over a `Fintype`, and consequent results about cardinalities of certain types. ## Implementation note This content had previously been in `Data.Fintype.Basic`, but was moved here to avoid requiring `Algebra.BigOperators` (and hence many other imports) as a dependency of `Fintype`. However many of the results here really belong in `Algebra.BigOperators.Group.Finset` and should be moved at some point. -/ assert_not_exists MulAction universe u v variable {α : Type*} {β : Type*} {γ : Type*} namespace Fintype @[to_additive] theorem prod_bool [CommMonoid α] (f : Bool → α) : ∏ b, f b = f true * f false := by simp #align fintype.prod_bool Fintype.prod_bool #align fintype.sum_bool Fintype.sum_bool theorem card_eq_sum_ones {α} [Fintype α] : Fintype.card α = ∑ _a : α, 1 := Finset.card_eq_sum_ones _ #align fintype.card_eq_sum_ones Fintype.card_eq_sum_ones section open Finset variable {ι : Type*} [DecidableEq ι] [Fintype ι] @[to_additive] theorem prod_extend_by_one [CommMonoid α] (s : Finset ι) (f : ι → α) : ∏ i, (if i ∈ s then f i else 1) = ∏ i ∈ s, f i := by rw [← prod_filter, filter_mem_eq_inter, univ_inter] #align fintype.prod_extend_by_one Fintype.prod_extend_by_one #align fintype.sum_extend_by_zero Fintype.sum_extend_by_zero end section variable {M : Type*} [Fintype α] [CommMonoid M] @[to_additive] theorem prod_eq_one (f : α → M) (h : ∀ a, f a = 1) : ∏ a, f a = 1 := Finset.prod_eq_one fun a _ha => h a #align fintype.prod_eq_one Fintype.prod_eq_one #align fintype.sum_eq_zero Fintype.sum_eq_zero @[to_additive] theorem prod_congr (f g : α → M) (h : ∀ a, f a = g a) : ∏ a, f a = ∏ a, g a := Finset.prod_congr rfl fun a _ha => h a #align fintype.prod_congr Fintype.prod_congr #align fintype.sum_congr Fintype.sum_congr @[to_additive] theorem prod_eq_single {f : α → M} (a : α) (h : ∀ x ≠ a, f x = 1) : ∏ x, f x = f a := Finset.prod_eq_single a (fun x _ hx => h x hx) fun ha => (ha (Finset.mem_univ a)).elim #align fintype.prod_eq_single Fintype.prod_eq_single #align fintype.sum_eq_single Fintype.sum_eq_single @[to_additive]
Mathlib/Data/Fintype/BigOperators.lean
83
86
theorem prod_eq_mul {f : α → M} (a b : α) (h₁ : a ≠ b) (h₂ : ∀ x, x ≠ a ∧ x ≠ b → f x = 1) : ∏ x, f x = f a * f b := by
apply Finset.prod_eq_mul a b h₁ fun x _ hx => h₂ x hx <;> exact fun hc => (hc (Finset.mem_univ _)).elim
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Logic.Function.Iterate import Mathlib.Order.Monotone.Basic #align_import order.iterate from "leanprover-community/mathlib"@"2258b40dacd2942571c8ce136215350c702dc78f" /-! # Inequalities on iterates In this file we prove some inequalities comparing `f^[n] x` and `g^[n] x` where `f` and `g` are two self-maps that commute with each other. Current selection of inequalities is motivated by formalization of the rotation number of a circle homeomorphism. -/ open Function open Function (Commute) namespace Monotone variable {α : Type*} [Preorder α] {f : α → α} {x y : ℕ → α} /-! ### Comparison of two sequences If $f$ is a monotone function, then $∀ k, x_{k+1} ≤ f(x_k)$ implies that $x_k$ grows slower than $f^k(x_0)$, and similarly for the reversed inequalities. If $x_k$ and $y_k$ are two sequences such that $x_{k+1} ≤ f(x_k)$ and $y_{k+1} ≥ f(y_k)$ for all $k < n$, then $x_0 ≤ y_0$ implies $x_n ≤ y_n$, see `Monotone.seq_le_seq`. If some of the inequalities in this lemma are strict, then we have $x_n < y_n$. The rest of the lemmas in this section formalize this fact for different inequalities made strict. -/ theorem seq_le_seq (hf : Monotone f) (n : ℕ) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n ≤ y n := by induction' n with n ihn · exact h₀ · refine (hx _ n.lt_succ_self).trans ((hf <| ihn ?_ ?_).trans (hy _ n.lt_succ_self)) · exact fun k hk => hx _ (hk.trans n.lt_succ_self) · exact fun k hk => hy _ (hk.trans n.lt_succ_self) #align monotone.seq_le_seq Monotone.seq_le_seq
Mathlib/Order/Iterate.lean
51
60
theorem seq_pos_lt_seq_of_lt_of_le (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) < f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n < y n := by
induction' n with n ihn · exact hn.false.elim suffices x n ≤ y n from (hx n n.lt_succ_self).trans_le ((hf this).trans <| hy n n.lt_succ_self) cases n with | zero => exact h₀ | succ n => refine (ihn n.zero_lt_succ (fun k hk => hx _ ?_) fun k hk => hy _ ?_).le <;> exact hk.trans n.succ.lt_succ_self
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.Order.Interval.Set.Group import Mathlib.Analysis.Convex.Segment import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional import Mathlib.Tactic.FieldSimp #align_import analysis.convex.between from "leanprover-community/mathlib"@"571e13cacbed7bf042fd3058ce27157101433842" /-! # Betweenness in affine spaces This file defines notions of a point in an affine space being between two given points. ## Main definitions * `affineSegment R x y`: The segment of points weakly between `x` and `y`. * `Wbtw R x y z`: The point `y` is weakly between `x` and `z`. * `Sbtw R x y z`: The point `y` is strictly between `x` and `z`. -/ variable (R : Type*) {V V' P P' : Type*} open AffineEquiv AffineMap section OrderedRing variable [OrderedRing R] [AddCommGroup V] [Module R V] [AddTorsor V P] variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P'] /-- The segment of points weakly between `x` and `y`. When convexity is refactored to support abstract affine combination spaces, this will no longer need to be a separate definition from `segment`. However, lemmas involving `+ᵥ` or `-ᵥ` will still be relevant after such a refactoring, as distinct from versions involving `+` or `-` in a module. -/ def affineSegment (x y : P) := lineMap x y '' Set.Icc (0 : R) 1 #align affine_segment affineSegment theorem affineSegment_eq_segment (x y : V) : affineSegment R x y = segment R x y := by rw [segment_eq_image_lineMap, affineSegment] #align affine_segment_eq_segment affineSegment_eq_segment theorem affineSegment_comm (x y : P) : affineSegment R x y = affineSegment R y x := by refine Set.ext fun z => ?_ constructor <;> · rintro ⟨t, ht, hxy⟩ refine ⟨1 - t, ?_, ?_⟩ · rwa [Set.sub_mem_Icc_iff_right, sub_self, sub_zero] · rwa [lineMap_apply_one_sub] #align affine_segment_comm affineSegment_comm theorem left_mem_affineSegment (x y : P) : x ∈ affineSegment R x y := ⟨0, Set.left_mem_Icc.2 zero_le_one, lineMap_apply_zero _ _⟩ #align left_mem_affine_segment left_mem_affineSegment theorem right_mem_affineSegment (x y : P) : y ∈ affineSegment R x y := ⟨1, Set.right_mem_Icc.2 zero_le_one, lineMap_apply_one _ _⟩ #align right_mem_affine_segment right_mem_affineSegment @[simp] theorem affineSegment_same (x : P) : affineSegment R x x = {x} := by -- Porting note: added as this doesn't do anything in `simp_rw` any more rw [affineSegment] -- Note: when adding "simp made no progress" in lean4#2336, -- had to change `lineMap_same` to `lineMap_same _`. Not sure why? -- Porting note: added `_ _` and `Function.const` simp_rw [lineMap_same _, AffineMap.coe_const _ _, Function.const, (Set.nonempty_Icc.mpr zero_le_one).image_const] #align affine_segment_same affineSegment_same variable {R} @[simp] theorem affineSegment_image (f : P →ᵃ[R] P') (x y : P) : f '' affineSegment R x y = affineSegment R (f x) (f y) := by rw [affineSegment, affineSegment, Set.image_image, ← comp_lineMap] rfl #align affine_segment_image affineSegment_image variable (R) @[simp] theorem affineSegment_const_vadd_image (x y : P) (v : V) : (v +ᵥ ·) '' affineSegment R x y = affineSegment R (v +ᵥ x) (v +ᵥ y) := affineSegment_image (AffineEquiv.constVAdd R P v : P →ᵃ[R] P) x y #align affine_segment_const_vadd_image affineSegment_const_vadd_image @[simp] theorem affineSegment_vadd_const_image (x y : V) (p : P) : (· +ᵥ p) '' affineSegment R x y = affineSegment R (x +ᵥ p) (y +ᵥ p) := affineSegment_image (AffineEquiv.vaddConst R p : V →ᵃ[R] P) x y #align affine_segment_vadd_const_image affineSegment_vadd_const_image @[simp] theorem affineSegment_const_vsub_image (x y p : P) : (p -ᵥ ·) '' affineSegment R x y = affineSegment R (p -ᵥ x) (p -ᵥ y) := affineSegment_image (AffineEquiv.constVSub R p : P →ᵃ[R] V) x y #align affine_segment_const_vsub_image affineSegment_const_vsub_image @[simp] theorem affineSegment_vsub_const_image (x y p : P) : (· -ᵥ p) '' affineSegment R x y = affineSegment R (x -ᵥ p) (y -ᵥ p) := affineSegment_image ((AffineEquiv.vaddConst R p).symm : P →ᵃ[R] V) x y #align affine_segment_vsub_const_image affineSegment_vsub_const_image variable {R} @[simp]
Mathlib/Analysis/Convex/Between.lean
115
117
theorem mem_const_vadd_affineSegment {x y z : P} (v : V) : v +ᵥ z ∈ affineSegment R (v +ᵥ x) (v +ᵥ y) ↔ z ∈ affineSegment R x y := by
rw [← affineSegment_const_vadd_image, (AddAction.injective v).mem_set_image]
/- 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.Computability.PartrecCode import Mathlib.Data.Set.Subsingleton #align_import computability.halting from "leanprover-community/mathlib"@"a50170a88a47570ed186b809ca754110590f9476" /-! # Computability theory and the halting problem A universal partial recursive function, Rice's theorem, and the halting problem. ## References * [Mario Carneiro, *Formalizing computability theory via partial recursive functions*][carneiro2019] -/ open Encodable Denumerable namespace Nat.Partrec open Computable Part theorem merge' {f g} (hf : Nat.Partrec f) (hg : Nat.Partrec g) : ∃ h, Nat.Partrec h ∧ ∀ a, (∀ x ∈ h a, x ∈ f a ∨ x ∈ g a) ∧ ((h a).Dom ↔ (f a).Dom ∨ (g a).Dom) := by obtain ⟨cf, rfl⟩ := Code.exists_code.1 hf obtain ⟨cg, rfl⟩ := Code.exists_code.1 hg have : Nat.Partrec fun n => Nat.rfindOpt fun k => cf.evaln k n <|> cg.evaln k n := Partrec.nat_iff.1 (Partrec.rfindOpt <| Primrec.option_orElse.to_comp.comp (Code.evaln_prim.to_comp.comp <| (snd.pair (const cf)).pair fst) (Code.evaln_prim.to_comp.comp <| (snd.pair (const cg)).pair fst)) refine ⟨_, this, fun n => ?_⟩ have : ∀ x ∈ rfindOpt fun k ↦ HOrElse.hOrElse (Code.evaln k cf n) fun _x ↦ Code.evaln k cg n, x ∈ Code.eval cf n ∨ x ∈ Code.eval cg n := by intro x h obtain ⟨k, e⟩ := Nat.rfindOpt_spec h revert e simp only [Option.mem_def] cases' e' : cf.evaln k n with y <;> simp <;> intro e · exact Or.inr (Code.evaln_sound e) · subst y exact Or.inl (Code.evaln_sound e') refine ⟨this, ⟨fun h => (this _ ⟨h, rfl⟩).imp Exists.fst Exists.fst, ?_⟩⟩ intro h rw [Nat.rfindOpt_dom] simp only [dom_iff_mem, Code.evaln_complete, Option.mem_def] at h obtain ⟨x, k, e⟩ | ⟨x, k, e⟩ := h · refine ⟨k, x, ?_⟩ simp only [e, Option.some_orElse, Option.mem_def] · refine ⟨k, ?_⟩ cases' cf.evaln k n with y · exact ⟨x, by simp only [e, Option.mem_def, Option.none_orElse]⟩ · exact ⟨y, by simp only [Option.some_orElse, Option.mem_def]⟩ #align nat.partrec.merge' Nat.Partrec.merge' end Nat.Partrec namespace Partrec variable {α : Type*} {β : Type*} {γ : Type*} {σ : Type*} variable [Primcodable α] [Primcodable β] [Primcodable γ] [Primcodable σ] open Computable Part open Nat.Partrec (Code) open Nat.Partrec.Code
Mathlib/Computability/Halting.lean
77
103
theorem merge' {f g : α →. σ} (hf : Partrec f) (hg : Partrec g) : ∃ k : α →. σ, Partrec k ∧ ∀ a, (∀ x ∈ k a, x ∈ f a ∨ x ∈ g a) ∧ ((k a).Dom ↔ (f a).Dom ∨ (g a).Dom) := by
let ⟨k, hk, H⟩ := Nat.Partrec.merge' (bind_decode₂_iff.1 hf) (bind_decode₂_iff.1 hg) let k' (a : α) := (k (encode a)).bind fun n => (decode (α := σ) n : Part σ) refine ⟨k', ((nat_iff.2 hk).comp Computable.encode).bind (Computable.decode.ofOption.comp snd).to₂, fun a => ?_⟩ have : ∀ x ∈ k' a, x ∈ f a ∨ x ∈ g a := by intro x h' simp only [k', exists_prop, mem_coe, mem_bind_iff, Option.mem_def] at h' obtain ⟨n, hn, hx⟩ := h' have := (H _).1 _ hn simp [mem_decode₂, encode_injective.eq_iff] at this obtain ⟨a', ha, rfl⟩ | ⟨a', ha, rfl⟩ := this <;> simp only [encodek, Option.some_inj] at hx <;> rw [hx] at ha · exact Or.inl ha · exact Or.inr ha refine ⟨this, ⟨fun h => (this _ ⟨h, rfl⟩).imp Exists.fst Exists.fst, ?_⟩⟩ intro h rw [bind_dom] have hk : (k (encode a)).Dom := (H _).2.2 (by simpa only [encodek₂, bind_some, coe_some] using h) exists hk simp only [exists_prop, mem_map_iff, mem_coe, mem_bind_iff, Option.mem_def] at H obtain ⟨a', _, y, _, e⟩ | ⟨a', _, y, _, e⟩ := (H _).1 _ ⟨hk, rfl⟩ <;> simp only [e.symm, encodek, coe_some, some_dom]
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.Polynomial.RingDivision #align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # "Mirror" of a univariate polynomial In this file we define `Polynomial.mirror`, a variant of `Polynomial.reverse`. The difference between `reverse` and `mirror` is that `reverse` will decrease the degree if the polynomial is divisible by `X`. ## Main definitions - `Polynomial.mirror` ## Main results - `Polynomial.mirror_mul_of_domain`: `mirror` preserves multiplication. - `Polynomial.irreducible_of_mirror`: an irreducibility criterion involving `mirror` -/ namespace Polynomial open Polynomial section Semiring variable {R : Type*} [Semiring R] (p q : R[X]) /-- mirror of a polynomial: reverses the coefficients while preserving `Polynomial.natDegree` -/ noncomputable def mirror := p.reverse * X ^ p.natTrailingDegree #align polynomial.mirror Polynomial.mirror @[simp] theorem mirror_zero : (0 : R[X]).mirror = 0 := by simp [mirror] #align polynomial.mirror_zero Polynomial.mirror_zero
Mathlib/Algebra/Polynomial/Mirror.lean
47
53
theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by
classical by_cases ha : a = 0 · rw [ha, monomial_zero_right, mirror_zero] · rw [mirror, reverse, natDegree_monomial n a, if_neg ha, natTrailingDegree_monomial ha, ← C_mul_X_pow_eq_monomial, reflect_C_mul_X_pow, revAt_le (le_refl n), tsub_self, pow_zero, mul_one]
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Scott Morrison -/ import Mathlib.CategoryTheory.Comma.Basic import Mathlib.CategoryTheory.PUnit import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.CategoryTheory.EssentiallySmall import Mathlib.Logic.Small.Set #align_import category_theory.structured_arrow from "leanprover-community/mathlib"@"8a318021995877a44630c898d0b2bc376fceef3b" /-! # The category of "structured arrows" For `T : C ⥤ D`, a `T`-structured arrow with source `S : D` is just a morphism `S ⟶ T.obj Y`, for some `Y : C`. These form a category with morphisms `g : Y ⟶ Y'` making the obvious diagram commute. We prove that `𝟙 (T.obj Y)` is the initial object in `T`-structured objects with source `T.obj Y`. -/ namespace CategoryTheory -- morphism levels before object levels. See note [CategoryTheory universes]. universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄ variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] /-- The category of `T`-structured arrows with domain `S : D` (here `T : C ⥤ D`), has as its objects `D`-morphisms of the form `S ⟶ T Y`, for some `Y : C`, and morphisms `C`-morphisms `Y ⟶ Y'` making the obvious triangle commute. -/ -- We explicitly come from `PUnit.{1}` here to obtain the correct universe for morphisms of -- structured arrows. -- Porting note(#5171): linter not ported yet -- @[nolint has_nonempty_instance] def StructuredArrow (S : D) (T : C ⥤ D) := Comma (Functor.fromPUnit.{0} S) T #align category_theory.structured_arrow CategoryTheory.StructuredArrow -- Porting note: not found by inferInstance instance (S : D) (T : C ⥤ D) : Category (StructuredArrow S T) := commaCategory namespace StructuredArrow /-- The obvious projection functor from structured arrows. -/ @[simps!] def proj (S : D) (T : C ⥤ D) : StructuredArrow S T ⥤ C := Comma.snd _ _ #align category_theory.structured_arrow.proj CategoryTheory.StructuredArrow.proj variable {S S' S'' : D} {Y Y' Y'' : C} {T T' : C ⥤ D} -- Porting note: this lemma was added because `Comma.hom_ext` -- was not triggered automatically -- See https://github.com/leanprover-community/mathlib4/issues/5229 @[ext] lemma hom_ext {X Y : StructuredArrow S T} (f g : X ⟶ Y) (h : f.right = g.right) : f = g := CommaMorphism.ext _ _ (Subsingleton.elim _ _) h @[simp] theorem hom_eq_iff {X Y : StructuredArrow S T} (f g : X ⟶ Y) : f = g ↔ f.right = g.right := ⟨fun h ↦ by rw [h], hom_ext _ _⟩ /-- Construct a structured arrow from a morphism. -/ def mk (f : S ⟶ T.obj Y) : StructuredArrow S T := ⟨⟨⟨⟩⟩, Y, f⟩ #align category_theory.structured_arrow.mk CategoryTheory.StructuredArrow.mk @[simp] theorem mk_left (f : S ⟶ T.obj Y) : (mk f).left = ⟨⟨⟩⟩ := rfl #align category_theory.structured_arrow.mk_left CategoryTheory.StructuredArrow.mk_left @[simp] theorem mk_right (f : S ⟶ T.obj Y) : (mk f).right = Y := rfl #align category_theory.structured_arrow.mk_right CategoryTheory.StructuredArrow.mk_right @[simp] theorem mk_hom_eq_self (f : S ⟶ T.obj Y) : (mk f).hom = f := rfl #align category_theory.structured_arrow.mk_hom_eq_self CategoryTheory.StructuredArrow.mk_hom_eq_self @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Comma/StructuredArrow.lean
90
91
theorem w {A B : StructuredArrow S T} (f : A ⟶ B) : A.hom ≫ T.map f.right = B.hom := by
have := f.w; aesop_cat
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.JapaneseBracket import Mathlib.Analysis.SpecialFunctions.Integrals import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Integral.IntegralEqImproper import Mathlib.MeasureTheory.Measure.Lebesgue.Integral #align_import analysis.special_functions.improper_integrals from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Evaluation of specific improper integrals This file contains some integrability results, and evaluations of integrals, over `ℝ` or over half-infinite intervals in `ℝ`. ## See also - `Mathlib.Analysis.SpecialFunctions.Integrals` -- integrals over finite intervals - `Mathlib.Analysis.SpecialFunctions.Gaussian` -- integral of `exp (-x ^ 2)` - `Mathlib.Analysis.SpecialFunctions.JapaneseBracket`-- integrability of `(1+‖x‖)^(-r)`. -/ open Real Set Filter MeasureTheory intervalIntegral open scoped Topology theorem integrableOn_exp_Iic (c : ℝ) : IntegrableOn exp (Iic c) := by refine integrableOn_Iic_of_intervalIntegral_norm_bounded (exp c) c (fun y => intervalIntegrable_exp.1) tendsto_id (eventually_of_mem (Iic_mem_atBot 0) fun y _ => ?_) simp_rw [norm_of_nonneg (exp_pos _).le, integral_exp, sub_le_self_iff] exact (exp_pos _).le #align integrable_on_exp_Iic integrableOn_exp_Iic theorem integral_exp_Iic (c : ℝ) : ∫ x : ℝ in Iic c, exp x = exp c := by refine tendsto_nhds_unique (intervalIntegral_tendsto_integral_Iic _ (integrableOn_exp_Iic _) tendsto_id) ?_ simp_rw [integral_exp, show 𝓝 (exp c) = 𝓝 (exp c - 0) by rw [sub_zero]] exact tendsto_exp_atBot.const_sub _ #align integral_exp_Iic integral_exp_Iic theorem integral_exp_Iic_zero : ∫ x : ℝ in Iic 0, exp x = 1 := exp_zero ▸ integral_exp_Iic 0 #align integral_exp_Iic_zero integral_exp_Iic_zero theorem integral_exp_neg_Ioi (c : ℝ) : (∫ x : ℝ in Ioi c, exp (-x)) = exp (-c) := by simpa only [integral_comp_neg_Ioi] using integral_exp_Iic (-c) #align integral_exp_neg_Ioi integral_exp_neg_Ioi theorem integral_exp_neg_Ioi_zero : (∫ x : ℝ in Ioi 0, exp (-x)) = 1 := by simpa only [neg_zero, exp_zero] using integral_exp_neg_Ioi 0 #align integral_exp_neg_Ioi_zero integral_exp_neg_Ioi_zero /-- If `0 < c`, then `(fun t : ℝ ↦ t ^ a)` is integrable on `(c, ∞)` for all `a < -1`. -/ theorem integrableOn_Ioi_rpow_of_lt {a : ℝ} (ha : a < -1) {c : ℝ} (hc : 0 < c) : IntegrableOn (fun t : ℝ => t ^ a) (Ioi c) := by have hd : ∀ x ∈ Ici c, HasDerivAt (fun t => t ^ (a + 1) / (a + 1)) (x ^ a) x := by intro x hx -- Porting note: helped `convert` with explicit arguments convert (hasDerivAt_rpow_const (p := a + 1) (Or.inl (hc.trans_le hx).ne')).div_const _ using 1 field_simp [show a + 1 ≠ 0 from ne_of_lt (by linarith), mul_comm] have ht : Tendsto (fun t => t ^ (a + 1) / (a + 1)) atTop (𝓝 (0 / (a + 1))) := by apply Tendsto.div_const simpa only [neg_neg] using tendsto_rpow_neg_atTop (by linarith : 0 < -(a + 1)) exact integrableOn_Ioi_deriv_of_nonneg' hd (fun t ht => rpow_nonneg (hc.trans ht).le a) ht #align integrable_on_Ioi_rpow_of_lt integrableOn_Ioi_rpow_of_lt theorem integrableOn_Ioi_rpow_iff {s t : ℝ} (ht : 0 < t) : IntegrableOn (fun x ↦ x ^ s) (Ioi t) ↔ s < -1 := by refine ⟨fun h ↦ ?_, fun h ↦ integrableOn_Ioi_rpow_of_lt h ht⟩ contrapose! h intro H have H' : IntegrableOn (fun x ↦ x ^ s) (Ioi (max 1 t)) := H.mono (Set.Ioi_subset_Ioi (le_max_right _ _)) le_rfl have : IntegrableOn (fun x ↦ x⁻¹) (Ioi (max 1 t)) := by apply H'.mono' measurable_inv.aestronglyMeasurable filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx have x_one : 1 ≤ x := ((le_max_left _ _).trans_lt (mem_Ioi.1 hx)).le simp only [norm_inv, Real.norm_eq_abs, abs_of_nonneg (zero_le_one.trans x_one)] rw [← Real.rpow_neg_one x] exact Real.rpow_le_rpow_of_exponent_le x_one h exact not_IntegrableOn_Ioi_inv this /-- The real power function with any exponent is not integrable on `(0, +∞)`. -/
Mathlib/Analysis/SpecialFunctions/ImproperIntegrals.lean
93
101
theorem not_integrableOn_Ioi_rpow (s : ℝ) : ¬ IntegrableOn (fun x ↦ x ^ s) (Ioi (0 : ℝ)) := by
intro h rcases le_or_lt s (-1) with hs|hs · have : IntegrableOn (fun x ↦ x ^ s) (Ioo (0 : ℝ) 1) := h.mono Ioo_subset_Ioi_self le_rfl rw [integrableOn_Ioo_rpow_iff zero_lt_one] at this exact hs.not_lt this · have : IntegrableOn (fun x ↦ x ^ s) (Ioi (1 : ℝ)) := h.mono (Ioi_subset_Ioi zero_le_one) le_rfl rw [integrableOn_Ioi_rpow_iff zero_lt_one] at this exact hs.not_lt this
/- 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.QuasiCompact import Mathlib.Topology.QuasiSeparated #align_import algebraic_geometry.morphisms.quasi_separated from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc" /-! # Quasi-separated morphisms A morphism of schemes `f : X ⟶ Y` is quasi-separated if the diagonal morphism `X ⟶ X ×[Y] X` is quasi-compact. A scheme is quasi-separated if the intersections of any two affine open sets is quasi-compact. (`AlgebraicGeometry.quasiSeparatedSpace_iff_affine`) We show that a morphism is quasi-separated if the preimage of every affine open is quasi-separated. We also show that this property is local at the target, and is stable under compositions and base-changes. ## Main result - `AlgebraicGeometry.is_localization_basicOpen_of_qcqs` (**Qcqs lemma**): If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`. -/ noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u open scoped AlgebraicGeometry namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) /-- A morphism is `QuasiSeparated` if diagonal map is quasi-compact. -/ @[mk_iff] class QuasiSeparated (f : X ⟶ Y) : Prop where /-- A morphism is `QuasiSeparated` if diagonal map is quasi-compact. -/ diagonalQuasiCompact : QuasiCompact (pullback.diagonal f) := by infer_instance #align algebraic_geometry.quasi_separated AlgebraicGeometry.QuasiSeparated /-- The `AffineTargetMorphismProperty` corresponding to `QuasiSeparated`, asserting that the domain is a quasi-separated scheme. -/ def QuasiSeparated.affineProperty : AffineTargetMorphismProperty := fun X _ _ _ => QuasiSeparatedSpace X.carrier #align algebraic_geometry.quasi_separated.affine_property AlgebraicGeometry.QuasiSeparated.affineProperty theorem quasiSeparatedSpace_iff_affine (X : Scheme) : QuasiSeparatedSpace X.carrier ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X.carrier) := by rw [quasiSeparatedSpace_iff] constructor · intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact · intro H suffices ∀ (U : Opens X.carrier) (_ : IsCompact U.1) (V : Opens X.carrier) (_ : IsCompact V.1), IsCompact (U ⊓ V).1 by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV' intro U hU V hV -- Porting note: it complains "unable to find motive", but telling Lean that motive is -- underscore is actually sufficient, weird apply compact_open_induction_on (P := _) V hV · simp · intro S _ V hV change IsCompact (U.1 ∩ (S.1 ∪ V.1)) rw [Set.inter_union_distrib_left] apply hV.union clear hV apply compact_open_induction_on (P := _) U hU · simp · intro S _ W hW change IsCompact ((S.1 ∪ W.1) ∩ V.1) rw [Set.union_inter_distrib_right] apply hW.union apply H #align algebraic_geometry.quasi_separated_space_iff_affine AlgebraicGeometry.quasiSeparatedSpace_iff_affine theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by delta AffineTargetMorphismProperty.diagonal rw [quasiSeparatedSpace_iff_affine] constructor · intro H U V haveI : IsAffine _ := U.2 haveI : IsAffine _ := V.2 let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X := pullback.fst ≫ X.ofRestrict _ -- Porting note: `inferInstance` does not work here have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _ have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding rw [IsOpenImmersion.range_pullback_to_base_of_left] at e erw [Subtype.range_coe, Subtype.range_coe] at e rw [isCompact_iff_compactSpace] exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e · introv H h₁ h₂ let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁ -- Porting note: `inferInstance` does not work here have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _ have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding rw [IsOpenImmersion.range_pullback_to_base_of_left] at e simp_rw [isCompact_iff_compactSpace] at H exact @Homeomorph.compactSpace _ _ _ _ (H ⟨⟨_, h₁.base_open.isOpen_range⟩, rangeIsAffineOpenOfOpenImmersion _⟩ ⟨⟨_, h₂.base_open.isOpen_range⟩, rangeIsAffineOpenOfOpenImmersion _⟩) e.symm #align algebraic_geometry.quasi_compact_affine_property_iff_quasi_separated_space AlgebraicGeometry.quasi_compact_affineProperty_iff_quasiSeparatedSpace theorem quasiSeparated_eq_diagonal_is_quasiCompact : @QuasiSeparated = MorphismProperty.diagonal @QuasiCompact := by ext; exact quasiSeparated_iff _ #align algebraic_geometry.quasi_separated_eq_diagonal_is_quasi_compact AlgebraicGeometry.quasiSeparated_eq_diagonal_is_quasiCompact theorem quasi_compact_affineProperty_diagonal_eq : QuasiCompact.affineProperty.diagonal = QuasiSeparated.affineProperty := by funext; rw [quasi_compact_affineProperty_iff_quasiSeparatedSpace]; rfl #align algebraic_geometry.quasi_compact_affine_property_diagonal_eq AlgebraicGeometry.quasi_compact_affineProperty_diagonal_eq
Mathlib/AlgebraicGeometry/Morphisms/QuasiSeparated.lean
126
130
theorem quasiSeparated_eq_affineProperty_diagonal : @QuasiSeparated = targetAffineLocally QuasiCompact.affineProperty.diagonal := by
rw [quasiSeparated_eq_diagonal_is_quasiCompact, quasiCompact_eq_affineProperty] exact diagonal_targetAffineLocally_eq_targetAffineLocally _ QuasiCompact.affineProperty_isLocal
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.SetTheory.Cardinal.Ordinal #align_import set_theory.cardinal.continuum from "leanprover-community/mathlib"@"e08a42b2dd544cf11eba72e5fc7bf199d4349925" /-! # Cardinality of continuum In this file we define `Cardinal.continuum` (notation: `𝔠`, localized in `Cardinal`) to be `2 ^ ℵ₀`. We also prove some `simp` lemmas about cardinal arithmetic involving `𝔠`. ## Notation - `𝔠` : notation for `Cardinal.continuum` in locale `Cardinal`. -/ namespace Cardinal universe u v open Cardinal /-- Cardinality of continuum. -/ def continuum : Cardinal.{u} := 2 ^ ℵ₀ #align cardinal.continuum Cardinal.continuum scoped notation "𝔠" => Cardinal.continuum @[simp] theorem two_power_aleph0 : 2 ^ aleph0.{u} = continuum.{u} := rfl #align cardinal.two_power_aleph_0 Cardinal.two_power_aleph0 @[simp] theorem lift_continuum : lift.{v} 𝔠 = 𝔠 := by rw [← two_power_aleph0, lift_two_power, lift_aleph0, two_power_aleph0] #align cardinal.lift_continuum Cardinal.lift_continuum @[simp]
Mathlib/SetTheory/Cardinal/Continuum.lean
46
48
theorem continuum_le_lift {c : Cardinal.{u}} : 𝔠 ≤ lift.{v} c ↔ 𝔠 ≤ c := by
-- Porting note: added explicit universes rw [← lift_continuum.{u,v}, lift_le]
/- Copyright (c) 2023 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Probability.Kernel.MeasurableIntegral import Mathlib.MeasureTheory.Integral.SetIntegral #align_import probability.kernel.with_density from "leanprover-community/mathlib"@"c0d694db494dd4f9aa57f2714b6e4c82b4ebc113" /-! # With Density For an s-finite kernel `κ : kernel α β` and a function `f : α → β → ℝ≥0∞` which is finite everywhere, we define `withDensity κ f` as the kernel `a ↦ (κ a).withDensity (f a)`. This is an s-finite kernel. ## Main definitions * `ProbabilityTheory.kernel.withDensity κ (f : α → β → ℝ≥0∞)`: kernel `a ↦ (κ a).withDensity (f a)`. It is defined if `κ` is s-finite. If `f` is finite everywhere, then this is also an s-finite kernel. The class of s-finite kernels is the smallest class of kernels that contains finite kernels and which is stable by `withDensity`. Integral: `∫⁻ b, g b ∂(withDensity κ f a) = ∫⁻ b, f a b * g b ∂(κ a)` ## Main statements * `ProbabilityTheory.kernel.lintegral_withDensity`: `∫⁻ b, g b ∂(withDensity κ f a) = ∫⁻ b, f a b * g b ∂(κ a)` -/ open MeasureTheory ProbabilityTheory open scoped MeasureTheory ENNReal NNReal namespace ProbabilityTheory.kernel variable {α β ι : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} variable {κ : kernel α β} {f : α → β → ℝ≥0∞} /-- Kernel with image `(κ a).withDensity (f a)` if `Function.uncurry f` is measurable, and with image 0 otherwise. If `Function.uncurry f` is measurable, it satisfies `∫⁻ b, g b ∂(withDensity κ f hf a) = ∫⁻ b, f a b * g b ∂(κ a)`. -/ noncomputable def withDensity (κ : kernel α β) [IsSFiniteKernel κ] (f : α → β → ℝ≥0∞) : kernel α β := @dite _ (Measurable (Function.uncurry f)) (Classical.dec _) (fun hf => (⟨fun a => (κ a).withDensity (f a), by refine Measure.measurable_of_measurable_coe _ fun s hs => ?_ simp_rw [withDensity_apply _ hs] exact hf.set_lintegral_kernel_prod_right hs⟩ : kernel α β)) fun _ => 0 #align probability_theory.kernel.with_density ProbabilityTheory.kernel.withDensity theorem withDensity_of_not_measurable (κ : kernel α β) [IsSFiniteKernel κ] (hf : ¬Measurable (Function.uncurry f)) : withDensity κ f = 0 := by classical exact dif_neg hf #align probability_theory.kernel.with_density_of_not_measurable ProbabilityTheory.kernel.withDensity_of_not_measurable protected theorem withDensity_apply (κ : kernel α β) [IsSFiniteKernel κ] (hf : Measurable (Function.uncurry f)) (a : α) : withDensity κ f a = (κ a).withDensity (f a) := by classical rw [withDensity, dif_pos hf] rfl #align probability_theory.kernel.with_density_apply ProbabilityTheory.kernel.withDensity_apply protected theorem withDensity_apply' (κ : kernel α β) [IsSFiniteKernel κ] (hf : Measurable (Function.uncurry f)) (a : α) (s : Set β) : withDensity κ f a s = ∫⁻ b in s, f a b ∂κ a := by rw [kernel.withDensity_apply κ hf, withDensity_apply' _ s] #align probability_theory.kernel.with_density_apply' ProbabilityTheory.kernel.withDensity_apply' nonrec lemma withDensity_congr_ae (κ : kernel α β) [IsSFiniteKernel κ] {f g : α → β → ℝ≥0∞} (hf : Measurable (Function.uncurry f)) (hg : Measurable (Function.uncurry g)) (hfg : ∀ a, f a =ᵐ[κ a] g a) : withDensity κ f = withDensity κ g := by ext a rw [kernel.withDensity_apply _ hf,kernel.withDensity_apply _ hg, withDensity_congr_ae (hfg a)] nonrec lemma withDensity_absolutelyContinuous [IsSFiniteKernel κ] (f : α → β → ℝ≥0∞) (a : α) : kernel.withDensity κ f a ≪ κ a := by by_cases hf : Measurable (Function.uncurry f) · rw [kernel.withDensity_apply _ hf] exact withDensity_absolutelyContinuous _ _ · rw [withDensity_of_not_measurable _ hf] simp [Measure.AbsolutelyContinuous.zero] @[simp] lemma withDensity_one (κ : kernel α β) [IsSFiniteKernel κ] : kernel.withDensity κ 1 = κ := by ext; rw [kernel.withDensity_apply _ measurable_const]; simp @[simp] lemma withDensity_one' (κ : kernel α β) [IsSFiniteKernel κ] : kernel.withDensity κ (fun _ _ ↦ 1) = κ := kernel.withDensity_one _ @[simp] lemma withDensity_zero (κ : kernel α β) [IsSFiniteKernel κ] : kernel.withDensity κ 0 = 0 := by ext; rw [kernel.withDensity_apply _ measurable_const]; simp @[simp] lemma withDensity_zero' (κ : kernel α β) [IsSFiniteKernel κ] : kernel.withDensity κ (fun _ _ ↦ 0) = 0 := kernel.withDensity_zero _ theorem lintegral_withDensity (κ : kernel α β) [IsSFiniteKernel κ] (hf : Measurable (Function.uncurry f)) (a : α) {g : β → ℝ≥0∞} (hg : Measurable g) : ∫⁻ b, g b ∂withDensity κ f a = ∫⁻ b, f a b * g b ∂κ a := by rw [kernel.withDensity_apply _ hf, lintegral_withDensity_eq_lintegral_mul _ (Measurable.of_uncurry_left hf) hg] simp_rw [Pi.mul_apply] #align probability_theory.kernel.lintegral_with_density ProbabilityTheory.kernel.lintegral_withDensity
Mathlib/Probability/Kernel/WithDensity.lean
116
122
theorem integral_withDensity {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : β → E} [IsSFiniteKernel κ] {a : α} {g : α → β → ℝ≥0} (hg : Measurable (Function.uncurry g)) : ∫ b, f b ∂withDensity κ (fun a b => g a b) a = ∫ b, g a b • f b ∂κ a := by
rw [kernel.withDensity_apply, integral_withDensity_eq_integral_smul] · exact Measurable.of_uncurry_left hg · exact measurable_coe_nnreal_ennreal.comp hg
/- Copyright (c) 2021 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker -/ import Mathlib.Analysis.Normed.Order.Basic import Mathlib.Analysis.Asymptotics.Asymptotics import Mathlib.Analysis.NormedSpace.Basic #align_import analysis.asymptotics.specific_asymptotics from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # A collection of specific asymptotic results This file contains specific lemmas about asymptotics which don't have their place in the general theory developed in `Mathlib.Analysis.Asymptotics.Asymptotics`. -/ open Filter Asymptotics open Topology section NormedField /-- If `f : 𝕜 → E` is bounded in a punctured neighborhood of `a`, then `f(x) = o((x - a)⁻¹)` as `x → a`, `x ≠ a`. -/
Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean
28
33
theorem Filter.IsBoundedUnder.isLittleO_sub_self_inv {𝕜 E : Type*} [NormedField 𝕜] [Norm E] {a : 𝕜} {f : 𝕜 → E} (h : IsBoundedUnder (· ≤ ·) (𝓝[≠] a) (norm ∘ f)) : f =o[𝓝[≠] a] fun x => (x - a)⁻¹ := by
refine (h.isBigO_const (one_ne_zero' ℝ)).trans_isLittleO (isLittleO_const_left.2 <| Or.inr ?_) simp only [(· ∘ ·), norm_inv] exact (tendsto_norm_sub_self_punctured_nhds a).inv_tendsto_zero