Context stringlengths 57 6.04k | file_name stringlengths 21 79 | start int64 14 1.49k | end int64 18 1.5k | theorem stringlengths 25 1.55k | proof stringlengths 5 7.36k | num_lines int64 1 150 | complexity_score float64 2.72 139,370,958,066,637,970,000,000,000,000,000,000,000,000,000,000,000,000,000B | diff_level int64 0 2 | file_diff_level float64 0 2 | theorem_same_file int64 1 32 | rank_file int64 0 2.51k |
|---|---|---|---|---|---|---|---|---|---|---|---|
import Mathlib.CategoryTheory.Preadditive.Injective
import Mathlib.Algebra.Homology.ShortComplex.HomologicalComplex
import Mathlib.Algebra.Homology.QuasiIso
#align_import category_theory.preadditive.injective_resolution from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7"
noncomputable section
universe v u
namespace CategoryTheory
open Limits HomologicalComplex CochainComplex
variable {C : Type u} [Category.{v} C] [HasZeroObject C] [HasZeroMorphisms C]
-- Porting note(#5171): this linter isn't ported yet.
-- @[nolint has_nonempty_instance]
structure InjectiveResolution (Z : C) where
cocomplex : CochainComplex C ℕ
injective : ∀ n, Injective (cocomplex.X n) := by infer_instance
[hasHomology : ∀ i, cocomplex.HasHomology i]
ι : (single₀ C).obj Z ⟶ cocomplex
quasiIso : QuasiIso ι := by infer_instance
set_option linter.uppercaseLean3 false in
#align category_theory.InjectiveResolution CategoryTheory.InjectiveResolution
open InjectiveResolution in
attribute [instance] injective hasHomology InjectiveResolution.quasiIso
class HasInjectiveResolution (Z : C) : Prop where
out : Nonempty (InjectiveResolution Z)
#align category_theory.has_injective_resolution CategoryTheory.HasInjectiveResolution
attribute [inherit_doc HasInjectiveResolution] HasInjectiveResolution.out
section
variable (C)
class HasInjectiveResolutions : Prop where
out : ∀ Z : C, HasInjectiveResolution Z
#align category_theory.has_injective_resolutions CategoryTheory.HasInjectiveResolutions
attribute [instance 100] HasInjectiveResolutions.out
end
namespace InjectiveResolution
variable {Z : C} (I : InjectiveResolution Z)
lemma cocomplex_exactAt_succ (n : ℕ) :
I.cocomplex.ExactAt (n + 1) := by
rw [← quasiIsoAt_iff_exactAt I.ι (n + 1) (exactAt_succ_single_obj _ _)]
infer_instance
lemma exact_succ (n : ℕ):
(ShortComplex.mk _ _ (I.cocomplex.d_comp_d n (n + 1) (n + 2))).Exact :=
(HomologicalComplex.exactAt_iff' _ n (n + 1) (n + 2) (by simp)
(by simp only [CochainComplex.next]; rfl)).1 (I.cocomplex_exactAt_succ n)
@[simp]
theorem ι_f_succ (n : ℕ) : I.ι.f (n + 1) = 0 :=
(isZero_single_obj_X _ _ _ _ (by simp)).eq_of_src _ _
set_option linter.uppercaseLean3 false in
#align category_theory.InjectiveResolution.ι_f_succ CategoryTheory.InjectiveResolution.ι_f_succ
-- Porting note (#10618): removed @[simp] simp can prove this
@[reassoc]
| Mathlib/CategoryTheory/Preadditive/InjectiveResolution.lean | 104 | 106 | theorem ι_f_zero_comp_complex_d :
I.ι.f 0 ≫ I.cocomplex.d 0 1 = 0 := by |
simp
| 1 | 2.718282 | 0 | 0 | 2 | 4 |
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Order.Hom.Set
#align_import data.set.intervals.order_iso from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105"
open Set
namespace OrderIso
section Preorder
variable {α β : Type*} [Preorder α] [Preorder β]
@[simp]
theorem preimage_Iic (e : α ≃o β) (b : β) : e ⁻¹' Iic b = Iic (e.symm b) := by
ext x
simp [← e.le_iff_le]
#align order_iso.preimage_Iic OrderIso.preimage_Iic
@[simp]
theorem preimage_Ici (e : α ≃o β) (b : β) : e ⁻¹' Ici b = Ici (e.symm b) := by
ext x
simp [← e.le_iff_le]
#align order_iso.preimage_Ici OrderIso.preimage_Ici
@[simp]
theorem preimage_Iio (e : α ≃o β) (b : β) : e ⁻¹' Iio b = Iio (e.symm b) := by
ext x
simp [← e.lt_iff_lt]
#align order_iso.preimage_Iio OrderIso.preimage_Iio
@[simp]
theorem preimage_Ioi (e : α ≃o β) (b : β) : e ⁻¹' Ioi b = Ioi (e.symm b) := by
ext x
simp [← e.lt_iff_lt]
#align order_iso.preimage_Ioi OrderIso.preimage_Ioi
@[simp]
theorem preimage_Icc (e : α ≃o β) (a b : β) : e ⁻¹' Icc a b = Icc (e.symm a) (e.symm b) := by
simp [← Ici_inter_Iic]
#align order_iso.preimage_Icc OrderIso.preimage_Icc
@[simp]
theorem preimage_Ico (e : α ≃o β) (a b : β) : e ⁻¹' Ico a b = Ico (e.symm a) (e.symm b) := by
simp [← Ici_inter_Iio]
#align order_iso.preimage_Ico OrderIso.preimage_Ico
@[simp]
theorem preimage_Ioc (e : α ≃o β) (a b : β) : e ⁻¹' Ioc a b = Ioc (e.symm a) (e.symm b) := by
simp [← Ioi_inter_Iic]
#align order_iso.preimage_Ioc OrderIso.preimage_Ioc
@[simp]
theorem preimage_Ioo (e : α ≃o β) (a b : β) : e ⁻¹' Ioo a b = Ioo (e.symm a) (e.symm b) := by
simp [← Ioi_inter_Iio]
#align order_iso.preimage_Ioo OrderIso.preimage_Ioo
@[simp]
theorem image_Iic (e : α ≃o β) (a : α) : e '' Iic a = Iic (e a) := by
rw [e.image_eq_preimage, e.symm.preimage_Iic, e.symm_symm]
#align order_iso.image_Iic OrderIso.image_Iic
@[simp]
theorem image_Ici (e : α ≃o β) (a : α) : e '' Ici a = Ici (e a) :=
e.dual.image_Iic a
#align order_iso.image_Ici OrderIso.image_Ici
@[simp]
theorem image_Iio (e : α ≃o β) (a : α) : e '' Iio a = Iio (e a) := by
rw [e.image_eq_preimage, e.symm.preimage_Iio, e.symm_symm]
#align order_iso.image_Iio OrderIso.image_Iio
@[simp]
theorem image_Ioi (e : α ≃o β) (a : α) : e '' Ioi a = Ioi (e a) :=
e.dual.image_Iio a
#align order_iso.image_Ioi OrderIso.image_Ioi
@[simp]
theorem image_Ioo (e : α ≃o β) (a b : α) : e '' Ioo a b = Ioo (e a) (e b) := by
rw [e.image_eq_preimage, e.symm.preimage_Ioo, e.symm_symm]
#align order_iso.image_Ioo OrderIso.image_Ioo
@[simp]
theorem image_Ioc (e : α ≃o β) (a b : α) : e '' Ioc a b = Ioc (e a) (e b) := by
rw [e.image_eq_preimage, e.symm.preimage_Ioc, e.symm_symm]
#align order_iso.image_Ioc OrderIso.image_Ioc
@[simp]
theorem image_Ico (e : α ≃o β) (a b : α) : e '' Ico a b = Ico (e a) (e b) := by
rw [e.image_eq_preimage, e.symm.preimage_Ico, e.symm_symm]
#align order_iso.image_Ico OrderIso.image_Ico
@[simp]
| Mathlib/Order/Interval/Set/OrderIso.lean | 103 | 104 | theorem image_Icc (e : α ≃o β) (a b : α) : e '' Icc a b = Icc (e a) (e b) := by |
rw [e.image_eq_preimage, e.symm.preimage_Icc, e.symm_symm]
| 1 | 2.718282 | 0 | 0.285714 | 14 | 310 |
import Mathlib.Data.Set.Lattice
#align_import data.set.accumulate from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
variable {α β γ : Type*} {s : α → Set β} {t : α → Set γ}
namespace Set
def Accumulate [LE α] (s : α → Set β) (x : α) : Set β :=
⋃ y ≤ x, s y
#align set.accumulate Set.Accumulate
theorem accumulate_def [LE α] {x : α} : Accumulate s x = ⋃ y ≤ x, s y :=
rfl
#align set.accumulate_def Set.accumulate_def
@[simp]
| Mathlib/Data/Set/Accumulate.lean | 31 | 32 | theorem mem_accumulate [LE α] {x : α} {z : β} : z ∈ Accumulate s x ↔ ∃ y ≤ x, z ∈ s y := by |
simp_rw [accumulate_def, mem_iUnion₂, exists_prop]
| 1 | 2.718282 | 0 | 1 | 3 | 998 |
import Mathlib.RingTheory.MvPowerSeries.Basic
import Mathlib.RingTheory.Ideal.LocalRing
#align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60"
noncomputable section
open Finset (antidiagonal mem_antidiagonal)
namespace MvPowerSeries
open Finsupp
variable {σ R : Type*}
section Ring
variable [Ring R]
protected noncomputable def inv.aux (a : R) (φ : MvPowerSeries σ R) : MvPowerSeries σ R
| n =>
letI := Classical.decEq σ
if n = 0 then a
else
-a *
∑ x ∈ antidiagonal n, if _ : x.2 < n then coeff R x.1 φ * inv.aux a φ x.2 else 0
termination_by n => n
#align mv_power_series.inv.aux MvPowerSeries.inv.aux
theorem coeff_inv_aux [DecidableEq σ] (n : σ →₀ ℕ) (a : R) (φ : MvPowerSeries σ R) :
coeff R n (inv.aux a φ) =
if n = 0 then a
else
-a *
∑ x ∈ antidiagonal n, if x.2 < n then coeff R x.1 φ * coeff R x.2 (inv.aux a φ) else 0 :=
show inv.aux a φ n = _ by
cases Subsingleton.elim ‹DecidableEq σ› (Classical.decEq σ)
rw [inv.aux]
rfl
#align mv_power_series.coeff_inv_aux MvPowerSeries.coeff_inv_aux
def invOfUnit (φ : MvPowerSeries σ R) (u : Rˣ) : MvPowerSeries σ R :=
inv.aux (↑u⁻¹) φ
#align mv_power_series.inv_of_unit MvPowerSeries.invOfUnit
theorem coeff_invOfUnit [DecidableEq σ] (n : σ →₀ ℕ) (φ : MvPowerSeries σ R) (u : Rˣ) :
coeff R n (invOfUnit φ u) =
if n = 0 then ↑u⁻¹
else
-↑u⁻¹ *
∑ x ∈ antidiagonal n,
if x.2 < n then coeff R x.1 φ * coeff R x.2 (invOfUnit φ u) else 0 := by
convert coeff_inv_aux n (↑u⁻¹) φ
#align mv_power_series.coeff_inv_of_unit MvPowerSeries.coeff_invOfUnit
@[simp]
| Mathlib/RingTheory/MvPowerSeries/Inverse.lean | 101 | 104 | theorem constantCoeff_invOfUnit (φ : MvPowerSeries σ R) (u : Rˣ) :
constantCoeff σ R (invOfUnit φ u) = ↑u⁻¹ := by |
classical
rw [← coeff_zero_eq_constantCoeff_apply, coeff_invOfUnit, if_pos rfl]
| 2 | 7.389056 | 1 | 1 | 3 | 920 |
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.FDeriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.RestrictScalars
#align_import analysis.calculus.deriv.comp from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
universe u v w
open scoped Classical
open Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L L₁ L₂ : Filter 𝕜}
section Composition
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' F]
[IsScalarTower 𝕜 𝕜' F] {s' t' : Set 𝕜'} {h : 𝕜 → 𝕜'} {h₁ : 𝕜 → 𝕜} {h₂ : 𝕜' → 𝕜'} {h' h₂' : 𝕜'}
{h₁' : 𝕜} {g₁ : 𝕜' → F} {g₁' : F} {L' : Filter 𝕜'} {y : 𝕜'} (x)
theorem HasDerivAtFilter.scomp (hg : HasDerivAtFilter g₁ g₁' (h x) L')
(hh : HasDerivAtFilter h h' x L) (hL : Tendsto h L L') :
HasDerivAtFilter (g₁ ∘ h) (h' • g₁') x L := by
simpa using ((hg.restrictScalars 𝕜).comp x hh hL).hasDerivAtFilter
#align has_deriv_at_filter.scomp HasDerivAtFilter.scomp
theorem HasDerivAtFilter.scomp_of_eq (hg : HasDerivAtFilter g₁ g₁' y L')
(hh : HasDerivAtFilter h h' x L) (hy : y = h x) (hL : Tendsto h L L') :
HasDerivAtFilter (g₁ ∘ h) (h' • g₁') x L := by
rw [hy] at hg; exact hg.scomp x hh hL
theorem HasDerivWithinAt.scomp_hasDerivAt (hg : HasDerivWithinAt g₁ g₁' s' (h x))
(hh : HasDerivAt h h' x) (hs : ∀ x, h x ∈ s') : HasDerivAt (g₁ ∘ h) (h' • g₁') x :=
hg.scomp x hh <| tendsto_inf.2 ⟨hh.continuousAt, tendsto_principal.2 <| eventually_of_forall hs⟩
#align has_deriv_within_at.scomp_has_deriv_at HasDerivWithinAt.scomp_hasDerivAt
theorem HasDerivWithinAt.scomp_hasDerivAt_of_eq (hg : HasDerivWithinAt g₁ g₁' s' y)
(hh : HasDerivAt h h' x) (hs : ∀ x, h x ∈ s') (hy : y = h x) :
HasDerivAt (g₁ ∘ h) (h' • g₁') x := by
rw [hy] at hg; exact hg.scomp_hasDerivAt x hh hs
nonrec theorem HasDerivWithinAt.scomp (hg : HasDerivWithinAt g₁ g₁' t' (h x))
(hh : HasDerivWithinAt h h' s x) (hst : MapsTo h s t') :
HasDerivWithinAt (g₁ ∘ h) (h' • g₁') s x :=
hg.scomp x hh <| hh.continuousWithinAt.tendsto_nhdsWithin hst
#align has_deriv_within_at.scomp HasDerivWithinAt.scomp
theorem HasDerivWithinAt.scomp_of_eq (hg : HasDerivWithinAt g₁ g₁' t' y)
(hh : HasDerivWithinAt h h' s x) (hst : MapsTo h s t') (hy : y = h x) :
HasDerivWithinAt (g₁ ∘ h) (h' • g₁') s x := by
rw [hy] at hg; exact hg.scomp x hh hst
nonrec theorem HasDerivAt.scomp (hg : HasDerivAt g₁ g₁' (h x)) (hh : HasDerivAt h h' x) :
HasDerivAt (g₁ ∘ h) (h' • g₁') x :=
hg.scomp x hh hh.continuousAt
#align has_deriv_at.scomp HasDerivAt.scomp
| Mathlib/Analysis/Calculus/Deriv/Comp.lean | 113 | 116 | theorem HasDerivAt.scomp_of_eq
(hg : HasDerivAt g₁ g₁' y) (hh : HasDerivAt h h' x) (hy : y = h x) :
HasDerivAt (g₁ ∘ h) (h' • g₁') x := by |
rw [hy] at hg; exact hg.scomp x hh
| 1 | 2.718282 | 0 | 0 | 14 | 81 |
import Mathlib.CategoryTheory.Generator
import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic
#align_import category_theory.preadditive.generator from "leanprover-community/mathlib"@"09f981f72d43749f1fa072deade828d9c1e185bb"
universe v u
open CategoryTheory Opposite
namespace CategoryTheory
variable {C : Type u} [Category.{v} C] [Preadditive C]
theorem Preadditive.isSeparating_iff (𝒢 : Set C) :
IsSeparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : G ⟶ X), h ≫ f = 0) → f = 0 :=
⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.comp_zero] using hf), fun h𝒢 X Y f g hfg =>
sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩
#align category_theory.preadditive.is_separating_iff CategoryTheory.Preadditive.isSeparating_iff
theorem Preadditive.isCoseparating_iff (𝒢 : Set C) :
IsCoseparating 𝒢 ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : Y ⟶ G), f ≫ h = 0) → f = 0 :=
⟨fun h𝒢 X Y f hf => h𝒢 _ _ (by simpa only [Limits.zero_comp] using hf), fun h𝒢 X Y f g hfg =>
sub_eq_zero.1 <| h𝒢 _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩
#align category_theory.preadditive.is_coseparating_iff CategoryTheory.Preadditive.isCoseparating_iff
theorem Preadditive.isSeparator_iff (G : C) :
IsSeparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : G ⟶ X, h ≫ f = 0) → f = 0 :=
⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.comp_zero] using hf), fun hG =>
(isSeparator_def _).2 fun X Y f g hfg =>
sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.comp_sub, sub_eq_zero] using hfg)⟩
#align category_theory.preadditive.is_separator_iff CategoryTheory.Preadditive.isSeparator_iff
theorem Preadditive.isCoseparator_iff (G : C) :
IsCoseparator G ↔ ∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ h : Y ⟶ G, f ≫ h = 0) → f = 0 :=
⟨fun hG X Y f hf => hG.def _ _ (by simpa only [Limits.zero_comp] using hf), fun hG =>
(isCoseparator_def _).2 fun X Y f g hfg =>
sub_eq_zero.1 <| hG _ (by simpa only [Preadditive.sub_comp, sub_eq_zero] using hfg)⟩
#align category_theory.preadditive.is_coseparator_iff CategoryTheory.Preadditive.isCoseparator_iff
theorem isSeparator_iff_faithful_preadditiveCoyoneda (G : C) :
IsSeparator G ↔ (preadditiveCoyoneda.obj (op G)).Faithful := by
rw [isSeparator_iff_faithful_coyoneda_obj, ← whiskering_preadditiveCoyoneda, Functor.comp_obj,
whiskeringRight_obj_obj]
exact ⟨fun h => Functor.Faithful.of_comp _ (forget AddCommGroupCat),
fun h => Functor.Faithful.comp _ _⟩
#align category_theory.is_separator_iff_faithful_preadditive_coyoneda CategoryTheory.isSeparator_iff_faithful_preadditiveCoyoneda
| Mathlib/CategoryTheory/Preadditive/Generator.lean | 62 | 66 | theorem isSeparator_iff_faithful_preadditiveCoyonedaObj (G : C) :
IsSeparator G ↔ (preadditiveCoyonedaObj (op G)).Faithful := by |
rw [isSeparator_iff_faithful_preadditiveCoyoneda, preadditiveCoyoneda_obj]
exact ⟨fun h => Functor.Faithful.of_comp _ (forget₂ _ AddCommGroupCat.{v}),
fun h => Functor.Faithful.comp _ _⟩
| 3 | 20.085537 | 1 | 1.5 | 4 | 1,629 |
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"
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]
-- 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
@[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 _ _⟩
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
| 1 | 2.718282 | 0 | 0.5 | 2 | 432 |
import Mathlib.Data.Set.Lattice
#align_import data.set.intervals.disjoint from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
universe u v w
variable {ι : Sort u} {α : Type v} {β : Type w}
open Set
open OrderDual (toDual)
namespace Set
section LinearOrder
variable [LinearOrder α] {a₁ a₂ b₁ b₂ : α}
@[simp]
theorem Ico_disjoint_Ico : Disjoint (Ico a₁ a₂) (Ico b₁ b₂) ↔ min a₂ b₂ ≤ max a₁ b₁ := by
simp_rw [Set.disjoint_iff_inter_eq_empty, Ico_inter_Ico, Ico_eq_empty_iff, inf_eq_min, sup_eq_max,
not_lt]
#align set.Ico_disjoint_Ico Set.Ico_disjoint_Ico
@[simp]
theorem Ioc_disjoint_Ioc : Disjoint (Ioc a₁ a₂) (Ioc b₁ b₂) ↔ min a₂ b₂ ≤ max a₁ b₁ := by
have h : _ ↔ min (toDual a₁) (toDual b₁) ≤ max (toDual a₂) (toDual b₂) := Ico_disjoint_Ico
simpa only [dual_Ico] using h
#align set.Ioc_disjoint_Ioc Set.Ioc_disjoint_Ioc
@[simp]
theorem Ioo_disjoint_Ioo [DenselyOrdered α] :
Disjoint (Set.Ioo a₁ a₂) (Set.Ioo b₁ b₂) ↔ min a₂ b₂ ≤ max a₁ b₁ := by
simp_rw [Set.disjoint_iff_inter_eq_empty, Ioo_inter_Ioo, Ioo_eq_empty_iff, inf_eq_min, sup_eq_max,
not_lt]
theorem eq_of_Ico_disjoint {x₁ x₂ y₁ y₂ : α} (h : Disjoint (Ico x₁ x₂) (Ico y₁ y₂)) (hx : x₁ < x₂)
(h2 : x₂ ∈ Ico y₁ y₂) : y₁ = x₂ := by
rw [Ico_disjoint_Ico, min_eq_left (le_of_lt h2.2), le_max_iff] at h
apply le_antisymm h2.1
exact h.elim (fun h => absurd hx (not_lt_of_le h)) id
#align set.eq_of_Ico_disjoint Set.eq_of_Ico_disjoint
@[simp]
| Mathlib/Order/Interval/Set/Disjoint.lean | 170 | 172 | theorem iUnion_Ico_eq_Iio_self_iff {f : ι → α} {a : α} :
⋃ i, Ico (f i) a = Iio a ↔ ∀ x < a, ∃ i, f i ≤ x := by |
simp [← Ici_inter_Iio, ← iUnion_inter, subset_def]
| 1 | 2.718282 | 0 | 0.333333 | 18 | 364 |
import Mathlib.CategoryTheory.Monoidal.Category
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
import Mathlib.CategoryTheory.Products.Basic
#align_import category_theory.monoidal.functor from "leanprover-community/mathlib"@"3d7987cda72abc473c7cdbbb075170e9ac620042"
open CategoryTheory
universe v₁ v₂ v₃ u₁ u₂ u₃
open CategoryTheory.Category
open CategoryTheory.Functor
namespace CategoryTheory
section
open MonoidalCategory
variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] (D : Type u₂) [Category.{v₂} D]
[MonoidalCategory.{v₂} D]
-- The direction of `left_unitality` and `right_unitality` as simp lemmas may look strange:
-- remember the rule of thumb that component indices of natural transformations
-- "weigh more" than structural maps.
-- (However by this argument `associativity` is currently stated backwards!)
structure LaxMonoidalFunctor extends C ⥤ D where
ε : 𝟙_ D ⟶ obj (𝟙_ C)
μ : ∀ X Y : C, obj X ⊗ obj Y ⟶ obj (X ⊗ Y)
μ_natural_left :
∀ {X Y : C} (f : X ⟶ Y) (X' : C),
map f ▷ obj X' ≫ μ Y X' = μ X X' ≫ map (f ▷ X') := by
aesop_cat
μ_natural_right :
∀ {X Y : C} (X' : C) (f : X ⟶ Y) ,
obj X' ◁ map f ≫ μ X' Y = μ X' X ≫ map (X' ◁ f) := by
aesop_cat
associativity :
∀ X Y Z : C,
μ X Y ▷ obj Z ≫ μ (X ⊗ Y) Z ≫ map (α_ X Y Z).hom =
(α_ (obj X) (obj Y) (obj Z)).hom ≫ obj X ◁ μ Y Z ≫ μ X (Y ⊗ Z) := by
aesop_cat
-- unitality
left_unitality : ∀ X : C, (λ_ (obj X)).hom = ε ▷ obj X ≫ μ (𝟙_ C) X ≫ map (λ_ X).hom := by
aesop_cat
right_unitality : ∀ X : C, (ρ_ (obj X)).hom = obj X ◁ ε ≫ μ X (𝟙_ C) ≫ map (ρ_ X).hom := by
aesop_cat
#align category_theory.lax_monoidal_functor CategoryTheory.LaxMonoidalFunctor
-- Porting note (#11215): TODO: remove this configuration and use the default configuration.
-- We keep this to be consistent with Lean 3.
-- See also `initialize_simps_projections MonoidalFunctor` below.
-- This may require waiting on https://github.com/leanprover-community/mathlib4/pull/2936
initialize_simps_projections LaxMonoidalFunctor (+toFunctor, -obj, -map)
attribute [reassoc (attr := simp)] LaxMonoidalFunctor.μ_natural_left
attribute [reassoc (attr := simp)] LaxMonoidalFunctor.μ_natural_right
attribute [simp] LaxMonoidalFunctor.left_unitality
attribute [simp] LaxMonoidalFunctor.right_unitality
attribute [reassoc (attr := simp)] LaxMonoidalFunctor.associativity
-- When `rewrite_search` lands, add @[search] attributes to
-- LaxMonoidalFunctor.μ_natural LaxMonoidalFunctor.left_unitality
-- LaxMonoidalFunctor.right_unitality LaxMonoidalFunctor.associativity
section
variable {C D}
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Monoidal/Functor.lean | 113 | 116 | theorem LaxMonoidalFunctor.μ_natural (F : LaxMonoidalFunctor C D) {X Y X' Y' : C}
(f : X ⟶ Y) (g : X' ⟶ Y') :
(F.map f ⊗ F.map g) ≫ F.μ Y Y' = F.μ X X' ≫ F.map (f ⊗ g) := by |
simp [tensorHom_def]
| 1 | 2.718282 | 0 | 0.5 | 2 | 491 |
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"
noncomputable section
open Polynomial
abbrev goldenRatio : ℝ := (1 + √5) / 2
#align golden_ratio goldenRatio
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
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
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]
| Mathlib/Data/Real/GoldenRatio.lean | 84 | 84 | theorem gold_sub_goldConj : φ - ψ = √5 := by | ring
| 1 | 2.718282 | 0 | 0.894737 | 19 | 776 |
import Mathlib.Data.ENNReal.Inv
#align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
open Set NNReal ENNReal
namespace ENNReal
section iInf
variable {ι : Sort*} {f g : ι → ℝ≥0∞}
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}
theorem toNNReal_iInf (hf : ∀ i, f i ≠ ∞) : (iInf f).toNNReal = ⨅ i, (f i).toNNReal := by
cases isEmpty_or_nonempty ι
· rw [iInf_of_empty, top_toNNReal, NNReal.iInf_empty]
· lift f to ι → ℝ≥0 using hf
simp_rw [← coe_iInf, toNNReal_coe]
#align ennreal.to_nnreal_infi ENNReal.toNNReal_iInf
theorem toNNReal_sInf (s : Set ℝ≥0∞) (hs : ∀ r ∈ s, r ≠ ∞) :
(sInf s).toNNReal = sInf (ENNReal.toNNReal '' s) := by
have hf : ∀ i, ((↑) : s → ℝ≥0∞) i ≠ ∞ := fun ⟨r, rs⟩ => hs r rs
-- Porting note: `← sInf_image'` had to be replaced by `← image_eq_range` as the lemmas are used
-- in a different order.
simpa only [← sInf_range, ← image_eq_range, Subtype.range_coe_subtype] using (toNNReal_iInf hf)
#align ennreal.to_nnreal_Inf ENNReal.toNNReal_sInf
theorem toNNReal_iSup (hf : ∀ i, f i ≠ ∞) : (iSup f).toNNReal = ⨆ i, (f i).toNNReal := by
lift f to ι → ℝ≥0 using hf
simp_rw [toNNReal_coe]
by_cases h : BddAbove (range f)
· rw [← coe_iSup h, toNNReal_coe]
· rw [NNReal.iSup_of_not_bddAbove h, iSup_coe_eq_top.2 h, top_toNNReal]
#align ennreal.to_nnreal_supr ENNReal.toNNReal_iSup
theorem toNNReal_sSup (s : Set ℝ≥0∞) (hs : ∀ r ∈ s, r ≠ ∞) :
(sSup s).toNNReal = sSup (ENNReal.toNNReal '' s) := by
have hf : ∀ i, ((↑) : s → ℝ≥0∞) i ≠ ∞ := fun ⟨r, rs⟩ => hs r rs
-- Porting note: `← sSup_image'` had to be replaced by `← image_eq_range` as the lemmas are used
-- in a different order.
simpa only [← sSup_range, ← image_eq_range, Subtype.range_coe_subtype] using (toNNReal_iSup hf)
#align ennreal.to_nnreal_Sup ENNReal.toNNReal_sSup
theorem toReal_iInf (hf : ∀ i, f i ≠ ∞) : (iInf f).toReal = ⨅ i, (f i).toReal := by
simp only [ENNReal.toReal, toNNReal_iInf hf, NNReal.coe_iInf]
#align ennreal.to_real_infi ENNReal.toReal_iInf
theorem toReal_sInf (s : Set ℝ≥0∞) (hf : ∀ r ∈ s, r ≠ ∞) :
(sInf s).toReal = sInf (ENNReal.toReal '' s) := by
simp only [ENNReal.toReal, toNNReal_sInf s hf, NNReal.coe_sInf, Set.image_image]
#align ennreal.to_real_Inf ENNReal.toReal_sInf
| Mathlib/Data/ENNReal/Real.lean | 581 | 582 | theorem toReal_iSup (hf : ∀ i, f i ≠ ∞) : (iSup f).toReal = ⨆ i, (f i).toReal := by |
simp only [ENNReal.toReal, toNNReal_iSup hf, NNReal.coe_iSup]
| 1 | 2.718282 | 0 | 0.857143 | 21 | 755 |
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.Index
import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.GroupTheory.GroupAction.Quotient
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.Tactic.IntervalCases
#align_import group_theory.p_group from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
open Fintype MulAction
variable (p : ℕ) (G : Type*) [Group G]
def IsPGroup : Prop :=
∀ g : G, ∃ k : ℕ, g ^ p ^ k = 1
#align is_p_group IsPGroup
variable {p} {G}
namespace IsPGroup
theorem iff_orderOf [hp : Fact p.Prime] : IsPGroup p G ↔ ∀ g : G, ∃ k : ℕ, orderOf g = p ^ k :=
forall_congr' fun g =>
⟨fun ⟨k, hk⟩ =>
Exists.imp (fun _ h => h.right)
((Nat.dvd_prime_pow hp.out).mp (orderOf_dvd_of_pow_eq_one hk)),
Exists.imp fun k hk => by rw [← hk, pow_orderOf_eq_one]⟩
#align is_p_group.iff_order_of IsPGroup.iff_orderOf
theorem of_card [Fintype G] {n : ℕ} (hG : card G = p ^ n) : IsPGroup p G := fun g =>
⟨n, by rw [← hG, pow_card_eq_one]⟩
#align is_p_group.of_card IsPGroup.of_card
theorem of_bot : IsPGroup p (⊥ : Subgroup G) :=
of_card (by rw [← Nat.card_eq_fintype_card, Subgroup.card_bot, pow_zero])
#align is_p_group.of_bot IsPGroup.of_bot
theorem iff_card [Fact p.Prime] [Fintype G] : IsPGroup p G ↔ ∃ n : ℕ, card G = p ^ n := by
have hG : card G ≠ 0 := card_ne_zero
refine ⟨fun h => ?_, fun ⟨n, hn⟩ => of_card hn⟩
suffices ∀ q ∈ Nat.factors (card G), q = p by
use (card G).factors.length
rw [← List.prod_replicate, ← List.eq_replicate_of_mem this, Nat.prod_factors hG]
intro q hq
obtain ⟨hq1, hq2⟩ := (Nat.mem_factors hG).mp hq
haveI : Fact q.Prime := ⟨hq1⟩
obtain ⟨g, hg⟩ := exists_prime_orderOf_dvd_card q hq2
obtain ⟨k, hk⟩ := (iff_orderOf.mp h) g
exact (hq1.pow_eq_iff.mp (hg.symm.trans hk).symm).1.symm
#align is_p_group.iff_card IsPGroup.iff_card
alias ⟨exists_card_eq, _⟩ := iff_card
section GIsPGroup
variable (hG : IsPGroup p G)
theorem of_injective {H : Type*} [Group H] (ϕ : H →* G) (hϕ : Function.Injective ϕ) :
IsPGroup p H := by
simp_rw [IsPGroup, ← hϕ.eq_iff, ϕ.map_pow, ϕ.map_one]
exact fun h => hG (ϕ h)
#align is_p_group.of_injective IsPGroup.of_injective
theorem to_subgroup (H : Subgroup G) : IsPGroup p H :=
hG.of_injective H.subtype Subtype.coe_injective
#align is_p_group.to_subgroup IsPGroup.to_subgroup
theorem of_surjective {H : Type*} [Group H] (ϕ : G →* H) (hϕ : Function.Surjective ϕ) :
IsPGroup p H := by
refine fun h => Exists.elim (hϕ h) fun g hg => Exists.imp (fun k hk => ?_) (hG g)
rw [← hg, ← ϕ.map_pow, hk, ϕ.map_one]
#align is_p_group.of_surjective IsPGroup.of_surjective
theorem to_quotient (H : Subgroup G) [H.Normal] : IsPGroup p (G ⧸ H) :=
hG.of_surjective (QuotientGroup.mk' H) Quotient.surjective_Quotient_mk''
#align is_p_group.to_quotient IsPGroup.to_quotient
theorem of_equiv {H : Type*} [Group H] (ϕ : G ≃* H) : IsPGroup p H :=
hG.of_surjective ϕ.toMonoidHom ϕ.surjective
#align is_p_group.of_equiv IsPGroup.of_equiv
theorem orderOf_coprime {n : ℕ} (hn : p.Coprime n) (g : G) : (orderOf g).Coprime n :=
let ⟨k, hk⟩ := hG g
(hn.pow_left k).coprime_dvd_left (orderOf_dvd_of_pow_eq_one hk)
#align is_p_group.order_of_coprime IsPGroup.orderOf_coprime
noncomputable def powEquiv {n : ℕ} (hn : p.Coprime n) : G ≃ G :=
let h : ∀ g : G, (Nat.card (Subgroup.zpowers g)).Coprime n := fun g =>
(Nat.card_zpowers g).symm ▸ hG.orderOf_coprime hn g
{ toFun := (· ^ n)
invFun := fun g => (powCoprime (h g)).symm ⟨g, Subgroup.mem_zpowers g⟩
left_inv := fun g =>
Subtype.ext_iff.1 <|
(powCoprime (h (g ^ n))).left_inv
⟨g, _, Subtype.ext_iff.1 <| (powCoprime (h g)).left_inv ⟨g, Subgroup.mem_zpowers g⟩⟩
right_inv := fun g =>
Subtype.ext_iff.1 <| (powCoprime (h g)).right_inv ⟨g, Subgroup.mem_zpowers g⟩ }
#align is_p_group.pow_equiv IsPGroup.powEquiv
@[simp]
theorem powEquiv_apply {n : ℕ} (hn : p.Coprime n) (g : G) : hG.powEquiv hn g = g ^ n :=
rfl
#align is_p_group.pow_equiv_apply IsPGroup.powEquiv_apply
@[simp]
| Mathlib/GroupTheory/PGroup.lean | 123 | 124 | theorem powEquiv_symm_apply {n : ℕ} (hn : p.Coprime n) (g : G) :
(hG.powEquiv hn).symm g = g ^ (orderOf g).gcdB n := by | rw [← Nat.card_zpowers]; rfl
| 1 | 2.718282 | 0 | 1 | 4 | 836 |
import Mathlib.Data.Finset.Fold
import Mathlib.Algebra.GCDMonoid.Multiset
#align_import algebra.gcd_monoid.finset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
#align_import algebra.gcd_monoid.div from "leanprover-community/mathlib"@"b537794f8409bc9598febb79cd510b1df5f4539d"
variable {ι α β γ : Type*}
namespace Finset
open Multiset
variable [CancelCommMonoidWithZero α] [NormalizedGCDMonoid α]
section gcd
def gcd (s : Finset β) (f : β → α) : α :=
s.fold GCDMonoid.gcd 0 f
#align finset.gcd Finset.gcd
variable {s s₁ s₂ : Finset β} {f : β → α}
theorem gcd_def : s.gcd f = (s.1.map f).gcd :=
rfl
#align finset.gcd_def Finset.gcd_def
@[simp]
theorem gcd_empty : (∅ : Finset β).gcd f = 0 :=
fold_empty
#align finset.gcd_empty Finset.gcd_empty
theorem dvd_gcd_iff {a : α} : a ∣ s.gcd f ↔ ∀ b ∈ s, a ∣ f b := by
apply Iff.trans Multiset.dvd_gcd
simp only [Multiset.mem_map, and_imp, exists_imp]
exact ⟨fun k b hb ↦ k _ _ hb rfl, fun k a' b hb h ↦ h ▸ k _ hb⟩
#align finset.dvd_gcd_iff Finset.dvd_gcd_iff
theorem gcd_dvd {b : β} (hb : b ∈ s) : s.gcd f ∣ f b :=
dvd_gcd_iff.1 dvd_rfl _ hb
#align finset.gcd_dvd Finset.gcd_dvd
theorem dvd_gcd {a : α} : (∀ b ∈ s, a ∣ f b) → a ∣ s.gcd f :=
dvd_gcd_iff.2
#align finset.dvd_gcd Finset.dvd_gcd
@[simp]
theorem gcd_insert [DecidableEq β] {b : β} :
(insert b s : Finset β).gcd f = GCDMonoid.gcd (f b) (s.gcd f) := by
by_cases h : b ∈ s
· rw [insert_eq_of_mem h,
(gcd_eq_right_iff (f b) (s.gcd f) (Multiset.normalize_gcd (s.1.map f))).2 (gcd_dvd h)]
apply fold_insert h
#align finset.gcd_insert Finset.gcd_insert
@[simp]
theorem gcd_singleton {b : β} : ({b} : Finset β).gcd f = normalize (f b) :=
Multiset.gcd_singleton
#align finset.gcd_singleton Finset.gcd_singleton
-- Porting note: Priority changed for `simpNF`
@[simp 1100]
| Mathlib/Algebra/GCDMonoid/Finset.lean | 181 | 181 | theorem normalize_gcd : normalize (s.gcd f) = s.gcd f := by | simp [gcd_def]
| 1 | 2.718282 | 0 | 1 | 13 | 925 |
import Mathlib.Algebra.Polynomial.Splits
#align_import algebra.cubic_discriminant from "leanprover-community/mathlib"@"930133160e24036d5242039fe4972407cd4f1222"
noncomputable section
@[ext]
structure Cubic (R : Type*) where
(a b c d : R)
#align cubic Cubic
namespace Cubic
open Cubic Polynomial
open Polynomial
variable {R S F K : Type*}
instance [Inhabited R] : Inhabited (Cubic R) :=
⟨⟨default, default, default, default⟩⟩
instance [Zero R] : Zero (Cubic R) :=
⟨⟨0, 0, 0, 0⟩⟩
section Basic
variable {P Q : Cubic R} {a b c d a' b' c' d' : R} [Semiring R]
def toPoly (P : Cubic R) : R[X] :=
C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d
#align cubic.to_poly Cubic.toPoly
theorem C_mul_prod_X_sub_C_eq [CommRing S] {w x y z : S} :
C w * (X - C x) * (X - C y) * (X - C z) =
toPoly ⟨w, w * -(x + y + z), w * (x * y + x * z + y * z), w * -(x * y * z)⟩ := by
simp only [toPoly, C_neg, C_add, C_mul]
ring1
set_option linter.uppercaseLean3 false in
#align cubic.C_mul_prod_X_sub_C_eq Cubic.C_mul_prod_X_sub_C_eq
theorem prod_X_sub_C_eq [CommRing S] {x y z : S} :
(X - C x) * (X - C y) * (X - C z) =
toPoly ⟨1, -(x + y + z), x * y + x * z + y * z, -(x * y * z)⟩ := by
rw [← one_mul <| X - C x, ← C_1, C_mul_prod_X_sub_C_eq, one_mul, one_mul, one_mul]
set_option linter.uppercaseLean3 false in
#align cubic.prod_X_sub_C_eq Cubic.prod_X_sub_C_eq
section Coeff
private theorem coeffs : (∀ n > 3, P.toPoly.coeff n = 0) ∧ P.toPoly.coeff 3 = P.a ∧
P.toPoly.coeff 2 = P.b ∧ P.toPoly.coeff 1 = P.c ∧ P.toPoly.coeff 0 = P.d := by
simp only [toPoly, coeff_add, coeff_C, coeff_C_mul_X, coeff_C_mul_X_pow]
set_option tactic.skipAssignedInstances false in norm_num
intro n hn
repeat' rw [if_neg]
any_goals linarith only [hn]
repeat' rw [zero_add]
@[simp]
theorem coeff_eq_zero {n : ℕ} (hn : 3 < n) : P.toPoly.coeff n = 0 :=
coeffs.1 n hn
#align cubic.coeff_eq_zero Cubic.coeff_eq_zero
@[simp]
theorem coeff_eq_a : P.toPoly.coeff 3 = P.a :=
coeffs.2.1
#align cubic.coeff_eq_a Cubic.coeff_eq_a
@[simp]
theorem coeff_eq_b : P.toPoly.coeff 2 = P.b :=
coeffs.2.2.1
#align cubic.coeff_eq_b Cubic.coeff_eq_b
@[simp]
theorem coeff_eq_c : P.toPoly.coeff 1 = P.c :=
coeffs.2.2.2.1
#align cubic.coeff_eq_c Cubic.coeff_eq_c
@[simp]
theorem coeff_eq_d : P.toPoly.coeff 0 = P.d :=
coeffs.2.2.2.2
#align cubic.coeff_eq_d Cubic.coeff_eq_d
theorem a_of_eq (h : P.toPoly = Q.toPoly) : P.a = Q.a := by rw [← coeff_eq_a, h, coeff_eq_a]
#align cubic.a_of_eq Cubic.a_of_eq
theorem b_of_eq (h : P.toPoly = Q.toPoly) : P.b = Q.b := by rw [← coeff_eq_b, h, coeff_eq_b]
#align cubic.b_of_eq Cubic.b_of_eq
theorem c_of_eq (h : P.toPoly = Q.toPoly) : P.c = Q.c := by rw [← coeff_eq_c, h, coeff_eq_c]
#align cubic.c_of_eq Cubic.c_of_eq
theorem d_of_eq (h : P.toPoly = Q.toPoly) : P.d = Q.d := by rw [← coeff_eq_d, h, coeff_eq_d]
#align cubic.d_of_eq Cubic.d_of_eq
theorem toPoly_injective (P Q : Cubic R) : P.toPoly = Q.toPoly ↔ P = Q :=
⟨fun h ↦ Cubic.ext P Q (a_of_eq h) (b_of_eq h) (c_of_eq h) (d_of_eq h), congr_arg toPoly⟩
#align cubic.to_poly_injective Cubic.toPoly_injective
theorem of_a_eq_zero (ha : P.a = 0) : P.toPoly = C P.b * X ^ 2 + C P.c * X + C P.d := by
rw [toPoly, ha, C_0, zero_mul, zero_add]
#align cubic.of_a_eq_zero Cubic.of_a_eq_zero
theorem of_a_eq_zero' : toPoly ⟨0, b, c, d⟩ = C b * X ^ 2 + C c * X + C d :=
of_a_eq_zero rfl
#align cubic.of_a_eq_zero' Cubic.of_a_eq_zero'
| Mathlib/Algebra/CubicDiscriminant.lean | 145 | 146 | theorem of_b_eq_zero (ha : P.a = 0) (hb : P.b = 0) : P.toPoly = C P.c * X + C P.d := by |
rw [of_a_eq_zero ha, hb, C_0, zero_mul, zero_add]
| 1 | 2.718282 | 0 | 0.1 | 10 | 246 |
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"
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)
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]
| 1 | 2.718282 | 0 | 0 | 1 | 197 |
import Mathlib.Combinatorics.SimpleGraph.Connectivity
import Mathlib.Data.Nat.Lattice
#align_import combinatorics.simple_graph.metric from "leanprover-community/mathlib"@"352ecfe114946c903338006dd3287cb5a9955ff2"
namespace SimpleGraph
variable {V : Type*} (G : SimpleGraph V)
noncomputable def dist (u v : V) : ℕ :=
sInf (Set.range (Walk.length : G.Walk u v → ℕ))
#align simple_graph.dist SimpleGraph.dist
variable {G}
protected theorem Reachable.exists_walk_of_dist {u v : V} (hr : G.Reachable u v) :
∃ p : G.Walk u v, p.length = G.dist u v :=
Nat.sInf_mem (Set.range_nonempty_iff_nonempty.mpr hr)
#align simple_graph.reachable.exists_walk_of_dist SimpleGraph.Reachable.exists_walk_of_dist
protected theorem Connected.exists_walk_of_dist (hconn : G.Connected) (u v : V) :
∃ p : G.Walk u v, p.length = G.dist u v :=
(hconn u v).exists_walk_of_dist
#align simple_graph.connected.exists_walk_of_dist SimpleGraph.Connected.exists_walk_of_dist
theorem dist_le {u v : V} (p : G.Walk u v) : G.dist u v ≤ p.length :=
Nat.sInf_le ⟨p, rfl⟩
#align simple_graph.dist_le SimpleGraph.dist_le
@[simp]
theorem dist_eq_zero_iff_eq_or_not_reachable {u v : V} :
G.dist u v = 0 ↔ u = v ∨ ¬G.Reachable u v := by simp [dist, Nat.sInf_eq_zero, Reachable]
#align simple_graph.dist_eq_zero_iff_eq_or_not_reachable SimpleGraph.dist_eq_zero_iff_eq_or_not_reachable
theorem dist_self {v : V} : dist G v v = 0 := by simp
#align simple_graph.dist_self SimpleGraph.dist_self
protected theorem Reachable.dist_eq_zero_iff {u v : V} (hr : G.Reachable u v) :
G.dist u v = 0 ↔ u = v := by simp [hr]
#align simple_graph.reachable.dist_eq_zero_iff SimpleGraph.Reachable.dist_eq_zero_iff
protected theorem Reachable.pos_dist_of_ne {u v : V} (h : G.Reachable u v) (hne : u ≠ v) :
0 < G.dist u v :=
Nat.pos_of_ne_zero (by simp [h, hne])
#align simple_graph.reachable.pos_dist_of_ne SimpleGraph.Reachable.pos_dist_of_ne
protected theorem Connected.dist_eq_zero_iff (hconn : G.Connected) {u v : V} :
G.dist u v = 0 ↔ u = v := by simp [hconn u v]
#align simple_graph.connected.dist_eq_zero_iff SimpleGraph.Connected.dist_eq_zero_iff
protected theorem Connected.pos_dist_of_ne {u v : V} (hconn : G.Connected) (hne : u ≠ v) :
0 < G.dist u v :=
Nat.pos_of_ne_zero (by intro h; exact False.elim (hne (hconn.dist_eq_zero_iff.mp h)))
#align simple_graph.connected.pos_dist_of_ne SimpleGraph.Connected.pos_dist_of_ne
| Mathlib/Combinatorics/SimpleGraph/Metric.lean | 95 | 96 | theorem dist_eq_zero_of_not_reachable {u v : V} (h : ¬G.Reachable u v) : G.dist u v = 0 := by |
simp [h]
| 1 | 2.718282 | 0 | 1 | 7 | 1,136 |
import Mathlib.Init.Logic
import Mathlib.Tactic.AdaptationNote
import Mathlib.Tactic.Coe
set_option autoImplicit true
-- We align Lean 3 lemmas with lemmas in `Init.SimpLemmas` in Lean 4.
#align band_self Bool.and_self
#align band_tt Bool.and_true
#align band_ff Bool.and_false
#align tt_band Bool.true_and
#align ff_band Bool.false_and
#align bor_self Bool.or_self
#align bor_tt Bool.or_true
#align bor_ff Bool.or_false
#align tt_bor Bool.true_or
#align ff_bor Bool.false_or
#align bnot_bnot Bool.not_not
namespace Bool
#align bool.cond_tt Bool.cond_true
#align bool.cond_ff Bool.cond_false
#align cond_a_a Bool.cond_self
attribute [simp] xor_self
#align bxor_self Bool.xor_self
#align bxor_tt Bool.xor_true
#align bxor_ff Bool.xor_false
#align tt_bxor Bool.true_xor
#align ff_bxor Bool.false_xor
theorem true_eq_false_eq_False : ¬true = false := by decide
#align tt_eq_ff_eq_false Bool.true_eq_false_eq_False
theorem false_eq_true_eq_False : ¬false = true := by decide
#align ff_eq_tt_eq_false Bool.false_eq_true_eq_False
theorem eq_false_eq_not_eq_true (b : Bool) : (¬b = true) = (b = false) := by simp
#align eq_ff_eq_not_eq_tt Bool.eq_false_eq_not_eq_true
theorem eq_true_eq_not_eq_false (b : Bool) : (¬b = false) = (b = true) := by simp
#align eq_tt_eq_not_eq_ft Bool.eq_true_eq_not_eq_false
theorem eq_false_of_not_eq_true {b : Bool} : ¬b = true → b = false :=
Eq.mp (eq_false_eq_not_eq_true b)
#align eq_ff_of_not_eq_tt Bool.eq_false_of_not_eq_true
theorem eq_true_of_not_eq_false {b : Bool} : ¬b = false → b = true :=
Eq.mp (eq_true_eq_not_eq_false b)
#align eq_tt_of_not_eq_ff Bool.eq_true_of_not_eq_false
theorem and_eq_true_eq_eq_true_and_eq_true (a b : Bool) :
((a && b) = true) = (a = true ∧ b = true) := by simp
#align band_eq_true_eq_eq_tt_and_eq_tt Bool.and_eq_true_eq_eq_true_and_eq_true
| Mathlib/Init/Data/Bool/Lemmas.lean | 72 | 73 | theorem or_eq_true_eq_eq_true_or_eq_true (a b : Bool) :
((a || b) = true) = (a = true ∨ b = true) := by | simp
| 1 | 2.718282 | 0 | 0 | 7 | 206 |
import Mathlib.Probability.Kernel.Disintegration.Unique
import Mathlib.Probability.Notation
#align_import probability.kernel.cond_distrib from "leanprover-community/mathlib"@"00abe0695d8767201e6d008afa22393978bb324d"
open MeasureTheory Set Filter TopologicalSpace
open scoped ENNReal MeasureTheory ProbabilityTheory
namespace ProbabilityTheory
variable {α β Ω F : Type*} [MeasurableSpace Ω] [StandardBorelSpace Ω]
[Nonempty Ω] [NormedAddCommGroup F] {mα : MeasurableSpace α} {μ : Measure α} [IsFiniteMeasure μ]
{X : α → β} {Y : α → Ω}
noncomputable irreducible_def condDistrib {_ : MeasurableSpace α} [MeasurableSpace β] (Y : α → Ω)
(X : α → β) (μ : Measure α) [IsFiniteMeasure μ] : kernel β Ω :=
(μ.map fun a => (X a, Y a)).condKernel
#align probability_theory.cond_distrib ProbabilityTheory.condDistrib
instance [MeasurableSpace β] : IsMarkovKernel (condDistrib Y X μ) := by
rw [condDistrib]; infer_instance
variable {mβ : MeasurableSpace β} {s : Set Ω} {t : Set β} {f : β × Ω → F}
lemma condDistrib_apply_of_ne_zero [MeasurableSingletonClass β]
(hY : Measurable Y) (x : β) (hX : μ.map X {x} ≠ 0) (s : Set Ω) :
condDistrib Y X μ x s = (μ.map X {x})⁻¹ * μ.map (fun a => (X a, Y a)) ({x} ×ˢ s) := by
rw [condDistrib, Measure.condKernel_apply_of_ne_zero _ s]
· rw [Measure.fst_map_prod_mk hY]
· rwa [Measure.fst_map_prod_mk hY]
section Measurability
theorem measurable_condDistrib (hs : MeasurableSet s) :
Measurable[mβ.comap X] fun a => condDistrib Y X μ (X a) s :=
(kernel.measurable_coe _ hs).comp (Measurable.of_comap_le le_rfl)
#align probability_theory.measurable_cond_distrib ProbabilityTheory.measurable_condDistrib
theorem _root_.MeasureTheory.AEStronglyMeasurable.ae_integrable_condDistrib_map_iff
(hY : AEMeasurable Y μ) (hf : AEStronglyMeasurable f (μ.map fun a => (X a, Y a))) :
(∀ᵐ a ∂μ.map X, Integrable (fun ω => f (a, ω)) (condDistrib Y X μ a)) ∧
Integrable (fun a => ∫ ω, ‖f (a, ω)‖ ∂condDistrib Y X μ a) (μ.map X) ↔
Integrable f (μ.map fun a => (X a, Y a)) := by
rw [condDistrib, ← hf.ae_integrable_condKernel_iff, Measure.fst_map_prod_mk₀ hY]
#align measure_theory.ae_strongly_measurable.ae_integrable_cond_distrib_map_iff MeasureTheory.AEStronglyMeasurable.ae_integrable_condDistrib_map_iff
variable [NormedSpace ℝ F] [CompleteSpace F]
| Mathlib/Probability/Kernel/CondDistrib.lean | 98 | 101 | theorem _root_.MeasureTheory.AEStronglyMeasurable.integral_condDistrib_map
(hY : AEMeasurable Y μ) (hf : AEStronglyMeasurable f (μ.map fun a => (X a, Y a))) :
AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂condDistrib Y X μ x) (μ.map X) := by |
rw [← Measure.fst_map_prod_mk₀ hY, condDistrib]; exact hf.integral_condKernel
| 1 | 2.718282 | 0 | 0.777778 | 9 | 692 |
import Mathlib.RingTheory.Localization.Basic
#align_import ring_theory.localization.integer from "leanprover-community/mathlib"@"9556784a5b84697562e9c6acb40500d4a82e675a"
variable {R : Type*} [CommSemiring R] {M : Submonoid R} {S : Type*} [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
open Function
namespace IsLocalization
section
variable (R)
-- TODO: define a subalgebra of `IsInteger`s
def IsInteger (a : S) : Prop :=
a ∈ (algebraMap R S).rangeS
#align is_localization.is_integer IsLocalization.IsInteger
end
theorem isInteger_zero : IsInteger R (0 : S) :=
Subsemiring.zero_mem _
#align is_localization.is_integer_zero IsLocalization.isInteger_zero
theorem isInteger_one : IsInteger R (1 : S) :=
Subsemiring.one_mem _
#align is_localization.is_integer_one IsLocalization.isInteger_one
theorem isInteger_add {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a + b) :=
Subsemiring.add_mem _ ha hb
#align is_localization.is_integer_add IsLocalization.isInteger_add
theorem isInteger_mul {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a * b) :=
Subsemiring.mul_mem _ ha hb
#align is_localization.is_integer_mul IsLocalization.isInteger_mul
theorem isInteger_smul {a : R} {b : S} (hb : IsInteger R b) : IsInteger R (a • b) := by
rcases hb with ⟨b', hb⟩
use a * b'
rw [← hb, (algebraMap R S).map_mul, Algebra.smul_def]
#align is_localization.is_integer_smul IsLocalization.isInteger_smul
variable (M)
variable [IsLocalization M S]
theorem exists_integer_multiple' (a : S) : ∃ b : M, IsInteger R (a * algebraMap R S b) :=
let ⟨⟨Num, denom⟩, h⟩ := IsLocalization.surj _ a
⟨denom, Set.mem_range.mpr ⟨Num, h.symm⟩⟩
#align is_localization.exists_integer_multiple' IsLocalization.exists_integer_multiple'
| Mathlib/RingTheory/Localization/Integer.lean | 85 | 87 | theorem exists_integer_multiple (a : S) : ∃ b : M, IsInteger R ((b : R) • a) := by |
simp_rw [Algebra.smul_def, mul_comm _ a]
apply exists_integer_multiple'
| 2 | 7.389056 | 1 | 1.4 | 5 | 1,499 |
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Data.Fintype.Card
import Mathlib.GroupTheory.Perm.Basic
#align_import group_theory.perm.support from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
open Equiv Finset
namespace Equiv.Perm
variable {α : Type*}
section support
variable [DecidableEq α] [Fintype α] {f g : Perm α}
def support (f : Perm α) : Finset α :=
univ.filter fun x => f x ≠ x
#align equiv.perm.support Equiv.Perm.support
@[simp]
theorem mem_support {x : α} : x ∈ f.support ↔ f x ≠ x := by
rw [support, mem_filter, and_iff_right (mem_univ x)]
#align equiv.perm.mem_support Equiv.Perm.mem_support
| Mathlib/GroupTheory/Perm/Support.lean | 301 | 301 | theorem not_mem_support {x : α} : x ∉ f.support ↔ f x = x := by | simp
| 1 | 2.718282 | 0 | 0.944444 | 18 | 795 |
import Mathlib.Analysis.SpecialFunctions.Complex.Arg
import Mathlib.Analysis.SpecialFunctions.Log.Basic
#align_import analysis.special_functions.complex.log from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
namespace Complex
open Set Filter Bornology
open scoped Real Topology ComplexConjugate
-- Porting note: @[pp_nodot] does not exist in mathlib4
noncomputable def log (x : ℂ) : ℂ :=
x.abs.log + arg x * I
#align complex.log Complex.log
theorem log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log]
#align complex.log_re Complex.log_re
theorem log_im (x : ℂ) : x.log.im = x.arg := by simp [log]
#align complex.log_im Complex.log_im
theorem neg_pi_lt_log_im (x : ℂ) : -π < (log x).im := by simp only [log_im, neg_pi_lt_arg]
#align complex.neg_pi_lt_log_im Complex.neg_pi_lt_log_im
theorem log_im_le_pi (x : ℂ) : (log x).im ≤ π := by simp only [log_im, arg_le_pi]
#align complex.log_im_le_pi Complex.log_im_le_pi
theorem exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x := by
rw [log, exp_add_mul_I, ← ofReal_sin, sin_arg, ← ofReal_cos, cos_arg hx, ← ofReal_exp,
Real.exp_log (abs.pos hx), mul_add, ofReal_div, ofReal_div,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), ← mul_assoc,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), re_add_im]
#align complex.exp_log Complex.exp_log
@[simp]
theorem range_exp : Set.range exp = {0}ᶜ :=
Set.ext fun x =>
⟨by
rintro ⟨x, rfl⟩
exact exp_ne_zero x, fun hx => ⟨log x, exp_log hx⟩⟩
#align complex.range_exp Complex.range_exp
theorem log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) : log (exp x) = x := by
rw [log, abs_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, ← ofReal_exp,
arg_mul_cos_add_sin_mul_I (Real.exp_pos _) ⟨hx₁, hx₂⟩, re_add_im]
#align complex.log_exp Complex.log_exp
theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) (hy₁ : -π < y.im)
(hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y := by
rw [← log_exp hx₁ hx₂, ← log_exp hy₁ hy₂, hxy]
#align complex.exp_inj_of_neg_pi_lt_of_le_pi Complex.exp_inj_of_neg_pi_lt_of_le_pi
theorem ofReal_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x :=
Complex.ext (by rw [log_re, ofReal_re, abs_of_nonneg hx])
(by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx])
#align complex.of_real_log Complex.ofReal_log
@[simp, norm_cast]
lemma natCast_log {n : ℕ} : Real.log n = log n := ofReal_natCast n ▸ ofReal_log n.cast_nonneg
@[simp]
lemma ofNat_log {n : ℕ} [n.AtLeastTwo] :
Real.log (no_index (OfNat.ofNat n)) = log (OfNat.ofNat n) :=
natCast_log
theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by simp [log_re]
#align complex.log_of_real_re Complex.log_ofReal_re
theorem log_ofReal_mul {r : ℝ} (hr : 0 < r) {x : ℂ} (hx : x ≠ 0) :
log (r * x) = Real.log r + log x := by
replace hx := Complex.abs.ne_zero_iff.mpr hx
simp_rw [log, map_mul, abs_ofReal, arg_real_mul _ hr, abs_of_pos hr, Real.log_mul hr.ne' hx,
ofReal_add, add_assoc]
#align complex.log_of_real_mul Complex.log_ofReal_mul
theorem log_mul_ofReal (r : ℝ) (hr : 0 < r) (x : ℂ) (hx : x ≠ 0) :
log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx]
#align complex.log_mul_of_real Complex.log_mul_ofReal
lemma log_mul_eq_add_log_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
log (x * y) = log x + log y ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
refine ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hx₀ hy₀
simp_rw [add_re, add_im, log_re, log_im, AbsoluteValue.map_mul,
Real.log_mul (abs.ne_zero hx₀) (abs.ne_zero hy₀), true_and]
alias ⟨_, log_mul⟩ := log_mul_eq_add_log_iff
@[simp]
theorem log_zero : log 0 = 0 := by simp [log]
#align complex.log_zero Complex.log_zero
@[simp]
theorem log_one : log 1 = 0 := by simp [log]
#align complex.log_one Complex.log_one
theorem log_neg_one : log (-1) = π * I := by simp [log]
#align complex.log_neg_one Complex.log_neg_one
theorem log_I : log I = π / 2 * I := by simp [log]
set_option linter.uppercaseLean3 false in
#align complex.log_I Complex.log_I
| Mathlib/Analysis/SpecialFunctions/Complex/Log.lean | 120 | 120 | theorem log_neg_I : log (-I) = -(π / 2) * I := by | simp [log]
| 1 | 2.718282 | 0 | 0.375 | 16 | 378 |
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Int.GCD
import Mathlib.RingTheory.Coprime.Basic
#align_import ring_theory.coprime.lemmas from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
universe u v
section RelPrime
variable {α I} [CommMonoid α] [DecompositionMonoid α] {x y z : α} {s : I → α} {t : Finset I}
theorem IsRelPrime.prod_left : (∀ i ∈ t, IsRelPrime (s i) x) → IsRelPrime (∏ i ∈ t, s i) x := by
classical
refine Finset.induction_on t (fun _ ↦ isRelPrime_one_left) fun b t hbt ih H ↦ ?_
rw [Finset.prod_insert hbt]
rw [Finset.forall_mem_insert] at H
exact H.1.mul_left (ih H.2)
theorem IsRelPrime.prod_right : (∀ i ∈ t, IsRelPrime x (s i)) → IsRelPrime x (∏ i ∈ t, s i) := by
simpa only [isRelPrime_comm] using IsRelPrime.prod_left (α := α)
theorem IsRelPrime.prod_left_iff : IsRelPrime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsRelPrime (s i) x := by
classical
refine Finset.induction_on t (iff_of_true isRelPrime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_
rw [Finset.prod_insert hbt, IsRelPrime.mul_left_iff, ih, Finset.forall_mem_insert]
| Mathlib/RingTheory/Coprime/Lemmas.lean | 250 | 251 | theorem IsRelPrime.prod_right_iff : IsRelPrime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsRelPrime x (s i) := by |
simpa only [isRelPrime_comm] using IsRelPrime.prod_left_iff (α := α)
| 1 | 2.718282 | 0 | 1.111111 | 18 | 1,195 |
import Mathlib.Algebra.CharP.ExpChar
import Mathlib.GroupTheory.OrderOfElement
#align_import algebra.char_p.two from "leanprover-community/mathlib"@"7f1ba1a333d66eed531ecb4092493cd1b6715450"
variable {R ι : Type*}
namespace CharTwo
section Semiring
variable [Semiring R] [CharP R 2]
| Mathlib/Algebra/CharP/Two.lean | 29 | 29 | theorem two_eq_zero : (2 : R) = 0 := by | rw [← Nat.cast_two, CharP.cast_eq_zero]
| 1 | 2.718282 | 0 | 0.2 | 10 | 273 |
import Mathlib.Order.Interval.Multiset
#align_import data.nat.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29"
-- TODO
-- assert_not_exists Ring
open Finset Nat
variable (a b c : ℕ)
namespace Nat
instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ where
finsetIcc a b := ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩
finsetIco a b := ⟨List.range' a (b - a), List.nodup_range' _ _⟩
finsetIoc a b := ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩
finsetIoo a b := ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩
finset_mem_Icc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega
finset_mem_Ico a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega
finset_mem_Ioc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega
finset_mem_Ioo a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega
theorem Icc_eq_range' : Icc a b = ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩ :=
rfl
#align nat.Icc_eq_range' Nat.Icc_eq_range'
theorem Ico_eq_range' : Ico a b = ⟨List.range' a (b - a), List.nodup_range' _ _⟩ :=
rfl
#align nat.Ico_eq_range' Nat.Ico_eq_range'
theorem Ioc_eq_range' : Ioc a b = ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩ :=
rfl
#align nat.Ioc_eq_range' Nat.Ioc_eq_range'
theorem Ioo_eq_range' : Ioo a b = ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩ :=
rfl
#align nat.Ioo_eq_range' Nat.Ioo_eq_range'
theorem uIcc_eq_range' :
uIcc a b = ⟨List.range' (min a b) (max a b + 1 - min a b), List.nodup_range' _ _⟩ := rfl
#align nat.uIcc_eq_range' Nat.uIcc_eq_range'
theorem Iio_eq_range : Iio = range := by
ext b x
rw [mem_Iio, mem_range]
#align nat.Iio_eq_range Nat.Iio_eq_range
@[simp]
theorem Ico_zero_eq_range : Ico 0 = range := by rw [← Nat.bot_eq_zero, ← Iio_eq_Ico, Iio_eq_range]
#align nat.Ico_zero_eq_range Nat.Ico_zero_eq_range
lemma range_eq_Icc_zero_sub_one (n : ℕ) (hn : n ≠ 0): range n = Icc 0 (n - 1) := by
ext b
simp_all only [mem_Icc, zero_le, true_and, mem_range]
exact lt_iff_le_pred (zero_lt_of_ne_zero hn)
theorem _root_.Finset.range_eq_Ico : range = Ico 0 :=
Ico_zero_eq_range.symm
#align finset.range_eq_Ico Finset.range_eq_Ico
@[simp]
theorem card_Icc : (Icc a b).card = b + 1 - a :=
List.length_range' _ _ _
#align nat.card_Icc Nat.card_Icc
@[simp]
theorem card_Ico : (Ico a b).card = b - a :=
List.length_range' _ _ _
#align nat.card_Ico Nat.card_Ico
@[simp]
theorem card_Ioc : (Ioc a b).card = b - a :=
List.length_range' _ _ _
#align nat.card_Ioc Nat.card_Ioc
@[simp]
theorem card_Ioo : (Ioo a b).card = b - a - 1 :=
List.length_range' _ _ _
#align nat.card_Ioo Nat.card_Ioo
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 :=
(card_Icc _ _).trans $ by rw [← Int.natCast_inj, sup_eq_max, inf_eq_min, Int.ofNat_sub] <;> omega
#align nat.card_uIcc Nat.card_uIcc
@[simp]
lemma card_Iic : (Iic b).card = b + 1 := by rw [Iic_eq_Icc, card_Icc, Nat.bot_eq_zero, Nat.sub_zero]
#align nat.card_Iic Nat.card_Iic
@[simp]
theorem card_Iio : (Iio b).card = b := by rw [Iio_eq_Ico, card_Ico, Nat.bot_eq_zero, Nat.sub_zero]
#align nat.card_Iio Nat.card_Iio
-- Porting note (#10618): simp can prove this
-- @[simp]
| Mathlib/Order/Interval/Finset/Nat.lean | 114 | 115 | theorem card_fintypeIcc : Fintype.card (Set.Icc a b) = b + 1 - a := by |
rw [Fintype.card_ofFinset, card_Icc]
| 1 | 2.718282 | 0 | 0.125 | 8 | 253 |
import Mathlib.Analysis.Convex.Side
import Mathlib.Geometry.Euclidean.Angle.Oriented.Rotation
import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
#align_import geometry.euclidean.angle.oriented.affine from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open FiniteDimensional Complex
open scoped Affine EuclideanGeometry Real RealInnerProductSpace ComplexConjugate
namespace EuclideanGeometry
variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P] [hd2 : Fact (finrank ℝ V = 2)] [Module.Oriented ℝ V (Fin 2)]
abbrev o := @Module.Oriented.positiveOrientation
def oangle (p₁ p₂ p₃ : P) : Real.Angle :=
o.oangle (p₁ -ᵥ p₂) (p₃ -ᵥ p₂)
#align euclidean_geometry.oangle EuclideanGeometry.oangle
@[inherit_doc] scoped notation "∡" => EuclideanGeometry.oangle
theorem continuousAt_oangle {x : P × P × P} (hx12 : x.1 ≠ x.2.1) (hx32 : x.2.2 ≠ x.2.1) :
ContinuousAt (fun y : P × P × P => ∡ y.1 y.2.1 y.2.2) x := by
let f : P × P × P → V × V := fun y => (y.1 -ᵥ y.2.1, y.2.2 -ᵥ y.2.1)
have hf1 : (f x).1 ≠ 0 := by simp [hx12]
have hf2 : (f x).2 ≠ 0 := by simp [hx32]
exact (o.continuousAt_oangle hf1 hf2).comp ((continuous_fst.vsub continuous_snd.fst).prod_mk
(continuous_snd.snd.vsub continuous_snd.fst)).continuousAt
#align euclidean_geometry.continuous_at_oangle EuclideanGeometry.continuousAt_oangle
@[simp]
theorem oangle_self_left (p₁ p₂ : P) : ∡ p₁ p₁ p₂ = 0 := by simp [oangle]
#align euclidean_geometry.oangle_self_left EuclideanGeometry.oangle_self_left
@[simp]
theorem oangle_self_right (p₁ p₂ : P) : ∡ p₁ p₂ p₂ = 0 := by simp [oangle]
#align euclidean_geometry.oangle_self_right EuclideanGeometry.oangle_self_right
@[simp]
theorem oangle_self_left_right (p₁ p₂ : P) : ∡ p₁ p₂ p₁ = 0 :=
o.oangle_self _
#align euclidean_geometry.oangle_self_left_right EuclideanGeometry.oangle_self_left_right
theorem left_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₂ := by
rw [← @vsub_ne_zero V]; exact o.left_ne_zero_of_oangle_ne_zero h
#align euclidean_geometry.left_ne_of_oangle_ne_zero EuclideanGeometry.left_ne_of_oangle_ne_zero
| Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean | 80 | 81 | theorem right_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₃ ≠ p₂ := by |
rw [← @vsub_ne_zero V]; exact o.right_ne_zero_of_oangle_ne_zero h
| 1 | 2.718282 | 0 | 0.333333 | 6 | 356 |
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Order.Hom.Set
#align_import data.set.intervals.order_iso from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105"
open Set
namespace OrderIso
section Preorder
variable {α β : Type*} [Preorder α] [Preorder β]
@[simp]
theorem preimage_Iic (e : α ≃o β) (b : β) : e ⁻¹' Iic b = Iic (e.symm b) := by
ext x
simp [← e.le_iff_le]
#align order_iso.preimage_Iic OrderIso.preimage_Iic
@[simp]
theorem preimage_Ici (e : α ≃o β) (b : β) : e ⁻¹' Ici b = Ici (e.symm b) := by
ext x
simp [← e.le_iff_le]
#align order_iso.preimage_Ici OrderIso.preimage_Ici
@[simp]
theorem preimage_Iio (e : α ≃o β) (b : β) : e ⁻¹' Iio b = Iio (e.symm b) := by
ext x
simp [← e.lt_iff_lt]
#align order_iso.preimage_Iio OrderIso.preimage_Iio
@[simp]
theorem preimage_Ioi (e : α ≃o β) (b : β) : e ⁻¹' Ioi b = Ioi (e.symm b) := by
ext x
simp [← e.lt_iff_lt]
#align order_iso.preimage_Ioi OrderIso.preimage_Ioi
@[simp]
theorem preimage_Icc (e : α ≃o β) (a b : β) : e ⁻¹' Icc a b = Icc (e.symm a) (e.symm b) := by
simp [← Ici_inter_Iic]
#align order_iso.preimage_Icc OrderIso.preimage_Icc
@[simp]
theorem preimage_Ico (e : α ≃o β) (a b : β) : e ⁻¹' Ico a b = Ico (e.symm a) (e.symm b) := by
simp [← Ici_inter_Iio]
#align order_iso.preimage_Ico OrderIso.preimage_Ico
@[simp]
theorem preimage_Ioc (e : α ≃o β) (a b : β) : e ⁻¹' Ioc a b = Ioc (e.symm a) (e.symm b) := by
simp [← Ioi_inter_Iic]
#align order_iso.preimage_Ioc OrderIso.preimage_Ioc
@[simp]
theorem preimage_Ioo (e : α ≃o β) (a b : β) : e ⁻¹' Ioo a b = Ioo (e.symm a) (e.symm b) := by
simp [← Ioi_inter_Iio]
#align order_iso.preimage_Ioo OrderIso.preimage_Ioo
@[simp]
theorem image_Iic (e : α ≃o β) (a : α) : e '' Iic a = Iic (e a) := by
rw [e.image_eq_preimage, e.symm.preimage_Iic, e.symm_symm]
#align order_iso.image_Iic OrderIso.image_Iic
@[simp]
theorem image_Ici (e : α ≃o β) (a : α) : e '' Ici a = Ici (e a) :=
e.dual.image_Iic a
#align order_iso.image_Ici OrderIso.image_Ici
@[simp]
theorem image_Iio (e : α ≃o β) (a : α) : e '' Iio a = Iio (e a) := by
rw [e.image_eq_preimage, e.symm.preimage_Iio, e.symm_symm]
#align order_iso.image_Iio OrderIso.image_Iio
@[simp]
theorem image_Ioi (e : α ≃o β) (a : α) : e '' Ioi a = Ioi (e a) :=
e.dual.image_Iio a
#align order_iso.image_Ioi OrderIso.image_Ioi
@[simp]
theorem image_Ioo (e : α ≃o β) (a b : α) : e '' Ioo a b = Ioo (e a) (e b) := by
rw [e.image_eq_preimage, e.symm.preimage_Ioo, e.symm_symm]
#align order_iso.image_Ioo OrderIso.image_Ioo
@[simp]
theorem image_Ioc (e : α ≃o β) (a b : α) : e '' Ioc a b = Ioc (e a) (e b) := by
rw [e.image_eq_preimage, e.symm.preimage_Ioc, e.symm_symm]
#align order_iso.image_Ioc OrderIso.image_Ioc
@[simp]
| Mathlib/Order/Interval/Set/OrderIso.lean | 98 | 99 | theorem image_Ico (e : α ≃o β) (a b : α) : e '' Ico a b = Ico (e a) (e b) := by |
rw [e.image_eq_preimage, e.symm.preimage_Ico, e.symm_symm]
| 1 | 2.718282 | 0 | 0.285714 | 14 | 310 |
import Mathlib.Data.Fin.Tuple.Basic
import Mathlib.Data.List.Join
#align_import data.list.of_fn from "leanprover-community/mathlib"@"bf27744463e9620ca4e4ebe951fe83530ae6949b"
universe u
variable {α : Type u}
open Nat
namespace List
#noalign list.length_of_fn_aux
@[simp]
theorem length_ofFn_go {n} (f : Fin n → α) (i j h) : length (ofFn.go f i j h) = i := by
induction i generalizing j <;> simp_all [ofFn.go]
@[simp]
theorem length_ofFn {n} (f : Fin n → α) : length (ofFn f) = n := by
simp [ofFn, length_ofFn_go]
#align list.length_of_fn List.length_ofFn
#noalign list.nth_of_fn_aux
theorem get_ofFn_go {n} (f : Fin n → α) (i j h) (k) (hk) :
get (ofFn.go f i j h) ⟨k, hk⟩ = f ⟨j + k, by simp at hk; omega⟩ := by
let i+1 := i
cases k <;> simp [ofFn.go, get_ofFn_go (i := i)]
congr 2; omega
-- Porting note (#10756): new theorem
@[simp]
| Mathlib/Data/List/OfFn.lean | 58 | 59 | theorem get_ofFn {n} (f : Fin n → α) (i) : get (ofFn f) i = f (Fin.cast (by simp) i) := by |
cases i; simp [ofFn, get_ofFn_go]
| 1 | 2.718282 | 0 | 0.6 | 10 | 535 |
import Mathlib.Data.Int.Bitwise
import Mathlib.Data.Int.Order.Lemmas
import Mathlib.Data.Set.Function
import Mathlib.Order.Interval.Set.Basic
#align_import data.int.lemmas from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f"
open Nat
namespace Int
theorem le_natCast_sub (m n : ℕ) : (m - n : ℤ) ≤ ↑(m - n : ℕ) := by
by_cases h : m ≥ n
· exact le_of_eq (Int.ofNat_sub h).symm
· simp [le_of_not_ge h, ofNat_le]
#align int.le_coe_nat_sub Int.le_natCast_sub
-- Porting note (#10618): simp can prove this @[simp]
theorem succ_natCast_pos (n : ℕ) : 0 < (n : ℤ) + 1 :=
lt_add_one_iff.mpr (by simp)
#align int.succ_coe_nat_pos Int.succ_natCast_pos
variable {a b : ℤ} {n : ℕ}
theorem natAbs_eq_iff_sq_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a ^ 2 = b ^ 2 := by
rw [sq, sq]
exact natAbs_eq_iff_mul_self_eq
#align int.nat_abs_eq_iff_sq_eq Int.natAbs_eq_iff_sq_eq
theorem natAbs_lt_iff_sq_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a ^ 2 < b ^ 2 := by
rw [sq, sq]
exact natAbs_lt_iff_mul_self_lt
#align int.nat_abs_lt_iff_sq_lt Int.natAbs_lt_iff_sq_lt
theorem natAbs_le_iff_sq_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a ^ 2 ≤ b ^ 2 := by
rw [sq, sq]
exact natAbs_le_iff_mul_self_le
#align int.nat_abs_le_iff_sq_le Int.natAbs_le_iff_sq_le
| Mathlib/Data/Int/Lemmas.lean | 60 | 61 | theorem natAbs_inj_of_nonneg_of_nonneg {a b : ℤ} (ha : 0 ≤ a) (hb : 0 ≤ b) :
natAbs a = natAbs b ↔ a = b := by | rw [← sq_eq_sq ha hb, ← natAbs_eq_iff_sq_eq]
| 1 | 2.718282 | 0 | 0.818182 | 11 | 720 |
import Mathlib.Init.Logic
import Mathlib.Init.Function
import Mathlib.Init.Algebra.Classes
import Batteries.Util.LibraryNote
import Batteries.Tactic.Lint.Basic
#align_import logic.basic from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe"
#align_import init.ite_simp from "leanprover-community/lean"@"4a03bdeb31b3688c31d02d7ff8e0ff2e5d6174db"
open Function
attribute [local instance 10] Classical.propDecidable
open Function
alias Membership.mem.ne_of_not_mem := ne_of_mem_of_not_mem
alias Membership.mem.ne_of_not_mem' := ne_of_mem_of_not_mem'
#align has_mem.mem.ne_of_not_mem Membership.mem.ne_of_not_mem
#align has_mem.mem.ne_of_not_mem' Membership.mem.ne_of_not_mem'
section Equality
-- todo: change name
theorem forall_cond_comm {α} {s : α → Prop} {p : α → α → Prop} :
(∀ a, s a → ∀ b, s b → p a b) ↔ ∀ a b, s a → s b → p a b :=
⟨fun h a b ha hb ↦ h a ha b hb, fun h a ha b hb ↦ h a b ha hb⟩
#align ball_cond_comm forall_cond_comm
theorem forall_mem_comm {α β} [Membership α β] {s : β} {p : α → α → Prop} :
(∀ a (_ : a ∈ s) b (_ : b ∈ s), p a b) ↔ ∀ a b, a ∈ s → b ∈ s → p a b :=
forall_cond_comm
#align ball_mem_comm forall_mem_comm
@[deprecated (since := "2024-03-23")] alias ball_cond_comm := forall_cond_comm
@[deprecated (since := "2024-03-23")] alias ball_mem_comm := forall_mem_comm
#align ne_of_apply_ne ne_of_apply_ne
lemma ne_of_eq_of_ne {α : Sort*} {a b c : α} (h₁ : a = b) (h₂ : b ≠ c) : a ≠ c := h₁.symm ▸ h₂
lemma ne_of_ne_of_eq {α : Sort*} {a b c : α} (h₁ : a ≠ b) (h₂ : b = c) : a ≠ c := h₂ ▸ h₁
alias Eq.trans_ne := ne_of_eq_of_ne
alias Ne.trans_eq := ne_of_ne_of_eq
#align eq.trans_ne Eq.trans_ne
#align ne.trans_eq Ne.trans_eq
theorem eq_equivalence {α : Sort*} : Equivalence (@Eq α) :=
⟨Eq.refl, @Eq.symm _, @Eq.trans _⟩
#align eq_equivalence eq_equivalence
-- These were migrated to Batteries but the `@[simp]` attributes were (mysteriously?) removed.
attribute [simp] eq_mp_eq_cast eq_mpr_eq_cast
#align eq_mp_eq_cast eq_mp_eq_cast
#align eq_mpr_eq_cast eq_mpr_eq_cast
#align cast_cast cast_cast
-- @[simp] -- FIXME simp ignores proof rewrites
theorem congr_refl_left {α β : Sort*} (f : α → β) {a b : α} (h : a = b) :
congr (Eq.refl f) h = congr_arg f h := rfl
#align congr_refl_left congr_refl_left
-- @[simp] -- FIXME simp ignores proof rewrites
theorem congr_refl_right {α β : Sort*} {f g : α → β} (h : f = g) (a : α) :
congr h (Eq.refl a) = congr_fun h a := rfl
#align congr_refl_right congr_refl_right
-- @[simp] -- FIXME simp ignores proof rewrites
theorem congr_arg_refl {α β : Sort*} (f : α → β) (a : α) :
congr_arg f (Eq.refl a) = Eq.refl (f a) :=
rfl
#align congr_arg_refl congr_arg_refl
-- @[simp] -- FIXME simp ignores proof rewrites
theorem congr_fun_rfl {α β : Sort*} (f : α → β) (a : α) : congr_fun (Eq.refl f) a = Eq.refl (f a) :=
rfl
#align congr_fun_rfl congr_fun_rfl
-- @[simp] -- FIXME simp ignores proof rewrites
theorem congr_fun_congr_arg {α β γ : Sort*} (f : α → β → γ) {a a' : α} (p : a = a') (b : β) :
congr_fun (congr_arg f p) b = congr_arg (fun a ↦ f a b) p := rfl
#align congr_fun_congr_arg congr_fun_congr_arg
#align heq_of_cast_eq heq_of_cast_eq
#align cast_eq_iff_heq cast_eq_iff_heq
| Mathlib/Logic/Basic.lean | 591 | 592 | theorem Eq.rec_eq_cast {α : Sort _} {P : α → Sort _} {x y : α} (h : x = y) (z : P x) :
h ▸ z = cast (congr_arg P h) z := by | induction h; rfl
| 1 | 2.718282 | 0 | 0 | 8 | 105 |
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.FDeriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.RestrictScalars
#align_import analysis.calculus.deriv.comp from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
universe u v w
open scoped Classical
open Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L L₁ L₂ : Filter 𝕜}
section Composition
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' F]
[IsScalarTower 𝕜 𝕜' F] {s' t' : Set 𝕜'} {h : 𝕜 → 𝕜'} {h₁ : 𝕜 → 𝕜} {h₂ : 𝕜' → 𝕜'} {h' h₂' : 𝕜'}
{h₁' : 𝕜} {g₁ : 𝕜' → F} {g₁' : F} {L' : Filter 𝕜'} {y : 𝕜'} (x)
theorem HasDerivAtFilter.scomp (hg : HasDerivAtFilter g₁ g₁' (h x) L')
(hh : HasDerivAtFilter h h' x L) (hL : Tendsto h L L') :
HasDerivAtFilter (g₁ ∘ h) (h' • g₁') x L := by
simpa using ((hg.restrictScalars 𝕜).comp x hh hL).hasDerivAtFilter
#align has_deriv_at_filter.scomp HasDerivAtFilter.scomp
theorem HasDerivAtFilter.scomp_of_eq (hg : HasDerivAtFilter g₁ g₁' y L')
(hh : HasDerivAtFilter h h' x L) (hy : y = h x) (hL : Tendsto h L L') :
HasDerivAtFilter (g₁ ∘ h) (h' • g₁') x L := by
rw [hy] at hg; exact hg.scomp x hh hL
theorem HasDerivWithinAt.scomp_hasDerivAt (hg : HasDerivWithinAt g₁ g₁' s' (h x))
(hh : HasDerivAt h h' x) (hs : ∀ x, h x ∈ s') : HasDerivAt (g₁ ∘ h) (h' • g₁') x :=
hg.scomp x hh <| tendsto_inf.2 ⟨hh.continuousAt, tendsto_principal.2 <| eventually_of_forall hs⟩
#align has_deriv_within_at.scomp_has_deriv_at HasDerivWithinAt.scomp_hasDerivAt
| Mathlib/Analysis/Calculus/Deriv/Comp.lean | 90 | 93 | theorem HasDerivWithinAt.scomp_hasDerivAt_of_eq (hg : HasDerivWithinAt g₁ g₁' s' y)
(hh : HasDerivAt h h' x) (hs : ∀ x, h x ∈ s') (hy : y = h x) :
HasDerivAt (g₁ ∘ h) (h' • g₁') x := by |
rw [hy] at hg; exact hg.scomp_hasDerivAt x hh hs
| 1 | 2.718282 | 0 | 0 | 14 | 81 |
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Shift
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
variable
{𝕜 : Type*} [NontriviallyNormedField 𝕜]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{R : Type*} [Semiring R] [Module R F] [SMulCommClass 𝕜 R F] [ContinuousConstSMul R F]
{n : ℕ} {x : 𝕜} {s : Set 𝕜} (hx : x ∈ s) (h : UniqueDiffOn 𝕜 s) {f g : 𝕜 → F}
theorem iteratedDerivWithin_add (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) :
iteratedDerivWithin n (f + g) s x =
iteratedDerivWithin n f s x + iteratedDerivWithin n g s x := by
simp_rw [iteratedDerivWithin, iteratedFDerivWithin_add_apply hf hg h hx,
ContinuousMultilinearMap.add_apply]
theorem iteratedDerivWithin_congr (hfg : Set.EqOn f g s) :
Set.EqOn (iteratedDerivWithin n f s) (iteratedDerivWithin n g s) s := by
induction n generalizing f g with
| zero => rwa [iteratedDerivWithin_zero]
| succ n IH =>
intro y hy
have : UniqueDiffWithinAt 𝕜 s y := h.uniqueDiffWithinAt hy
rw [iteratedDerivWithin_succ this, iteratedDerivWithin_succ this]
exact derivWithin_congr (IH hfg) (IH hfg hy)
theorem iteratedDerivWithin_const_add (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c + f z) s x = iteratedDerivWithin n f s x := by
obtain ⟨n, rfl⟩ := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ' h hx, iteratedDerivWithin_succ' h hx]
refine iteratedDerivWithin_congr h ?_ hx
intro y hy
exact derivWithin_const_add (h.uniqueDiffWithinAt hy) _
theorem iteratedDerivWithin_const_neg (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c - f z) s x = iteratedDerivWithin n (fun z => -f z) s x := by
obtain ⟨n, rfl⟩ := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ' h hx, iteratedDerivWithin_succ' h hx]
refine iteratedDerivWithin_congr h ?_ hx
intro y hy
have : UniqueDiffWithinAt 𝕜 s y := h.uniqueDiffWithinAt hy
rw [derivWithin.neg this]
exact derivWithin_const_sub this _
theorem iteratedDerivWithin_const_smul (c : R) (hf : ContDiffOn 𝕜 n f s) :
iteratedDerivWithin n (c • f) s x = c • iteratedDerivWithin n f s x := by
simp_rw [iteratedDerivWithin]
rw [iteratedFDerivWithin_const_smul_apply hf h hx]
simp only [ContinuousMultilinearMap.smul_apply]
| Mathlib/Analysis/Calculus/IteratedDeriv/Lemmas.lean | 64 | 66 | theorem iteratedDerivWithin_const_mul (c : 𝕜) {f : 𝕜 → 𝕜} (hf : ContDiffOn 𝕜 n f s) :
iteratedDerivWithin n (fun z => c * f z) s x = c * iteratedDerivWithin n f s x := by |
simpa using iteratedDerivWithin_const_smul (F := 𝕜) hx h c hf
| 1 | 2.718282 | 0 | 1.2 | 10 | 1,290 |
import Mathlib.Probability.Kernel.Composition
#align_import probability.kernel.invariance from "leanprover-community/mathlib"@"3b92d54a05ee592aa2c6181a4e76b1bb7cc45d0b"
open MeasureTheory
open scoped MeasureTheory ENNReal ProbabilityTheory
namespace ProbabilityTheory
variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
namespace kernel
@[simp]
theorem bind_add (μ ν : Measure α) (κ : kernel α β) : (μ + ν).bind κ = μ.bind κ + ν.bind κ := by
ext1 s hs
rw [Measure.bind_apply hs (kernel.measurable _), lintegral_add_measure, Measure.coe_add,
Pi.add_apply, Measure.bind_apply hs (kernel.measurable _),
Measure.bind_apply hs (kernel.measurable _)]
#align probability_theory.kernel.bind_add ProbabilityTheory.kernel.bind_add
@[simp]
theorem bind_smul (κ : kernel α β) (μ : Measure α) (r : ℝ≥0∞) : (r • μ).bind κ = r • μ.bind κ := by
ext1 s hs
rw [Measure.bind_apply hs (kernel.measurable _), lintegral_smul_measure, Measure.coe_smul,
Pi.smul_apply, Measure.bind_apply hs (kernel.measurable _), smul_eq_mul]
#align probability_theory.kernel.bind_smul ProbabilityTheory.kernel.bind_smul
| Mathlib/Probability/Kernel/Invariance.lean | 57 | 60 | theorem const_bind_eq_comp_const (κ : kernel α β) (μ : Measure α) :
const α (μ.bind κ) = κ ∘ₖ const α μ := by |
ext a s hs
simp_rw [comp_apply' _ _ _ hs, const_apply, Measure.bind_apply hs (kernel.measurable _)]
| 2 | 7.389056 | 1 | 1 | 6 | 1,165 |
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.set.ncard from "leanprover-community/mathlib"@"74c2af38a828107941029b03839882c5c6f87a04"
namespace Set
variable {α β : Type*} {s t : Set α}
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]
| 1 | 2.718282 | 0 | 0.5 | 14 | 454 |
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Data.Nat.Totient
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.GroupTheory.Subgroup.Simple
import Mathlib.Tactic.Group
import Mathlib.GroupTheory.Exponent
#align_import group_theory.specific_groups.cyclic from "leanprover-community/mathlib"@"0f6670b8af2dff699de1c0b4b49039b31bc13c46"
universe u
variable {α : Type u} {a : α}
section Cyclic
attribute [local instance] setFintype
open Subgroup
class IsAddCyclic (α : Type u) [AddGroup α] : Prop where
exists_generator : ∃ g : α, ∀ x, x ∈ AddSubgroup.zmultiples g
#align is_add_cyclic IsAddCyclic
@[to_additive]
class IsCyclic (α : Type u) [Group α] : Prop where
exists_generator : ∃ g : α, ∀ x, x ∈ zpowers g
#align is_cyclic IsCyclic
@[to_additive]
instance (priority := 100) isCyclic_of_subsingleton [Group α] [Subsingleton α] : IsCyclic α :=
⟨⟨1, fun x => by
rw [Subsingleton.elim x 1]
exact mem_zpowers 1⟩⟩
#align is_cyclic_of_subsingleton isCyclic_of_subsingleton
#align is_add_cyclic_of_subsingleton isAddCyclic_of_subsingleton
@[simp]
theorem isCyclic_multiplicative_iff [AddGroup α] : IsCyclic (Multiplicative α) ↔ IsAddCyclic α :=
⟨fun H ↦ ⟨H.1⟩, fun H ↦ ⟨H.1⟩⟩
instance isCyclic_multiplicative [AddGroup α] [IsAddCyclic α] : IsCyclic (Multiplicative α) :=
isCyclic_multiplicative_iff.mpr inferInstance
@[simp]
theorem isAddCyclic_additive_iff [Group α] : IsAddCyclic (Additive α) ↔ IsCyclic α :=
⟨fun H ↦ ⟨H.1⟩, fun H ↦ ⟨H.1⟩⟩
instance isAddCyclic_additive [Group α] [IsCyclic α] : IsAddCyclic (Additive α) :=
isAddCyclic_additive_iff.mpr inferInstance
@[to_additive
"A cyclic group is always commutative. This is not an `instance` because often we have
a better proof of `AddCommGroup`."]
def IsCyclic.commGroup [hg : Group α] [IsCyclic α] : CommGroup α :=
{ hg with
mul_comm := fun x y =>
let ⟨_, hg⟩ := IsCyclic.exists_generator (α := α)
let ⟨_, hn⟩ := hg x
let ⟨_, hm⟩ := hg y
hm ▸ hn ▸ zpow_mul_comm _ _ _ }
#align is_cyclic.comm_group IsCyclic.commGroup
#align is_add_cyclic.add_comm_group IsAddCyclic.addCommGroup
variable [Group α]
@[to_additive "A non-cyclic additive group is non-trivial."]
theorem Nontrivial.of_not_isCyclic (nc : ¬IsCyclic α) : Nontrivial α := by
contrapose! nc
exact @isCyclic_of_subsingleton _ _ (not_nontrivial_iff_subsingleton.mp nc)
@[to_additive]
theorem MonoidHom.map_cyclic {G : Type*} [Group G] [h : IsCyclic G] (σ : G →* G) :
∃ m : ℤ, ∀ g : G, σ g = g ^ m := by
obtain ⟨h, hG⟩ := IsCyclic.exists_generator (α := G)
obtain ⟨m, hm⟩ := hG (σ h)
refine ⟨m, fun g => ?_⟩
obtain ⟨n, rfl⟩ := hG g
rw [MonoidHom.map_zpow, ← hm, ← zpow_mul, ← zpow_mul']
#align monoid_hom.map_cyclic MonoidHom.map_cyclic
#align monoid_add_hom.map_add_cyclic AddMonoidHom.map_addCyclic
@[deprecated (since := "2024-02-21")] alias
MonoidAddHom.map_add_cyclic := AddMonoidHom.map_addCyclic
@[to_additive]
theorem isCyclic_of_orderOf_eq_card [Fintype α] (x : α) (hx : orderOf x = Fintype.card α) :
IsCyclic α := by
classical
use x
simp_rw [← SetLike.mem_coe, ← Set.eq_univ_iff_forall]
rw [← Fintype.card_congr (Equiv.Set.univ α), ← Fintype.card_zpowers] at hx
exact Set.eq_of_subset_of_card_le (Set.subset_univ _) (ge_of_eq hx)
#align is_cyclic_of_order_of_eq_card isCyclic_of_orderOf_eq_card
#align is_add_cyclic_of_order_of_eq_card isAddCyclic_of_addOrderOf_eq_card
@[deprecated (since := "2024-02-21")]
alias isAddCyclic_of_orderOf_eq_card := isAddCyclic_of_addOrderOf_eq_card
@[to_additive]
theorem Subgroup.eq_bot_or_eq_top_of_prime_card {G : Type*} [Group G] {_ : Fintype G}
(H : Subgroup G) [hp : Fact (Fintype.card G).Prime] : H = ⊥ ∨ H = ⊤ := by
classical
have := card_subgroup_dvd_card H
rwa [Nat.card_eq_fintype_card (α := G), Nat.dvd_prime hp.1, ← Nat.card_eq_fintype_card,
← eq_bot_iff_card, card_eq_iff_eq_top] at this
@[to_additive "Any non-identity element of a finite group of prime order generates the group."]
theorem zpowers_eq_top_of_prime_card {G : Type*} [Group G] {_ : Fintype G} {p : ℕ}
[hp : Fact p.Prime] (h : Fintype.card G = p) {g : G} (hg : g ≠ 1) : zpowers g = ⊤ := by
subst h
have := (zpowers g).eq_bot_or_eq_top_of_prime_card
rwa [zpowers_eq_bot, or_iff_right hg] at this
@[to_additive]
| Mathlib/GroupTheory/SpecificGroups/Cyclic.lean | 152 | 154 | theorem mem_zpowers_of_prime_card {G : Type*} [Group G] {_ : Fintype G} {p : ℕ} [hp : Fact p.Prime]
(h : Fintype.card G = p) {g g' : G} (hg : g ≠ 1) : g' ∈ zpowers g := by |
simp_rw [zpowers_eq_top_of_prime_card h hg, Subgroup.mem_top]
| 1 | 2.718282 | 0 | 1.333333 | 6 | 1,386 |
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Int.GCD
import Mathlib.RingTheory.Coprime.Basic
#align_import ring_theory.coprime.lemmas from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
universe u v
section IsCoprime
variable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I}
section
theorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by
constructor
· rintro ⟨a, b, h⟩
have : 1 = m * a + n * b := by rwa [mul_comm m, mul_comm n, eq_comm]
exact Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, this⟩)
· rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one]
intro h
exact ⟨_, _, h⟩
theorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by
rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast]
#align nat.is_coprime_iff_coprime Nat.isCoprime_iff_coprime
alias ⟨IsCoprime.nat_coprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime
#align is_coprime.nat_coprime IsCoprime.nat_coprime
#align nat.coprime.is_coprime Nat.Coprime.isCoprime
theorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) :
IsCoprime (a : R) (b : R) := by
rw [← isCoprime_iff_coprime] at h
rw [← Int.cast_natCast a, ← Int.cast_natCast b]
exact IsCoprime.intCast h
theorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ}
(h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 :=
IsCoprime.ne_zero_or_ne_zero (R := A) <| by
simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A)
theorem IsCoprime.prod_left : (∀ i ∈ t, IsCoprime (s i) x) → IsCoprime (∏ i ∈ t, s i) x := by
classical
refine Finset.induction_on t (fun _ ↦ isCoprime_one_left) fun b t hbt ih H ↦ ?_
rw [Finset.prod_insert hbt]
rw [Finset.forall_mem_insert] at H
exact H.1.mul_left (ih H.2)
#align is_coprime.prod_left IsCoprime.prod_left
| Mathlib/RingTheory/Coprime/Lemmas.lean | 69 | 70 | theorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by |
simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R)
| 1 | 2.718282 | 0 | 1.111111 | 18 | 1,195 |
import Mathlib.Order.RelClasses
import Mathlib.Order.Interval.Set.Basic
#align_import order.bounded from "leanprover-community/mathlib"@"aba57d4d3dae35460225919dcd82fe91355162f9"
namespace Set
variable {α : Type*} {r : α → α → Prop} {s t : Set α}
theorem Bounded.mono (hst : s ⊆ t) (hs : Bounded r t) : Bounded r s :=
hs.imp fun _ ha b hb => ha b (hst hb)
#align set.bounded.mono Set.Bounded.mono
theorem Unbounded.mono (hst : s ⊆ t) (hs : Unbounded r s) : Unbounded r t := fun a =>
let ⟨b, hb, hb'⟩ := hs a
⟨b, hst hb, hb'⟩
#align set.unbounded.mono Set.Unbounded.mono
theorem unbounded_le_of_forall_exists_lt [Preorder α] (h : ∀ a, ∃ b ∈ s, a < b) :
Unbounded (· ≤ ·) s := fun a =>
let ⟨b, hb, hb'⟩ := h a
⟨b, hb, fun hba => hba.not_lt hb'⟩
#align set.unbounded_le_of_forall_exists_lt Set.unbounded_le_of_forall_exists_lt
theorem unbounded_le_iff [LinearOrder α] : Unbounded (· ≤ ·) s ↔ ∀ a, ∃ b ∈ s, a < b := by
simp only [Unbounded, not_le]
#align set.unbounded_le_iff Set.unbounded_le_iff
theorem unbounded_lt_of_forall_exists_le [Preorder α] (h : ∀ a, ∃ b ∈ s, a ≤ b) :
Unbounded (· < ·) s := fun a =>
let ⟨b, hb, hb'⟩ := h a
⟨b, hb, fun hba => hba.not_le hb'⟩
#align set.unbounded_lt_of_forall_exists_le Set.unbounded_lt_of_forall_exists_le
theorem unbounded_lt_iff [LinearOrder α] : Unbounded (· < ·) s ↔ ∀ a, ∃ b ∈ s, a ≤ b := by
simp only [Unbounded, not_lt]
#align set.unbounded_lt_iff Set.unbounded_lt_iff
theorem unbounded_ge_of_forall_exists_gt [Preorder α] (h : ∀ a, ∃ b ∈ s, b < a) :
Unbounded (· ≥ ·) s :=
@unbounded_le_of_forall_exists_lt αᵒᵈ _ _ h
#align set.unbounded_ge_of_forall_exists_gt Set.unbounded_ge_of_forall_exists_gt
theorem unbounded_ge_iff [LinearOrder α] : Unbounded (· ≥ ·) s ↔ ∀ a, ∃ b ∈ s, b < a :=
⟨fun h a =>
let ⟨b, hb, hba⟩ := h a
⟨b, hb, lt_of_not_ge hba⟩,
unbounded_ge_of_forall_exists_gt⟩
#align set.unbounded_ge_iff Set.unbounded_ge_iff
theorem unbounded_gt_of_forall_exists_ge [Preorder α] (h : ∀ a, ∃ b ∈ s, b ≤ a) :
Unbounded (· > ·) s := fun a =>
let ⟨b, hb, hb'⟩ := h a
⟨b, hb, fun hba => not_le_of_gt hba hb'⟩
#align set.unbounded_gt_of_forall_exists_ge Set.unbounded_gt_of_forall_exists_ge
theorem unbounded_gt_iff [LinearOrder α] : Unbounded (· > ·) s ↔ ∀ a, ∃ b ∈ s, b ≤ a :=
⟨fun h a =>
let ⟨b, hb, hba⟩ := h a
⟨b, hb, le_of_not_gt hba⟩,
unbounded_gt_of_forall_exists_ge⟩
#align set.unbounded_gt_iff Set.unbounded_gt_iff
theorem Bounded.rel_mono {r' : α → α → Prop} (h : Bounded r s) (hrr' : r ≤ r') : Bounded r' s :=
let ⟨a, ha⟩ := h
⟨a, fun b hb => hrr' b a (ha b hb)⟩
#align set.bounded.rel_mono Set.Bounded.rel_mono
theorem bounded_le_of_bounded_lt [Preorder α] (h : Bounded (· < ·) s) : Bounded (· ≤ ·) s :=
h.rel_mono fun _ _ => le_of_lt
#align set.bounded_le_of_bounded_lt Set.bounded_le_of_bounded_lt
theorem Unbounded.rel_mono {r' : α → α → Prop} (hr : r' ≤ r) (h : Unbounded r s) : Unbounded r' s :=
fun a =>
let ⟨b, hb, hba⟩ := h a
⟨b, hb, fun hba' => hba (hr b a hba')⟩
#align set.unbounded.rel_mono Set.Unbounded.rel_mono
theorem unbounded_lt_of_unbounded_le [Preorder α] (h : Unbounded (· ≤ ·) s) : Unbounded (· < ·) s :=
h.rel_mono fun _ _ => le_of_lt
#align set.unbounded_lt_of_unbounded_le Set.unbounded_lt_of_unbounded_le
theorem bounded_le_iff_bounded_lt [Preorder α] [NoMaxOrder α] :
Bounded (· ≤ ·) s ↔ Bounded (· < ·) s := by
refine ⟨fun h => ?_, bounded_le_of_bounded_lt⟩
cases' h with a ha
cases' exists_gt a with b hb
exact ⟨b, fun c hc => lt_of_le_of_lt (ha c hc) hb⟩
#align set.bounded_le_iff_bounded_lt Set.bounded_le_iff_bounded_lt
| Mathlib/Order/Bounded.lean | 116 | 118 | theorem unbounded_lt_iff_unbounded_le [Preorder α] [NoMaxOrder α] :
Unbounded (· < ·) s ↔ Unbounded (· ≤ ·) s := by |
simp_rw [← not_bounded_iff, bounded_le_iff_bounded_lt]
| 1 | 2.718282 | 0 | 0.5 | 4 | 419 |
import Mathlib.Tactic.Ring.Basic
import Mathlib.Tactic.TryThis
import Mathlib.Tactic.Conv
import Mathlib.Util.Qq
set_option autoImplicit true
-- In this file we would like to be able to use multi-character auto-implicits.
set_option relaxedAutoImplicit true
namespace Mathlib.Tactic
open Lean hiding Rat
open Qq Meta
namespace RingNF
open Ring
inductive RingMode where
| SOP
| raw
deriving Inhabited, BEq, Repr
structure Config where
red := TransparencyMode.reducible
recursive := true
mode := RingMode.SOP
deriving Inhabited, BEq, Repr
declare_config_elab elabConfig Config
structure Context where
ctx : Simp.Context
simp : Simp.Result → SimpM Simp.Result
abbrev M := ReaderT Context AtomM
def rewrite (parent : Expr) (root := true) : M Simp.Result :=
fun nctx rctx s ↦ do
let pre : Simp.Simproc := fun e =>
try
guard <| root || parent != e -- recursion guard
let e ← withReducible <| whnf e
guard e.isApp -- all interesting ring expressions are applications
let ⟨u, α, e⟩ ← inferTypeQ' e
let sα ← synthInstanceQ (q(CommSemiring $α) : Q(Type u))
let c ← mkCache sα
let ⟨a, _, pa⟩ ← match ← isAtomOrDerivable sα c e rctx s with
| none => eval sα c e rctx s -- `none` indicates that `eval` will find something algebraic.
| some none => failure -- No point rewriting atoms
| some (some r) => pure r -- Nothing algebraic for `eval` to use, but `norm_num` simplifies.
let r ← nctx.simp { expr := a, proof? := pa }
if ← withReducible <| isDefEq r.expr e then return .done { expr := r.expr }
pure (.done r)
catch _ => pure <| .continue
let post := Simp.postDefault #[]
(·.1) <$> Simp.main parent nctx.ctx (methods := { pre, post })
variable [CommSemiring R]
theorem add_assoc_rev (a b c : R) : a + (b + c) = a + b + c := (add_assoc ..).symm
theorem mul_assoc_rev (a b c : R) : a * (b * c) = a * b * c := (mul_assoc ..).symm
theorem mul_neg {R} [Ring R] (a b : R) : a * -b = -(a * b) := by simp
theorem add_neg {R} [Ring R] (a b : R) : a + -b = a - b := (sub_eq_add_neg ..).symm
| Mathlib/Tactic/Ring/RingNF.lean | 120 | 120 | theorem nat_rawCast_0 : (Nat.rawCast 0 : R) = 0 := by | simp
| 1 | 2.718282 | 0 | 0 | 6 | 217 |
import Mathlib.Data.Matrix.Invertible
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.LinearAlgebra.Matrix.PosDef
#align_import linear_algebra.matrix.schur_complement from "leanprover-community/mathlib"@"a176cb1219e300e85793d44583dede42377b51af"
variable {l m n α : Type*}
namespace Matrix
open scoped Matrix
section CommRing
variable [Fintype l] [Fintype m] [Fintype n]
variable [DecidableEq l] [DecidableEq m] [DecidableEq n]
variable [CommRing α]
theorem fromBlocks_eq_of_invertible₁₁ (A : Matrix m m α) (B : Matrix m n α) (C : Matrix l m α)
(D : Matrix l n α) [Invertible A] :
fromBlocks A B C D =
fromBlocks 1 0 (C * ⅟ A) 1 * fromBlocks A 0 0 (D - C * ⅟ A * B) *
fromBlocks 1 (⅟ A * B) 0 1 := by
simp only [fromBlocks_multiply, Matrix.mul_zero, Matrix.zero_mul, add_zero, zero_add,
Matrix.one_mul, Matrix.mul_one, invOf_mul_self, Matrix.mul_invOf_self_assoc,
Matrix.mul_invOf_mul_self_cancel, Matrix.mul_assoc, add_sub_cancel]
#align matrix.from_blocks_eq_of_invertible₁₁ Matrix.fromBlocks_eq_of_invertible₁₁
theorem fromBlocks_eq_of_invertible₂₂ (A : Matrix l m α) (B : Matrix l n α) (C : Matrix n m α)
(D : Matrix n n α) [Invertible D] :
fromBlocks A B C D =
fromBlocks 1 (B * ⅟ D) 0 1 * fromBlocks (A - B * ⅟ D * C) 0 0 D *
fromBlocks 1 0 (⅟ D * C) 1 :=
(Matrix.reindex (Equiv.sumComm _ _) (Equiv.sumComm _ _)).injective <| by
simpa [reindex_apply, Equiv.sumComm_symm, ← submatrix_mul_equiv _ _ _ (Equiv.sumComm n m), ←
submatrix_mul_equiv _ _ _ (Equiv.sumComm n l), Equiv.sumComm_apply,
fromBlocks_submatrix_sum_swap_sum_swap] using fromBlocks_eq_of_invertible₁₁ D C B A
#align matrix.from_blocks_eq_of_invertible₂₂ Matrix.fromBlocks_eq_of_invertible₂₂
section Det
theorem det_fromBlocks₁₁ (A : Matrix m m α) (B : Matrix m n α) (C : Matrix n m α)
(D : Matrix n n α) [Invertible A] :
(Matrix.fromBlocks A B C D).det = det A * det (D - C * ⅟ A * B) := by
rw [fromBlocks_eq_of_invertible₁₁ (A := A), det_mul, det_mul, det_fromBlocks_zero₂₁,
det_fromBlocks_zero₂₁, det_fromBlocks_zero₁₂, det_one, det_one, one_mul, one_mul, mul_one]
#align matrix.det_from_blocks₁₁ Matrix.det_fromBlocks₁₁
@[simp]
theorem det_fromBlocks_one₁₁ (B : Matrix m n α) (C : Matrix n m α) (D : Matrix n n α) :
(Matrix.fromBlocks 1 B C D).det = det (D - C * B) := by
haveI : Invertible (1 : Matrix m m α) := invertibleOne
rw [det_fromBlocks₁₁, invOf_one, Matrix.mul_one, det_one, one_mul]
#align matrix.det_from_blocks_one₁₁ Matrix.det_fromBlocks_one₁₁
theorem det_fromBlocks₂₂ (A : Matrix m m α) (B : Matrix m n α) (C : Matrix n m α)
(D : Matrix n n α) [Invertible D] :
(Matrix.fromBlocks A B C D).det = det D * det (A - B * ⅟ D * C) := by
have : fromBlocks A B C D =
(fromBlocks D C B A).submatrix (Equiv.sumComm _ _) (Equiv.sumComm _ _) := by
ext (i j)
cases i <;> cases j <;> rfl
rw [this, det_submatrix_equiv_self, det_fromBlocks₁₁]
#align matrix.det_from_blocks₂₂ Matrix.det_fromBlocks₂₂
@[simp]
theorem det_fromBlocks_one₂₂ (A : Matrix m m α) (B : Matrix m n α) (C : Matrix n m α) :
(Matrix.fromBlocks A B C 1).det = det (A - B * C) := by
haveI : Invertible (1 : Matrix n n α) := invertibleOne
rw [det_fromBlocks₂₂, invOf_one, Matrix.mul_one, det_one, one_mul]
#align matrix.det_from_blocks_one₂₂ Matrix.det_fromBlocks_one₂₂
theorem det_one_add_mul_comm (A : Matrix m n α) (B : Matrix n m α) :
det (1 + A * B) = det (1 + B * A) :=
calc
det (1 + A * B) = det (fromBlocks 1 (-A) B 1) := by
rw [det_fromBlocks_one₂₂, Matrix.neg_mul, sub_neg_eq_add]
_ = det (1 + B * A) := by rw [det_fromBlocks_one₁₁, Matrix.mul_neg, sub_neg_eq_add]
#align matrix.det_one_add_mul_comm Matrix.det_one_add_mul_comm
| Mathlib/LinearAlgebra/Matrix/SchurComplement.lean | 434 | 435 | theorem det_mul_add_one_comm (A : Matrix m n α) (B : Matrix n m α) :
det (A * B + 1) = det (B * A + 1) := by | rw [add_comm, det_one_add_mul_comm, add_comm]
| 1 | 2.718282 | 0 | 1.1875 | 16 | 1,248 |
import Mathlib.Topology.Category.TopCat.EpiMono
import Mathlib.Topology.Category.TopCat.Limits.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.CategoryTheory.Limits.ConcreteCategory
import Mathlib.Data.Set.Subsingleton
import Mathlib.Tactic.CategoryTheory.Elementwise
#align_import topology.category.Top.limits.products from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1"
-- Porting note: every ML3 decl has an uppercase letter
set_option linter.uppercaseLean3 false
open TopologicalSpace
open CategoryTheory
open CategoryTheory.Limits
universe v u w
noncomputable section
namespace TopCat
variable {J : Type v} [SmallCategory J]
abbrev piπ {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : TopCat.of (∀ i, α i) ⟶ α i :=
⟨fun f => f i, continuous_apply i⟩
#align Top.pi_π TopCat.piπ
@[simps! pt π_app]
def piFan {ι : Type v} (α : ι → TopCat.{max v u}) : Fan α :=
Fan.mk (TopCat.of (∀ i, α i)) (piπ.{v,u} α)
#align Top.pi_fan TopCat.piFan
def piFanIsLimit {ι : Type v} (α : ι → TopCat.{max v u}) : IsLimit (piFan α) where
lift S :=
{ toFun := fun s i => S.π.app ⟨i⟩ s
continuous_toFun := continuous_pi (fun i => (S.π.app ⟨i⟩).2) }
uniq := by
intro S m h
apply ContinuousMap.ext; intro x
funext i
set_option tactic.skipAssignedInstances false in
dsimp
rw [ContinuousMap.coe_mk, ← h ⟨i⟩]
rfl
fac s j := rfl
#align Top.pi_fan_is_limit TopCat.piFanIsLimit
def piIsoPi {ι : Type v} (α : ι → TopCat.{max v u}) : ∏ᶜ α ≅ TopCat.of (∀ i, α i) :=
(limit.isLimit _).conePointUniqueUpToIso (piFanIsLimit.{v, u} α)
-- Specifying the universes in `piFanIsLimit` wasn't necessary when we had `TopCatMax`
#align Top.pi_iso_pi TopCat.piIsoPi
@[reassoc (attr := simp)]
| Mathlib/Topology/Category/TopCat/Limits/Products.lean | 72 | 73 | theorem piIsoPi_inv_π {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) :
(piIsoPi α).inv ≫ Pi.π α i = piπ α i := by | simp [piIsoPi]
| 1 | 2.718282 | 0 | 0.5 | 4 | 450 |
import Mathlib.Algebra.MvPolynomial.Variables
#align_import data.mv_polynomial.supported from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
universe u v w
namespace MvPolynomial
variable {σ τ : Type*} {R : Type u} {S : Type v} {r : R} {e : ℕ} {n m : σ}
section CommSemiring
variable [CommSemiring R] {p q : MvPolynomial σ R}
variable (R)
noncomputable def supported (s : Set σ) : Subalgebra R (MvPolynomial σ R) :=
Algebra.adjoin R (X '' s)
#align mv_polynomial.supported MvPolynomial.supported
variable {R}
open Algebra
theorem supported_eq_range_rename (s : Set σ) : supported R s = (rename ((↑) : s → σ)).range := by
rw [supported, Set.image_eq_range, adjoin_range_eq_range_aeval, rename]
congr
#align mv_polynomial.supported_eq_range_rename MvPolynomial.supported_eq_range_rename
noncomputable def supportedEquivMvPolynomial (s : Set σ) : supported R s ≃ₐ[R] MvPolynomial s R :=
(Subalgebra.equivOfEq _ _ (supported_eq_range_rename s)).trans
(AlgEquiv.ofInjective (rename ((↑) : s → σ)) (rename_injective _ Subtype.val_injective)).symm
#align mv_polynomial.supported_equiv_mv_polynomial MvPolynomial.supportedEquivMvPolynomial
@[simp, nolint simpNF] -- Porting note: the `simpNF` linter complained about this lemma.
theorem supportedEquivMvPolynomial_symm_C (s : Set σ) (x : R) :
(supportedEquivMvPolynomial s).symm (C x) = algebraMap R (supported R s) x := by
ext1
simp [supportedEquivMvPolynomial, MvPolynomial.algebraMap_eq]
set_option linter.uppercaseLean3 false in
#align mv_polynomial.supported_equiv_mv_polynomial_symm_C MvPolynomial.supportedEquivMvPolynomial_symm_C
@[simp, nolint simpNF] -- Porting note: the `simpNF` linter complained about this lemma.
theorem supportedEquivMvPolynomial_symm_X (s : Set σ) (i : s) :
(↑((supportedEquivMvPolynomial s).symm (X i : MvPolynomial s R)) : MvPolynomial σ R) = X ↑i :=
by simp [supportedEquivMvPolynomial]
set_option linter.uppercaseLean3 false in
#align mv_polynomial.supported_equiv_mv_polynomial_symm_X MvPolynomial.supportedEquivMvPolynomial_symm_X
variable {s t : Set σ}
theorem mem_supported : p ∈ supported R s ↔ ↑p.vars ⊆ s := by
classical
rw [supported_eq_range_rename, AlgHom.mem_range]
constructor
· rintro ⟨p, rfl⟩
refine _root_.trans (Finset.coe_subset.2 (vars_rename _ _)) ?_
simp
· intro hs
exact exists_rename_eq_of_vars_subset_range p ((↑) : s → σ) Subtype.val_injective (by simpa)
#align mv_polynomial.mem_supported MvPolynomial.mem_supported
theorem supported_eq_vars_subset : (supported R s : Set (MvPolynomial σ R)) = { p | ↑p.vars ⊆ s } :=
Set.ext fun _ ↦ mem_supported
#align mv_polynomial.supported_eq_vars_subset MvPolynomial.supported_eq_vars_subset
@[simp]
theorem mem_supported_vars (p : MvPolynomial σ R) : p ∈ supported R (↑p.vars : Set σ) := by
rw [mem_supported]
#align mv_polynomial.mem_supported_vars MvPolynomial.mem_supported_vars
variable (s)
theorem supported_eq_adjoin_X : supported R s = Algebra.adjoin R (X '' s) := rfl
set_option linter.uppercaseLean3 false in
#align mv_polynomial.supported_eq_adjoin_X MvPolynomial.supported_eq_adjoin_X
@[simp]
| Mathlib/Algebra/MvPolynomial/Supported.lean | 102 | 103 | theorem supported_univ : supported R (Set.univ : Set σ) = ⊤ := by |
simp [Algebra.eq_top_iff, mem_supported]
| 1 | 2.718282 | 0 | 0.888889 | 9 | 773 |
import Mathlib.AlgebraicGeometry.Spec
import Mathlib.Algebra.Category.Ring.Constructions
import Mathlib.CategoryTheory.Elementwise
#align_import algebraic_geometry.Scheme from "leanprover-community/mathlib"@"88474d1b5af6d37c2ab728b757771bced7f5194c"
-- Explicit universe annotations were used in this file to improve perfomance #12737
set_option linter.uppercaseLean3 false
universe u
noncomputable section
open TopologicalSpace
open CategoryTheory
open TopCat
open Opposite
namespace AlgebraicGeometry
structure Scheme extends LocallyRingedSpace where
local_affine :
∀ x : toLocallyRingedSpace,
∃ (U : OpenNhds x) (R : CommRingCat),
Nonempty
(toLocallyRingedSpace.restrict U.openEmbedding ≅ Spec.toLocallyRingedSpace.obj (op R))
#align algebraic_geometry.Scheme AlgebraicGeometry.Scheme
namespace Scheme
-- @[nolint has_nonempty_instance] -- Porting note(#5171): linter not ported yet
def Hom (X Y : Scheme) : Type* :=
X.toLocallyRingedSpace ⟶ Y.toLocallyRingedSpace
#align algebraic_geometry.Scheme.hom AlgebraicGeometry.Scheme.Hom
instance : Category Scheme :=
{ InducedCategory.category Scheme.toLocallyRingedSpace with Hom := Hom }
-- porting note (#10688): added to ease automation
@[continuity]
lemma Hom.continuous {X Y : Scheme} (f : X ⟶ Y) : Continuous f.1.base := f.1.base.2
protected abbrev sheaf (X : Scheme) :=
X.toSheafedSpace.sheaf
#align algebraic_geometry.Scheme.sheaf AlgebraicGeometry.Scheme.sheaf
instance : CoeSort Scheme Type* where
coe X := X.carrier
@[simps!]
def forgetToLocallyRingedSpace : Scheme ⥤ LocallyRingedSpace :=
inducedFunctor _
-- deriving Full, Faithful -- Porting note: no delta derive handler, see https://github.com/leanprover-community/mathlib4/issues/5020
#align algebraic_geometry.Scheme.forget_to_LocallyRingedSpace AlgebraicGeometry.Scheme.forgetToLocallyRingedSpace
@[simps!]
def fullyFaithfulForgetToLocallyRingedSpace :
forgetToLocallyRingedSpace.FullyFaithful :=
fullyFaithfulInducedFunctor _
instance : forgetToLocallyRingedSpace.Full :=
InducedCategory.full _
instance : forgetToLocallyRingedSpace.Faithful :=
InducedCategory.faithful _
@[simps!]
def forgetToTop : Scheme ⥤ TopCat :=
Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToTop
#align algebraic_geometry.Scheme.forget_to_Top AlgebraicGeometry.Scheme.forgetToTop
-- Porting note: Lean seems not able to find this coercion any more
instance hasCoeToTopCat : CoeOut Scheme TopCat where
coe X := X.carrier
-- Porting note: added this unification hint just in case
unif_hint forgetToTop_obj_eq_coe (X : Scheme) where ⊢
forgetToTop.obj X ≟ (X : TopCat)
@[simp]
theorem id_val_base (X : Scheme) : (𝟙 X : _).1.base = 𝟙 _ :=
rfl
#align algebraic_geometry.Scheme.id_val_base AlgebraicGeometry.Scheme.id_val_base
@[simp]
theorem id_app {X : Scheme} (U : (Opens X.carrier)ᵒᵖ) :
(𝟙 X : _).val.c.app U =
X.presheaf.map (eqToHom (by induction' U with U; cases U; rfl)) :=
PresheafedSpace.id_c_app X.toPresheafedSpace U
#align algebraic_geometry.Scheme.id_app AlgebraicGeometry.Scheme.id_app
@[reassoc]
theorem comp_val {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).val = f.val ≫ g.val :=
rfl
#align algebraic_geometry.Scheme.comp_val AlgebraicGeometry.Scheme.comp_val
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_coeBase {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).val.base = f.val.base ≫ g.val.base :=
rfl
#align algebraic_geometry.Scheme.comp_coe_base AlgebraicGeometry.Scheme.comp_coeBase
-- Porting note: removed elementwise attribute, as generated lemmas were trivial.
@[reassoc]
theorem comp_val_base {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).val.base = f.val.base ≫ g.val.base :=
rfl
#align algebraic_geometry.Scheme.comp_val_base AlgebraicGeometry.Scheme.comp_val_base
theorem comp_val_base_apply {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :
(f ≫ g).val.base x = g.val.base (f.val.base x) := by
simp
#align algebraic_geometry.Scheme.comp_val_base_apply AlgebraicGeometry.Scheme.comp_val_base_apply
@[simp, reassoc] -- reassoc lemma does not need `simp`
theorem comp_val_c_app {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(f ≫ g).val.c.app U = g.val.c.app U ≫ f.val.c.app _ :=
rfl
#align algebraic_geometry.Scheme.comp_val_c_app AlgebraicGeometry.Scheme.comp_val_c_app
| Mathlib/AlgebraicGeometry/Scheme.lean | 155 | 157 | theorem congr_app {X Y : Scheme} {f g : X ⟶ Y} (e : f = g) (U) :
f.val.c.app U = g.val.c.app U ≫ X.presheaf.map (eqToHom (by subst e; rfl)) := by |
subst e; dsimp; simp
| 1 | 2.718282 | 0 | 0.333333 | 3 | 354 |
import Mathlib.Topology.Separation
import Mathlib.Algebra.BigOperators.Finprod
#align_import topology.algebra.infinite_sum.basic from "leanprover-community/mathlib"@"3b52265189f3fb43aa631edffce5d060fafaf82f"
noncomputable section
open Filter Function
open scoped Topology
variable {α β γ : Type*}
section HasProd
variable [CommMonoid α] [TopologicalSpace α]
@[to_additive "Infinite sum on a topological monoid
The `atTop` filter on `Finset β` is the limit of all finite sets towards the entire type. So we sum
up bigger and bigger sets. This sum operation is invariant under reordering. In particular,
the function `ℕ → ℝ` sending `n` to `(-1)^n / (n+1)` does not have a
sum for this definition, but a series which is absolutely convergent will have the correct sum.
This is based on Mario Carneiro's
[infinite sum `df-tsms` in Metamath](http://us.metamath.org/mpeuni/df-tsms.html).
For the definition and many statements, `α` does not need to be a topological monoid. We only add
this assumption later, for the lemmas where it is relevant."]
def HasProd (f : β → α) (a : α) : Prop :=
Tendsto (fun s : Finset β ↦ ∏ b ∈ s, f b) atTop (𝓝 a)
#align has_sum HasSum
@[to_additive "`Summable f` means that `f` has some (infinite) sum. Use `tsum` to get the value."]
def Multipliable (f : β → α) : Prop :=
∃ a, HasProd f a
#align summable Summable
open scoped Classical in
@[to_additive "`∑' i, f i` is the sum of `f` it exists, or 0 otherwise."]
noncomputable irreducible_def tprod {β} (f : β → α) :=
if h : Multipliable f then
if (mulSupport f).Finite then finprod f
else h.choose
else 1
#align tsum tsum
-- see Note [operator precedence of big operators]
@[inherit_doc tprod]
notation3 "∏' "(...)", "r:67:(scoped f => tprod f) => r
@[inherit_doc tsum]
notation3 "∑' "(...)", "r:67:(scoped f => tsum f) => r
variable {f g : β → α} {a b : α} {s : Finset β}
@[to_additive]
theorem HasProd.multipliable (h : HasProd f a) : Multipliable f :=
⟨a, h⟩
#align has_sum.summable HasSum.summable
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Defs.lean | 124 | 125 | theorem tprod_eq_one_of_not_multipliable (h : ¬Multipliable f) : ∏' b, f b = 1 := by |
simp [tprod_def, h]
| 1 | 2.718282 | 0 | 0.5 | 4 | 493 |
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.FDeriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.RestrictScalars
#align_import analysis.calculus.deriv.comp from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
universe u v w
open scoped Classical
open Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L L₁ L₂ : Filter 𝕜}
section CompositionVector
open ContinuousLinearMap
variable {l : F → E} {l' : F →L[𝕜] E} {y : F}
variable (x)
theorem HasFDerivWithinAt.comp_hasDerivWithinAt {t : Set F} (hl : HasFDerivWithinAt l l' t (f x))
(hf : HasDerivWithinAt f f' s x) (hst : MapsTo f s t) :
HasDerivWithinAt (l ∘ f) (l' f') s x := by
simpa only [one_apply, one_smul, smulRight_apply, coe_comp', (· ∘ ·)] using
(hl.comp x hf.hasFDerivWithinAt hst).hasDerivWithinAt
#align has_fderiv_within_at.comp_has_deriv_within_at HasFDerivWithinAt.comp_hasDerivWithinAt
theorem HasFDerivWithinAt.comp_hasDerivWithinAt_of_eq {t : Set F}
(hl : HasFDerivWithinAt l l' t y)
(hf : HasDerivWithinAt f f' s x) (hst : MapsTo f s t) (hy : y = f x) :
HasDerivWithinAt (l ∘ f) (l' f') s x := by
rw [hy] at hl; exact hl.comp_hasDerivWithinAt x hf hst
theorem HasFDerivAt.comp_hasDerivWithinAt (hl : HasFDerivAt l l' (f x))
(hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (l ∘ f) (l' f') s x :=
hl.hasFDerivWithinAt.comp_hasDerivWithinAt x hf (mapsTo_univ _ _)
#align has_fderiv_at.comp_has_deriv_within_at HasFDerivAt.comp_hasDerivWithinAt
theorem HasFDerivAt.comp_hasDerivWithinAt_of_eq (hl : HasFDerivAt l l' y)
(hf : HasDerivWithinAt f f' s x) (hy : y = f x) :
HasDerivWithinAt (l ∘ f) (l' f') s x := by
rw [hy] at hl; exact hl.comp_hasDerivWithinAt x hf
theorem HasFDerivAt.comp_hasDerivAt (hl : HasFDerivAt l l' (f x)) (hf : HasDerivAt f f' x) :
HasDerivAt (l ∘ f) (l' f') x :=
hasDerivWithinAt_univ.mp <| hl.comp_hasDerivWithinAt x hf.hasDerivWithinAt
#align has_fderiv_at.comp_has_deriv_at HasFDerivAt.comp_hasDerivAt
theorem HasFDerivAt.comp_hasDerivAt_of_eq
(hl : HasFDerivAt l l' y) (hf : HasDerivAt f f' x) (hy : y = f x) :
HasDerivAt (l ∘ f) (l' f') x := by
rw [hy] at hl; exact hl.comp_hasDerivAt x hf
theorem HasStrictFDerivAt.comp_hasStrictDerivAt (hl : HasStrictFDerivAt l l' (f x))
(hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (l ∘ f) (l' f') x := by
simpa only [one_apply, one_smul, smulRight_apply, coe_comp', (· ∘ ·)] using
(hl.comp x hf.hasStrictFDerivAt).hasStrictDerivAt
#align has_strict_fderiv_at.comp_has_strict_deriv_at HasStrictFDerivAt.comp_hasStrictDerivAt
theorem HasStrictFDerivAt.comp_hasStrictDerivAt_of_eq (hl : HasStrictFDerivAt l l' y)
(hf : HasStrictDerivAt f f' x) (hy : y = f x) :
HasStrictDerivAt (l ∘ f) (l' f') x := by
rw [hy] at hl; exact hl.comp_hasStrictDerivAt x hf
theorem fderivWithin.comp_derivWithin {t : Set F} (hl : DifferentiableWithinAt 𝕜 l t (f x))
(hf : DifferentiableWithinAt 𝕜 f s x) (hs : MapsTo f s t) (hxs : UniqueDiffWithinAt 𝕜 s x) :
derivWithin (l ∘ f) s x = (fderivWithin 𝕜 l t (f x) : F → E) (derivWithin f s x) :=
(hl.hasFDerivWithinAt.comp_hasDerivWithinAt x hf.hasDerivWithinAt hs).derivWithin hxs
#align fderiv_within.comp_deriv_within fderivWithin.comp_derivWithin
theorem fderivWithin.comp_derivWithin_of_eq {t : Set F} (hl : DifferentiableWithinAt 𝕜 l t y)
(hf : DifferentiableWithinAt 𝕜 f s x) (hs : MapsTo f s t) (hxs : UniqueDiffWithinAt 𝕜 s x)
(hy : y = f x) :
derivWithin (l ∘ f) s x = (fderivWithin 𝕜 l t (f x) : F → E) (derivWithin f s x) := by
rw [hy] at hl; exact fderivWithin.comp_derivWithin x hl hf hs hxs
theorem fderiv.comp_deriv (hl : DifferentiableAt 𝕜 l (f x)) (hf : DifferentiableAt 𝕜 f x) :
deriv (l ∘ f) x = (fderiv 𝕜 l (f x) : F → E) (deriv f x) :=
(hl.hasFDerivAt.comp_hasDerivAt x hf.hasDerivAt).deriv
#align fderiv.comp_deriv fderiv.comp_deriv
| Mathlib/Analysis/Calculus/Deriv/Comp.lean | 415 | 418 | theorem fderiv.comp_deriv_of_eq (hl : DifferentiableAt 𝕜 l y) (hf : DifferentiableAt 𝕜 f x)
(hy : y = f x) :
deriv (l ∘ f) x = (fderiv 𝕜 l (f x) : F → E) (deriv f x) := by |
rw [hy] at hl; exact fderiv.comp_deriv x hl hf
| 1 | 2.718282 | 0 | 0 | 14 | 81 |
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section OrderedAddCommGroup
variable [OrderedAddCommGroup α] (a b c : α)
@[simp]
theorem preimage_const_add_Ici : (fun x => a + x) ⁻¹' Ici b = Ici (b - a) :=
ext fun _x => sub_le_iff_le_add'.symm
#align set.preimage_const_add_Ici Set.preimage_const_add_Ici
@[simp]
theorem preimage_const_add_Ioi : (fun x => a + x) ⁻¹' Ioi b = Ioi (b - a) :=
ext fun _x => sub_lt_iff_lt_add'.symm
#align set.preimage_const_add_Ioi Set.preimage_const_add_Ioi
@[simp]
theorem preimage_const_add_Iic : (fun x => a + x) ⁻¹' Iic b = Iic (b - a) :=
ext fun _x => le_sub_iff_add_le'.symm
#align set.preimage_const_add_Iic Set.preimage_const_add_Iic
@[simp]
theorem preimage_const_add_Iio : (fun x => a + x) ⁻¹' Iio b = Iio (b - a) :=
ext fun _x => lt_sub_iff_add_lt'.symm
#align set.preimage_const_add_Iio Set.preimage_const_add_Iio
@[simp]
theorem preimage_const_add_Icc : (fun x => a + x) ⁻¹' Icc b c = Icc (b - a) (c - a) := by
simp [← Ici_inter_Iic]
#align set.preimage_const_add_Icc Set.preimage_const_add_Icc
@[simp]
theorem preimage_const_add_Ico : (fun x => a + x) ⁻¹' Ico b c = Ico (b - a) (c - a) := by
simp [← Ici_inter_Iio]
#align set.preimage_const_add_Ico Set.preimage_const_add_Ico
@[simp]
theorem preimage_const_add_Ioc : (fun x => a + x) ⁻¹' Ioc b c = Ioc (b - a) (c - a) := by
simp [← Ioi_inter_Iic]
#align set.preimage_const_add_Ioc Set.preimage_const_add_Ioc
@[simp]
theorem preimage_const_add_Ioo : (fun x => a + x) ⁻¹' Ioo b c = Ioo (b - a) (c - a) := by
simp [← Ioi_inter_Iio]
#align set.preimage_const_add_Ioo Set.preimage_const_add_Ioo
@[simp]
theorem preimage_add_const_Ici : (fun x => x + a) ⁻¹' Ici b = Ici (b - a) :=
ext fun _x => sub_le_iff_le_add.symm
#align set.preimage_add_const_Ici Set.preimage_add_const_Ici
@[simp]
theorem preimage_add_const_Ioi : (fun x => x + a) ⁻¹' Ioi b = Ioi (b - a) :=
ext fun _x => sub_lt_iff_lt_add.symm
#align set.preimage_add_const_Ioi Set.preimage_add_const_Ioi
@[simp]
theorem preimage_add_const_Iic : (fun x => x + a) ⁻¹' Iic b = Iic (b - a) :=
ext fun _x => le_sub_iff_add_le.symm
#align set.preimage_add_const_Iic Set.preimage_add_const_Iic
@[simp]
theorem preimage_add_const_Iio : (fun x => x + a) ⁻¹' Iio b = Iio (b - a) :=
ext fun _x => lt_sub_iff_add_lt.symm
#align set.preimage_add_const_Iio Set.preimage_add_const_Iio
@[simp]
theorem preimage_add_const_Icc : (fun x => x + a) ⁻¹' Icc b c = Icc (b - a) (c - a) := by
simp [← Ici_inter_Iic]
#align set.preimage_add_const_Icc Set.preimage_add_const_Icc
@[simp]
| Mathlib/Data/Set/Pointwise/Interval.lean | 197 | 198 | theorem preimage_add_const_Ico : (fun x => x + a) ⁻¹' Ico b c = Ico (b - a) (c - a) := by |
simp [← Ici_inter_Iio]
| 1 | 2.718282 | 0 | 0.37931 | 29 | 381 |
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Algebra.Order.Ring.Int
import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Data.Nat.Cast.Order
#align_import algebra.order.ring.abs from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
variable {α : Type*}
lemma odd_abs [LinearOrder α] [Ring α] {a : α} : Odd (abs a) ↔ Odd a := by
cases' abs_choice a with h h <;> simp only [h, odd_neg]
section
variable [Ring α] [LinearOrder α] {a b : α}
@[simp]
| Mathlib/Algebra/Order/Ring/Abs.lean | 192 | 193 | theorem abs_dvd (a b : α) : |a| ∣ b ↔ a ∣ b := by |
cases' abs_choice a with h h <;> simp only [h, neg_dvd]
| 1 | 2.718282 | 0 | 0 | 2 | 141 |
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Data.Nat.Factorization.Basic
import Mathlib.Analysis.NormedSpace.Real
#align_import analysis.special_functions.log.basic from "leanprover-community/mathlib"@"f23a09ce6d3f367220dc3cecad6b7eb69eb01690"
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {x y : ℝ}
-- @[pp_nodot] -- Porting note: removed
noncomputable def log (x : ℝ) : ℝ :=
if hx : x = 0 then 0 else expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩
#align real.log Real.log
theorem log_of_ne_zero (hx : x ≠ 0) : log x = expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ :=
dif_neg hx
#align real.log_of_ne_zero Real.log_of_ne_zero
theorem log_of_pos (hx : 0 < x) : log x = expOrderIso.symm ⟨x, hx⟩ := by
rw [log_of_ne_zero hx.ne']
congr
exact abs_of_pos hx
#align real.log_of_pos Real.log_of_pos
theorem exp_log_eq_abs (hx : x ≠ 0) : exp (log x) = |x| := by
rw [log_of_ne_zero hx, ← coe_expOrderIso_apply, OrderIso.apply_symm_apply, Subtype.coe_mk]
#align real.exp_log_eq_abs Real.exp_log_eq_abs
theorem exp_log (hx : 0 < x) : exp (log x) = x := by
rw [exp_log_eq_abs hx.ne']
exact abs_of_pos hx
#align real.exp_log Real.exp_log
theorem exp_log_of_neg (hx : x < 0) : exp (log x) = -x := by
rw [exp_log_eq_abs (ne_of_lt hx)]
exact abs_of_neg hx
#align real.exp_log_of_neg Real.exp_log_of_neg
theorem le_exp_log (x : ℝ) : x ≤ exp (log x) := by
by_cases h_zero : x = 0
· rw [h_zero, log, dif_pos rfl, exp_zero]
exact zero_le_one
· rw [exp_log_eq_abs h_zero]
exact le_abs_self _
#align real.le_exp_log Real.le_exp_log
@[simp]
theorem log_exp (x : ℝ) : log (exp x) = x :=
exp_injective <| exp_log (exp_pos x)
#align real.log_exp Real.log_exp
theorem surjOn_log : SurjOn log (Ioi 0) univ := fun x _ => ⟨exp x, exp_pos x, log_exp x⟩
#align real.surj_on_log Real.surjOn_log
theorem log_surjective : Surjective log := fun x => ⟨exp x, log_exp x⟩
#align real.log_surjective Real.log_surjective
@[simp]
theorem range_log : range log = univ :=
log_surjective.range_eq
#align real.range_log Real.range_log
@[simp]
theorem log_zero : log 0 = 0 :=
dif_pos rfl
#align real.log_zero Real.log_zero
@[simp]
theorem log_one : log 1 = 0 :=
exp_injective <| by rw [exp_log zero_lt_one, exp_zero]
#align real.log_one Real.log_one
@[simp]
theorem log_abs (x : ℝ) : log |x| = log x := by
by_cases h : x = 0
· simp [h]
· rw [← exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs]
#align real.log_abs Real.log_abs
@[simp]
theorem log_neg_eq_log (x : ℝ) : log (-x) = log x := by rw [← log_abs x, ← log_abs (-x), abs_neg]
#align real.log_neg_eq_log Real.log_neg_eq_log
theorem sinh_log {x : ℝ} (hx : 0 < x) : sinh (log x) = (x - x⁻¹) / 2 := by
rw [sinh_eq, exp_neg, exp_log hx]
#align real.sinh_log Real.sinh_log
| Mathlib/Analysis/SpecialFunctions/Log/Basic.lean | 118 | 119 | theorem cosh_log {x : ℝ} (hx : 0 < x) : cosh (log x) = (x + x⁻¹) / 2 := by |
rw [cosh_eq, exp_neg, exp_log hx]
| 1 | 2.718282 | 0 | 0.583333 | 12 | 525 |
import Mathlib.Topology.Algebra.GroupWithZero
import Mathlib.Topology.Order.OrderClosed
#align_import topology.algebra.with_zero_topology from "leanprover-community/mathlib"@"3e0c4d76b6ebe9dfafb67d16f7286d2731ed6064"
open Topology Filter TopologicalSpace Filter Set Function
namespace WithZeroTopology
variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α}
{f : α → Γ₀}
scoped instance (priority := 100) topologicalSpace : TopologicalSpace Γ₀ :=
nhdsAdjoint 0 <| ⨅ γ ≠ 0, 𝓟 (Iio γ)
#align with_zero_topology.topological_space WithZeroTopology.topologicalSpace
theorem nhds_eq_update : (𝓝 : Γ₀ → Filter Γ₀) = update pure 0 (⨅ γ ≠ 0, 𝓟 (Iio γ)) := by
rw [nhds_nhdsAdjoint, sup_of_le_right]
exact le_iInf₂ fun γ hγ ↦ le_principal_iff.2 <| zero_lt_iff.2 hγ
#align with_zero_topology.nhds_eq_update WithZeroTopology.nhds_eq_update
theorem nhds_zero : 𝓝 (0 : Γ₀) = ⨅ γ ≠ 0, 𝓟 (Iio γ) := by
rw [nhds_eq_update, update_same]
#align with_zero_topology.nhds_zero WithZeroTopology.nhds_zero
theorem hasBasis_nhds_zero : (𝓝 (0 : Γ₀)).HasBasis (fun γ : Γ₀ => γ ≠ 0) Iio := by
rw [nhds_zero]
refine hasBasis_biInf_principal ?_ ⟨1, one_ne_zero⟩
exact directedOn_iff_directed.2 (Monotone.directed_ge fun a b hab => Iio_subset_Iio hab)
#align with_zero_topology.has_basis_nhds_zero WithZeroTopology.hasBasis_nhds_zero
theorem Iio_mem_nhds_zero (hγ : γ ≠ 0) : Iio γ ∈ 𝓝 (0 : Γ₀) :=
hasBasis_nhds_zero.mem_of_mem hγ
#align with_zero_topology.Iio_mem_nhds_zero WithZeroTopology.Iio_mem_nhds_zero
theorem nhds_zero_of_units (γ : Γ₀ˣ) : Iio ↑γ ∈ 𝓝 (0 : Γ₀) :=
Iio_mem_nhds_zero γ.ne_zero
#align with_zero_topology.nhds_zero_of_units WithZeroTopology.nhds_zero_of_units
theorem tendsto_zero : Tendsto f l (𝓝 (0 : Γ₀)) ↔ ∀ (γ₀) (_ : γ₀ ≠ 0), ∀ᶠ x in l, f x < γ₀ := by
simp [nhds_zero]
#align with_zero_topology.tendsto_zero WithZeroTopology.tendsto_zero
@[simp]
theorem nhds_of_ne_zero {γ : Γ₀} (h₀ : γ ≠ 0) : 𝓝 γ = pure γ :=
nhds_nhdsAdjoint_of_ne _ h₀
#align with_zero_topology.nhds_of_ne_zero WithZeroTopology.nhds_of_ne_zero
theorem nhds_coe_units (γ : Γ₀ˣ) : 𝓝 (γ : Γ₀) = pure (γ : Γ₀) :=
nhds_of_ne_zero γ.ne_zero
#align with_zero_topology.nhds_coe_units WithZeroTopology.nhds_coe_units
theorem singleton_mem_nhds_of_units (γ : Γ₀ˣ) : ({↑γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by simp
#align with_zero_topology.singleton_mem_nhds_of_units WithZeroTopology.singleton_mem_nhds_of_units
theorem singleton_mem_nhds_of_ne_zero (h : γ ≠ 0) : ({γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by simp [h]
#align with_zero_topology.singleton_mem_nhds_of_ne_zero WithZeroTopology.singleton_mem_nhds_of_ne_zero
theorem hasBasis_nhds_of_ne_zero {x : Γ₀} (h : x ≠ 0) :
HasBasis (𝓝 x) (fun _ : Unit => True) fun _ => {x} := by
rw [nhds_of_ne_zero h]
exact hasBasis_pure _
#align with_zero_topology.has_basis_nhds_of_ne_zero WithZeroTopology.hasBasis_nhds_of_ne_zero
theorem hasBasis_nhds_units (γ : Γ₀ˣ) :
HasBasis (𝓝 (γ : Γ₀)) (fun _ : Unit => True) fun _ => {↑γ} :=
hasBasis_nhds_of_ne_zero γ.ne_zero
#align with_zero_topology.has_basis_nhds_units WithZeroTopology.hasBasis_nhds_units
| Mathlib/Topology/Algebra/WithZeroTopology.lean | 120 | 121 | theorem tendsto_of_ne_zero {γ : Γ₀} (h : γ ≠ 0) : Tendsto f l (𝓝 γ) ↔ ∀ᶠ x in l, f x = γ := by |
rw [nhds_of_ne_zero h, tendsto_pure]
| 1 | 2.718282 | 0 | 0.454545 | 11 | 414 |
import Mathlib.Control.Functor.Multivariate
import Mathlib.Data.PFunctor.Univariate.Basic
#align_import data.pfunctor.multivariate.basic from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d"
universe u v
open MvFunctor
@[pp_with_univ]
structure MvPFunctor (n : ℕ) where
A : Type u
B : A → TypeVec.{u} n
#align mvpfunctor MvPFunctor
namespace MvPFunctor
open MvFunctor (LiftP LiftR)
variable {n m : ℕ} (P : MvPFunctor.{u} n)
@[coe]
def Obj (α : TypeVec.{u} n) : Type u :=
Σ a : P.A, P.B a ⟹ α
#align mvpfunctor.obj MvPFunctor.Obj
instance : CoeFun (MvPFunctor.{u} n) (fun _ => TypeVec.{u} n → Type u) where
coe := Obj
def map {α β : TypeVec n} (f : α ⟹ β) : P α → P β := fun ⟨a, g⟩ => ⟨a, TypeVec.comp f g⟩
#align mvpfunctor.map MvPFunctor.map
instance : Inhabited (MvPFunctor n) :=
⟨⟨default, default⟩⟩
instance Obj.inhabited {α : TypeVec n} [Inhabited P.A] [∀ i, Inhabited (α i)] :
Inhabited (P α) :=
⟨⟨default, fun _ _ => default⟩⟩
#align mvpfunctor.obj.inhabited MvPFunctor.Obj.inhabited
instance : MvFunctor.{u} P.Obj :=
⟨@MvPFunctor.map n P⟩
theorem map_eq {α β : TypeVec n} (g : α ⟹ β) (a : P.A) (f : P.B a ⟹ α) :
@MvFunctor.map _ P.Obj _ _ _ g ⟨a, f⟩ = ⟨a, g ⊚ f⟩ :=
rfl
#align mvpfunctor.map_eq MvPFunctor.map_eq
theorem id_map {α : TypeVec n} : ∀ x : P α, TypeVec.id <$$> x = x
| ⟨_, _⟩ => rfl
#align mvpfunctor.id_map MvPFunctor.id_map
theorem comp_map {α β γ : TypeVec n} (f : α ⟹ β) (g : β ⟹ γ) :
∀ x : P α, (g ⊚ f) <$$> x = g <$$> f <$$> x
| ⟨_, _⟩ => rfl
#align mvpfunctor.comp_map MvPFunctor.comp_map
instance : LawfulMvFunctor.{u} P.Obj where
id_map := @id_map _ P
comp_map := @comp_map _ P
def const (n : ℕ) (A : Type u) : MvPFunctor n :=
{ A
B := fun _ _ => PEmpty }
#align mvpfunctor.const MvPFunctor.const
def comp (P : MvPFunctor.{u} n) (Q : Fin2 n → MvPFunctor.{u} m) : MvPFunctor m where
A := Σ a₂ : P.1, ∀ i, P.2 a₂ i → (Q i).1
B a i := Σ(j : _) (b : P.2 a.1 j), (Q j).2 (a.snd j b) i
#align mvpfunctor.comp MvPFunctor.comp
variable {P} {Q : Fin2 n → MvPFunctor.{u} m} {α β : TypeVec.{u} m}
def comp.mk (x : P (fun i => Q i α)) : comp P Q α :=
⟨⟨x.1, fun _ a => (x.2 _ a).1⟩, fun i a => (x.snd a.fst a.snd.fst).snd i a.snd.snd⟩
#align mvpfunctor.comp.mk MvPFunctor.comp.mk
def comp.get (x : comp P Q α) : P (fun i => Q i α) :=
⟨x.1.1, fun i a => ⟨x.fst.snd i a, fun (j : Fin2 m) (b : (Q i).B _ j) => x.snd j ⟨i, ⟨a, b⟩⟩⟩⟩
#align mvpfunctor.comp.get MvPFunctor.comp.get
theorem comp.get_map (f : α ⟹ β) (x : comp P Q α) :
comp.get (f <$$> x) = (fun i (x : Q i α) => f <$$> x) <$$> comp.get x := by
rfl
#align mvpfunctor.comp.get_map MvPFunctor.comp.get_map
@[simp]
| Mathlib/Data/PFunctor/Multivariate/Basic.lean | 148 | 149 | theorem comp.get_mk (x : P (fun i => Q i α)) : comp.get (comp.mk x) = x := by |
rfl
| 1 | 2.718282 | 0 | 0.857143 | 7 | 749 |
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"
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']
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]
| 1 | 2.718282 | 0 | 0.625 | 8 | 545 |
import Mathlib.Topology.ContinuousFunction.Basic
#align_import topology.continuous_function.cocompact_map from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977"
universe u v w
open Filter Set
structure CocompactMap (α : Type u) (β : Type v) [TopologicalSpace α] [TopologicalSpace β] extends
ContinuousMap α β : Type max u v where
cocompact_tendsto' : Tendsto toFun (cocompact α) (cocompact β)
#align cocompact_map CocompactMap
section
class CocompactMapClass (F : Type*) (α β : outParam Type*) [TopologicalSpace α]
[TopologicalSpace β] [FunLike F α β] extends ContinuousMapClass F α β : Prop where
cocompact_tendsto (f : F) : Tendsto f (cocompact α) (cocompact β)
#align cocompact_map_class CocompactMapClass
end
export CocompactMapClass (cocompact_tendsto)
namespace CocompactMap
section Basics
variable {α β γ δ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
[TopologicalSpace δ]
instance : FunLike (CocompactMap α β) α β where
coe f := f.toFun
coe_injective' f g h := by
obtain ⟨⟨_, _⟩, _⟩ := f
obtain ⟨⟨_, _⟩, _⟩ := g
congr
instance : CocompactMapClass (CocompactMap α β) α β where
map_continuous f := f.continuous_toFun
cocompact_tendsto f := f.cocompact_tendsto'
@[simp]
theorem coe_toContinuousMap {f : CocompactMap α β} : (f.toContinuousMap : α → β) = f :=
rfl
#align cocompact_map.coe_to_continuous_fun CocompactMap.coe_toContinuousMap
@[ext]
theorem ext {f g : CocompactMap α β} (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext _ _ h
#align cocompact_map.ext CocompactMap.ext
protected def copy (f : CocompactMap α β) (f' : α → β) (h : f' = f) : CocompactMap α β where
toFun := f'
continuous_toFun := by
rw [h]
exact f.continuous_toFun
cocompact_tendsto' := by
simp_rw [h]
exact f.cocompact_tendsto'
#align cocompact_map.copy CocompactMap.copy
@[simp]
theorem coe_copy (f : CocompactMap α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=
rfl
#align cocompact_map.coe_copy CocompactMap.coe_copy
theorem copy_eq (f : CocompactMap α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=
DFunLike.ext' h
#align cocompact_map.copy_eq CocompactMap.copy_eq
@[simp]
theorem coe_mk (f : C(α, β)) (h : Tendsto f (cocompact α) (cocompact β)) :
⇑(⟨f, h⟩ : CocompactMap α β) = f :=
rfl
#align cocompact_map.coe_mk CocompactMap.coe_mk
section
variable (α)
protected def id : CocompactMap α α :=
⟨ContinuousMap.id _, tendsto_id⟩
#align cocompact_map.id CocompactMap.id
@[simp]
theorem coe_id : ⇑(CocompactMap.id α) = id :=
rfl
#align cocompact_map.coe_id CocompactMap.coe_id
end
instance : Inhabited (CocompactMap α α) :=
⟨CocompactMap.id α⟩
def comp (f : CocompactMap β γ) (g : CocompactMap α β) : CocompactMap α γ :=
⟨f.toContinuousMap.comp g, (cocompact_tendsto f).comp (cocompact_tendsto g)⟩
#align cocompact_map.comp CocompactMap.comp
@[simp]
theorem coe_comp (f : CocompactMap β γ) (g : CocompactMap α β) : ⇑(comp f g) = f ∘ g :=
rfl
#align cocompact_map.coe_comp CocompactMap.coe_comp
@[simp]
theorem comp_apply (f : CocompactMap β γ) (g : CocompactMap α β) (a : α) : comp f g a = f (g a) :=
rfl
#align cocompact_map.comp_apply CocompactMap.comp_apply
@[simp]
theorem comp_assoc (f : CocompactMap γ δ) (g : CocompactMap β γ) (h : CocompactMap α β) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
#align cocompact_map.comp_assoc CocompactMap.comp_assoc
@[simp]
theorem id_comp (f : CocompactMap α β) : (CocompactMap.id _).comp f = f :=
ext fun _ => rfl
#align cocompact_map.id_comp CocompactMap.id_comp
@[simp]
theorem comp_id (f : CocompactMap α β) : f.comp (CocompactMap.id _) = f :=
ext fun _ => rfl
#align cocompact_map.comp_id CocompactMap.comp_id
theorem tendsto_of_forall_preimage {f : α → β} (h : ∀ s, IsCompact s → IsCompact (f ⁻¹' s)) :
Tendsto f (cocompact α) (cocompact β) := fun s hs =>
match mem_cocompact.mp hs with
| ⟨t, ht, hts⟩ =>
mem_map.mpr (mem_cocompact.mpr ⟨f ⁻¹' t, h t ht, by simpa using preimage_mono hts⟩)
#align cocompact_map.tendsto_of_forall_preimage CocompactMap.tendsto_of_forall_preimage
| Mathlib/Topology/ContinuousFunction/CocompactMap.lean | 185 | 195 | theorem isCompact_preimage [T2Space β] (f : CocompactMap α β) ⦃s : Set β⦄ (hs : IsCompact s) :
IsCompact (f ⁻¹' s) := by |
obtain ⟨t, ht, hts⟩ :=
mem_cocompact'.mp
(by
simpa only [preimage_image_preimage, preimage_compl] using
mem_map.mp
(cocompact_tendsto f <|
mem_cocompact.mpr ⟨s, hs, compl_subset_compl.mpr (image_preimage_subset f _)⟩))
exact
ht.of_isClosed_subset (hs.isClosed.preimage <| map_continuous f) (by simpa using hts)
| 9 | 8,103.083928 | 2 | 2 | 1 | 2,005 |
import Mathlib.Algebra.Polynomial.Eval
#align_import data.polynomial.degree.lemmas from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f"
noncomputable section
open Polynomial
open Finsupp Finset
namespace Polynomial
universe u v w
variable {R : Type u} {S : Type v} {ι : Type w} {a b : R} {m n : ℕ}
section Semiring
variable [Semiring R] {p q r : R[X]}
section Degree
theorem natDegree_comp_le : natDegree (p.comp q) ≤ natDegree p * natDegree q :=
letI := Classical.decEq R
if h0 : p.comp q = 0 then by rw [h0, natDegree_zero]; exact Nat.zero_le _
else
WithBot.coe_le_coe.1 <|
calc
↑(natDegree (p.comp q)) = degree (p.comp q) := (degree_eq_natDegree h0).symm
_ = _ := congr_arg degree comp_eq_sum_left
_ ≤ _ := degree_sum_le _ _
_ ≤ _ :=
Finset.sup_le fun n hn =>
calc
degree (C (coeff p n) * q ^ n) ≤ degree (C (coeff p n)) + degree (q ^ n) :=
degree_mul_le _ _
_ ≤ natDegree (C (coeff p n)) + n • degree q :=
(add_le_add degree_le_natDegree (degree_pow_le _ _))
_ ≤ natDegree (C (coeff p n)) + n • ↑(natDegree q) :=
(add_le_add_left (nsmul_le_nsmul_right (@degree_le_natDegree _ _ q) n) _)
_ = (n * natDegree q : ℕ) := by
rw [natDegree_C, Nat.cast_zero, zero_add, nsmul_eq_mul];
simp
_ ≤ (natDegree p * natDegree q : ℕ) :=
WithBot.coe_le_coe.2 <|
mul_le_mul_of_nonneg_right (le_natDegree_of_ne_zero (mem_support_iff.1 hn))
(Nat.zero_le _)
#align polynomial.nat_degree_comp_le Polynomial.natDegree_comp_le
theorem degree_pos_of_root {p : R[X]} (hp : p ≠ 0) (h : IsRoot p a) : 0 < degree p :=
lt_of_not_ge fun hlt => by
have := eq_C_of_degree_le_zero hlt
rw [IsRoot, this, eval_C] at h
simp only [h, RingHom.map_zero] at this
exact hp this
#align polynomial.degree_pos_of_root Polynomial.degree_pos_of_root
theorem natDegree_le_iff_coeff_eq_zero : p.natDegree ≤ n ↔ ∀ N : ℕ, n < N → p.coeff N = 0 := by
simp_rw [natDegree_le_iff_degree_le, degree_le_iff_coeff_zero, Nat.cast_lt]
#align polynomial.nat_degree_le_iff_coeff_eq_zero Polynomial.natDegree_le_iff_coeff_eq_zero
theorem natDegree_add_le_iff_left {n : ℕ} (p q : R[X]) (qn : q.natDegree ≤ n) :
(p + q).natDegree ≤ n ↔ p.natDegree ≤ n := by
refine ⟨fun h => ?_, fun h => natDegree_add_le_of_degree_le h qn⟩
refine natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_
convert natDegree_le_iff_coeff_eq_zero.mp h m hm using 1
rw [coeff_add, natDegree_le_iff_coeff_eq_zero.mp qn _ hm, add_zero]
#align polynomial.nat_degree_add_le_iff_left Polynomial.natDegree_add_le_iff_left
theorem natDegree_add_le_iff_right {n : ℕ} (p q : R[X]) (pn : p.natDegree ≤ n) :
(p + q).natDegree ≤ n ↔ q.natDegree ≤ n := by
rw [add_comm]
exact natDegree_add_le_iff_left _ _ pn
#align polynomial.nat_degree_add_le_iff_right Polynomial.natDegree_add_le_iff_right
theorem natDegree_C_mul_le (a : R) (f : R[X]) : (C a * f).natDegree ≤ f.natDegree :=
calc
(C a * f).natDegree ≤ (C a).natDegree + f.natDegree := natDegree_mul_le
_ = 0 + f.natDegree := by rw [natDegree_C a]
_ = f.natDegree := zero_add _
set_option linter.uppercaseLean3 false in
#align polynomial.nat_degree_C_mul_le Polynomial.natDegree_C_mul_le
| Mathlib/Algebra/Polynomial/Degree/Lemmas.lean | 98 | 102 | theorem natDegree_mul_C_le (f : R[X]) (a : R) : (f * C a).natDegree ≤ f.natDegree :=
calc
(f * C a).natDegree ≤ f.natDegree + (C a).natDegree := natDegree_mul_le
_ = f.natDegree + 0 := by | rw [natDegree_C a]
_ = f.natDegree := add_zero _
| 2 | 7.389056 | 1 | 0.857143 | 14 | 751 |
import Mathlib.Algebra.Polynomial.Degree.Definitions
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.Tactic.Abel
#align_import ring_theory.polynomial.pochhammer from "leanprover-community/mathlib"@"53b216bcc1146df1c4a0a86877890ea9f1f01589"
universe u v
open Polynomial
open Polynomial
section Ring
variable (R : Type u) [Ring R]
noncomputable def descPochhammer : ℕ → R[X]
| 0 => 1
| n + 1 => X * (descPochhammer n).comp (X - 1)
@[simp]
theorem descPochhammer_zero : descPochhammer R 0 = 1 :=
rfl
@[simp]
theorem descPochhammer_one : descPochhammer R 1 = X := by simp [descPochhammer]
theorem descPochhammer_succ_left (n : ℕ) :
descPochhammer R (n + 1) = X * (descPochhammer R n).comp (X - 1) := by
rw [descPochhammer]
theorem monic_descPochhammer (n : ℕ) [Nontrivial R] [NoZeroDivisors R] :
Monic <| descPochhammer R n := by
induction' n with n hn
· simp
· have h : leadingCoeff (X - 1 : R[X]) = 1 := leadingCoeff_X_sub_C 1
have : natDegree (X - (1 : R[X])) ≠ 0 := ne_zero_of_eq_one <| natDegree_X_sub_C (1 : R)
rw [descPochhammer_succ_left, Monic.def, leadingCoeff_mul, leadingCoeff_comp this, hn, monic_X,
one_mul, one_mul, h, one_pow]
section
variable {R} {T : Type v} [Ring T]
@[simp]
theorem descPochhammer_map (f : R →+* T) (n : ℕ) :
(descPochhammer R n).map f = descPochhammer T n := by
induction' n with n ih
· simp
· simp [ih, descPochhammer_succ_left, map_comp]
end
@[simp, norm_cast]
theorem descPochhammer_eval_cast (n : ℕ) (k : ℤ) :
(((descPochhammer ℤ n).eval k : ℤ) : R) = ((descPochhammer R n).eval k : R) := by
rw [← descPochhammer_map (algebraMap ℤ R), eval_map, ← eq_intCast (algebraMap ℤ R)]
simp only [algebraMap_int_eq, eq_intCast, eval₂_at_intCast, Nat.cast_id, eq_natCast, Int.cast_id]
theorem descPochhammer_eval_zero {n : ℕ} :
(descPochhammer R n).eval 0 = if n = 0 then 1 else 0 := by
cases n
· simp
· simp [X_mul, Nat.succ_ne_zero, descPochhammer_succ_left]
| Mathlib/RingTheory/Polynomial/Pochhammer.lean | 295 | 295 | theorem descPochhammer_zero_eval_zero : (descPochhammer R 0).eval 0 = 1 := by | simp
| 1 | 2.718282 | 0 | 0.96 | 25 | 796 |
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"
-- 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
| Mathlib/Algebra/GeomSum.lean | 60 | 60 | theorem geom_sum_one (x : α) : ∑ i ∈ range 1, x ^ i = 1 := by | simp [geom_sum_succ']
| 1 | 2.718282 | 0 | 0.333333 | 6 | 358 |
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.TryThis
import Mathlib.Util.AtomM
set_option autoImplicit true
namespace Mathlib.Tactic.Abel
open Lean Elab Meta Tactic Qq
initialize registerTraceClass `abel
initialize registerTraceClass `abel.detail
structure Context where
α : Expr
univ : Level
α0 : Expr
isGroup : Bool
inst : Expr
def mkContext (e : Expr) : MetaM Context := do
let α ← inferType e
let c ← synthInstance (← mkAppM ``AddCommMonoid #[α])
let cg ← synthInstance? (← mkAppM ``AddCommGroup #[α])
let u ← mkFreshLevelMVar
_ ← isDefEq (.sort (.succ u)) (← inferType α)
let α0 ← Expr.ofNat α 0
match cg with
| some cg => return ⟨α, u, α0, true, cg⟩
| _ => return ⟨α, u, α0, false, c⟩
abbrev M := ReaderT Context AtomM
def Context.app (c : Context) (n : Name) (inst : Expr) : Array Expr → Expr :=
mkAppN (((@Expr.const n [c.univ]).app c.α).app inst)
def Context.mkApp (c : Context) (n inst : Name) (l : Array Expr) : MetaM Expr := do
return c.app n (← synthInstance ((Expr.const inst [c.univ]).app c.α)) l
def addG : Name → Name
| .str p s => .str p (s ++ "g")
| n => n
def iapp (n : Name) (xs : Array Expr) : M Expr := do
let c ← read
return c.app (if c.isGroup then addG n else n) c.inst xs
def term {α} [AddCommMonoid α] (n : ℕ) (x a : α) : α := n • x + a
def termg {α} [AddCommGroup α] (n : ℤ) (x a : α) : α := n • x + a
def mkTerm (n x a : Expr) : M Expr := iapp ``term #[n, x, a]
def intToExpr (n : ℤ) : M Expr := do
Expr.ofInt (mkConst (if (← read).isGroup then ``Int else ``Nat) []) n
inductive NormalExpr : Type
| zero (e : Expr) : NormalExpr
| nterm (e : Expr) (n : Expr × ℤ) (x : ℕ × Expr) (a : NormalExpr) : NormalExpr
deriving Inhabited
def NormalExpr.e : NormalExpr → Expr
| .zero e => e
| .nterm e .. => e
instance : Coe NormalExpr Expr where coe := NormalExpr.e
def NormalExpr.term' (n : Expr × ℤ) (x : ℕ × Expr) (a : NormalExpr) : M NormalExpr :=
return .nterm (← mkTerm n.1 x.2 a) n x a
def NormalExpr.zero' : M NormalExpr := return NormalExpr.zero (← read).α0
open NormalExpr
theorem const_add_term {α} [AddCommMonoid α] (k n x a a') (h : k + a = a') :
k + @term α _ n x a = term n x a' := by
simp [h.symm, term, add_comm, add_assoc]
theorem const_add_termg {α} [AddCommGroup α] (k n x a a') (h : k + a = a') :
k + @termg α _ n x a = termg n x a' := by
simp [h.symm, termg, add_comm, add_assoc]
theorem term_add_const {α} [AddCommMonoid α] (n x a k a') (h : a + k = a') :
@term α _ n x a + k = term n x a' := by
simp [h.symm, term, add_assoc]
| Mathlib/Tactic/Abel.lean | 140 | 142 | theorem term_add_constg {α} [AddCommGroup α] (n x a k a') (h : a + k = a') :
@termg α _ n x a + k = termg n x a' := by |
simp [h.symm, termg, add_assoc]
| 1 | 2.718282 | 0 | 0.125 | 8 | 249 |
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.Matrix.RowCol
import Mathlib.Data.Fin.VecNotation
import Mathlib.Tactic.FinCases
#align_import data.matrix.notation from "leanprover-community/mathlib"@"a99f85220eaf38f14f94e04699943e185a5e1d1a"
namespace Matrix
universe u uₘ uₙ uₒ
variable {α : Type u} {o n m : ℕ} {m' : Type uₘ} {n' : Type uₙ} {o' : Type uₒ}
open Matrix
variable (a b : ℕ)
instance repr [Repr α] : Repr (Matrix (Fin m) (Fin n) α) where
reprPrec f _p :=
(Std.Format.bracket "!![" · "]") <|
(Std.Format.joinSep · (";" ++ Std.Format.line)) <|
(List.finRange m).map fun i =>
Std.Format.fill <| -- wrap line in a single place rather than all at once
(Std.Format.joinSep · ("," ++ Std.Format.line)) <|
(List.finRange n).map fun j => _root_.repr (f i j)
#align matrix.has_repr Matrix.repr
@[simp]
theorem cons_val' (v : n' → α) (B : Fin m → n' → α) (i j) :
vecCons v B i j = vecCons (v j) (fun i => B i j) i := by refine Fin.cases ?_ ?_ i <;> simp
#align matrix.cons_val' Matrix.cons_val'
@[simp, nolint simpNF] -- Porting note: LHS does not simplify.
theorem head_val' (B : Fin m.succ → n' → α) (j : n') : (vecHead fun i => B i j) = vecHead B j :=
rfl
#align matrix.head_val' Matrix.head_val'
@[simp, nolint simpNF] -- Porting note: LHS does not simplify.
theorem tail_val' (B : Fin m.succ → n' → α) (j : n') :
(vecTail fun i => B i j) = fun i => vecTail B i j := rfl
#align matrix.tail_val' Matrix.tail_val'
section DotProduct
variable [AddCommMonoid α] [Mul α]
@[simp]
theorem dotProduct_empty (v w : Fin 0 → α) : dotProduct v w = 0 :=
Finset.sum_empty
#align matrix.dot_product_empty Matrix.dotProduct_empty
@[simp]
theorem cons_dotProduct (x : α) (v : Fin n → α) (w : Fin n.succ → α) :
dotProduct (vecCons x v) w = x * vecHead w + dotProduct v (vecTail w) := by
simp [dotProduct, Fin.sum_univ_succ, vecHead, vecTail]
#align matrix.cons_dot_product Matrix.cons_dotProduct
@[simp]
theorem dotProduct_cons (v : Fin n.succ → α) (x : α) (w : Fin n → α) :
dotProduct v (vecCons x w) = vecHead v * x + dotProduct (vecTail v) w := by
simp [dotProduct, Fin.sum_univ_succ, vecHead, vecTail]
#align matrix.dot_product_cons Matrix.dotProduct_cons
-- @[simp] -- Porting note (#10618): simp can prove this
| Mathlib/Data/Matrix/Notation.lean | 174 | 175 | theorem cons_dotProduct_cons (x : α) (v : Fin n → α) (y : α) (w : Fin n → α) :
dotProduct (vecCons x v) (vecCons y w) = x * y + dotProduct v w := by | simp
| 1 | 2.718282 | 0 | 0.75 | 12 | 672 |
import Mathlib.Data.DFinsupp.Interval
import Mathlib.Data.DFinsupp.Multiset
import Mathlib.Order.Interval.Finset.Nat
#align_import data.multiset.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29"
open Finset DFinsupp Function
open Pointwise
variable {α : Type*}
namespace Multiset
variable [DecidableEq α] (s t : Multiset α)
instance instLocallyFiniteOrder : LocallyFiniteOrder (Multiset α) :=
LocallyFiniteOrder.ofIcc (Multiset α)
(fun s t => (Finset.Icc (toDFinsupp s) (toDFinsupp t)).map
Multiset.equivDFinsupp.toEquiv.symm.toEmbedding)
fun s t x => by simp
theorem Icc_eq :
Finset.Icc s t = (Finset.Icc (toDFinsupp s) (toDFinsupp t)).map
Multiset.equivDFinsupp.toEquiv.symm.toEmbedding :=
rfl
#align multiset.Icc_eq Multiset.Icc_eq
theorem uIcc_eq :
uIcc s t =
(uIcc (toDFinsupp s) (toDFinsupp t)).map Multiset.equivDFinsupp.toEquiv.symm.toEmbedding :=
(Icc_eq _ _).trans <| by simp [uIcc]
#align multiset.uIcc_eq Multiset.uIcc_eq
theorem card_Icc :
(Finset.Icc s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) := by
simp_rw [Icc_eq, Finset.card_map, DFinsupp.card_Icc, Nat.card_Icc, Multiset.toDFinsupp_apply,
toDFinsupp_support]
#align multiset.card_Icc Multiset.card_Icc
theorem card_Ico :
(Finset.Ico s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) - 1 := by
rw [Finset.card_Ico_eq_card_Icc_sub_one, card_Icc]
#align multiset.card_Ico Multiset.card_Ico
theorem card_Ioc :
(Finset.Ioc s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) - 1 := by
rw [Finset.card_Ioc_eq_card_Icc_sub_one, card_Icc]
#align multiset.card_Ioc Multiset.card_Ioc
theorem card_Ioo :
(Finset.Ioo s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) - 2 := by
rw [Finset.card_Ioo_eq_card_Icc_sub_two, card_Icc]
#align multiset.card_Ioo Multiset.card_Ioo
theorem card_uIcc :
(uIcc s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, ((t.count i - s.count i : ℤ).natAbs + 1) := by
simp_rw [uIcc_eq, Finset.card_map, DFinsupp.card_uIcc, Nat.card_uIcc, Multiset.toDFinsupp_apply,
toDFinsupp_support]
#align multiset.card_uIcc Multiset.card_uIcc
| Mathlib/Data/Multiset/Interval.lean | 83 | 84 | theorem card_Iic : (Finset.Iic s).card = ∏ i ∈ s.toFinset, (s.count i + 1) := by |
simp_rw [Iic_eq_Icc, card_Icc, bot_eq_zero, toFinset_zero, empty_union, count_zero, tsub_zero]
| 1 | 2.718282 | 0 | 0.333333 | 6 | 338 |
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic
#align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
open Nat
section Euler
section Legendre
open ZMod
variable (p : ℕ) [Fact p.Prime]
def legendreSym (a : ℤ) : ℤ :=
quadraticChar (ZMod p) a
#align legendre_sym legendreSym
namespace legendreSym
theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by
rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc
· by_cases ha : (a : ZMod p) = 0
· rw [legendreSym, ha, quadraticChar_zero,
zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne']
norm_cast
· have := (ringChar_zmod_n p).symm.trans hc
-- p = 2
subst p
rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha]
revert ha
push_cast
generalize (a : ZMod 2) = b; fin_cases b
· tauto
· simp
· convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p)
exact (card p).symm
#align legendre_sym.eq_pow legendreSym.eq_pow
theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) :
legendreSym p a = 1 ∨ legendreSym p a = -1 :=
quadraticChar_dichotomy ha
#align legendre_sym.eq_one_or_neg_one legendreSym.eq_one_or_neg_one
theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) :
legendreSym p a = -1 ↔ ¬legendreSym p a = 1 :=
quadraticChar_eq_neg_one_iff_not_one ha
#align legendre_sym.eq_neg_one_iff_not_one legendreSym.eq_neg_one_iff_not_one
theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 :=
quadraticChar_eq_zero_iff
#align legendre_sym.eq_zero_iff legendreSym.eq_zero_iff
@[simp]
| Mathlib/NumberTheory/LegendreSymbol/Basic.lean | 152 | 152 | theorem at_zero : legendreSym p 0 = 0 := by | rw [legendreSym, Int.cast_zero, MulChar.map_zero]
| 1 | 2.718282 | 0 | 1 | 11 | 839 |
import Mathlib.Analysis.Normed.Group.Hom
import Mathlib.Analysis.NormedSpace.Basic
import Mathlib.Analysis.NormedSpace.LinearIsometry
import Mathlib.Algebra.Star.SelfAdjoint
import Mathlib.Algebra.Star.Subalgebra
import Mathlib.Algebra.Star.Unitary
import Mathlib.Topology.Algebra.Module.Star
#align_import analysis.normed_space.star.basic from "leanprover-community/mathlib"@"aa6669832974f87406a3d9d70fc5707a60546207"
open Topology
local postfix:max "⋆" => star
class NormedStarGroup (E : Type*) [SeminormedAddCommGroup E] [StarAddMonoid E] : Prop where
norm_star : ∀ x : E, ‖x⋆‖ = ‖x‖
#align normed_star_group NormedStarGroup
export NormedStarGroup (norm_star)
attribute [simp] norm_star
variable {𝕜 E α : Type*}
instance RingHomIsometric.starRingEnd [NormedCommRing E] [StarRing E] [NormedStarGroup E] :
RingHomIsometric (starRingEnd E) :=
⟨@norm_star _ _ _ _⟩
#align ring_hom_isometric.star_ring_end RingHomIsometric.starRingEnd
class CstarRing (E : Type*) [NonUnitalNormedRing E] [StarRing E] : Prop where
norm_star_mul_self : ∀ {x : E}, ‖x⋆ * x‖ = ‖x‖ * ‖x‖
#align cstar_ring CstarRing
instance : CstarRing ℝ where norm_star_mul_self {x} := by simp only [star, id, norm_mul]
namespace CstarRing
section NonUnital
variable [NonUnitalNormedRing E] [StarRing E] [CstarRing E]
-- see Note [lower instance priority]
instance (priority := 100) to_normedStarGroup : NormedStarGroup E :=
⟨by
intro x
by_cases htriv : x = 0
· simp only [htriv, star_zero]
· have hnt : 0 < ‖x‖ := norm_pos_iff.mpr htriv
have hnt_star : 0 < ‖x⋆‖ :=
norm_pos_iff.mpr ((AddEquiv.map_ne_zero_iff starAddEquiv (M := E)).mpr htriv)
have h₁ :=
calc
‖x‖ * ‖x‖ = ‖x⋆ * x‖ := norm_star_mul_self.symm
_ ≤ ‖x⋆‖ * ‖x‖ := norm_mul_le _ _
have h₂ :=
calc
‖x⋆‖ * ‖x⋆‖ = ‖x * x⋆‖ := by rw [← norm_star_mul_self, star_star]
_ ≤ ‖x‖ * ‖x⋆‖ := norm_mul_le _ _
exact le_antisymm (le_of_mul_le_mul_right h₂ hnt_star) (le_of_mul_le_mul_right h₁ hnt)⟩
#align cstar_ring.to_normed_star_group CstarRing.to_normedStarGroup
theorem norm_self_mul_star {x : E} : ‖x * x⋆‖ = ‖x‖ * ‖x‖ := by
nth_rw 1 [← star_star x]
simp only [norm_star_mul_self, norm_star]
#align cstar_ring.norm_self_mul_star CstarRing.norm_self_mul_star
theorem norm_star_mul_self' {x : E} : ‖x⋆ * x‖ = ‖x⋆‖ * ‖x‖ := by rw [norm_star_mul_self, norm_star]
#align cstar_ring.norm_star_mul_self' CstarRing.norm_star_mul_self'
theorem nnnorm_self_mul_star {x : E} : ‖x * x⋆‖₊ = ‖x‖₊ * ‖x‖₊ :=
Subtype.ext norm_self_mul_star
#align cstar_ring.nnnorm_self_mul_star CstarRing.nnnorm_self_mul_star
theorem nnnorm_star_mul_self {x : E} : ‖x⋆ * x‖₊ = ‖x‖₊ * ‖x‖₊ :=
Subtype.ext norm_star_mul_self
#align cstar_ring.nnnorm_star_mul_self CstarRing.nnnorm_star_mul_self
@[simp]
theorem star_mul_self_eq_zero_iff (x : E) : x⋆ * x = 0 ↔ x = 0 := by
rw [← norm_eq_zero, norm_star_mul_self]
exact mul_self_eq_zero.trans norm_eq_zero
#align cstar_ring.star_mul_self_eq_zero_iff CstarRing.star_mul_self_eq_zero_iff
theorem star_mul_self_ne_zero_iff (x : E) : x⋆ * x ≠ 0 ↔ x ≠ 0 := by
simp only [Ne, star_mul_self_eq_zero_iff]
#align cstar_ring.star_mul_self_ne_zero_iff CstarRing.star_mul_self_ne_zero_iff
@[simp]
| Mathlib/Analysis/NormedSpace/Star/Basic.lean | 145 | 146 | theorem mul_star_self_eq_zero_iff (x : E) : x * x⋆ = 0 ↔ x = 0 := by |
simpa only [star_eq_zero, star_star] using @star_mul_self_eq_zero_iff _ _ _ _ (star x)
| 1 | 2.718282 | 0 | 0.5 | 8 | 473 |
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import topology.metric_space.hausdorff_distance from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156"
noncomputable section
open NNReal ENNReal Topology Set Filter Bornology
universe u v w
variable {ι : Sort*} {α : Type u} {β : Type v}
namespace Metric
section Cthickening
variable [PseudoEMetricSpace α] {δ ε : ℝ} {s t : Set α} {x : α}
open EMetric
def cthickening (δ : ℝ) (E : Set α) : Set α :=
{ x : α | infEdist x E ≤ ENNReal.ofReal δ }
#align metric.cthickening Metric.cthickening
@[simp]
theorem mem_cthickening_iff : x ∈ cthickening δ s ↔ infEdist x s ≤ ENNReal.ofReal δ :=
Iff.rfl
#align metric.mem_cthickening_iff Metric.mem_cthickening_iff
lemma eventually_not_mem_cthickening_of_infEdist_pos {E : Set α} {x : α} (h : x ∉ closure E) :
∀ᶠ δ in 𝓝 (0 : ℝ), x ∉ Metric.cthickening δ E := by
obtain ⟨ε, ⟨ε_pos, ε_lt⟩⟩ := exists_real_pos_lt_infEdist_of_not_mem_closure h
filter_upwards [eventually_lt_nhds ε_pos] with δ hδ
simp only [cthickening, mem_setOf_eq, not_le]
exact ((ofReal_lt_ofReal_iff ε_pos).mpr hδ).trans ε_lt
theorem mem_cthickening_of_edist_le (x y : α) (δ : ℝ) (E : Set α) (h : y ∈ E)
(h' : edist x y ≤ ENNReal.ofReal δ) : x ∈ cthickening δ E :=
(infEdist_le_edist_of_mem h).trans h'
#align metric.mem_cthickening_of_edist_le Metric.mem_cthickening_of_edist_le
theorem mem_cthickening_of_dist_le {α : Type*} [PseudoMetricSpace α] (x y : α) (δ : ℝ) (E : Set α)
(h : y ∈ E) (h' : dist x y ≤ δ) : x ∈ cthickening δ E := by
apply mem_cthickening_of_edist_le x y δ E h
rw [edist_dist]
exact ENNReal.ofReal_le_ofReal h'
#align metric.mem_cthickening_of_dist_le Metric.mem_cthickening_of_dist_le
theorem cthickening_eq_preimage_infEdist (δ : ℝ) (E : Set α) :
cthickening δ E = (fun x => infEdist x E) ⁻¹' Iic (ENNReal.ofReal δ) :=
rfl
#align metric.cthickening_eq_preimage_inf_edist Metric.cthickening_eq_preimage_infEdist
theorem isClosed_cthickening {δ : ℝ} {E : Set α} : IsClosed (cthickening δ E) :=
IsClosed.preimage continuous_infEdist isClosed_Iic
#align metric.is_closed_cthickening Metric.isClosed_cthickening
@[simp]
| Mathlib/Topology/MetricSpace/Thickening.lean | 238 | 239 | theorem cthickening_empty (δ : ℝ) : cthickening δ (∅ : Set α) = ∅ := by |
simp only [cthickening, ENNReal.ofReal_ne_top, setOf_false, infEdist_empty, top_le_iff]
| 1 | 2.718282 | 0 | 0.777778 | 9 | 686 |
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.Polynomial.Degree.Lemmas
#align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448"
noncomputable section
open Polynomial
open Polynomial Finset
namespace Polynomial
variable {R : Type*} [Semiring R] {f : R[X]}
def eraseLead (f : R[X]) : R[X] :=
Polynomial.erase f.natDegree f
#align polynomial.erase_lead Polynomial.eraseLead
section EraseLead
theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by
simp only [eraseLead, support_erase]
#align polynomial.erase_lead_support Polynomial.eraseLead_support
theorem eraseLead_coeff (i : ℕ) :
f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by
simp only [eraseLead, coeff_erase]
#align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff
@[simp]
| Mathlib/Algebra/Polynomial/EraseLead.lean | 52 | 52 | theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by | simp [eraseLead_coeff]
| 1 | 2.718282 | 0 | 0.5 | 14 | 465 |
import Batteries.Data.List.Basic
namespace Batteries
inductive AssocList (α : Type u) (β : Type v) where
| nil
| cons (key : α) (value : β) (tail : AssocList α β)
deriving Inhabited
namespace AssocList
@[simp] def toList : AssocList α β → List (α × β)
| nil => []
| cons a b es => (a, b) :: es.toList
instance : EmptyCollection (AssocList α β) := ⟨nil⟩
@[simp] theorem empty_eq : (∅ : AssocList α β) = nil := rfl
def isEmpty : AssocList α β → Bool
| nil => true
| _ => false
@[simp] theorem isEmpty_eq (l : AssocList α β) : isEmpty l = l.toList.isEmpty := by
cases l <;> simp [*, isEmpty, List.isEmpty]
def length (L : AssocList α β) : Nat :=
match L with
| .nil => 0
| .cons _ _ t => t.length + 1
@[simp] theorem length_nil : length (nil : AssocList α β) = 0 := rfl
@[simp] theorem length_cons : length (cons a b t) = length t + 1 := rfl
theorem length_toList (l : AssocList α β) : l.toList.length = l.length := by
induction l <;> simp_all
@[specialize] def foldlM [Monad m] (f : δ → α → β → m δ) : (init : δ) → AssocList α β → m δ
| d, nil => pure d
| d, cons a b es => do foldlM f (← f d a b) es
@[simp] theorem foldlM_eq [Monad m] (f : δ → α → β → m δ) (init l) :
foldlM f init l = l.toList.foldlM (fun d (a, b) => f d a b) init := by
induction l generalizing init <;> simp [*, foldlM]
@[inline] def foldl (f : δ → α → β → δ) (init : δ) (as : AssocList α β) : δ :=
Id.run (foldlM f init as)
@[simp] theorem foldl_eq (f : δ → α → β → δ) (init l) :
foldl f init l = l.toList.foldl (fun d (a, b) => f d a b) init := by
simp [List.foldl_eq_foldlM, foldl, Id.run]
def toListTR (as : AssocList α β) : List (α × β) :=
as.foldl (init := #[]) (fun r a b => r.push (a, b)) |>.toList
@[csimp] theorem toList_eq_toListTR : @toList = @toListTR := by
funext α β as; simp [toListTR]
exact .symm <| (Array.foldl_data_eq_map (toList as) _ id).trans (List.map_id _)
@[specialize] def forM [Monad m] (f : α → β → m PUnit) : AssocList α β → m PUnit
| nil => pure ⟨⟩
| cons a b es => do f a b; forM f es
@[simp] theorem forM_eq [Monad m] (f : α → β → m PUnit) (l) :
forM f l = l.toList.forM (fun (a, b) => f a b) := by
induction l <;> simp [*, forM]
@[simp] def mapKey (f : α → δ) : AssocList α β → AssocList δ β
| nil => nil
| cons k v t => cons (f k) v (mapKey f t)
@[simp] theorem toList_mapKey (f : α → δ) (l : AssocList α β) :
(mapKey f l).toList = l.toList.map (fun (a, b) => (f a, b)) := by
induction l <;> simp [*]
@[simp] theorem length_mapKey : (mapKey f l).length = l.length := by
induction l <;> simp_all
@[simp] def mapVal (f : α → β → δ) : AssocList α β → AssocList α δ
| nil => nil
| cons k v t => cons k (f k v) (mapVal f t)
@[simp] theorem toList_mapVal (f : α → β → δ) (l : AssocList α β) :
(mapVal f l).toList = l.toList.map (fun (a, b) => (a, f a b)) := by
induction l <;> simp [*]
@[simp] theorem length_mapVal : (mapVal f l).length = l.length := by
induction l <;> simp_all
@[specialize] def findEntryP? (p : α → β → Bool) : AssocList α β → Option (α × β)
| nil => none
| cons k v es => bif p k v then some (k, v) else findEntryP? p es
@[simp] theorem findEntryP?_eq (p : α → β → Bool) (l : AssocList α β) :
findEntryP? p l = l.toList.find? fun (a, b) => p a b := by
induction l <;> simp [findEntryP?, List.find?_cons]; split <;> simp [*]
@[inline] def findEntry? [BEq α] (a : α) (l : AssocList α β) : Option (α × β) :=
findEntryP? (fun k _ => k == a) l
@[simp] theorem findEntry?_eq [BEq α] (a : α) (l : AssocList α β) :
findEntry? a l = l.toList.find? (·.1 == a) := findEntryP?_eq ..
def find? [BEq α] (a : α) : AssocList α β → Option β
| nil => none
| cons k v es => match k == a with
| true => some v
| false => find? a es
| .lake/packages/batteries/Batteries/Data/AssocList.lean | 139 | 141 | theorem find?_eq_findEntry? [BEq α] (a : α) (l : AssocList α β) :
find? a l = (l.findEntry? a).map (·.2) := by |
induction l <;> simp [find?, List.find?_cons]; split <;> simp [*]
| 1 | 2.718282 | 0 | 0 | 2 | 33 |
import Mathlib.MeasureTheory.Measure.NullMeasurable
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.Topology.Algebra.Order.LiminfLimsup
#align_import measure_theory.measure.measure_space from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
noncomputable section
open Set
open Filter hiding map
open Function MeasurableSpace
open scoped Classical symmDiff
open Topology Filter ENNReal NNReal Interval MeasureTheory
variable {α β γ δ ι R R' : Type*}
namespace MeasureTheory
section
variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}
instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) :=
⟨fun _s hs =>
let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs
⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
#align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated
| Mathlib/MeasureTheory/Measure/MeasureSpace.lean | 107 | 109 | theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :
(∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by |
simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]
| 1 | 2.718282 | 0 | 0.333333 | 6 | 331 |
import Mathlib.RingTheory.AdjoinRoot
import Mathlib.FieldTheory.Minpoly.Field
import Mathlib.RingTheory.Polynomial.GaussLemma
#align_import field_theory.minpoly.is_integrally_closed from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
open scoped Classical Polynomial
open Polynomial Set Function minpoly
namespace minpoly
variable {R S : Type*} [CommRing R] [CommRing S] [IsDomain R] [Algebra R S]
section
variable (K L : Type*) [Field K] [Algebra R K] [IsFractionRing R K] [CommRing L] [Nontrivial L]
[Algebra R L] [Algebra S L] [Algebra K L] [IsScalarTower R K L] [IsScalarTower R S L]
variable [IsIntegrallyClosed R]
theorem isIntegrallyClosed_eq_field_fractions [IsDomain S] {s : S} (hs : IsIntegral R s) :
minpoly K (algebraMap S L s) = (minpoly R s).map (algebraMap R K) := by
refine (eq_of_irreducible_of_monic ?_ ?_ ?_).symm
· exact ((monic hs).irreducible_iff_irreducible_map_fraction_map).1 (irreducible hs)
· rw [aeval_map_algebraMap, aeval_algebraMap_apply, aeval, map_zero]
· exact (monic hs).map _
#align minpoly.is_integrally_closed_eq_field_fractions minpoly.isIntegrallyClosed_eq_field_fractions
| Mathlib/FieldTheory/Minpoly/IsIntegrallyClosed.lean | 61 | 64 | theorem isIntegrallyClosed_eq_field_fractions' [IsDomain S] [Algebra K S] [IsScalarTower R K S]
{s : S} (hs : IsIntegral R s) : minpoly K s = (minpoly R s).map (algebraMap R K) := by |
let L := FractionRing S
rw [← isIntegrallyClosed_eq_field_fractions K L hs, algebraMap_eq (IsFractionRing.injective S L)]
| 2 | 7.389056 | 1 | 1.571429 | 7 | 1,708 |
import Mathlib.Data.Nat.Cast.Basic
import Mathlib.Algebra.CharZero.Defs
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Data.Nat.Cast.NeZero
import Mathlib.Algebra.Order.Ring.Nat
#align_import data.nat.cast.basic from "leanprover-community/mathlib"@"acebd8d49928f6ed8920e502a6c90674e75bd441"
variable {α β : Type*}
namespace Nat
section OrderedSemiring
variable [AddMonoidWithOne α] [PartialOrder α]
variable [CovariantClass α α (· + ·) (· ≤ ·)] [ZeroLEOneClass α]
@[mono]
theorem mono_cast : Monotone (Nat.cast : ℕ → α) :=
monotone_nat_of_le_succ fun n ↦ by
rw [Nat.cast_succ]; exact le_add_of_nonneg_right zero_le_one
#align nat.mono_cast Nat.mono_cast
@[deprecated mono_cast (since := "2024-02-10")]
theorem cast_le_cast {a b : ℕ} (h : a ≤ b) : (a : α) ≤ b := mono_cast h
@[gcongr]
theorem _root_.GCongr.natCast_le_natCast {a b : ℕ} (h : a ≤ b) : (a : α) ≤ b := mono_cast h
@[simp low]
theorem cast_nonneg' (n : ℕ) : 0 ≤ (n : α) :=
@Nat.cast_zero α _ ▸ mono_cast (Nat.zero_le n)
@[simp]
theorem cast_nonneg {α} [OrderedSemiring α] (n : ℕ) : 0 ≤ (n : α) :=
cast_nonneg' n
#align nat.cast_nonneg Nat.cast_nonneg
-- See note [no_index around OfNat.ofNat]
@[simp low]
theorem ofNat_nonneg' (n : ℕ) [n.AtLeastTwo] : 0 ≤ (no_index (OfNat.ofNat n : α)) := cast_nonneg' n
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ofNat_nonneg {α} [OrderedSemiring α] (n : ℕ) [n.AtLeastTwo] :
0 ≤ (no_index (OfNat.ofNat n : α)) :=
ofNat_nonneg' n
@[simp, norm_cast]
theorem cast_min {α} [LinearOrderedSemiring α] {a b : ℕ} : ((min a b : ℕ) : α) = min (a : α) b :=
(@mono_cast α _).map_min
#align nat.cast_min Nat.cast_min
@[simp, norm_cast]
theorem cast_max {α} [LinearOrderedSemiring α] {a b : ℕ} : ((max a b : ℕ) : α) = max (a : α) b :=
(@mono_cast α _).map_max
#align nat.cast_max Nat.cast_max
variable [CharZero α] {m n : ℕ}
theorem strictMono_cast : StrictMono (Nat.cast : ℕ → α) :=
mono_cast.strictMono_of_injective cast_injective
#align nat.strict_mono_cast Nat.strictMono_cast
@[simps! (config := .asFn)]
def castOrderEmbedding : ℕ ↪o α :=
OrderEmbedding.ofStrictMono Nat.cast Nat.strictMono_cast
#align nat.cast_order_embedding Nat.castOrderEmbedding
#align nat.cast_order_embedding_apply Nat.castOrderEmbedding_apply
@[simp, norm_cast]
theorem cast_le : (m : α) ≤ n ↔ m ≤ n :=
strictMono_cast.le_iff_le
#align nat.cast_le Nat.cast_le
@[simp, norm_cast, mono]
theorem cast_lt : (m : α) < n ↔ m < n :=
strictMono_cast.lt_iff_lt
#align nat.cast_lt Nat.cast_lt
@[simp, norm_cast]
| Mathlib/Data/Nat/Cast/Order.lean | 134 | 134 | theorem one_lt_cast : 1 < (n : α) ↔ 1 < n := by | rw [← cast_one, cast_lt]
| 1 | 2.718282 | 0 | 0.166667 | 6 | 261 |
import Mathlib.Data.List.Cycle
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.Perm.List
#align_import group_theory.perm.cycle.concrete from "leanprover-community/mathlib"@"00638177efd1b2534fc5269363ebf42a7871df9a"
open Equiv Equiv.Perm List
variable {α : Type*}
namespace Equiv.Perm
section Fintype
variable [Fintype α] [DecidableEq α] (p : Equiv.Perm α) (x : α)
def toList : List α :=
(List.range (cycleOf p x).support.card).map fun k => (p ^ k) x
#align equiv.perm.to_list Equiv.Perm.toList
@[simp]
theorem toList_one : toList (1 : Perm α) x = [] := by simp [toList, cycleOf_one]
#align equiv.perm.to_list_one Equiv.Perm.toList_one
@[simp]
theorem toList_eq_nil_iff {p : Perm α} {x} : toList p x = [] ↔ x ∉ p.support := by simp [toList]
#align equiv.perm.to_list_eq_nil_iff Equiv.Perm.toList_eq_nil_iff
@[simp]
theorem length_toList : length (toList p x) = (cycleOf p x).support.card := by simp [toList]
#align equiv.perm.length_to_list Equiv.Perm.length_toList
theorem toList_ne_singleton (y : α) : toList p x ≠ [y] := by
intro H
simpa [card_support_ne_one] using congr_arg length H
#align equiv.perm.to_list_ne_singleton Equiv.Perm.toList_ne_singleton
theorem two_le_length_toList_iff_mem_support {p : Perm α} {x : α} :
2 ≤ length (toList p x) ↔ x ∈ p.support := by simp
#align equiv.perm.two_le_length_to_list_iff_mem_support Equiv.Perm.two_le_length_toList_iff_mem_support
theorem length_toList_pos_of_mem_support (h : x ∈ p.support) : 0 < length (toList p x) :=
zero_lt_two.trans_le (two_le_length_toList_iff_mem_support.mpr h)
#align equiv.perm.length_to_list_pos_of_mem_support Equiv.Perm.length_toList_pos_of_mem_support
theorem get_toList (n : ℕ) (hn : n < length (toList p x)) :
(toList p x).get ⟨n, hn⟩ = (p ^ n) x := by simp [toList]
| Mathlib/GroupTheory/Perm/Cycle/Concrete.lean | 248 | 249 | theorem toList_get_zero (h : x ∈ p.support) :
(toList p x).get ⟨0, (length_toList_pos_of_mem_support _ _ h)⟩ = x := by | simp [toList]
| 1 | 2.718282 | 0 | 1 | 18 | 1,030 |
import Mathlib.Algebra.Field.Basic
import Mathlib.Algebra.GroupWithZero.Units.Equiv
import Mathlib.Algebra.Order.Field.Defs
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Order.Bounds.OrderIso
import Mathlib.Tactic.Positivity.Core
#align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd"
open Function OrderDual
variable {ι α β : Type*}
section LinearOrderedSemifield
variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ}
@[simps! (config := { simpRhs := true })]
def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α :=
{ Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha }
#align order_iso.mul_left₀ OrderIso.mulLeft₀
#align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply
#align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply
@[simps! (config := { simpRhs := true })]
def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α :=
{ Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha }
#align order_iso.mul_right₀ OrderIso.mulRight₀
#align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply
#align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply
theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b :=
⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h =>
calc
a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm
_ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le
_ = b / c := (div_eq_mul_one_div b c).symm
⟩
#align le_div_iff le_div_iff
theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc]
#align le_div_iff' le_div_iff'
theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b :=
⟨fun h =>
calc
a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm]
_ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le
,
fun h =>
calc
a / b = a * (1 / b) := div_eq_mul_one_div a b
_ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le
_ = c * b / b := (div_eq_mul_one_div (c * b) b).symm
_ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl
⟩
#align div_le_iff div_le_iff
| Mathlib/Algebra/Order/Field/Basic.lean | 76 | 76 | theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by | rw [mul_comm, div_le_iff hb]
| 1 | 2.718282 | 0 | 0.25 | 16 | 288 |
import Mathlib.FieldTheory.Minpoly.Field
#align_import ring_theory.power_basis from "leanprover-community/mathlib"@"d1d69e99ed34c95266668af4e288fc1c598b9a7f"
open Polynomial
open Polynomial
variable {R S T : Type*} [CommRing R] [Ring S] [Algebra R S]
variable {A B : Type*} [CommRing A] [CommRing B] [IsDomain B] [Algebra A B]
variable {K : Type*} [Field K]
-- Porting note(#5171): this linter isn't ported yet.
-- @[nolint has_nonempty_instance]
structure PowerBasis (R S : Type*) [CommRing R] [Ring S] [Algebra R S] where
gen : S
dim : ℕ
basis : Basis (Fin dim) R S
basis_eq_pow : ∀ (i), basis i = gen ^ (i : ℕ)
#align power_basis PowerBasis
-- this is usually not needed because of `basis_eq_pow` but can be needed in some cases;
-- in such circumstances, add it manually using `@[simps dim gen basis]`.
initialize_simps_projections PowerBasis (-basis)
namespace PowerBasis
@[simp]
theorem coe_basis (pb : PowerBasis R S) : ⇑pb.basis = fun i : Fin pb.dim => pb.gen ^ (i : ℕ) :=
funext pb.basis_eq_pow
#align power_basis.coe_basis PowerBasis.coe_basis
theorem finite (pb : PowerBasis R S) : Module.Finite R S := .of_basis pb.basis
#align power_basis.finite_dimensional PowerBasis.finite
@[deprecated] alias finiteDimensional := PowerBasis.finite
| Mathlib/RingTheory/PowerBasis.lean | 84 | 86 | theorem finrank [StrongRankCondition R] (pb : PowerBasis R S) :
FiniteDimensional.finrank R S = pb.dim := by |
rw [FiniteDimensional.finrank_eq_card_basis pb.basis, Fintype.card_fin]
| 1 | 2.718282 | 0 | 1.428571 | 7 | 1,518 |
import Mathlib.Analysis.NormedSpace.Multilinear.Basic
import Mathlib.Analysis.NormedSpace.Units
import Mathlib.Analysis.NormedSpace.OperatorNorm.Completeness
import Mathlib.Analysis.NormedSpace.OperatorNorm.Mul
#align_import analysis.normed_space.bounded_linear_maps from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a"
noncomputable section
open Topology
open Filter (Tendsto)
open Metric ContinuousLinearMap
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type*}
[NormedAddCommGroup G] [NormedSpace 𝕜 G]
structure IsBoundedLinearMap (𝕜 : Type*) [NormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] (f : E → F) extends
IsLinearMap 𝕜 f : Prop where
bound : ∃ M, 0 < M ∧ ∀ x : E, ‖f x‖ ≤ M * ‖x‖
#align is_bounded_linear_map IsBoundedLinearMap
theorem IsLinearMap.with_bound {f : E → F} (hf : IsLinearMap 𝕜 f) (M : ℝ)
(h : ∀ x : E, ‖f x‖ ≤ M * ‖x‖) : IsBoundedLinearMap 𝕜 f :=
⟨hf,
by_cases
(fun (this : M ≤ 0) =>
⟨1, zero_lt_one, fun x =>
(h x).trans <| mul_le_mul_of_nonneg_right (this.trans zero_le_one) (norm_nonneg x)⟩)
fun (this : ¬M ≤ 0) => ⟨M, lt_of_not_ge this, h⟩⟩
#align is_linear_map.with_bound IsLinearMap.with_bound
theorem ContinuousLinearMap.isBoundedLinearMap (f : E →L[𝕜] F) : IsBoundedLinearMap 𝕜 f :=
{ f.toLinearMap.isLinear with bound := f.bound }
#align continuous_linear_map.is_bounded_linear_map ContinuousLinearMap.isBoundedLinearMap
namespace IsBoundedLinearMap
def toLinearMap (f : E → F) (h : IsBoundedLinearMap 𝕜 f) : E →ₗ[𝕜] F :=
IsLinearMap.mk' _ h.toIsLinearMap
#align is_bounded_linear_map.to_linear_map IsBoundedLinearMap.toLinearMap
def toContinuousLinearMap {f : E → F} (hf : IsBoundedLinearMap 𝕜 f) : E →L[𝕜] F :=
{ toLinearMap f hf with
cont :=
let ⟨C, _, hC⟩ := hf.bound
AddMonoidHomClass.continuous_of_bound (toLinearMap f hf) C hC }
#align is_bounded_linear_map.to_continuous_linear_map IsBoundedLinearMap.toContinuousLinearMap
theorem zero : IsBoundedLinearMap 𝕜 fun _ : E => (0 : F) :=
(0 : E →ₗ[𝕜] F).isLinear.with_bound 0 <| by simp [le_refl]
#align is_bounded_linear_map.zero IsBoundedLinearMap.zero
theorem id : IsBoundedLinearMap 𝕜 fun x : E => x :=
LinearMap.id.isLinear.with_bound 1 <| by simp [le_refl]
#align is_bounded_linear_map.id IsBoundedLinearMap.id
theorem fst : IsBoundedLinearMap 𝕜 fun x : E × F => x.1 := by
refine (LinearMap.fst 𝕜 E F).isLinear.with_bound 1 fun x => ?_
rw [one_mul]
exact le_max_left _ _
#align is_bounded_linear_map.fst IsBoundedLinearMap.fst
theorem snd : IsBoundedLinearMap 𝕜 fun x : E × F => x.2 := by
refine (LinearMap.snd 𝕜 E F).isLinear.with_bound 1 fun x => ?_
rw [one_mul]
exact le_max_right _ _
#align is_bounded_linear_map.snd IsBoundedLinearMap.snd
variable {f g : E → F}
theorem smul (c : 𝕜) (hf : IsBoundedLinearMap 𝕜 f) : IsBoundedLinearMap 𝕜 (c • f) :=
let ⟨hlf, M, _, hM⟩ := hf
(c • hlf.mk' f).isLinear.with_bound (‖c‖ * M) fun x =>
calc
‖c • f x‖ = ‖c‖ * ‖f x‖ := norm_smul c (f x)
_ ≤ ‖c‖ * (M * ‖x‖) := mul_le_mul_of_nonneg_left (hM _) (norm_nonneg _)
_ = ‖c‖ * M * ‖x‖ := (mul_assoc _ _ _).symm
#align is_bounded_linear_map.smul IsBoundedLinearMap.smul
theorem neg (hf : IsBoundedLinearMap 𝕜 f) : IsBoundedLinearMap 𝕜 fun e => -f e := by
rw [show (fun e => -f e) = fun e => (-1 : 𝕜) • f e by funext; simp]
exact smul (-1) hf
#align is_bounded_linear_map.neg IsBoundedLinearMap.neg
| Mathlib/Analysis/NormedSpace/BoundedLinearMaps.lean | 144 | 151 | theorem add (hf : IsBoundedLinearMap 𝕜 f) (hg : IsBoundedLinearMap 𝕜 g) :
IsBoundedLinearMap 𝕜 fun e => f e + g e :=
let ⟨hlf, Mf, _, hMf⟩ := hf
let ⟨hlg, Mg, _, hMg⟩ := hg
(hlf.mk' _ + hlg.mk' _).isLinear.with_bound (Mf + Mg) fun x =>
calc
‖f x + g x‖ ≤ Mf * ‖x‖ + Mg * ‖x‖ := norm_add_le_of_le (hMf x) (hMg x)
_ ≤ (Mf + Mg) * ‖x‖ := by | rw [add_mul]
| 1 | 2.718282 | 0 | 0.538462 | 13 | 510 |
import Mathlib.Analysis.Complex.Circle
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup
#align_import analysis.complex.isometry from "leanprover-community/mathlib"@"ae690b0c236e488a0043f6faa8ce3546e7f2f9c5"
noncomputable section
open Complex
open ComplexConjugate
local notation "|" x "|" => Complex.abs x
def rotation : circle →* ℂ ≃ₗᵢ[ℝ] ℂ where
toFun a :=
{ DistribMulAction.toLinearEquiv ℝ ℂ a with
norm_map' := fun x => show |a * x| = |x| by rw [map_mul, abs_coe_circle, one_mul] }
map_one' := LinearIsometryEquiv.ext <| one_smul circle
map_mul' a b := LinearIsometryEquiv.ext <| mul_smul a b
#align rotation rotation
@[simp]
theorem rotation_apply (a : circle) (z : ℂ) : rotation a z = a * z :=
rfl
#align rotation_apply rotation_apply
@[simp]
theorem rotation_symm (a : circle) : (rotation a).symm = rotation a⁻¹ :=
LinearIsometryEquiv.ext fun _ => rfl
#align rotation_symm rotation_symm
@[simp]
theorem rotation_trans (a b : circle) : (rotation a).trans (rotation b) = rotation (b * a) := by
ext1
simp
#align rotation_trans rotation_trans
theorem rotation_ne_conjLIE (a : circle) : rotation a ≠ conjLIE := by
intro h
have h1 : rotation a 1 = conj 1 := LinearIsometryEquiv.congr_fun h 1
have hI : rotation a I = conj I := LinearIsometryEquiv.congr_fun h I
rw [rotation_apply, RingHom.map_one, mul_one] at h1
rw [rotation_apply, conj_I, ← neg_one_mul, mul_left_inj' I_ne_zero, h1, eq_neg_self_iff] at hI
exact one_ne_zero hI
#align rotation_ne_conj_lie rotation_ne_conjLIE
@[simps]
def rotationOf (e : ℂ ≃ₗᵢ[ℝ] ℂ) : circle :=
⟨e 1 / Complex.abs (e 1), by simp⟩
#align rotation_of rotationOf
@[simp]
theorem rotationOf_rotation (a : circle) : rotationOf (rotation a) = a :=
Subtype.ext <| by simp
#align rotation_of_rotation rotationOf_rotation
theorem rotation_injective : Function.Injective rotation :=
Function.LeftInverse.injective rotationOf_rotation
#align rotation_injective rotation_injective
theorem LinearIsometry.re_apply_eq_re_of_add_conj_eq (f : ℂ →ₗᵢ[ℝ] ℂ)
(h₃ : ∀ z, z + conj z = f z + conj (f z)) (z : ℂ) : (f z).re = z.re := by
simpa [ext_iff, add_re, add_im, conj_re, conj_im, ← two_mul,
show (2 : ℝ) ≠ 0 by simp [two_ne_zero]] using (h₃ z).symm
#align linear_isometry.re_apply_eq_re_of_add_conj_eq LinearIsometry.re_apply_eq_re_of_add_conj_eq
| Mathlib/Analysis/Complex/Isometry.lean | 96 | 101 | theorem LinearIsometry.im_apply_eq_im_or_neg_of_re_apply_eq_re {f : ℂ →ₗᵢ[ℝ] ℂ}
(h₂ : ∀ z, (f z).re = z.re) (z : ℂ) : (f z).im = z.im ∨ (f z).im = -z.im := by |
have h₁ := f.norm_map z
simp only [Complex.abs_def, norm_eq_abs] at h₁
rwa [Real.sqrt_inj (normSq_nonneg _) (normSq_nonneg _), normSq_apply (f z), normSq_apply z,
h₂, add_left_cancel_iff, mul_self_eq_mul_self_iff] at h₁
| 4 | 54.59815 | 2 | 1.571429 | 7 | 1,705 |
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
open Filter Metric Set
open scoped ComplexConjugate Real Topology
namespace Complex
variable {a x z : ℂ}
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine ⟨fun hz => ⟨arg z, ?_⟩, ?_⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
| Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean | 87 | 89 | theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by |
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
| 2 | 7.389056 | 1 | 1.571429 | 7 | 1,706 |
import Mathlib.Analysis.Seminorm
import Mathlib.Topology.Algebra.Equicontinuity
import Mathlib.Topology.MetricSpace.Equicontinuity
import Mathlib.Topology.Algebra.FilterBasis
import Mathlib.Topology.Algebra.Module.LocallyConvex
#align_import analysis.locally_convex.with_seminorms from "leanprover-community/mathlib"@"b31173ee05c911d61ad6a05bd2196835c932e0ec"
open NormedField Set Seminorm TopologicalSpace Filter List
open NNReal Pointwise Topology Uniformity
variable {𝕜 𝕜₂ 𝕝 𝕝₂ E F G ι ι' : Type*}
section FilterBasis
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable (𝕜 E ι)
abbrev SeminormFamily :=
ι → Seminorm 𝕜 E
#align seminorm_family SeminormFamily
variable {𝕜 E ι}
namespace SeminormFamily
def basisSets (p : SeminormFamily 𝕜 E ι) : Set (Set E) :=
⋃ (s : Finset ι) (r) (_ : 0 < r), singleton (ball (s.sup p) (0 : E) r)
#align seminorm_family.basis_sets SeminormFamily.basisSets
variable (p : SeminormFamily 𝕜 E ι)
theorem basisSets_iff {U : Set E} :
U ∈ p.basisSets ↔ ∃ (i : Finset ι) (r : ℝ), 0 < r ∧ U = ball (i.sup p) 0 r := by
simp only [basisSets, mem_iUnion, exists_prop, mem_singleton_iff]
#align seminorm_family.basis_sets_iff SeminormFamily.basisSets_iff
theorem basisSets_mem (i : Finset ι) {r : ℝ} (hr : 0 < r) : (i.sup p).ball 0 r ∈ p.basisSets :=
(basisSets_iff _).mpr ⟨i, _, hr, rfl⟩
#align seminorm_family.basis_sets_mem SeminormFamily.basisSets_mem
theorem basisSets_singleton_mem (i : ι) {r : ℝ} (hr : 0 < r) : (p i).ball 0 r ∈ p.basisSets :=
(basisSets_iff _).mpr ⟨{i}, _, hr, by rw [Finset.sup_singleton]⟩
#align seminorm_family.basis_sets_singleton_mem SeminormFamily.basisSets_singleton_mem
theorem basisSets_nonempty [Nonempty ι] : p.basisSets.Nonempty := by
let i := Classical.arbitrary ι
refine nonempty_def.mpr ⟨(p i).ball 0 1, ?_⟩
exact p.basisSets_singleton_mem i zero_lt_one
#align seminorm_family.basis_sets_nonempty SeminormFamily.basisSets_nonempty
theorem basisSets_intersect (U V : Set E) (hU : U ∈ p.basisSets) (hV : V ∈ p.basisSets) :
∃ z ∈ p.basisSets, z ⊆ U ∩ V := by
classical
rcases p.basisSets_iff.mp hU with ⟨s, r₁, hr₁, hU⟩
rcases p.basisSets_iff.mp hV with ⟨t, r₂, hr₂, hV⟩
use ((s ∪ t).sup p).ball 0 (min r₁ r₂)
refine ⟨p.basisSets_mem (s ∪ t) (lt_min_iff.mpr ⟨hr₁, hr₂⟩), ?_⟩
rw [hU, hV, ball_finset_sup_eq_iInter _ _ _ (lt_min_iff.mpr ⟨hr₁, hr₂⟩),
ball_finset_sup_eq_iInter _ _ _ hr₁, ball_finset_sup_eq_iInter _ _ _ hr₂]
exact
Set.subset_inter
(Set.iInter₂_mono' fun i hi =>
⟨i, Finset.subset_union_left hi, ball_mono <| min_le_left _ _⟩)
(Set.iInter₂_mono' fun i hi =>
⟨i, Finset.subset_union_right hi, ball_mono <| min_le_right _ _⟩)
#align seminorm_family.basis_sets_intersect SeminormFamily.basisSets_intersect
theorem basisSets_zero (U) (hU : U ∈ p.basisSets) : (0 : E) ∈ U := by
rcases p.basisSets_iff.mp hU with ⟨ι', r, hr, hU⟩
rw [hU, mem_ball_zero, map_zero]
exact hr
#align seminorm_family.basis_sets_zero SeminormFamily.basisSets_zero
theorem basisSets_add (U) (hU : U ∈ p.basisSets) :
∃ V ∈ p.basisSets, V + V ⊆ U := by
rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
use (s.sup p).ball 0 (r / 2)
refine ⟨p.basisSets_mem s (div_pos hr zero_lt_two), ?_⟩
refine Set.Subset.trans (ball_add_ball_subset (s.sup p) (r / 2) (r / 2) 0 0) ?_
rw [hU, add_zero, add_halves']
#align seminorm_family.basis_sets_add SeminormFamily.basisSets_add
| Mathlib/Analysis/LocallyConvex/WithSeminorms.lean | 130 | 134 | theorem basisSets_neg (U) (hU' : U ∈ p.basisSets) :
∃ V ∈ p.basisSets, V ⊆ (fun x : E => -x) ⁻¹' U := by |
rcases p.basisSets_iff.mp hU' with ⟨s, r, _, hU⟩
rw [hU, neg_preimage, neg_ball (s.sup p), neg_zero]
exact ⟨U, hU', Eq.subset hU⟩
| 3 | 20.085537 | 1 | 1.272727 | 11 | 1,349 |
import Mathlib.Order.Filter.AtTopBot
import Mathlib.Order.Filter.Subsingleton
open Set
variable {α β γ δ : Type*} {l : Filter α} {f : α → β}
namespace Filter
def EventuallyConst (f : α → β) (l : Filter α) : Prop := (map f l).Subsingleton
theorem HasBasis.eventuallyConst_iff {ι : Sort*} {p : ι → Prop} {s : ι → Set α}
(h : l.HasBasis p s) : EventuallyConst f l ↔ ∃ i, p i ∧ ∀ x ∈ s i, ∀ y ∈ s i, f x = f y :=
(h.map f).subsingleton_iff.trans <| by simp only [Set.Subsingleton, forall_mem_image]
theorem HasBasis.eventuallyConst_iff' {ι : Sort*} {p : ι → Prop} {s : ι → Set α}
{x : ι → α} (h : l.HasBasis p s) (hx : ∀ i, p i → x i ∈ s i) :
EventuallyConst f l ↔ ∃ i, p i ∧ ∀ y ∈ s i, f y = f (x i) :=
h.eventuallyConst_iff.trans <| exists_congr fun i ↦ and_congr_right fun hi ↦
⟨fun h ↦ (h · · (x i) (hx i hi)), fun h a ha b hb ↦ h a ha ▸ (h b hb).symm⟩
lemma eventuallyConst_iff_tendsto [Nonempty β] :
EventuallyConst f l ↔ ∃ x, Tendsto f l (pure x) :=
subsingleton_iff_exists_le_pure
alias ⟨EventuallyConst.exists_tendsto, _⟩ := eventuallyConst_iff_tendsto
theorem EventuallyConst.of_tendsto {x : β} (h : Tendsto f l (pure x)) : EventuallyConst f l :=
have : Nonempty β := ⟨x⟩; eventuallyConst_iff_tendsto.2 ⟨x, h⟩
theorem eventuallyConst_iff_exists_eventuallyEq [Nonempty β] :
EventuallyConst f l ↔ ∃ c, f =ᶠ[l] fun _ ↦ c :=
subsingleton_iff_exists_singleton_mem
alias ⟨EventuallyConst.eventuallyEq_const, _⟩ := eventuallyConst_iff_exists_eventuallyEq
theorem eventuallyConst_pred' {p : α → Prop} :
EventuallyConst p l ↔ (p =ᶠ[l] fun _ ↦ False) ∨ (p =ᶠ[l] fun _ ↦ True) := by
simp only [eventuallyConst_iff_exists_eventuallyEq, Prop.exists_iff]
| Mathlib/Order/Filter/EventuallyConst.lean | 61 | 63 | theorem eventuallyConst_pred {p : α → Prop} :
EventuallyConst p l ↔ (∀ᶠ x in l, p x) ∨ (∀ᶠ x in l, ¬p x) := by |
simp [eventuallyConst_pred', or_comm, EventuallyEq]
| 1 | 2.718282 | 0 | 0 | 4 | 36 |
import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation
import Mathlib.LinearAlgebra.Dual
#align_import linear_algebra.clifford_algebra.contraction from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
open LinearMap (BilinForm)
universe u1 u2 u3
variable {R : Type u1} [CommRing R]
variable {M : Type u2} [AddCommGroup M] [Module R M]
variable (Q : QuadraticForm R M)
namespace CliffordAlgebra
section contractLeft
variable (d d' : Module.Dual R M)
@[simps!]
def contractLeftAux (d : Module.Dual R M) :
M →ₗ[R] CliffordAlgebra Q × CliffordAlgebra Q →ₗ[R] CliffordAlgebra Q :=
haveI v_mul := (Algebra.lmul R (CliffordAlgebra Q)).toLinearMap ∘ₗ ι Q
d.smulRight (LinearMap.fst _ (CliffordAlgebra Q) (CliffordAlgebra Q)) -
v_mul.compl₂ (LinearMap.snd _ (CliffordAlgebra Q) _)
#align clifford_algebra.contract_left_aux CliffordAlgebra.contractLeftAux
theorem contractLeftAux_contractLeftAux (v : M) (x : CliffordAlgebra Q) (fx : CliffordAlgebra Q) :
contractLeftAux Q d v (ι Q v * x, contractLeftAux Q d v (x, fx)) = Q v • fx := by
simp only [contractLeftAux_apply_apply]
rw [mul_sub, ← mul_assoc, ι_sq_scalar, ← Algebra.smul_def, ← sub_add, mul_smul_comm, sub_self,
zero_add]
#align clifford_algebra.contract_left_aux_contract_left_aux CliffordAlgebra.contractLeftAux_contractLeftAux
variable {Q}
def contractLeft : Module.Dual R M →ₗ[R] CliffordAlgebra Q →ₗ[R] CliffordAlgebra Q where
toFun d := foldr' Q (contractLeftAux Q d) (contractLeftAux_contractLeftAux Q d) 0
map_add' d₁ d₂ :=
LinearMap.ext fun x => by
dsimp only
rw [LinearMap.add_apply]
induction' x using CliffordAlgebra.left_induction with r x y hx hy m x hx
· simp_rw [foldr'_algebraMap, smul_zero, zero_add]
· rw [map_add, map_add, map_add, add_add_add_comm, hx, hy]
· rw [foldr'_ι_mul, foldr'_ι_mul, foldr'_ι_mul, hx]
dsimp only [contractLeftAux_apply_apply]
rw [sub_add_sub_comm, mul_add, LinearMap.add_apply, add_smul]
map_smul' c d :=
LinearMap.ext fun x => by
dsimp only
rw [LinearMap.smul_apply, RingHom.id_apply]
induction' x using CliffordAlgebra.left_induction with r x y hx hy m x hx
· simp_rw [foldr'_algebraMap, smul_zero]
· rw [map_add, map_add, smul_add, hx, hy]
· rw [foldr'_ι_mul, foldr'_ι_mul, hx]
dsimp only [contractLeftAux_apply_apply]
rw [LinearMap.smul_apply, smul_assoc, mul_smul_comm, smul_sub]
#align clifford_algebra.contract_left CliffordAlgebra.contractLeft
def contractRight : CliffordAlgebra Q →ₗ[R] Module.Dual R M →ₗ[R] CliffordAlgebra Q :=
LinearMap.flip (LinearMap.compl₂ (LinearMap.compr₂ contractLeft reverse) reverse)
#align clifford_algebra.contract_right CliffordAlgebra.contractRight
theorem contractRight_eq (x : CliffordAlgebra Q) :
contractRight (Q := Q) x d = reverse (contractLeft (R := R) (M := M) d <| reverse x) :=
rfl
#align clifford_algebra.contract_right_eq CliffordAlgebra.contractRight_eq
local infixl:70 "⌋" => contractLeft (R := R) (M := M)
local infixl:70 "⌊" => contractRight (R := R) (M := M) (Q := Q)
-- Porting note: Lean needs to be reminded of this instance otherwise the statement of the
-- next result times out
instance : SMul R (CliffordAlgebra Q) := inferInstance
theorem contractLeft_ι_mul (a : M) (b : CliffordAlgebra Q) :
d⌋(ι Q a * b) = d a • b - ι Q a * (d⌋b) := by
-- Porting note: Lean cannot figure out anymore the third argument
refine foldr'_ι_mul _ _ ?_ _ _ _
exact fun m x fx ↦ contractLeftAux_contractLeftAux Q d m x fx
#align clifford_algebra.contract_left_ι_mul CliffordAlgebra.contractLeft_ι_mul
theorem contractRight_mul_ι (a : M) (b : CliffordAlgebra Q) :
b * ι Q a⌊d = d a • b - b⌊d * ι Q a := by
rw [contractRight_eq, reverse.map_mul, reverse_ι, contractLeft_ι_mul, map_sub, map_smul,
reverse_reverse, reverse.map_mul, reverse_ι, contractRight_eq]
#align clifford_algebra.contract_right_mul_ι CliffordAlgebra.contractRight_mul_ι
theorem contractLeft_algebraMap_mul (r : R) (b : CliffordAlgebra Q) :
d⌋(algebraMap _ _ r * b) = algebraMap _ _ r * (d⌋b) := by
rw [← Algebra.smul_def, map_smul, Algebra.smul_def]
#align clifford_algebra.contract_left_algebra_map_mul CliffordAlgebra.contractLeft_algebraMap_mul
theorem contractLeft_mul_algebraMap (a : CliffordAlgebra Q) (r : R) :
d⌋(a * algebraMap _ _ r) = d⌋a * algebraMap _ _ r := by
rw [← Algebra.commutes, contractLeft_algebraMap_mul, Algebra.commutes]
#align clifford_algebra.contract_left_mul_algebra_map CliffordAlgebra.contractLeft_mul_algebraMap
theorem contractRight_algebraMap_mul (r : R) (b : CliffordAlgebra Q) :
algebraMap _ _ r * b⌊d = algebraMap _ _ r * (b⌊d) := by
rw [← Algebra.smul_def, LinearMap.map_smul₂, Algebra.smul_def]
#align clifford_algebra.contract_right_algebra_map_mul CliffordAlgebra.contractRight_algebraMap_mul
| Mathlib/LinearAlgebra/CliffordAlgebra/Contraction.lean | 159 | 161 | theorem contractRight_mul_algebraMap (a : CliffordAlgebra Q) (r : R) :
a * algebraMap _ _ r⌊d = a⌊d * algebraMap _ _ r := by |
rw [← Algebra.commutes, contractRight_algebraMap_mul, Algebra.commutes]
| 1 | 2.718282 | 0 | 0.625 | 8 | 549 |
import Mathlib.Algebra.BigOperators.Group.Finset
#align_import data.nat.gcd.big_operators from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab"
namespace Nat
variable {ι : Type*}
theorem coprime_list_prod_left_iff {l : List ℕ} {k : ℕ} :
Coprime l.prod k ↔ ∀ n ∈ l, Coprime n k := by
induction l <;> simp [Nat.coprime_mul_iff_left, *]
theorem coprime_list_prod_right_iff {k : ℕ} {l : List ℕ} :
Coprime k l.prod ↔ ∀ n ∈ l, Coprime k n := by
simp_rw [coprime_comm (n := k), coprime_list_prod_left_iff]
theorem coprime_multiset_prod_left_iff {m : Multiset ℕ} {k : ℕ} :
Coprime m.prod k ↔ ∀ n ∈ m, Coprime n k := by
induction m using Quotient.inductionOn; simpa using coprime_list_prod_left_iff
theorem coprime_multiset_prod_right_iff {k : ℕ} {m : Multiset ℕ} :
Coprime k m.prod ↔ ∀ n ∈ m, Coprime k n := by
induction m using Quotient.inductionOn; simpa using coprime_list_prod_right_iff
theorem coprime_prod_left_iff {t : Finset ι} {s : ι → ℕ} {x : ℕ} :
Coprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, Coprime (s i) x := by
simpa using coprime_multiset_prod_left_iff (m := t.val.map s)
theorem coprime_prod_right_iff {x : ℕ} {t : Finset ι} {s : ι → ℕ} :
Coprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, Coprime x (s i) := by
simpa using coprime_multiset_prod_right_iff (m := t.val.map s)
alias ⟨_, Coprime.prod_left⟩ := coprime_prod_left_iff
#align nat.coprime_prod_left Nat.Coprime.prod_left
alias ⟨_, Coprime.prod_right⟩ := coprime_prod_right_iff
#align nat.coprime_prod_right Nat.Coprime.prod_right
| Mathlib/Data/Nat/GCD/BigOperators.lean | 52 | 54 | theorem coprime_fintype_prod_left_iff [Fintype ι] {s : ι → ℕ} {x : ℕ} :
Coprime (∏ i, s i) x ↔ ∀ i, Coprime (s i) x := by |
simp [coprime_prod_left_iff]
| 1 | 2.718282 | 0 | 0 | 8 | 159 |
import Mathlib.Algebra.MonoidAlgebra.Degree
import Mathlib.Algebra.MvPolynomial.Rename
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
#align_import data.mv_polynomial.variables from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
universe u v w
variable {R : Type u} {S : Type v}
namespace MvPolynomial
variable {σ τ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
section CommSemiring
variable [CommSemiring R] {p q : MvPolynomial σ R}
section Degrees
def degrees (p : MvPolynomial σ R) : Multiset σ :=
letI := Classical.decEq σ
p.support.sup fun s : σ →₀ ℕ => toMultiset s
#align mv_polynomial.degrees MvPolynomial.degrees
theorem degrees_def [DecidableEq σ] (p : MvPolynomial σ R) :
p.degrees = p.support.sup fun s : σ →₀ ℕ => Finsupp.toMultiset s := by rw [degrees]; convert rfl
#align mv_polynomial.degrees_def MvPolynomial.degrees_def
theorem degrees_monomial (s : σ →₀ ℕ) (a : R) : degrees (monomial s a) ≤ toMultiset s := by
classical
refine (supDegree_single s a).trans_le ?_
split_ifs
exacts [bot_le, le_rfl]
#align mv_polynomial.degrees_monomial MvPolynomial.degrees_monomial
theorem degrees_monomial_eq (s : σ →₀ ℕ) (a : R) (ha : a ≠ 0) :
degrees (monomial s a) = toMultiset s := by
classical
exact (supDegree_single s a).trans (if_neg ha)
#align mv_polynomial.degrees_monomial_eq MvPolynomial.degrees_monomial_eq
theorem degrees_C (a : R) : degrees (C a : MvPolynomial σ R) = 0 :=
Multiset.le_zero.1 <| degrees_monomial _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_C MvPolynomial.degrees_C
theorem degrees_X' (n : σ) : degrees (X n : MvPolynomial σ R) ≤ {n} :=
le_trans (degrees_monomial _ _) <| le_of_eq <| toMultiset_single _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X' MvPolynomial.degrees_X'
@[simp]
theorem degrees_X [Nontrivial R] (n : σ) : degrees (X n : MvPolynomial σ R) = {n} :=
(degrees_monomial_eq _ (1 : R) one_ne_zero).trans (toMultiset_single _ _)
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X MvPolynomial.degrees_X
@[simp]
theorem degrees_zero : degrees (0 : MvPolynomial σ R) = 0 := by
rw [← C_0]
exact degrees_C 0
#align mv_polynomial.degrees_zero MvPolynomial.degrees_zero
@[simp]
theorem degrees_one : degrees (1 : MvPolynomial σ R) = 0 :=
degrees_C 1
#align mv_polynomial.degrees_one MvPolynomial.degrees_one
| Mathlib/Algebra/MvPolynomial/Degrees.lean | 128 | 130 | theorem degrees_add [DecidableEq σ] (p q : MvPolynomial σ R) :
(p + q).degrees ≤ p.degrees ⊔ q.degrees := by |
simp_rw [degrees_def]; exact supDegree_add_le
| 1 | 2.718282 | 0 | 0.846154 | 13 | 743 |
import Mathlib.Data.List.Nodup
#align_import data.list.duplicate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
variable {α : Type*}
namespace List
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
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]
| 1 | 2.718282 | 0 | 0.818182 | 11 | 719 |
import Mathlib.Algebra.Field.Basic
import Mathlib.Algebra.GroupWithZero.Units.Equiv
import Mathlib.Algebra.Order.Field.Defs
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Order.Bounds.OrderIso
import Mathlib.Tactic.Positivity.Core
#align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd"
open Function OrderDual
variable {ι α β : Type*}
section LinearOrderedSemifield
variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ}
@[simps! (config := { simpRhs := true })]
def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α :=
{ Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha }
#align order_iso.mul_left₀ OrderIso.mulLeft₀
#align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply
#align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply
@[simps! (config := { simpRhs := true })]
def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α :=
{ Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha }
#align order_iso.mul_right₀ OrderIso.mulRight₀
#align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply
#align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply
theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b :=
⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h =>
calc
a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm
_ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le
_ = b / c := (div_eq_mul_one_div b c).symm
⟩
#align le_div_iff le_div_iff
theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc]
#align le_div_iff' le_div_iff'
theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b :=
⟨fun h =>
calc
a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm]
_ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le
,
fun h =>
calc
a / b = a * (1 / b) := div_eq_mul_one_div a b
_ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le
_ = c * b / b := (div_eq_mul_one_div (c * b) b).symm
_ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl
⟩
#align div_le_iff div_le_iff
theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb]
#align div_le_iff' div_le_iff'
lemma div_le_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b ≤ c ↔ a / c ≤ b := by
rw [div_le_iff hb, div_le_iff' hc]
theorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b :=
lt_iff_lt_of_le_iff_le <| div_le_iff hc
#align lt_div_iff lt_div_iff
theorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by rw [mul_comm, lt_div_iff hc]
#align lt_div_iff' lt_div_iff'
theorem div_lt_iff (hc : 0 < c) : b / c < a ↔ b < a * c :=
lt_iff_lt_of_le_iff_le (le_div_iff hc)
#align div_lt_iff div_lt_iff
theorem div_lt_iff' (hc : 0 < c) : b / c < a ↔ b < c * a := by rw [mul_comm, div_lt_iff hc]
#align div_lt_iff' div_lt_iff'
lemma div_lt_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b < c ↔ a / c < b := by
rw [div_lt_iff hb, div_lt_iff' hc]
theorem inv_mul_le_iff (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ b * c := by
rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div]
exact div_le_iff' h
#align inv_mul_le_iff inv_mul_le_iff
theorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by rw [inv_mul_le_iff h, mul_comm]
#align inv_mul_le_iff' inv_mul_le_iff'
| Mathlib/Algebra/Order/Field/Basic.lean | 107 | 107 | theorem mul_inv_le_iff (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ b * c := by | rw [mul_comm, inv_mul_le_iff h]
| 1 | 2.718282 | 0 | 0.25 | 16 | 288 |
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"
variable {α : Type*}
namespace RelEmbedding
variable {r : α → α → Prop} [IsStrictOrder α r]
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
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
| Mathlib/Order/OrderIsoNat.lean | 66 | 81 | theorem acc_iff_no_decreasing_seq {x} :
Acc r x ↔ IsEmpty { f : ((· > ·) : ℕ → ℕ → Prop) ↪r r // x ∈ Set.range f } := by |
constructor
· refine fun h => h.recOn fun x _ IH => ?_
constructor
rintro ⟨f, k, hf⟩
exact IsEmpty.elim' (IH (f (k + 1)) (hf ▸ f.map_rel_iff.2 (lt_add_one k))) ⟨f, _, rfl⟩
· have : ∀ x : { a // ¬Acc r a }, ∃ y : { a // ¬Acc r a }, r y.1 x.1 := by
rintro ⟨x, hx⟩
cases exists_not_acc_lt_of_not_acc hx with
| intro w h => exact ⟨⟨w, h.1⟩, h.2⟩
choose f h using this
refine fun E =>
by_contradiction fun hx => E.elim' ⟨natGT (fun n => (f^[n] ⟨x, hx⟩).1) fun n => ?_, 0, rfl⟩
simp only [Function.iterate_succ']
apply h
| 14 | 1,202,604.284165 | 2 | 1.6 | 5 | 1,718 |
import Mathlib.Algebra.ContinuedFractions.Basic
import Mathlib.Algebra.GroupWithZero.Basic
#align_import algebra.continued_fractions.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace GeneralizedContinuedFraction
section General
variable {α : Type*} {g : GeneralizedContinuedFraction α} {n : ℕ}
theorem terminatedAt_iff_s_terminatedAt : g.TerminatedAt n ↔ g.s.TerminatedAt n := by rfl
#align generalized_continued_fraction.terminated_at_iff_s_terminated_at GeneralizedContinuedFraction.terminatedAt_iff_s_terminatedAt
theorem terminatedAt_iff_s_none : g.TerminatedAt n ↔ g.s.get? n = none := by rfl
#align generalized_continued_fraction.terminated_at_iff_s_none GeneralizedContinuedFraction.terminatedAt_iff_s_none
theorem part_num_none_iff_s_none : g.partialNumerators.get? n = none ↔ g.s.get? n = none := by
cases s_nth_eq : g.s.get? n <;> simp [partialNumerators, s_nth_eq]
#align generalized_continued_fraction.part_num_none_iff_s_none GeneralizedContinuedFraction.part_num_none_iff_s_none
theorem terminatedAt_iff_part_num_none : g.TerminatedAt n ↔ g.partialNumerators.get? n = none := by
rw [terminatedAt_iff_s_none, part_num_none_iff_s_none]
#align generalized_continued_fraction.terminated_at_iff_part_num_none GeneralizedContinuedFraction.terminatedAt_iff_part_num_none
theorem part_denom_none_iff_s_none : g.partialDenominators.get? n = none ↔ g.s.get? n = none := by
cases s_nth_eq : g.s.get? n <;> simp [partialDenominators, s_nth_eq]
#align generalized_continued_fraction.part_denom_none_iff_s_none GeneralizedContinuedFraction.part_denom_none_iff_s_none
theorem terminatedAt_iff_part_denom_none :
g.TerminatedAt n ↔ g.partialDenominators.get? n = none := by
rw [terminatedAt_iff_s_none, part_denom_none_iff_s_none]
#align generalized_continued_fraction.terminated_at_iff_part_denom_none GeneralizedContinuedFraction.terminatedAt_iff_part_denom_none
theorem part_num_eq_s_a {gp : Pair α} (s_nth_eq : g.s.get? n = some gp) :
g.partialNumerators.get? n = some gp.a := by simp [partialNumerators, s_nth_eq]
#align generalized_continued_fraction.part_num_eq_s_a GeneralizedContinuedFraction.part_num_eq_s_a
theorem part_denom_eq_s_b {gp : Pair α} (s_nth_eq : g.s.get? n = some gp) :
g.partialDenominators.get? n = some gp.b := by simp [partialDenominators, s_nth_eq]
#align generalized_continued_fraction.part_denom_eq_s_b GeneralizedContinuedFraction.part_denom_eq_s_b
theorem exists_s_a_of_part_num {a : α} (nth_part_num_eq : g.partialNumerators.get? n = some a) :
∃ gp, g.s.get? n = some gp ∧ gp.a = a := by
simpa [partialNumerators, Stream'.Seq.map_get?] using nth_part_num_eq
#align generalized_continued_fraction.exists_s_a_of_part_num GeneralizedContinuedFraction.exists_s_a_of_part_num
| Mathlib/Algebra/ContinuedFractions/Translations.lean | 71 | 74 | theorem exists_s_b_of_part_denom {b : α}
(nth_part_denom_eq : g.partialDenominators.get? n = some b) :
∃ gp, g.s.get? n = some gp ∧ gp.b = b := by |
simpa [partialDenominators, Stream'.Seq.map_get?] using nth_part_denom_eq
| 1 | 2.718282 | 0 | 0.052632 | 19 | 240 |
import Mathlib.Algebra.MvPolynomial.Counit
import Mathlib.Algebra.MvPolynomial.Invertible
import Mathlib.RingTheory.WittVector.Defs
#align_import ring_theory.witt_vector.basic from "leanprover-community/mathlib"@"9556784a5b84697562e9c6acb40500d4a82e675a"
noncomputable section
open MvPolynomial Function
variable {p : ℕ} {R S T : Type*} [hp : Fact p.Prime] [CommRing R] [CommRing S] [CommRing T]
variable {α : Type*} {β : Type*}
local notation "𝕎" => WittVector p
local notation "W_" => wittPolynomial p
-- type as `\bbW`
open scoped Witt
namespace WittVector
def mapFun (f : α → β) : 𝕎 α → 𝕎 β := fun x => mk _ (f ∘ x.coeff)
#align witt_vector.map_fun WittVector.mapFun
namespace mapFun
-- Porting note: switched the proof to tactic mode. I think that `ext` was the issue.
theorem injective (f : α → β) (hf : Injective f) : Injective (mapFun f : 𝕎 α → 𝕎 β) := by
intros _ _ h
ext p
exact hf (congr_arg (fun x => coeff x p) h : _)
#align witt_vector.map_fun.injective WittVector.mapFun.injective
theorem surjective (f : α → β) (hf : Surjective f) : Surjective (mapFun f : 𝕎 α → 𝕎 β) := fun x =>
⟨mk _ fun n => Classical.choose <| hf <| x.coeff n,
by ext n; simp only [mapFun, coeff_mk, comp_apply, Classical.choose_spec (hf (x.coeff n))]⟩
#align witt_vector.map_fun.surjective WittVector.mapFun.surjective
-- Porting note: using `(x y : 𝕎 R)` instead of `(x y : WittVector p R)` produced sorries.
variable (f : R →+* S) (x y : WittVector p R)
-- porting note: a very crude port.
macro "map_fun_tac" : tactic => `(tactic| (
ext n
simp only [mapFun, mk, comp_apply, zero_coeff, map_zero,
-- Porting note: the lemmas on the next line do not have the `simp` tag in mathlib4
add_coeff, sub_coeff, mul_coeff, neg_coeff, nsmul_coeff, zsmul_coeff, pow_coeff,
peval, map_aeval, algebraMap_int_eq, coe_eval₂Hom] <;>
try { cases n <;> simp <;> done } <;> -- Porting note: this line solves `one`
apply eval₂Hom_congr (RingHom.ext_int _ _) _ rfl <;>
ext ⟨i, k⟩ <;>
fin_cases i <;> rfl))
-- and until `pow`.
-- We do not tag these lemmas as `@[simp]` because they will be bundled in `map` later on.
theorem zero : mapFun f (0 : 𝕎 R) = 0 := by map_fun_tac
#align witt_vector.map_fun.zero WittVector.mapFun.zero
theorem one : mapFun f (1 : 𝕎 R) = 1 := by map_fun_tac
#align witt_vector.map_fun.one WittVector.mapFun.one
theorem add : mapFun f (x + y) = mapFun f x + mapFun f y := by map_fun_tac
#align witt_vector.map_fun.add WittVector.mapFun.add
theorem sub : mapFun f (x - y) = mapFun f x - mapFun f y := by map_fun_tac
#align witt_vector.map_fun.sub WittVector.mapFun.sub
| Mathlib/RingTheory/WittVector/Basic.lean | 114 | 114 | theorem mul : mapFun f (x * y) = mapFun f x * mapFun f y := by | map_fun_tac
| 1 | 2.718282 | 0 | 0.090909 | 11 | 242 |
import Mathlib.FieldTheory.RatFunc.Basic
import Mathlib.RingTheory.EuclideanDomain
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Polynomial.Content
noncomputable section
universe u
variable {K : Type u}
namespace RatFunc
section Eval
open scoped Classical
open scoped nonZeroDivisors Polynomial
open RatFunc
section Domain
variable [CommRing K] [IsDomain K]
def C : K →+* RatFunc K := algebraMap _ _
set_option linter.uppercaseLean3 false in #align ratfunc.C RatFunc.C
@[simp]
theorem algebraMap_eq_C : algebraMap K (RatFunc K) = C :=
rfl
set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_eq_C RatFunc.algebraMap_eq_C
@[simp]
theorem algebraMap_C (a : K) : algebraMap K[X] (RatFunc K) (Polynomial.C a) = C a :=
rfl
set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_C RatFunc.algebraMap_C
@[simp]
theorem algebraMap_comp_C : (algebraMap K[X] (RatFunc K)).comp Polynomial.C = C :=
rfl
set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_comp_C RatFunc.algebraMap_comp_C
| Mathlib/FieldTheory/RatFunc/AsPolynomial.lean | 61 | 62 | theorem smul_eq_C_mul (r : K) (x : RatFunc K) : r • x = C r * x := by |
rw [Algebra.smul_def, algebraMap_eq_C]
| 1 | 2.718282 | 0 | 0 | 1 | 7 |
import Mathlib.Analysis.SpecialFunctions.Complex.Log
#align_import analysis.special_functions.pow.complex from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8"
open scoped Classical
open Real Topology Filter ComplexConjugate Finset Set
namespace Complex
noncomputable def cpow (x y : ℂ) : ℂ :=
if x = 0 then if y = 0 then 1 else 0 else exp (log x * y)
#align complex.cpow Complex.cpow
noncomputable instance : Pow ℂ ℂ :=
⟨cpow⟩
@[simp]
theorem cpow_eq_pow (x y : ℂ) : cpow x y = x ^ y :=
rfl
#align complex.cpow_eq_pow Complex.cpow_eq_pow
theorem cpow_def (x y : ℂ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) :=
rfl
#align complex.cpow_def Complex.cpow_def
theorem cpow_def_of_ne_zero {x : ℂ} (hx : x ≠ 0) (y : ℂ) : x ^ y = exp (log x * y) :=
if_neg hx
#align complex.cpow_def_of_ne_zero Complex.cpow_def_of_ne_zero
@[simp]
| Mathlib/Analysis/SpecialFunctions/Pow/Complex.lean | 45 | 45 | theorem cpow_zero (x : ℂ) : x ^ (0 : ℂ) = 1 := by | simp [cpow_def]
| 1 | 2.718282 | 0 | 0.636364 | 11 | 551 |
import Mathlib.SetTheory.Cardinal.Basic
import Mathlib.Tactic.Ring
#align_import data.nat.count from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988"
open Finset
namespace Nat
variable (p : ℕ → Prop)
section Count
variable [DecidablePred p]
def count (n : ℕ) : ℕ :=
(List.range n).countP p
#align nat.count Nat.count
@[simp]
| Mathlib/Data/Nat/Count.lean | 38 | 39 | theorem count_zero : count p 0 = 0 := by |
rw [count, List.range_zero, List.countP, List.countP.go]
| 1 | 2.718282 | 0 | 0.642857 | 14 | 554 |
import Mathlib.Geometry.Manifold.ContMDiff.Product
import Mathlib.Analysis.NormedSpace.OperatorNorm.Prod
open Set ChartedSpace SmoothManifoldWithCorners
open scoped Topology Manifold
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
-- declare a smooth manifold `M` over the pair `(E, H)`.
{E : Type*}
[NormedAddCommGroup E] [NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H]
{I : ModelWithCorners 𝕜 E H} {M : Type*} [TopologicalSpace M] [ChartedSpace H M]
[SmoothManifoldWithCorners I M]
-- declare a smooth manifold `M'` over the pair `(E', H')`.
{E' : Type*}
[NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H']
{I' : ModelWithCorners 𝕜 E' H'} {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
[SmoothManifoldWithCorners I' M']
-- declare a smooth manifold `N` over the pair `(F, G)`.
{F : Type*}
[NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type*} [TopologicalSpace G]
{J : ModelWithCorners 𝕜 F G} {N : Type*} [TopologicalSpace N] [ChartedSpace G N]
[SmoothManifoldWithCorners J N]
-- declare a smooth manifold `N'` over the pair `(F', G')`.
{F' : Type*}
[NormedAddCommGroup F'] [NormedSpace 𝕜 F'] {G' : Type*} [TopologicalSpace G']
{J' : ModelWithCorners 𝕜 F' G'} {N' : Type*} [TopologicalSpace N'] [ChartedSpace G' N']
[SmoothManifoldWithCorners J' N']
-- F₁, F₂, F₃, F₄ are normed spaces
{F₁ : Type*} [NormedAddCommGroup F₁] [NormedSpace 𝕜 F₁] {F₂ : Type*} [NormedAddCommGroup F₂]
[NormedSpace 𝕜 F₂] {F₃ : Type*} [NormedAddCommGroup F₃] [NormedSpace 𝕜 F₃] {F₄ : Type*}
[NormedAddCommGroup F₄] [NormedSpace 𝕜 F₄]
-- declare functions, sets, points and smoothness indices
{f f₁ : M → M'} {s t : Set M} {x : M} {m n : ℕ∞}
section Module
theorem contMDiffWithinAt_iff_contDiffWithinAt {f : E → E'} {s : Set E} {x : E} :
ContMDiffWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') n f s x ↔ ContDiffWithinAt 𝕜 n f s x := by
simp (config := { contextual := true }) only [ContMDiffWithinAt, liftPropWithinAt_iff',
ContDiffWithinAtProp, iff_def, mfld_simps]
exact ContDiffWithinAt.continuousWithinAt
#align cont_mdiff_within_at_iff_cont_diff_within_at contMDiffWithinAt_iff_contDiffWithinAt
alias ⟨ContMDiffWithinAt.contDiffWithinAt, ContDiffWithinAt.contMDiffWithinAt⟩ :=
contMDiffWithinAt_iff_contDiffWithinAt
#align cont_mdiff_within_at.cont_diff_within_at ContMDiffWithinAt.contDiffWithinAt
#align cont_diff_within_at.cont_mdiff_within_at ContDiffWithinAt.contMDiffWithinAt
| Mathlib/Geometry/Manifold/ContMDiff/NormedSpace.lean | 63 | 65 | theorem contMDiffAt_iff_contDiffAt {f : E → E'} {x : E} :
ContMDiffAt 𝓘(𝕜, E) 𝓘(𝕜, E') n f x ↔ ContDiffAt 𝕜 n f x := by |
rw [← contMDiffWithinAt_univ, contMDiffWithinAt_iff_contDiffWithinAt, contDiffWithinAt_univ]
| 1 | 2.718282 | 0 | 0.333333 | 3 | 329 |
import Mathlib.Algebra.Order.Ring.Nat
#align_import data.nat.dist from "leanprover-community/mathlib"@"d50b12ae8e2bd910d08a94823976adae9825718b"
namespace Nat
def dist (n m : ℕ) :=
n - m + (m - n)
#align nat.dist Nat.dist
-- Should be aligned to `Nat.dist.eq_def`, but that is generated on demand and isn't present yet.
#noalign nat.dist.def
theorem dist_comm (n m : ℕ) : dist n m = dist m n := by simp [dist, add_comm]
#align nat.dist_comm Nat.dist_comm
@[simp]
| Mathlib/Data/Nat/Dist.lean | 31 | 31 | theorem dist_self (n : ℕ) : dist n n = 0 := by | simp [dist, tsub_self]
| 1 | 2.718282 | 0 | 0.266667 | 15 | 309 |
import Mathlib.Algebra.Algebra.Operations
import Mathlib.Algebra.Algebra.Subalgebra.Basic
import Mathlib.Algebra.Ring.Subring.Pointwise
import Mathlib.RingTheory.Adjoin.Basic
#align_import algebra.algebra.subalgebra.pointwise from "leanprover-community/mathlib"@"b2c707cd190a58ea0565c86695a19e99ccecc215"
namespace Subalgebra
section Pointwise
variable {R : Type*} {A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]
theorem mul_toSubmodule_le (S T : Subalgebra R A) :
(Subalgebra.toSubmodule S)* (Subalgebra.toSubmodule T) ≤ Subalgebra.toSubmodule (S ⊔ T) := by
rw [Submodule.mul_le]
intro y hy z hz
show y * z ∈ S ⊔ T
exact mul_mem (Algebra.mem_sup_left hy) (Algebra.mem_sup_right hz)
#align subalgebra.mul_to_submodule_le Subalgebra.mul_toSubmodule_le
@[simp]
| Mathlib/Algebra/Algebra/Subalgebra/Pointwise.lean | 37 | 44 | theorem mul_self (S : Subalgebra R A) : (Subalgebra.toSubmodule S) * (Subalgebra.toSubmodule S)
= (Subalgebra.toSubmodule S) := by |
apply le_antisymm
· refine (mul_toSubmodule_le _ _).trans_eq ?_
rw [sup_idem]
· intro x hx1
rw [← mul_one x]
exact Submodule.mul_mem_mul hx1 (show (1 : A) ∈ S from one_mem S)
| 6 | 403.428793 | 2 | 2 | 3 | 2,120 |
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Ring.Invertible
import Mathlib.Data.Nat.Cast.Order
#align_import algebra.order.invertible from "leanprover-community/mathlib"@"ee0c179cd3c8a45aa5bffbf1b41d8dbede452865"
variable {α : Type*} [LinearOrderedSemiring α] {a : α}
@[simp]
theorem invOf_pos [Invertible a] : 0 < ⅟ a ↔ 0 < a :=
haveI : 0 < a * ⅟ a := by simp only [mul_invOf_self, zero_lt_one]
⟨fun h => pos_of_mul_pos_left this h.le, fun h => pos_of_mul_pos_right this h.le⟩
#align inv_of_pos invOf_pos
@[simp]
| Mathlib/Algebra/Order/Invertible.lean | 25 | 25 | theorem invOf_nonpos [Invertible a] : ⅟ a ≤ 0 ↔ a ≤ 0 := by | simp only [← not_lt, invOf_pos]
| 1 | 2.718282 | 0 | 0.5 | 4 | 441 |
import Mathlib.Data.Option.NAry
import Mathlib.Data.Seq.Computation
#align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace Stream'
universe u v w
def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop :=
∀ {n : ℕ}, s n = none → s (n + 1) = none
#align stream.is_seq Stream'.IsSeq
def Seq (α : Type u) : Type u :=
{ f : Stream' (Option α) // f.IsSeq }
#align stream.seq Stream'.Seq
def Seq1 (α) :=
α × Seq α
#align stream.seq1 Stream'.Seq1
namespace Seq
variable {α : Type u} {β : Type v} {γ : Type w}
def nil : Seq α :=
⟨Stream'.const none, fun {_} _ => rfl⟩
#align stream.seq.nil Stream'.Seq.nil
instance : Inhabited (Seq α) :=
⟨nil⟩
def cons (a : α) (s : Seq α) : Seq α :=
⟨some a::s.1, by
rintro (n | _) h
· contradiction
· exact s.2 h⟩
#align stream.seq.cons Stream'.Seq.cons
@[simp]
theorem val_cons (s : Seq α) (x : α) : (cons x s).val = some x::s.val :=
rfl
#align stream.seq.val_cons Stream'.Seq.val_cons
def get? : Seq α → ℕ → Option α :=
Subtype.val
#align stream.seq.nth Stream'.Seq.get?
@[simp]
theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f :=
rfl
#align stream.seq.nth_mk Stream'.Seq.get?_mk
@[simp]
theorem get?_nil (n : ℕ) : (@nil α).get? n = none :=
rfl
#align stream.seq.nth_nil Stream'.Seq.get?_nil
@[simp]
theorem get?_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a :=
rfl
#align stream.seq.nth_cons_zero Stream'.Seq.get?_cons_zero
@[simp]
theorem get?_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n :=
rfl
#align stream.seq.nth_cons_succ Stream'.Seq.get?_cons_succ
@[ext]
protected theorem ext {s t : Seq α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t :=
Subtype.eq <| funext h
#align stream.seq.ext Stream'.Seq.ext
theorem cons_injective2 : Function.Injective2 (cons : α → Seq α → Seq α) := fun x y s t h =>
⟨by rw [← Option.some_inj, ← get?_cons_zero, h, get?_cons_zero],
Seq.ext fun n => by simp_rw [← get?_cons_succ x s n, h, get?_cons_succ]⟩
#align stream.seq.cons_injective2 Stream'.Seq.cons_injective2
theorem cons_left_injective (s : Seq α) : Function.Injective fun x => cons x s :=
cons_injective2.left _
#align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective
theorem cons_right_injective (x : α) : Function.Injective (cons x) :=
cons_injective2.right _
#align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective
def TerminatedAt (s : Seq α) (n : ℕ) : Prop :=
s.get? n = none
#align stream.seq.terminated_at Stream'.Seq.TerminatedAt
instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) :=
decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt; cases s.get? n <;> simp
#align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable
def Terminates (s : Seq α) : Prop :=
∃ n : ℕ, s.TerminatedAt n
#align stream.seq.terminates Stream'.Seq.Terminates
| Mathlib/Data/Seq/Seq.lean | 129 | 130 | theorem not_terminates_iff {s : Seq α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by |
simp only [Terminates, TerminatedAt, ← Ne.eq_def, Option.ne_none_iff_isSome, not_exists, iff_self]
| 1 | 2.718282 | 0 | 0.666667 | 3 | 601 |
import Mathlib.Data.Nat.Bits
import Mathlib.Order.Lattice
#align_import data.nat.size from "leanprover-community/mathlib"@"18a5306c091183ac90884daa9373fa3b178e8607"
namespace Nat
section
set_option linter.deprecated false
theorem shiftLeft_eq_mul_pow (m) : ∀ n, m <<< n = m * 2 ^ n := shiftLeft_eq _
#align nat.shiftl_eq_mul_pow Nat.shiftLeft_eq_mul_pow
theorem shiftLeft'_tt_eq_mul_pow (m) : ∀ n, shiftLeft' true m n + 1 = (m + 1) * 2 ^ n
| 0 => by simp [shiftLeft', pow_zero, Nat.one_mul]
| k + 1 => by
change bit1 (shiftLeft' true m k) + 1 = (m + 1) * (2 ^ k * 2)
rw [bit1_val]
change 2 * (shiftLeft' true m k + 1) = _
rw [shiftLeft'_tt_eq_mul_pow m k, mul_left_comm, mul_comm 2]
#align nat.shiftl'_tt_eq_mul_pow Nat.shiftLeft'_tt_eq_mul_pow
end
#align nat.one_shiftl Nat.one_shiftLeft
#align nat.zero_shiftl Nat.zero_shiftLeft
#align nat.shiftr_eq_div_pow Nat.shiftRight_eq_div_pow
| Mathlib/Data/Nat/Size.lean | 38 | 39 | theorem shiftLeft'_ne_zero_left (b) {m} (h : m ≠ 0) (n) : shiftLeft' b m n ≠ 0 := by |
induction n <;> simp [bit_ne_zero, shiftLeft', *]
| 1 | 2.718282 | 0 | 0.666667 | 9 | 569 |
import Mathlib.Algebra.Group.Basic
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Data.Set.Function
import Mathlib.Order.Interval.Set.Basic
#align_import data.set.intervals.monoid from "leanprover-community/mathlib"@"aba57d4d3dae35460225919dcd82fe91355162f9"
namespace Set
variable {M : Type*} [OrderedCancelAddCommMonoid M] [ExistsAddOfLE M] (a b c d : M)
theorem Ici_add_bij : BijOn (· + d) (Ici a) (Ici (a + d)) := by
refine
⟨fun x h => add_le_add_right (mem_Ici.mp h) _, (add_left_injective d).injOn, fun _ h => ?_⟩
obtain ⟨c, rfl⟩ := exists_add_of_le (mem_Ici.mp h)
rw [mem_Ici, add_right_comm, add_le_add_iff_right] at h
exact ⟨a + c, h, by rw [add_right_comm]⟩
#align set.Ici_add_bij Set.Ici_add_bij
theorem Ioi_add_bij : BijOn (· + d) (Ioi a) (Ioi (a + d)) := by
refine
⟨fun x h => add_lt_add_right (mem_Ioi.mp h) _, fun _ _ _ _ h => add_right_cancel h, fun _ h =>
?_⟩
obtain ⟨c, rfl⟩ := exists_add_of_le (mem_Ioi.mp h).le
rw [mem_Ioi, add_right_comm, add_lt_add_iff_right] at h
exact ⟨a + c, h, by rw [add_right_comm]⟩
#align set.Ioi_add_bij Set.Ioi_add_bij
theorem Icc_add_bij : BijOn (· + d) (Icc a b) (Icc (a + d) (b + d)) := by
rw [← Ici_inter_Iic, ← Ici_inter_Iic]
exact
(Ici_add_bij a d).inter_mapsTo (fun x hx => add_le_add_right hx _) fun x hx =>
le_of_add_le_add_right hx.2
#align set.Icc_add_bij Set.Icc_add_bij
theorem Ioo_add_bij : BijOn (· + d) (Ioo a b) (Ioo (a + d) (b + d)) := by
rw [← Ioi_inter_Iio, ← Ioi_inter_Iio]
exact
(Ioi_add_bij a d).inter_mapsTo (fun x hx => add_lt_add_right hx _) fun x hx =>
lt_of_add_lt_add_right hx.2
#align set.Ioo_add_bij Set.Ioo_add_bij
theorem Ioc_add_bij : BijOn (· + d) (Ioc a b) (Ioc (a + d) (b + d)) := by
rw [← Ioi_inter_Iic, ← Ioi_inter_Iic]
exact
(Ioi_add_bij a d).inter_mapsTo (fun x hx => add_le_add_right hx _) fun x hx =>
le_of_add_le_add_right hx.2
#align set.Ioc_add_bij Set.Ioc_add_bij
theorem Ico_add_bij : BijOn (· + d) (Ico a b) (Ico (a + d) (b + d)) := by
rw [← Ici_inter_Iio, ← Ici_inter_Iio]
exact
(Ici_add_bij a d).inter_mapsTo (fun x hx => add_lt_add_right hx _) fun x hx =>
lt_of_add_lt_add_right hx.2
#align set.Ico_add_bij Set.Ico_add_bij
@[simp]
theorem image_add_const_Ici : (fun x => x + a) '' Ici b = Ici (b + a) :=
(Ici_add_bij _ _).image_eq
#align set.image_add_const_Ici Set.image_add_const_Ici
@[simp]
theorem image_add_const_Ioi : (fun x => x + a) '' Ioi b = Ioi (b + a) :=
(Ioi_add_bij _ _).image_eq
#align set.image_add_const_Ioi Set.image_add_const_Ioi
@[simp]
theorem image_add_const_Icc : (fun x => x + a) '' Icc b c = Icc (b + a) (c + a) :=
(Icc_add_bij _ _ _).image_eq
#align set.image_add_const_Icc Set.image_add_const_Icc
@[simp]
theorem image_add_const_Ico : (fun x => x + a) '' Ico b c = Ico (b + a) (c + a) :=
(Ico_add_bij _ _ _).image_eq
#align set.image_add_const_Ico Set.image_add_const_Ico
@[simp]
theorem image_add_const_Ioc : (fun x => x + a) '' Ioc b c = Ioc (b + a) (c + a) :=
(Ioc_add_bij _ _ _).image_eq
#align set.image_add_const_Ioc Set.image_add_const_Ioc
@[simp]
theorem image_add_const_Ioo : (fun x => x + a) '' Ioo b c = Ioo (b + a) (c + a) :=
(Ioo_add_bij _ _ _).image_eq
#align set.image_add_const_Ioo Set.image_add_const_Ioo
@[simp]
theorem image_const_add_Ici : (fun x => a + x) '' Ici b = Ici (a + b) := by
simp only [add_comm a, image_add_const_Ici]
#align set.image_const_add_Ici Set.image_const_add_Ici
@[simp]
theorem image_const_add_Ioi : (fun x => a + x) '' Ioi b = Ioi (a + b) := by
simp only [add_comm a, image_add_const_Ioi]
#align set.image_const_add_Ioi Set.image_const_add_Ioi
@[simp]
| Mathlib/Algebra/Order/Interval/Set/Monoid.lean | 123 | 124 | theorem image_const_add_Icc : (fun x => a + x) '' Icc b c = Icc (a + b) (a + c) := by |
simp only [add_comm a, image_add_const_Icc]
| 1 | 2.718282 | 0 | 1.090909 | 11 | 1,187 |
import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2
#align_import measure_theory.function.conditional_expectation.condexp_L1 from "leanprover-community/mathlib"@"d8bbb04e2d2a44596798a9207ceefc0fb236e41e"
noncomputable section
open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap
open scoped NNReal ENNReal Topology MeasureTheory
namespace MeasureTheory
variable {α β F F' G G' 𝕜 : Type*} {p : ℝ≥0∞} [RCLike 𝕜]
-- 𝕜 for ℝ or ℂ
-- F for a Lp submodule
[NormedAddCommGroup F]
[NormedSpace 𝕜 F]
-- F' for integrals on a Lp submodule
[NormedAddCommGroup F']
[NormedSpace 𝕜 F'] [NormedSpace ℝ F'] [CompleteSpace F']
-- G for a Lp add_subgroup
[NormedAddCommGroup G]
-- G' for integrals on a Lp add_subgroup
[NormedAddCommGroup G']
[NormedSpace ℝ G'] [CompleteSpace G']
section CondexpInd
variable {m m0 : MeasurableSpace α} {μ : Measure α} {s t : Set α} [NormedSpace ℝ G]
section CondexpIndL1Fin
set_option linter.uppercaseLean3 false
def condexpIndL1Fin (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
(x : G) : α →₁[μ] G :=
(integrable_condexpIndSMul hm hs hμs x).toL1 _
#align measure_theory.condexp_ind_L1_fin MeasureTheory.condexpIndL1Fin
theorem condexpIndL1Fin_ae_eq_condexpIndSMul (hm : m ≤ m0) [SigmaFinite (μ.trim hm)]
(hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) :
condexpIndL1Fin hm hs hμs x =ᵐ[μ] condexpIndSMul hm hs hμs x :=
(integrable_condexpIndSMul hm hs hμs x).coeFn_toL1
#align measure_theory.condexp_ind_L1_fin_ae_eq_condexp_ind_smul MeasureTheory.condexpIndL1Fin_ae_eq_condexpIndSMul
variable {hm : m ≤ m0} [SigmaFinite (μ.trim hm)]
-- Porting note: this lemma fills the hole in `refine' (Memℒp.coeFn_toLp _) ...`
-- which is not automatically filled in Lean 4
private theorem q {hs : MeasurableSet s} {hμs : μ s ≠ ∞} {x : G} :
Memℒp (condexpIndSMul hm hs hμs x) 1 μ := by
rw [memℒp_one_iff_integrable]; apply integrable_condexpIndSMul
theorem condexpIndL1Fin_add (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x y : G) :
condexpIndL1Fin hm hs hμs (x + y) =
condexpIndL1Fin hm hs hμs x + condexpIndL1Fin hm hs hμs y := by
ext1
refine (Memℒp.coeFn_toLp q).trans ?_
refine EventuallyEq.trans ?_ (Lp.coeFn_add _ _).symm
refine EventuallyEq.trans ?_
(EventuallyEq.add (Memℒp.coeFn_toLp q).symm (Memℒp.coeFn_toLp q).symm)
rw [condexpIndSMul_add]
refine (Lp.coeFn_add _ _).trans (eventually_of_forall fun a => ?_)
rfl
#align measure_theory.condexp_ind_L1_fin_add MeasureTheory.condexpIndL1Fin_add
| Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean | 105 | 113 | theorem condexpIndL1Fin_smul (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : ℝ) (x : G) :
condexpIndL1Fin hm hs hμs (c • x) = c • condexpIndL1Fin hm hs hμs x := by |
ext1
refine (Memℒp.coeFn_toLp q).trans ?_
refine EventuallyEq.trans ?_ (Lp.coeFn_smul _ _).symm
rw [condexpIndSMul_smul hs hμs c x]
refine (Lp.coeFn_smul _ _).trans ?_
refine (condexpIndL1Fin_ae_eq_condexpIndSMul hm hs hμs x).mono fun y hy => ?_
simp only [Pi.smul_apply, hy]
| 7 | 1,096.633158 | 2 | 2 | 4 | 2,398 |
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Data.Fintype.Card
import Mathlib.GroupTheory.Perm.Basic
#align_import group_theory.perm.support from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
open Equiv Finset
namespace Equiv.Perm
variable {α : Type*}
section support
section Set
variable (p q : Perm α)
theorem set_support_inv_eq : { x | p⁻¹ x ≠ x } = { x | p x ≠ x } := by
ext x
simp only [Set.mem_setOf_eq, Ne]
rw [inv_def, symm_apply_eq, eq_comm]
#align equiv.perm.set_support_inv_eq Equiv.Perm.set_support_inv_eq
| Mathlib/GroupTheory/Perm/Support.lean | 270 | 271 | theorem set_support_apply_mem {p : Perm α} {a : α} :
p a ∈ { x | p x ≠ x } ↔ a ∈ { x | p x ≠ x } := by | simp
| 1 | 2.718282 | 0 | 0.944444 | 18 | 795 |
import Mathlib.Computability.DFA
import Mathlib.Data.Fintype.Powerset
#align_import computability.NFA from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514"
open Set
open Computability
universe u v
-- Porting note: Required as `NFA` is used in mathlib3
set_option linter.uppercaseLean3 false
structure NFA (α : Type u) (σ : Type v) where
step : σ → α → Set σ
start : Set σ
accept : Set σ
#align NFA NFA
variable {α : Type u} {σ σ' : Type v} (M : NFA α σ)
namespace NFA
instance : Inhabited (NFA α σ) :=
⟨NFA.mk (fun _ _ => ∅) ∅ ∅⟩
def stepSet (S : Set σ) (a : α) : Set σ :=
⋃ s ∈ S, M.step s a
#align NFA.step_set NFA.stepSet
theorem mem_stepSet (s : σ) (S : Set σ) (a : α) : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.step t a := by
simp [stepSet]
#align NFA.mem_step_set NFA.mem_stepSet
@[simp]
| Mathlib/Computability/NFA.lean | 58 | 58 | theorem stepSet_empty (a : α) : M.stepSet ∅ a = ∅ := by | simp [stepSet]
| 1 | 2.718282 | 0 | 0.333333 | 6 | 365 |
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"
noncomputable section
open QuotientAddGroup Metric Set Topology NNReal
variable {M N : Type*} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N]
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
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]
theorem QuotientAddGroup.norm_mk {S : AddSubgroup M} (x : M) :
‖(x : M ⧸ S)‖ = infDist x S := by
rw [norm_eq_infDist, ← infDist_image (IsometryEquiv.subLeft x).isometry,
IsometryEquiv.subLeft_apply, sub_zero, ← IsometryEquiv.preimage_symm]
congr 1 with y
simp only [mem_preimage, IsometryEquiv.subLeft_symm_apply, mem_setOf_eq, QuotientAddGroup.eq,
neg_add, neg_neg, neg_add_cancel_right, SetLike.mem_coe]
theorem image_norm_nonempty {S : AddSubgroup M} (x : M ⧸ S) :
(norm '' { m | mk' S m = x }).Nonempty :=
.image _ <| Quot.exists_rep x
#align image_norm_nonempty image_norm_nonempty
theorem bddBelow_image_norm (s : Set M) : BddBelow (norm '' s) :=
⟨0, forall_mem_image.2 fun _ _ ↦ norm_nonneg _⟩
#align bdd_below_image_norm bddBelow_image_norm
theorem isGLB_quotient_norm {S : AddSubgroup M} (x : M ⧸ S) :
IsGLB (norm '' { m | mk' S m = x }) (‖x‖) :=
isGLB_csInf (image_norm_nonempty x) (bddBelow_image_norm _)
theorem quotient_norm_neg {S : AddSubgroup M} (x : M ⧸ S) : ‖-x‖ = ‖x‖ := by
simp only [AddSubgroup.quotient_norm_eq]
congr 1 with r
constructor <;> { rintro ⟨m, hm, rfl⟩; use -m; simpa [neg_eq_iff_eq_neg] using hm }
#align quotient_norm_neg quotient_norm_neg
theorem quotient_norm_sub_rev {S : AddSubgroup M} (x y : M ⧸ S) : ‖x - y‖ = ‖y - x‖ := by
rw [← neg_sub, quotient_norm_neg]
#align quotient_norm_sub_rev quotient_norm_sub_rev
theorem quotient_norm_mk_le (S : AddSubgroup M) (m : M) : ‖mk' S m‖ ≤ ‖m‖ :=
csInf_le (bddBelow_image_norm _) <| Set.mem_image_of_mem _ rfl
#align quotient_norm_mk_le quotient_norm_mk_le
theorem quotient_norm_mk_le' (S : AddSubgroup M) (m : M) : ‖(m : M ⧸ S)‖ ≤ ‖m‖ :=
quotient_norm_mk_le S m
#align quotient_norm_mk_le' quotient_norm_mk_le'
| Mathlib/Analysis/Normed/Group/Quotient.lean | 162 | 166 | theorem quotient_norm_mk_eq (S : AddSubgroup M) (m : M) :
‖mk' S m‖ = sInf ((‖m + ·‖) '' S) := by |
rw [mk'_apply, norm_mk, sInf_image', ← infDist_image isometry_neg, image_neg,
neg_coe_set (H := S), infDist_eq_iInf]
simp only [dist_eq_norm', sub_neg_eq_add, add_comm]
| 3 | 20.085537 | 1 | 1 | 8 | 984 |
import Aesop
import Mathlib.Algebra.Group.Defs
import Mathlib.Data.Nat.Defs
import Mathlib.Data.Int.Defs
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.Cases
import Mathlib.Tactic.SimpRw
import Mathlib.Tactic.SplitIfs
#align_import algebra.group.basic from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c"
assert_not_exists MonoidWithZero
assert_not_exists DenselyOrdered
open Function
universe u
variable {α β G M : Type*}
@[to_additive]
instance CommMagma.to_isCommutative [CommMagma G] : Std.Commutative (α := G) (· * ·) := ⟨mul_comm⟩
#align comm_semigroup.to_is_commutative CommMagma.to_isCommutative
#align add_comm_semigroup.to_is_commutative AddCommMagma.to_isCommutative
attribute [local simp] mul_assoc sub_eq_add_neg
section DivInvMonoid
variable [DivInvMonoid G] {a b c : G}
@[to_additive, field_simps] -- The attributes are out of order on purpose
theorem inv_eq_one_div (x : G) : x⁻¹ = 1 / x := by rw [div_eq_mul_inv, one_mul]
#align inv_eq_one_div inv_eq_one_div
#align neg_eq_zero_sub neg_eq_zero_sub
@[to_additive]
theorem mul_one_div (x y : G) : x * (1 / y) = x / y := by
rw [div_eq_mul_inv, one_mul, div_eq_mul_inv]
#align mul_one_div mul_one_div
#align add_zero_sub add_zero_sub
@[to_additive]
theorem mul_div_assoc (a b c : G) : a * b / c = a * (b / c) := by
rw [div_eq_mul_inv, div_eq_mul_inv, mul_assoc _ _ _]
#align mul_div_assoc mul_div_assoc
#align add_sub_assoc add_sub_assoc
@[to_additive, field_simps] -- The attributes are out of order on purpose
theorem mul_div_assoc' (a b c : G) : a * (b / c) = a * b / c :=
(mul_div_assoc _ _ _).symm
#align mul_div_assoc' mul_div_assoc'
#align add_sub_assoc' add_sub_assoc'
@[to_additive (attr := simp)]
theorem one_div (a : G) : 1 / a = a⁻¹ :=
(inv_eq_one_div a).symm
#align one_div one_div
#align zero_sub zero_sub
@[to_additive]
| Mathlib/Algebra/Group/Basic.lean | 474 | 474 | theorem mul_div (a b c : G) : a * (b / c) = a * b / c := by | simp only [mul_assoc, div_eq_mul_inv]
| 1 | 2.718282 | 0 | 0.333333 | 18 | 367 |
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Algebra.Ring.Action.Basic
import Mathlib.GroupTheory.GroupAction.Hom
import Mathlib.GroupTheory.GroupAction.Quotient
#align_import algebra.polynomial.group_ring_action from "leanprover-community/mathlib"@"afad8e438d03f9d89da2914aa06cb4964ba87a18"
variable (M : Type*) [Monoid M]
open Polynomial
namespace Polynomial
variable (R : Type*) [Semiring R]
variable {M}
-- Porting note: changed `(· • ·) m` to `HSMul.hSMul m`
theorem smul_eq_map [MulSemiringAction M R] (m : M) :
HSMul.hSMul m = map (MulSemiringAction.toRingHom M R m) := by
suffices DistribMulAction.toAddMonoidHom R[X] m =
(mapRingHom (MulSemiringAction.toRingHom M R m)).toAddMonoidHom by
ext1 r
exact DFunLike.congr_fun this r
ext n r : 2
change m • monomial n r = map (MulSemiringAction.toRingHom M R m) (monomial n r)
rw [Polynomial.map_monomial, Polynomial.smul_monomial, MulSemiringAction.toRingHom_apply]
#align polynomial.smul_eq_map Polynomial.smul_eq_map
variable (M)
noncomputable instance [MulSemiringAction M R] : MulSemiringAction M R[X] :=
{ Polynomial.distribMulAction with
smul_one := fun m ↦
smul_eq_map R m ▸ Polynomial.map_one (MulSemiringAction.toRingHom M R m)
smul_mul := fun m _ _ ↦
smul_eq_map R m ▸ Polynomial.map_mul (MulSemiringAction.toRingHom M R m) }
variable {M R}
variable [MulSemiringAction M R]
@[simp]
theorem smul_X (m : M) : (m • X : R[X]) = X :=
(smul_eq_map R m).symm ▸ map_X _
set_option linter.uppercaseLean3 false in
#align polynomial.smul_X Polynomial.smul_X
variable (S : Type*) [CommSemiring S] [MulSemiringAction M S]
theorem smul_eval_smul (m : M) (f : S[X]) (x : S) : (m • f).eval (m • x) = m • f.eval x :=
Polynomial.induction_on f (fun r ↦ by rw [smul_C, eval_C, eval_C])
(fun f g ihf ihg ↦ by rw [smul_add, eval_add, ihf, ihg, eval_add, smul_add]) fun n r _ ↦ by
rw [smul_mul', smul_pow', smul_C, smul_X, eval_mul, eval_C, eval_pow, eval_X, eval_mul, eval_C,
eval_pow, eval_X, smul_mul', smul_pow']
#align polynomial.smul_eval_smul Polynomial.smul_eval_smul
variable (G : Type*) [Group G]
theorem eval_smul' [MulSemiringAction G S] (g : G) (f : S[X]) (x : S) :
f.eval (g • x) = g • (g⁻¹ • f).eval x := by
rw [← smul_eval_smul, smul_inv_smul]
#align polynomial.eval_smul' Polynomial.eval_smul'
| Mathlib/Algebra/Polynomial/GroupRingAction.lean | 76 | 78 | theorem smul_eval [MulSemiringAction G S] (g : G) (f : S[X]) (x : S) :
(g • f).eval x = g • f.eval (g⁻¹ • x) := by |
rw [← smul_eval_smul, smul_inv_smul]
| 1 | 2.718282 | 0 | 0.666667 | 3 | 603 |
import Mathlib.Data.Multiset.Nodup
#align_import data.multiset.dedup from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
namespace Multiset
open List
variable {α β : Type*} [DecidableEq α]
def dedup (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => (l.dedup : Multiset α)) fun _ _ p => Quot.sound p.dedup
#align multiset.dedup Multiset.dedup
@[simp]
theorem coe_dedup (l : List α) : @dedup α _ l = l.dedup :=
rfl
#align multiset.coe_dedup Multiset.coe_dedup
@[simp]
theorem dedup_zero : @dedup α _ 0 = 0 :=
rfl
#align multiset.dedup_zero Multiset.dedup_zero
@[simp]
theorem mem_dedup {a : α} {s : Multiset α} : a ∈ dedup s ↔ a ∈ s :=
Quot.induction_on s fun _ => List.mem_dedup
#align multiset.mem_dedup Multiset.mem_dedup
@[simp]
theorem dedup_cons_of_mem {a : α} {s : Multiset α} : a ∈ s → dedup (a ::ₘ s) = dedup s :=
Quot.induction_on s fun _ m => @congr_arg _ _ _ _ ofList <| List.dedup_cons_of_mem m
#align multiset.dedup_cons_of_mem Multiset.dedup_cons_of_mem
@[simp]
theorem dedup_cons_of_not_mem {a : α} {s : Multiset α} : a ∉ s → dedup (a ::ₘ s) = a ::ₘ dedup s :=
Quot.induction_on s fun _ m => congr_arg ofList <| List.dedup_cons_of_not_mem m
#align multiset.dedup_cons_of_not_mem Multiset.dedup_cons_of_not_mem
theorem dedup_le (s : Multiset α) : dedup s ≤ s :=
Quot.induction_on s fun _ => (dedup_sublist _).subperm
#align multiset.dedup_le Multiset.dedup_le
theorem dedup_subset (s : Multiset α) : dedup s ⊆ s :=
subset_of_le <| dedup_le _
#align multiset.dedup_subset Multiset.dedup_subset
theorem subset_dedup (s : Multiset α) : s ⊆ dedup s := fun _ => mem_dedup.2
#align multiset.subset_dedup Multiset.subset_dedup
@[simp]
theorem dedup_subset' {s t : Multiset α} : dedup s ⊆ t ↔ s ⊆ t :=
⟨Subset.trans (subset_dedup _), Subset.trans (dedup_subset _)⟩
#align multiset.dedup_subset' Multiset.dedup_subset'
@[simp]
theorem subset_dedup' {s t : Multiset α} : s ⊆ dedup t ↔ s ⊆ t :=
⟨fun h => Subset.trans h (dedup_subset _), fun h => Subset.trans h (subset_dedup _)⟩
#align multiset.subset_dedup' Multiset.subset_dedup'
@[simp]
theorem nodup_dedup (s : Multiset α) : Nodup (dedup s) :=
Quot.induction_on s List.nodup_dedup
#align multiset.nodup_dedup Multiset.nodup_dedup
theorem dedup_eq_self {s : Multiset α} : dedup s = s ↔ Nodup s :=
⟨fun e => e ▸ nodup_dedup s, Quot.induction_on s fun _ h => congr_arg ofList h.dedup⟩
#align multiset.dedup_eq_self Multiset.dedup_eq_self
alias ⟨_, Nodup.dedup⟩ := dedup_eq_self
#align multiset.nodup.dedup Multiset.Nodup.dedup
theorem count_dedup (m : Multiset α) (a : α) : m.dedup.count a = if a ∈ m then 1 else 0 :=
Quot.induction_on m fun _ => by
simp only [quot_mk_to_coe'', coe_dedup, mem_coe, List.mem_dedup, coe_nodup, coe_count]
apply List.count_dedup _ _
#align multiset.count_dedup Multiset.count_dedup
@[simp]
theorem dedup_idem {m : Multiset α} : m.dedup.dedup = m.dedup :=
Quot.induction_on m fun _ => @congr_arg _ _ _ _ ofList List.dedup_idem
#align multiset.dedup_idempotent Multiset.dedup_idem
theorem dedup_eq_zero {s : Multiset α} : dedup s = 0 ↔ s = 0 :=
⟨fun h => eq_zero_of_subset_zero <| h ▸ subset_dedup _, fun h => h.symm ▸ dedup_zero⟩
#align multiset.dedup_eq_zero Multiset.dedup_eq_zero
@[simp]
theorem dedup_singleton {a : α} : dedup ({a} : Multiset α) = {a} :=
(nodup_singleton _).dedup
#align multiset.dedup_singleton Multiset.dedup_singleton
theorem le_dedup {s t : Multiset α} : s ≤ dedup t ↔ s ≤ t ∧ Nodup s :=
⟨fun h => ⟨le_trans h (dedup_le _), nodup_of_le h (nodup_dedup _)⟩,
fun ⟨l, d⟩ => (le_iff_subset d).2 <| Subset.trans (subset_of_le l) (subset_dedup _)⟩
#align multiset.le_dedup Multiset.le_dedup
theorem le_dedup_self {s : Multiset α} : s ≤ dedup s ↔ Nodup s := by
rw [le_dedup, and_iff_right le_rfl]
#align multiset.le_dedup_self Multiset.le_dedup_self
| Mathlib/Data/Multiset/Dedup.lean | 116 | 117 | theorem dedup_ext {s t : Multiset α} : dedup s = dedup t ↔ ∀ a, a ∈ s ↔ a ∈ t := by |
simp [Nodup.ext]
| 1 | 2.718282 | 0 | 0.25 | 4 | 296 |
import Mathlib.Algebra.BigOperators.Finsupp
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Data.Fintype.BigOperators
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.LinearAlgebra.LinearIndependent
import Mathlib.SetTheory.Cardinal.Cofinality
#align_import linear_algebra.basis from "leanprover-community/mathlib"@"13bce9a6b6c44f6b4c91ac1c1d2a816e2533d395"
noncomputable section
universe u
open Function Set Submodule
variable {ι : Type*} {ι' : Type*} {R : Type*} {R₂ : Type*} {K : Type*}
variable {M : Type*} {M' M'' : Type*} {V : Type u} {V' : Type*}
section Module
variable [Semiring R]
variable [AddCommMonoid M] [Module R M] [AddCommMonoid M'] [Module R M']
section
variable (ι R M)
structure Basis where
ofRepr ::
repr : M ≃ₗ[R] ι →₀ R
#align basis Basis
#align basis.repr Basis.repr
#align basis.of_repr Basis.ofRepr
end
instance uniqueBasis [Subsingleton R] : Unique (Basis ι R M) :=
⟨⟨⟨default⟩⟩, fun ⟨b⟩ => by rw [Subsingleton.elim b]⟩
#align unique_basis uniqueBasis
namespace Basis
instance : Inhabited (Basis ι R (ι →₀ R)) :=
⟨.ofRepr (LinearEquiv.refl _ _)⟩
variable (b b₁ : Basis ι R M) (i : ι) (c : R) (x : M)
section repr
theorem repr_injective : Injective (repr : Basis ι R M → M ≃ₗ[R] ι →₀ R) := fun f g h => by
cases f; cases g; congr
#align basis.repr_injective Basis.repr_injective
instance instFunLike : FunLike (Basis ι R M) ι M where
coe b i := b.repr.symm (Finsupp.single i 1)
coe_injective' f g h := repr_injective <| LinearEquiv.symm_bijective.injective <|
LinearEquiv.toLinearMap_injective <| by ext; exact congr_fun h _
#align basis.fun_like Basis.instFunLike
@[simp]
theorem coe_ofRepr (e : M ≃ₗ[R] ι →₀ R) : ⇑(ofRepr e) = fun i => e.symm (Finsupp.single i 1) :=
rfl
#align basis.coe_of_repr Basis.coe_ofRepr
protected theorem injective [Nontrivial R] : Injective b :=
b.repr.symm.injective.comp fun _ _ => (Finsupp.single_left_inj (one_ne_zero : (1 : R) ≠ 0)).mp
#align basis.injective Basis.injective
theorem repr_symm_single_one : b.repr.symm (Finsupp.single i 1) = b i :=
rfl
#align basis.repr_symm_single_one Basis.repr_symm_single_one
theorem repr_symm_single : b.repr.symm (Finsupp.single i c) = c • b i :=
calc
b.repr.symm (Finsupp.single i c) = b.repr.symm (c • Finsupp.single i (1 : R)) := by
{ rw [Finsupp.smul_single', mul_one] }
_ = c • b i := by rw [LinearEquiv.map_smul, repr_symm_single_one]
#align basis.repr_symm_single Basis.repr_symm_single
@[simp]
theorem repr_self : b.repr (b i) = Finsupp.single i 1 :=
LinearEquiv.apply_symm_apply _ _
#align basis.repr_self Basis.repr_self
theorem repr_self_apply (j) [Decidable (i = j)] : b.repr (b i) j = if i = j then 1 else 0 := by
rw [repr_self, Finsupp.single_apply]
#align basis.repr_self_apply Basis.repr_self_apply
@[simp]
theorem repr_symm_apply (v) : b.repr.symm v = Finsupp.total ι M R b v :=
calc
b.repr.symm v = b.repr.symm (v.sum Finsupp.single) := by simp
_ = v.sum fun i vi => b.repr.symm (Finsupp.single i vi) := map_finsupp_sum ..
_ = Finsupp.total ι M R b v := by simp only [repr_symm_single, Finsupp.total_apply]
#align basis.repr_symm_apply Basis.repr_symm_apply
@[simp]
theorem coe_repr_symm : ↑b.repr.symm = Finsupp.total ι M R b :=
LinearMap.ext fun v => b.repr_symm_apply v
#align basis.coe_repr_symm Basis.coe_repr_symm
@[simp]
theorem repr_total (v) : b.repr (Finsupp.total _ _ _ b v) = v := by
rw [← b.coe_repr_symm]
exact b.repr.apply_symm_apply v
#align basis.repr_total Basis.repr_total
@[simp]
theorem total_repr : Finsupp.total _ _ _ b (b.repr x) = x := by
rw [← b.coe_repr_symm]
exact b.repr.symm_apply_apply x
#align basis.total_repr Basis.total_repr
| Mathlib/LinearAlgebra/Basis.lean | 178 | 179 | theorem repr_range : LinearMap.range (b.repr : M →ₗ[R] ι →₀ R) = Finsupp.supported R R univ := by |
rw [LinearEquiv.range, Finsupp.supported_univ]
| 1 | 2.718282 | 0 | 0.9 | 10 | 779 |
import Mathlib.Computability.Halting
import Mathlib.Computability.TuringMachine
import Mathlib.Data.Num.Lemmas
import Mathlib.Tactic.DeriveFintype
#align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"6155d4351090a6fad236e3d2e4e0e4e7342668e8"
open Function (update)
open Relation
namespace Turing
namespace ToPartrec
inductive Code
| zero'
| succ
| tail
| cons : Code → Code → Code
| comp : Code → Code → Code
| case : Code → Code → Code
| fix : Code → Code
deriving DecidableEq, Inhabited
#align turing.to_partrec.code Turing.ToPartrec.Code
#align turing.to_partrec.code.zero' Turing.ToPartrec.Code.zero'
#align turing.to_partrec.code.succ Turing.ToPartrec.Code.succ
#align turing.to_partrec.code.tail Turing.ToPartrec.Code.tail
#align turing.to_partrec.code.cons Turing.ToPartrec.Code.cons
#align turing.to_partrec.code.comp Turing.ToPartrec.Code.comp
#align turing.to_partrec.code.case Turing.ToPartrec.Code.case
#align turing.to_partrec.code.fix Turing.ToPartrec.Code.fix
def Code.eval : Code → List ℕ →. List ℕ
| Code.zero' => fun v => pure (0 :: v)
| Code.succ => fun v => pure [v.headI.succ]
| Code.tail => fun v => pure v.tail
| Code.cons f fs => fun v => do
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns)
| Code.comp f g => fun v => g.eval v >>= f.eval
| Code.case f g => fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail)
| Code.fix f =>
PFun.fix fun v => (f.eval v).map fun v => if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail
#align turing.to_partrec.code.eval Turing.ToPartrec.Code.eval
namespace Code
@[simp]
theorem zero'_eval : zero'.eval = fun v => pure (0 :: v) := by simp [eval]
@[simp]
theorem succ_eval : succ.eval = fun v => pure [v.headI.succ] := by simp [eval]
@[simp]
theorem tail_eval : tail.eval = fun v => pure v.tail := by simp [eval]
@[simp]
theorem cons_eval (f fs) : (cons f fs).eval = fun v => do {
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns) } := by simp [eval]
@[simp]
theorem comp_eval (f g) : (comp f g).eval = fun v => g.eval v >>= f.eval := by simp [eval]
@[simp]
theorem case_eval (f g) :
(case f g).eval = fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail) := by
simp [eval]
@[simp]
theorem fix_eval (f) : (fix f).eval =
PFun.fix fun v => (f.eval v).map fun v =>
if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail := by
simp [eval]
def nil : Code :=
tail.comp succ
#align turing.to_partrec.code.nil Turing.ToPartrec.Code.nil
@[simp]
| Mathlib/Computability/TMToPartrec.lean | 174 | 174 | theorem nil_eval (v) : nil.eval v = pure [] := by | simp [nil]
| 1 | 2.718282 | 0 | 0.285714 | 14 | 314 |
import Mathlib.FieldTheory.RatFunc.Defs
import Mathlib.RingTheory.EuclideanDomain
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Polynomial.Content
#align_import field_theory.ratfunc from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6"
universe u v
noncomputable section
open scoped Classical
open scoped nonZeroDivisors Polynomial
variable {K : Type u}
namespace RatFunc
section Field
variable [CommRing K]
protected irreducible_def zero : RatFunc K :=
⟨0⟩
#align ratfunc.zero RatFunc.zero
instance : Zero (RatFunc K) :=
⟨RatFunc.zero⟩
-- Porting note: added `OfNat.ofNat`. using `simp?` produces `simp only [zero_def]`
-- that does not close the goal
theorem ofFractionRing_zero : (ofFractionRing 0 : RatFunc K) = 0 := by
simp only [Zero.zero, OfNat.ofNat, RatFunc.zero]
#align ratfunc.of_fraction_ring_zero RatFunc.ofFractionRing_zero
protected irreducible_def add : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p + q⟩
#align ratfunc.add RatFunc.add
instance : Add (RatFunc K) :=
⟨RatFunc.add⟩
-- Porting note: added `HAdd.hAdd`. using `simp?` produces `simp only [add_def]`
-- that does not close the goal
theorem ofFractionRing_add (p q : FractionRing K[X]) :
ofFractionRing (p + q) = ofFractionRing p + ofFractionRing q := by
simp only [HAdd.hAdd, Add.add, RatFunc.add]
#align ratfunc.of_fraction_ring_add RatFunc.ofFractionRing_add
protected irreducible_def sub : RatFunc K → RatFunc K → RatFunc K
| ⟨p⟩, ⟨q⟩ => ⟨p - q⟩
#align ratfunc.sub RatFunc.sub
instance : Sub (RatFunc K) :=
⟨RatFunc.sub⟩
-- Porting note: added `HSub.hSub`. using `simp?` produces `simp only [sub_def]`
-- that does not close the goal
theorem ofFractionRing_sub (p q : FractionRing K[X]) :
ofFractionRing (p - q) = ofFractionRing p - ofFractionRing q := by
simp only [Sub.sub, HSub.hSub, RatFunc.sub]
#align ratfunc.of_fraction_ring_sub RatFunc.ofFractionRing_sub
protected irreducible_def neg : RatFunc K → RatFunc K
| ⟨p⟩ => ⟨-p⟩
#align ratfunc.neg RatFunc.neg
instance : Neg (RatFunc K) :=
⟨RatFunc.neg⟩
theorem ofFractionRing_neg (p : FractionRing K[X]) :
ofFractionRing (-p) = -ofFractionRing p := by simp only [Neg.neg, RatFunc.neg]
#align ratfunc.of_fraction_ring_neg RatFunc.ofFractionRing_neg
protected irreducible_def one : RatFunc K :=
⟨1⟩
#align ratfunc.one RatFunc.one
instance : One (RatFunc K) :=
⟨RatFunc.one⟩
-- Porting note: added `OfNat.ofNat`. using `simp?` produces `simp only [one_def]`
-- that does not close the goal
| Mathlib/FieldTheory/RatFunc/Basic.lean | 131 | 132 | theorem ofFractionRing_one : (ofFractionRing 1 : RatFunc K) = 1 := by |
simp only [One.one, OfNat.ofNat, RatFunc.one]
| 1 | 2.718282 | 0 | 0.416667 | 12 | 404 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.