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.Analysis.Convex.Topology
import Mathlib.Analysis.NormedSpace.Pointwise
import Mathlib.Analysis.Seminorm
import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Analysis.RCLike.Basic
#align_import analysis.convex.gauge from "leanprover-community/mathlib"@"373b03b5b9d0486534edbe94747f23cb3712f93d"
open NormedField Set
open scoped Pointwise Topology NNReal
noncomputable section
variable {𝕜 E F : Type*}
section AddCommGroup
variable [AddCommGroup E] [Module ℝ E]
def gauge (s : Set E) (x : E) : ℝ :=
sInf { r : ℝ | 0 < r ∧ x ∈ r • s }
#align gauge gauge
variable {s t : Set E} {x : E} {a : ℝ}
theorem gauge_def : gauge s x = sInf ({ r ∈ Set.Ioi (0 : ℝ) | x ∈ r • s }) :=
rfl
#align gauge_def gauge_def
theorem gauge_def' : gauge s x = sInf {r ∈ Set.Ioi (0 : ℝ) | r⁻¹ • x ∈ s} := by
congrm sInf {r | ?_}
exact and_congr_right fun hr => mem_smul_set_iff_inv_smul_mem₀ hr.ne' _ _
#align gauge_def' gauge_def'
private theorem gauge_set_bddBelow : BddBelow { r : ℝ | 0 < r ∧ x ∈ r • s } :=
⟨0, fun _ hr => hr.1.le⟩
theorem Absorbent.gauge_set_nonempty (absorbs : Absorbent ℝ s) :
{ r : ℝ | 0 < r ∧ x ∈ r • s }.Nonempty :=
let ⟨r, hr₁, hr₂⟩ := (absorbs x).exists_pos
⟨r, hr₁, hr₂ r (Real.norm_of_nonneg hr₁.le).ge rfl⟩
#align absorbent.gauge_set_nonempty Absorbent.gauge_set_nonempty
theorem gauge_mono (hs : Absorbent ℝ s) (h : s ⊆ t) : gauge t ≤ gauge s := fun _ =>
csInf_le_csInf gauge_set_bddBelow hs.gauge_set_nonempty fun _ hr => ⟨hr.1, smul_set_mono h hr.2⟩
#align gauge_mono gauge_mono
theorem exists_lt_of_gauge_lt (absorbs : Absorbent ℝ s) (h : gauge s x < a) :
∃ b, 0 < b ∧ b < a ∧ x ∈ b • s := by
obtain ⟨b, ⟨hb, hx⟩, hba⟩ := exists_lt_of_csInf_lt absorbs.gauge_set_nonempty h
exact ⟨b, hb, hba, hx⟩
#align exists_lt_of_gauge_lt exists_lt_of_gauge_lt
@[simp]
theorem gauge_zero : gauge s 0 = 0 := by
rw [gauge_def']
by_cases h : (0 : E) ∈ s
· simp only [smul_zero, sep_true, h, csInf_Ioi]
· simp only [smul_zero, sep_false, h, Real.sInf_empty]
#align gauge_zero gauge_zero
@[simp]
theorem gauge_zero' : gauge (0 : Set E) = 0 := by
ext x
rw [gauge_def']
obtain rfl | hx := eq_or_ne x 0
· simp only [csInf_Ioi, mem_zero, Pi.zero_apply, eq_self_iff_true, sep_true, smul_zero]
· simp only [mem_zero, Pi.zero_apply, inv_eq_zero, smul_eq_zero]
convert Real.sInf_empty
exact eq_empty_iff_forall_not_mem.2 fun r hr => hr.2.elim (ne_of_gt hr.1) hx
#align gauge_zero' gauge_zero'
@[simp]
theorem gauge_empty : gauge (∅ : Set E) = 0 := by
ext
simp only [gauge_def', Real.sInf_empty, mem_empty_iff_false, Pi.zero_apply, sep_false]
#align gauge_empty gauge_empty
theorem gauge_of_subset_zero (h : s ⊆ 0) : gauge s = 0 := by
obtain rfl | rfl := subset_singleton_iff_eq.1 h
exacts [gauge_empty, gauge_zero']
#align gauge_of_subset_zero gauge_of_subset_zero
theorem gauge_nonneg (x : E) : 0 ≤ gauge s x :=
Real.sInf_nonneg _ fun _ hx => hx.1.le
#align gauge_nonneg gauge_nonneg
| Mathlib/Analysis/Convex/Gauge.lean | 129 | 131 | theorem gauge_neg (symmetric : ∀ x ∈ s, -x ∈ s) (x : E) : gauge s (-x) = gauge s x := by |
have : ∀ x, -x ∈ s ↔ x ∈ s := fun x => ⟨fun h => by simpa using symmetric _ h, symmetric x⟩
simp_rw [gauge_def', smul_neg, this]
| 2 | 7.389056 | 1 | 1.090909 | 11 | 1,185 |
import Mathlib.Analysis.NormedSpace.PiLp
import Mathlib.Analysis.InnerProductSpace.PiL2
#align_import analysis.matrix from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open scoped NNReal Matrix
namespace Matrix
variable {R l m n α β : Type*} [Fintype l] [Fintype m] [Fintype n]
section LinfLinf
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β]
protected def seminormedAddCommGroup : SeminormedAddCommGroup (Matrix m n α) :=
Pi.seminormedAddCommGroup
#align matrix.seminormed_add_comm_group Matrix.seminormedAddCommGroup
attribute [local instance] Matrix.seminormedAddCommGroup
-- Porting note (#10756): new theorem (along with all the uses of this lemma below)
theorem norm_def (A : Matrix m n α) : ‖A‖ = ‖fun i j => A i j‖ := rfl
lemma norm_eq_sup_sup_nnnorm (A : Matrix m n α) :
‖A‖ = Finset.sup Finset.univ fun i ↦ Finset.sup Finset.univ fun j ↦ ‖A i j‖₊ := by
simp_rw [Matrix.norm_def, Pi.norm_def, Pi.nnnorm_def]
-- Porting note (#10756): new theorem (along with all the uses of this lemma below)
theorem nnnorm_def (A : Matrix m n α) : ‖A‖₊ = ‖fun i j => A i j‖₊ := rfl
theorem norm_le_iff {r : ℝ} (hr : 0 ≤ r) {A : Matrix m n α} : ‖A‖ ≤ r ↔ ∀ i j, ‖A i j‖ ≤ r := by
simp_rw [norm_def, pi_norm_le_iff_of_nonneg hr]
#align matrix.norm_le_iff Matrix.norm_le_iff
theorem nnnorm_le_iff {r : ℝ≥0} {A : Matrix m n α} : ‖A‖₊ ≤ r ↔ ∀ i j, ‖A i j‖₊ ≤ r := by
simp_rw [nnnorm_def, pi_nnnorm_le_iff]
#align matrix.nnnorm_le_iff Matrix.nnnorm_le_iff
theorem norm_lt_iff {r : ℝ} (hr : 0 < r) {A : Matrix m n α} : ‖A‖ < r ↔ ∀ i j, ‖A i j‖ < r := by
simp_rw [norm_def, pi_norm_lt_iff hr]
#align matrix.norm_lt_iff Matrix.norm_lt_iff
theorem nnnorm_lt_iff {r : ℝ≥0} (hr : 0 < r) {A : Matrix m n α} :
‖A‖₊ < r ↔ ∀ i j, ‖A i j‖₊ < r := by
simp_rw [nnnorm_def, pi_nnnorm_lt_iff hr]
#align matrix.nnnorm_lt_iff Matrix.nnnorm_lt_iff
theorem norm_entry_le_entrywise_sup_norm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖ ≤ ‖A‖ :=
(norm_le_pi_norm (A i) j).trans (norm_le_pi_norm A i)
#align matrix.norm_entry_le_entrywise_sup_norm Matrix.norm_entry_le_entrywise_sup_norm
theorem nnnorm_entry_le_entrywise_sup_nnnorm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖₊ ≤ ‖A‖₊ :=
(nnnorm_le_pi_nnnorm (A i) j).trans (nnnorm_le_pi_nnnorm A i)
#align matrix.nnnorm_entry_le_entrywise_sup_nnnorm Matrix.nnnorm_entry_le_entrywise_sup_nnnorm
@[simp]
theorem nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) :
‖A.map f‖₊ = ‖A‖₊ := by
simp only [nnnorm_def, Pi.nnnorm_def, Matrix.map_apply, hf]
#align matrix.nnnorm_map_eq Matrix.nnnorm_map_eq
@[simp]
theorem norm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖ = ‖a‖) : ‖A.map f‖ = ‖A‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_map_eq A f fun a => Subtype.ext <| hf a : _)
#align matrix.norm_map_eq Matrix.norm_map_eq
@[simp]
theorem nnnorm_transpose (A : Matrix m n α) : ‖Aᵀ‖₊ = ‖A‖₊ :=
Finset.sup_comm _ _ _
#align matrix.nnnorm_transpose Matrix.nnnorm_transpose
@[simp]
theorem norm_transpose (A : Matrix m n α) : ‖Aᵀ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_transpose A
#align matrix.norm_transpose Matrix.norm_transpose
@[simp]
theorem nnnorm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖₊ = ‖A‖₊ :=
(nnnorm_map_eq _ _ nnnorm_star).trans A.nnnorm_transpose
#align matrix.nnnorm_conj_transpose Matrix.nnnorm_conjTranspose
@[simp]
theorem norm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) : ‖Aᴴ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_conjTranspose A
#align matrix.norm_conj_transpose Matrix.norm_conjTranspose
instance [StarAddMonoid α] [NormedStarGroup α] : NormedStarGroup (Matrix m m α) :=
⟨norm_conjTranspose⟩
@[simp]
theorem nnnorm_col (v : m → α) : ‖col v‖₊ = ‖v‖₊ := by
simp [nnnorm_def, Pi.nnnorm_def]
#align matrix.nnnorm_col Matrix.nnnorm_col
@[simp]
theorem norm_col (v : m → α) : ‖col v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_col v
#align matrix.norm_col Matrix.norm_col
@[simp]
| Mathlib/Analysis/Matrix.lean | 161 | 162 | theorem nnnorm_row (v : n → α) : ‖row v‖₊ = ‖v‖₊ := by |
simp [nnnorm_def, Pi.nnnorm_def]
| 1 | 2.718282 | 0 | 0.533333 | 15 | 509 |
import Mathlib.Data.Fin.Fin2
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.Common
#align_import data.typevec from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
universe u v w
@[pp_with_univ]
def TypeVec (n : ℕ) :=
Fin2 n → Type*
#align typevec TypeVec
instance {n} : Inhabited (TypeVec.{u} n) :=
⟨fun _ => PUnit⟩
namespace TypeVec
variable {n : ℕ}
def Arrow (α β : TypeVec n) :=
∀ i : Fin2 n, α i → β i
#align typevec.arrow TypeVec.Arrow
@[inherit_doc] scoped[MvFunctor] infixl:40 " ⟹ " => TypeVec.Arrow
open MvFunctor
@[ext]
| Mathlib/Data/TypeVec.lean | 60 | 62 | theorem Arrow.ext {α β : TypeVec n} (f g : α ⟹ β) :
(∀ i, f i = g i) → f = g := by |
intro h; funext i; apply h
| 1 | 2.718282 | 0 | 1 | 2 | 1,009 |
import Batteries.Tactic.Init
import Batteries.Tactic.Alias
import Batteries.Tactic.Lint.Misc
instance {f : α → β} [DecidablePred p] : DecidablePred (p ∘ f) :=
inferInstanceAs <| DecidablePred fun x => p (f x)
@[deprecated] alias proofIrrel := proof_irrel
theorem Function.id_def : @id α = fun x => x := rfl
alias ⟨forall_not_of_not_exists, not_exists_of_forall_not⟩ := not_exists
protected alias ⟨Decidable.exists_not_of_not_forall, _⟩ := Decidable.not_forall
theorem heq_iff_eq : HEq a b ↔ a = b := ⟨eq_of_heq, heq_of_eq⟩
@[simp] theorem eq_rec_constant {α : Sort _} {a a' : α} {β : Sort _} (y : β) (h : a = a') :
(@Eq.rec α a (fun α _ => β) y a' h) = y := by cases h; rfl
theorem congrArg₂ (f : α → β → γ) {x x' : α} {y y' : β}
(hx : x = x') (hy : y = y') : f x y = f x' y' := by subst hx hy; rfl
theorem congrFun₂ {β : α → Sort _} {γ : ∀ a, β a → Sort _}
{f g : ∀ a b, γ a b} (h : f = g) (a : α) (b : β a) :
f a b = g a b :=
congrFun (congrFun h _) _
theorem congrFun₃ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _}
{f g : ∀ a b c, δ a b c} (h : f = g) (a : α) (b : β a) (c : γ a b) :
f a b c = g a b c :=
congrFun₂ (congrFun h _) _ _
theorem funext₂ {β : α → Sort _} {γ : ∀ a, β a → Sort _}
{f g : ∀ a b, γ a b} (h : ∀ a b, f a b = g a b) : f = g :=
funext fun _ => funext <| h _
theorem funext₃ {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _}
{f g : ∀ a b c, δ a b c} (h : ∀ a b c, f a b c = g a b c) : f = g :=
funext fun _ => funext₂ <| h _
theorem Function.funext_iff {β : α → Sort u} {f₁ f₂ : ∀ x : α, β x} : f₁ = f₂ ↔ ∀ a, f₁ a = f₂ a :=
⟨congrFun, funext⟩
theorem ne_of_apply_ne {α β : Sort _} (f : α → β) {x y : α} : f x ≠ f y → x ≠ y :=
mt <| congrArg _
protected theorem Eq.congr (h₁ : x₁ = y₁) (h₂ : x₂ = y₂) : x₁ = x₂ ↔ y₁ = y₂ := by
subst h₁; subst h₂; rfl
theorem Eq.congr_left {x y z : α} (h : x = y) : x = z ↔ y = z := by rw [h]
theorem Eq.congr_right {x y z : α} (h : x = y) : z = x ↔ z = y := by rw [h]
alias congr_arg := congrArg
alias congr_arg₂ := congrArg₂
alias congr_fun := congrFun
alias congr_fun₂ := congrFun₂
alias congr_fun₃ := congrFun₃
theorem heq_of_cast_eq : ∀ (e : α = β) (_ : cast e a = a'), HEq a a'
| rfl, rfl => .rfl
theorem cast_eq_iff_heq : cast e a = a' ↔ HEq a a' :=
⟨heq_of_cast_eq _, fun h => by cases h; rfl⟩
| .lake/packages/batteries/Batteries/Logic.lean | 88 | 91 | theorem eqRec_eq_cast {α : Sort _} {a : α} {motive : (a' : α) → a = a' → Sort _}
(x : motive a (rfl : a = a)) {a' : α} (e : a = a') :
@Eq.rec α a motive x a' e = cast (e ▸ rfl) x := by |
subst e; rfl
| 1 | 2.718282 | 0 | 0 | 8 | 67 |
import Mathlib.Logic.Equiv.Defs
import Mathlib.Tactic.MkIffOfInductiveProp
import Mathlib.Tactic.PPWithUniv
#align_import logic.small.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105"
universe u w v v'
@[mk_iff, pp_with_univ]
class Small (α : Type v) : Prop where
equiv_small : ∃ S : Type w, Nonempty (α ≃ S)
#align small Small
theorem Small.mk' {α : Type v} {S : Type w} (e : α ≃ S) : Small.{w} α :=
⟨⟨S, ⟨e⟩⟩⟩
#align small.mk' Small.mk'
@[pp_with_univ]
def Shrink (α : Type v) [Small.{w} α] : Type w :=
Classical.choose (@Small.equiv_small α _)
#align shrink Shrink
noncomputable def equivShrink (α : Type v) [Small.{w} α] : α ≃ Shrink α :=
Nonempty.some (Classical.choose_spec (@Small.equiv_small α _))
#align equiv_shrink equivShrink
@[ext]
| Mathlib/Logic/Small/Defs.lean | 56 | 58 | theorem Shrink.ext {α : Type v} [Small.{w} α] {x y : Shrink α}
(w : (equivShrink _).symm x = (equivShrink _).symm y) : x = y := by |
simpa using w
| 1 | 2.718282 | 0 | 0 | 1 | 212 |
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
section
variable {ι : Type*} [Fintype ι]
theorem isBoundedLinearMap_prod_multilinear {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] :
IsBoundedLinearMap 𝕜 fun p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G =>
p.1.prod p.2 where
map_add p₁ p₂ := by ext : 1; rfl
map_smul c p := by ext : 1; rfl
bound := by
refine ⟨1, zero_lt_one, fun p ↦ ?_⟩
rw [one_mul]
apply ContinuousMultilinearMap.opNorm_le_bound _ (norm_nonneg _) _
intro m
rw [ContinuousMultilinearMap.prod_apply, norm_prod_le_iff]
constructor
· exact (p.1.le_opNorm m).trans (mul_le_mul_of_nonneg_right (norm_fst_le p) <| by positivity)
· exact (p.2.le_opNorm m).trans (mul_le_mul_of_nonneg_right (norm_snd_le p) <| by positivity)
#align is_bounded_linear_map_prod_multilinear isBoundedLinearMap_prod_multilinear
theorem isBoundedLinearMap_continuousMultilinearMap_comp_linear (g : G →L[𝕜] E) :
IsBoundedLinearMap 𝕜 fun f : ContinuousMultilinearMap 𝕜 (fun _ : ι => E) F =>
f.compContinuousLinearMap fun _ => g := by
refine
IsLinearMap.with_bound
⟨fun f₁ f₂ => by ext; rfl,
fun c f => by ext; rfl⟩
(‖g‖ ^ Fintype.card ι) fun f => ?_
apply ContinuousMultilinearMap.opNorm_le_bound _ _ _
· apply_rules [mul_nonneg, pow_nonneg, norm_nonneg]
intro m
calc
‖f (g ∘ m)‖ ≤ ‖f‖ * ∏ i, ‖g (m i)‖ := f.le_opNorm _
_ ≤ ‖f‖ * ∏ i, ‖g‖ * ‖m i‖ := by
apply mul_le_mul_of_nonneg_left _ (norm_nonneg _)
exact Finset.prod_le_prod (fun i _ => norm_nonneg _) fun i _ => g.le_opNorm _
_ = ‖g‖ ^ Fintype.card ι * ‖f‖ * ∏ i, ‖m i‖ := by
simp only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ]
ring
#align is_bounded_linear_map_continuous_multilinear_map_comp_linear isBoundedLinearMap_continuousMultilinearMap_comp_linear
end
section BilinearMap
namespace ContinuousLinearMap
variable {R : Type*}
variable {𝕜₂ 𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NontriviallyNormedField 𝕜₂]
variable {M : Type*} [TopologicalSpace M]
variable {σ₁₂ : 𝕜 →+* 𝕜₂}
variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜₂ G'] [NormedSpace 𝕜' G']
variable [SMulCommClass 𝕜₂ 𝕜' G']
section Ring
variable [Ring R] [AddCommGroup M] [Module R M] {ρ₁₂ : R →+* 𝕜'}
theorem map_sub₂ (f : M →SL[ρ₁₂] F →SL[σ₁₂] G') (x x' : M) (y : F) :
f (x - x') y = f x y - f x' y := by rw [f.map_sub, sub_apply]
#align continuous_linear_map.map_sub₂ ContinuousLinearMap.map_sub₂
| Mathlib/Analysis/NormedSpace/BoundedLinearMaps.lean | 307 | 308 | theorem map_neg₂ (f : M →SL[ρ₁₂] F →SL[σ₁₂] G') (x : M) (y : F) : f (-x) y = -f x y := by |
rw [f.map_neg, neg_apply]
| 1 | 2.718282 | 0 | 0.538462 | 13 | 510 |
import Mathlib.CategoryTheory.Abelian.Basic
import Mathlib.CategoryTheory.Preadditive.Opposite
import Mathlib.CategoryTheory.Limits.Opposites
#align_import category_theory.abelian.opposite from "leanprover-community/mathlib"@"a5ff45a1c92c278b03b52459a620cfd9c49ebc80"
noncomputable section
namespace CategoryTheory
open CategoryTheory.Limits
variable (C : Type*) [Category C] [Abelian C]
-- Porting note: these local instances do not seem to be necessary
--attribute [local instance]
-- hasFiniteLimits_of_hasEqualizers_and_finite_products
-- hasFiniteColimits_of_hasCoequalizers_and_finite_coproducts
-- Abelian.hasFiniteBiproducts
instance : Abelian Cᵒᵖ := by
-- Porting note: priorities of `Abelian.has_kernels` and `Abelian.has_cokernels` have
-- been set to 90 in `Abelian.Basic` in order to prevent a timeout here
exact {
normalMonoOfMono := fun f => normalMonoOfNormalEpiUnop _ (normalEpiOfEpi f.unop)
normalEpiOfEpi := fun f => normalEpiOfNormalMonoUnop _ (normalMonoOfMono f.unop) }
section
variable {C}
variable {X Y : C} (f : X ⟶ Y) {A B : Cᵒᵖ} (g : A ⟶ B)
-- TODO: Generalize (this will work whenever f has a cokernel)
-- (The abelian case is probably sufficient for most applications.)
@[simps]
def kernelOpUnop : (kernel f.op).unop ≅ cokernel f where
hom := (kernel.lift f.op (cokernel.π f).op <| by simp [← op_comp]).unop
inv :=
cokernel.desc f (kernel.ι f.op).unop <| by
rw [← f.unop_op, ← unop_comp, f.unop_op]
simp
hom_inv_id := by
rw [← unop_id, ← (cokernel.desc f _ _).unop_op, ← unop_comp]
congr 1
ext
simp [← op_comp]
inv_hom_id := by
ext
simp [← unop_comp]
#align category_theory.kernel_op_unop CategoryTheory.kernelOpUnop
-- TODO: Generalize (this will work whenever f has a kernel)
-- (The abelian case is probably sufficient for most applications.)
@[simps]
def cokernelOpUnop : (cokernel f.op).unop ≅ kernel f where
hom :=
kernel.lift f (cokernel.π f.op).unop <| by
rw [← f.unop_op, ← unop_comp, f.unop_op]
simp
inv := (cokernel.desc f.op (kernel.ι f).op <| by simp [← op_comp]).unop
hom_inv_id := by
rw [← unop_id, ← (kernel.lift f _ _).unop_op, ← unop_comp]
congr 1
ext
simp [← op_comp]
inv_hom_id := by
ext
simp [← unop_comp]
#align category_theory.cokernel_op_unop CategoryTheory.cokernelOpUnop
@[simps!]
def kernelUnopOp : Opposite.op (kernel g.unop) ≅ cokernel g :=
(cokernelOpUnop g.unop).op
#align category_theory.kernel_unop_op CategoryTheory.kernelUnopOp
@[simps!]
def cokernelUnopOp : Opposite.op (cokernel g.unop) ≅ kernel g :=
(kernelOpUnop g.unop).op
#align category_theory.cokernel_unop_op CategoryTheory.cokernelUnopOp
theorem cokernel.π_op :
(cokernel.π f.op).unop =
(cokernelOpUnop f).hom ≫ kernel.ι f ≫ eqToHom (Opposite.unop_op _).symm := by
simp [cokernelOpUnop]
#align category_theory.cokernel.π_op CategoryTheory.cokernel.π_op
theorem kernel.ι_op :
(kernel.ι f.op).unop = eqToHom (Opposite.unop_op _) ≫ cokernel.π f ≫ (kernelOpUnop f).inv := by
simp [kernelOpUnop]
#align category_theory.kernel.ι_op CategoryTheory.kernel.ι_op
@[simps!]
def kernelOpOp : kernel f.op ≅ Opposite.op (cokernel f) :=
(kernelOpUnop f).op.symm
#align category_theory.kernel_op_op CategoryTheory.kernelOpOp
@[simps!]
def cokernelOpOp : cokernel f.op ≅ Opposite.op (kernel f) :=
(cokernelOpUnop f).op.symm
#align category_theory.cokernel_op_op CategoryTheory.cokernelOpOp
@[simps!]
def kernelUnopUnop : kernel g.unop ≅ (cokernel g).unop :=
(kernelUnopOp g).unop.symm
#align category_theory.kernel_unop_unop CategoryTheory.kernelUnopUnop
| Mathlib/CategoryTheory/Abelian/Opposite.lean | 124 | 126 | theorem kernel.ι_unop :
(kernel.ι g.unop).op = eqToHom (Opposite.op_unop _) ≫ cokernel.π g ≫ (kernelUnopOp g).inv := by |
simp
| 1 | 2.718282 | 0 | 0 | 4 | 133 |
import Mathlib.RingTheory.Polynomial.Basic
import Mathlib.RingTheory.Ideal.LocalRing
#align_import data.polynomial.expand from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
universe u v w
open Polynomial
open Finset
namespace Polynomial
section CommSemiring
variable (R : Type u) [CommSemiring R] {S : Type v} [CommSemiring S] (p q : ℕ)
noncomputable def expand : R[X] →ₐ[R] R[X] :=
{ (eval₂RingHom C (X ^ p) : R[X] →+* R[X]) with commutes' := fun _ => eval₂_C _ _ }
#align polynomial.expand Polynomial.expand
theorem coe_expand : (expand R p : R[X] → R[X]) = eval₂ C (X ^ p) :=
rfl
#align polynomial.coe_expand Polynomial.coe_expand
variable {R}
theorem expand_eq_comp_X_pow {f : R[X]} : expand R p f = f.comp (X ^ p) := rfl
theorem expand_eq_sum {f : R[X]} : expand R p f = f.sum fun e a => C a * (X ^ p) ^ e := by
simp [expand, eval₂]
#align polynomial.expand_eq_sum Polynomial.expand_eq_sum
@[simp]
theorem expand_C (r : R) : expand R p (C r) = C r :=
eval₂_C _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_C Polynomial.expand_C
@[simp]
theorem expand_X : expand R p X = X ^ p :=
eval₂_X _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_X Polynomial.expand_X
@[simp]
theorem expand_monomial (r : R) : expand R p (monomial q r) = monomial (q * p) r := by
simp_rw [← smul_X_eq_monomial, AlgHom.map_smul, AlgHom.map_pow, expand_X, mul_comm, pow_mul]
#align polynomial.expand_monomial Polynomial.expand_monomial
theorem expand_expand (f : R[X]) : expand R p (expand R q f) = expand R (p * q) f :=
Polynomial.induction_on f (fun r => by simp_rw [expand_C])
(fun f g ihf ihg => by simp_rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
simp_rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, AlgHom.map_pow, expand_X, pow_mul]
#align polynomial.expand_expand Polynomial.expand_expand
theorem expand_mul (f : R[X]) : expand R (p * q) f = expand R p (expand R q f) :=
(expand_expand p q f).symm
#align polynomial.expand_mul Polynomial.expand_mul
@[simp]
theorem expand_zero (f : R[X]) : expand R 0 f = C (eval 1 f) := by simp [expand]
#align polynomial.expand_zero Polynomial.expand_zero
@[simp]
theorem expand_one (f : R[X]) : expand R 1 f = f :=
Polynomial.induction_on f (fun r => by rw [expand_C])
(fun f g ihf ihg => by rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, pow_one]
#align polynomial.expand_one Polynomial.expand_one
theorem expand_pow (f : R[X]) : expand R (p ^ q) f = (expand R p)^[q] f :=
Nat.recOn q (by rw [pow_zero, expand_one, Function.iterate_zero, id]) fun n ih => by
rw [Function.iterate_succ_apply', pow_succ', expand_mul, ih]
#align polynomial.expand_pow Polynomial.expand_pow
theorem derivative_expand (f : R[X]) : Polynomial.derivative (expand R p f) =
expand R p (Polynomial.derivative f) * (p * (X ^ (p - 1) : R[X])) := by
rw [coe_expand, derivative_eval₂_C, derivative_pow, C_eq_natCast, derivative_X, mul_one]
#align polynomial.derivative_expand Polynomial.derivative_expand
theorem coeff_expand {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff n = if p ∣ n then f.coeff (n / p) else 0 := by
simp only [expand_eq_sum]
simp_rw [coeff_sum, ← pow_mul, C_mul_X_pow_eq_monomial, coeff_monomial, sum]
split_ifs with h
· rw [Finset.sum_eq_single (n / p), Nat.mul_div_cancel' h, if_pos rfl]
· intro b _ hb2
rw [if_neg]
intro hb3
apply hb2
rw [← hb3, Nat.mul_div_cancel_left b hp]
· intro hn
rw [not_mem_support_iff.1 hn]
split_ifs <;> rfl
· rw [Finset.sum_eq_zero]
intro k _
rw [if_neg]
exact fun hkn => h ⟨k, hkn.symm⟩
#align polynomial.coeff_expand Polynomial.coeff_expand
@[simp]
theorem coeff_expand_mul {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff (n * p) = f.coeff n := by
rw [coeff_expand hp, if_pos (dvd_mul_left _ _), Nat.mul_div_cancel _ hp]
#align polynomial.coeff_expand_mul Polynomial.coeff_expand_mul
@[simp]
| Mathlib/Algebra/Polynomial/Expand.lean | 127 | 128 | theorem coeff_expand_mul' {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff (p * n) = f.coeff n := by | rw [mul_comm, coeff_expand_mul hp]
| 1 | 2.718282 | 0 | 0.285714 | 7 | 311 |
import Mathlib.Algebra.Algebra.Defs
import Mathlib.Algebra.Polynomial.FieldDivision
import Mathlib.FieldTheory.Minpoly.Basic
import Mathlib.RingTheory.Adjoin.Basic
import Mathlib.RingTheory.FinitePresentation
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.PowerBasis
import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.RingTheory.QuotientNoetherian
#align_import ring_theory.adjoin_root from "leanprover-community/mathlib"@"5c4b3d41a84bd2a1d79c7d9265e58a891e71be89"
noncomputable section
open scoped Classical
open Polynomial
universe u v w
variable {R : Type u} {S : Type v} {K : Type w}
open Polynomial Ideal
def AdjoinRoot [CommRing R] (f : R[X]) : Type u :=
Polynomial R ⧸ (span {f} : Ideal R[X])
#align adjoin_root AdjoinRoot
namespace AdjoinRoot
section CommRing
variable [CommRing R] (f : R[X])
instance instCommRing : CommRing (AdjoinRoot f) :=
Ideal.Quotient.commRing _
#align adjoin_root.comm_ring AdjoinRoot.instCommRing
instance : Inhabited (AdjoinRoot f) :=
⟨0⟩
instance : DecidableEq (AdjoinRoot f) :=
Classical.decEq _
protected theorem nontrivial [IsDomain R] (h : degree f ≠ 0) : Nontrivial (AdjoinRoot f) :=
Ideal.Quotient.nontrivial
(by
simp_rw [Ne, span_singleton_eq_top, Polynomial.isUnit_iff, not_exists, not_and]
rintro x hx rfl
exact h (degree_C hx.ne_zero))
#align adjoin_root.nontrivial AdjoinRoot.nontrivial
def mk : R[X] →+* AdjoinRoot f :=
Ideal.Quotient.mk _
#align adjoin_root.mk AdjoinRoot.mk
@[elab_as_elim]
theorem induction_on {C : AdjoinRoot f → Prop} (x : AdjoinRoot f) (ih : ∀ p : R[X], C (mk f p)) :
C x :=
Quotient.inductionOn' x ih
#align adjoin_root.induction_on AdjoinRoot.induction_on
def of : R →+* AdjoinRoot f :=
(mk f).comp C
#align adjoin_root.of AdjoinRoot.of
instance instSMulAdjoinRoot [DistribSMul S R] [IsScalarTower S R R] : SMul S (AdjoinRoot f) :=
Submodule.Quotient.instSMul' _
instance [DistribSMul S R] [IsScalarTower S R R] : DistribSMul S (AdjoinRoot f) :=
Submodule.Quotient.distribSMul' _
@[simp]
theorem smul_mk [DistribSMul S R] [IsScalarTower S R R] (a : S) (x : R[X]) :
a • mk f x = mk f (a • x) :=
rfl
#align adjoin_root.smul_mk AdjoinRoot.smul_mk
| Mathlib/RingTheory/AdjoinRoot.lean | 120 | 121 | theorem smul_of [DistribSMul S R] [IsScalarTower S R R] (a : S) (x : R) :
a • of f x = of f (a • x) := by | rw [of, RingHom.comp_apply, RingHom.comp_apply, smul_mk, smul_C]
| 1 | 2.718282 | 0 | 0 | 1 | 143 |
import Mathlib.Tactic.Monotonicity
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Topology.MetricSpace.Lipschitz
#align_import topology.metric_space.algebra from "leanprover-community/mathlib"@"14d34b71b6d896b6e5f1ba2ec9124b9cd1f90fca"
open NNReal
noncomputable section
variable (α β : Type*) [PseudoMetricSpace α] [PseudoMetricSpace β]
section LipschitzMul
class LipschitzAdd [AddMonoid β] : Prop where
lipschitz_add : ∃ C, LipschitzWith C fun p : β × β => p.1 + p.2
#align has_lipschitz_add LipschitzAdd
@[to_additive]
class LipschitzMul [Monoid β] : Prop where
lipschitz_mul : ∃ C, LipschitzWith C fun p : β × β => p.1 * p.2
#align has_lipschitz_mul LipschitzMul
def LipschitzAdd.C [AddMonoid β] [_i : LipschitzAdd β] : ℝ≥0 := Classical.choose _i.lipschitz_add
set_option linter.uppercaseLean3 false in
#align has_lipschitz_add.C LipschitzAdd.C
variable [Monoid β]
@[to_additive existing] -- Porting note: had to add `LipschitzAdd.C`. to_additive silently failed
def LipschitzMul.C [_i : LipschitzMul β] : ℝ≥0 := Classical.choose _i.lipschitz_mul
set_option linter.uppercaseLean3 false in
#align has_lipschitz_mul.C LipschitzMul.C
variable {β}
@[to_additive]
theorem lipschitzWith_lipschitz_const_mul_edist [_i : LipschitzMul β] :
LipschitzWith (LipschitzMul.C β) fun p : β × β => p.1 * p.2 :=
Classical.choose_spec _i.lipschitz_mul
#align lipschitz_with_lipschitz_const_mul_edist lipschitzWith_lipschitz_const_mul_edist
#align lipschitz_with_lipschitz_const_add_edist lipschitzWith_lipschitz_const_add_edist
variable [LipschitzMul β]
@[to_additive]
| Mathlib/Topology/MetricSpace/Algebra.lean | 75 | 78 | theorem lipschitz_with_lipschitz_const_mul :
∀ p q : β × β, dist (p.1 * p.2) (q.1 * q.2) ≤ LipschitzMul.C β * dist p q := by |
rw [← lipschitzWith_iff_dist_le_mul]
exact lipschitzWith_lipschitz_const_mul_edist
| 2 | 7.389056 | 1 | 1 | 1 | 877 |
import Mathlib.Logic.Equiv.Defs
#align_import data.erased from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
universe u
def Erased (α : Sort u) : Sort max 1 u :=
Σ's : α → Prop, ∃ a, (fun b => a = b) = s
#align erased Erased
namespace Erased
@[inline]
def mk {α} (a : α) : Erased α :=
⟨fun b => a = b, a, rfl⟩
#align erased.mk Erased.mk
noncomputable def out {α} : Erased α → α
| ⟨_, h⟩ => Classical.choose h
#align erased.out Erased.out
abbrev OutType (a : Erased (Sort u)) : Sort u :=
out a
#align erased.out_type Erased.OutType
theorem out_proof {p : Prop} (a : Erased p) : p :=
out a
#align erased.out_proof Erased.out_proof
@[simp]
theorem out_mk {α} (a : α) : (mk a).out = a := by
let h := (mk a).2; show Classical.choose h = a
have := Classical.choose_spec h
exact cast (congr_fun this a).symm rfl
#align erased.out_mk Erased.out_mk
@[simp]
theorem mk_out {α} : ∀ a : Erased α, mk (out a) = a
| ⟨s, h⟩ => by simp only [mk]; congr; exact Classical.choose_spec h
#align erased.mk_out Erased.mk_out
@[ext]
theorem out_inj {α} (a b : Erased α) (h : a.out = b.out) : a = b := by simpa using congr_arg mk h
#align erased.out_inj Erased.out_inj
noncomputable def equiv (α) : Erased α ≃ α :=
⟨out, mk, mk_out, out_mk⟩
#align erased.equiv Erased.equiv
instance (α : Type u) : Repr (Erased α) :=
⟨fun _ _ => "Erased"⟩
instance (α : Type u) : ToString (Erased α) :=
⟨fun _ => "Erased"⟩
-- Porting note: Deleted `has_to_format`
def choice {α} (h : Nonempty α) : Erased α :=
mk (Classical.choice h)
#align erased.choice Erased.choice
@[simp]
theorem nonempty_iff {α} : Nonempty (Erased α) ↔ Nonempty α :=
⟨fun ⟨a⟩ => ⟨a.out⟩, fun ⟨a⟩ => ⟨mk a⟩⟩
#align erased.nonempty_iff Erased.nonempty_iff
instance {α} [h : Nonempty α] : Inhabited (Erased α) :=
⟨choice h⟩
def bind {α β} (a : Erased α) (f : α → Erased β) : Erased β :=
⟨fun b => (f a.out).1 b, (f a.out).2⟩
#align erased.bind Erased.bind
@[simp]
theorem bind_eq_out {α β} (a f) : @bind α β a f = f a.out := rfl
#align erased.bind_eq_out Erased.bind_eq_out
def join {α} (a : Erased (Erased α)) : Erased α :=
bind a id
#align erased.join Erased.join
@[simp]
theorem join_eq_out {α} (a) : @join α a = a.out :=
bind_eq_out _ _
#align erased.join_eq_out Erased.join_eq_out
def map {α β} (f : α → β) (a : Erased α) : Erased β :=
bind a (mk ∘ f)
#align erased.map Erased.map
@[simp]
| Mathlib/Data/Erased.lean | 131 | 131 | theorem map_out {α β} {f : α → β} (a : Erased α) : (a.map f).out = f a.out := by | simp [map]
| 1 | 2.718282 | 0 | 0.333333 | 3 | 347 |
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Combinatorics.SimpleGraph.Basic
import Mathlib.Data.Rat.Cast.Order
import Mathlib.Order.Partition.Finpartition
import Mathlib.Tactic.GCongr
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.Ring
#align_import combinatorics.simple_graph.density from "leanprover-community/mathlib"@"a4ec43f53b0bd44c697bcc3f5a62edd56f269ef1"
open Finset
variable {𝕜 ι κ α β : Type*}
namespace Rel
section Asymmetric
variable [LinearOrderedField 𝕜] (r : α → β → Prop) [∀ a, DecidablePred (r a)] {s s₁ s₂ : Finset α}
{t t₁ t₂ : Finset β} {a : α} {b : β} {δ : 𝕜}
def interedges (s : Finset α) (t : Finset β) : Finset (α × β) :=
(s ×ˢ t).filter fun e ↦ r e.1 e.2
#align rel.interedges Rel.interedges
def edgeDensity (s : Finset α) (t : Finset β) : ℚ :=
(interedges r s t).card / (s.card * t.card)
#align rel.edge_density Rel.edgeDensity
variable {r}
theorem mem_interedges_iff {x : α × β} : x ∈ interedges r s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ r x.1 x.2 := by
rw [interedges, mem_filter, Finset.mem_product, and_assoc]
#align rel.mem_interedges_iff Rel.mem_interedges_iff
theorem mk_mem_interedges_iff : (a, b) ∈ interedges r s t ↔ a ∈ s ∧ b ∈ t ∧ r a b :=
mem_interedges_iff
#align rel.mk_mem_interedges_iff Rel.mk_mem_interedges_iff
@[simp]
theorem interedges_empty_left (t : Finset β) : interedges r ∅ t = ∅ := by
rw [interedges, Finset.empty_product, filter_empty]
#align rel.interedges_empty_left Rel.interedges_empty_left
theorem interedges_mono (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) : interedges r s₂ t₂ ⊆ interedges r s₁ t₁ :=
fun x ↦ by
simp_rw [mem_interedges_iff]
exact fun h ↦ ⟨hs h.1, ht h.2.1, h.2.2⟩
#align rel.interedges_mono Rel.interedges_mono
variable (r)
theorem card_interedges_add_card_interedges_compl (s : Finset α) (t : Finset β) :
(interedges r s t).card + (interedges (fun x y ↦ ¬r x y) s t).card = s.card * t.card := by
classical
rw [← card_product, interedges, interedges, ← card_union_of_disjoint, filter_union_filter_neg_eq]
exact disjoint_filter.2 fun _ _ ↦ Classical.not_not.2
#align rel.card_interedges_add_card_interedges_compl Rel.card_interedges_add_card_interedges_compl
theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) :
Disjoint (interedges r s t) (interedges r s' t) := by
rw [Finset.disjoint_left] at hs ⊢
intro _ hx hy
rw [mem_interedges_iff] at hx hy
exact hs hx.1 hy.1
#align rel.interedges_disjoint_left Rel.interedges_disjoint_left
theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') :
Disjoint (interedges r s t) (interedges r s t') := by
rw [Finset.disjoint_left] at ht ⊢
intro _ hx hy
rw [mem_interedges_iff] at hx hy
exact ht hx.2.1 hy.2.1
#align rel.interedges_disjoint_right Rel.interedges_disjoint_right
theorem card_interedges_le_mul (s : Finset α) (t : Finset β) :
(interedges r s t).card ≤ s.card * t.card :=
(card_filter_le _ _).trans (card_product _ _).le
#align rel.card_interedges_le_mul Rel.card_interedges_le_mul
theorem edgeDensity_nonneg (s : Finset α) (t : Finset β) : 0 ≤ edgeDensity r s t := by
apply div_nonneg <;> exact mod_cast Nat.zero_le _
#align rel.edge_density_nonneg Rel.edgeDensity_nonneg
theorem edgeDensity_le_one (s : Finset α) (t : Finset β) : edgeDensity r s t ≤ 1 := by
apply div_le_one_of_le
· exact mod_cast card_interedges_le_mul r s t
· exact mod_cast Nat.zero_le _
#align rel.edge_density_le_one Rel.edgeDensity_le_one
theorem edgeDensity_add_edgeDensity_compl (hs : s.Nonempty) (ht : t.Nonempty) :
edgeDensity r s t + edgeDensity (fun x y ↦ ¬r x y) s t = 1 := by
rw [edgeDensity, edgeDensity, div_add_div_same, div_eq_one_iff_eq]
· exact mod_cast card_interedges_add_card_interedges_compl r s t
· exact mod_cast (mul_pos hs.card_pos ht.card_pos).ne'
#align rel.edge_density_add_edge_density_compl Rel.edgeDensity_add_edgeDensity_compl
@[simp]
| Mathlib/Combinatorics/SimpleGraph/Density.lean | 154 | 155 | theorem edgeDensity_empty_left (t : Finset β) : edgeDensity r ∅ t = 0 := by |
rw [edgeDensity, Finset.card_empty, Nat.cast_zero, zero_mul, div_zero]
| 1 | 2.718282 | 0 | 0.785714 | 14 | 695 |
import Mathlib.Tactic.Ring
set_option autoImplicit true
namespace Mathlib.Tactic.LinearCombination
open Lean hiding Rat
open Elab Meta Term
theorem pf_add_c [Add α] (p : a = b) (c : α) : a + c = b + c := p ▸ rfl
theorem c_add_pf [Add α] (p : b = c) (a : α) : a + b = a + c := p ▸ rfl
theorem add_pf [Add α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ + a₂ = b₁ + b₂ := p₁ ▸ p₂ ▸ rfl
theorem pf_sub_c [Sub α] (p : a = b) (c : α) : a - c = b - c := p ▸ rfl
theorem c_sub_pf [Sub α] (p : b = c) (a : α) : a - b = a - c := p ▸ rfl
theorem sub_pf [Sub α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ - a₂ = b₁ - b₂ := p₁ ▸ p₂ ▸ rfl
theorem neg_pf [Neg α] (p : (a:α) = b) : -a = -b := p ▸ rfl
theorem pf_mul_c [Mul α] (p : a = b) (c : α) : a * c = b * c := p ▸ rfl
theorem c_mul_pf [Mul α] (p : b = c) (a : α) : a * b = a * c := p ▸ rfl
theorem mul_pf [Mul α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ * a₂ = b₁ * b₂ := p₁ ▸ p₂ ▸ rfl
theorem inv_pf [Inv α] (p : (a:α) = b) : a⁻¹ = b⁻¹ := p ▸ rfl
theorem pf_div_c [Div α] (p : a = b) (c : α) : a / c = b / c := p ▸ rfl
theorem c_div_pf [Div α] (p : b = c) (a : α) : a / b = a / c := p ▸ rfl
theorem div_pf [Div α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ / a₂ = b₁ / b₂ := p₁ ▸ p₂ ▸ rfl
partial def expandLinearCombo (stx : Syntax.Term) : TermElabM (Option Syntax.Term) := do
let mut result ← match stx with
| `(($e)) => expandLinearCombo e
| `($e₁ + $e₂) => do
match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with
| none, none => pure none
| some p₁, none => ``(pf_add_c $p₁ $e₂)
| none, some p₂ => ``(c_add_pf $p₂ $e₁)
| some p₁, some p₂ => ``(add_pf $p₁ $p₂)
| `($e₁ - $e₂) => do
match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with
| none, none => pure none
| some p₁, none => ``(pf_sub_c $p₁ $e₂)
| none, some p₂ => ``(c_sub_pf $p₂ $e₁)
| some p₁, some p₂ => ``(sub_pf $p₁ $p₂)
| `(-$e) => do
match ← expandLinearCombo e with
| none => pure none
| some p => ``(neg_pf $p)
| `(← $e) => do
match ← expandLinearCombo e with
| none => pure none
| some p => ``(Eq.symm $p)
| `($e₁ * $e₂) => do
match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with
| none, none => pure none
| some p₁, none => ``(pf_mul_c $p₁ $e₂)
| none, some p₂ => ``(c_mul_pf $p₂ $e₁)
| some p₁, some p₂ => ``(mul_pf $p₁ $p₂)
| `($e⁻¹) => do
match ← expandLinearCombo e with
| none => pure none
| some p => ``(inv_pf $p)
| `($e₁ / $e₂) => do
match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with
| none, none => pure none
| some p₁, none => ``(pf_div_c $p₁ $e₂)
| none, some p₂ => ``(c_div_pf $p₂ $e₁)
| some p₁, some p₂ => ``(div_pf $p₁ $p₂)
| e => do
let e ← elabTerm e none
let eType ← inferType e
let .true := (← withReducible do whnf eType).isEq | pure none
some <$> e.toSyntax
return result.map fun r => ⟨r.raw.setInfo (SourceInfo.fromRef stx true)⟩
theorem eq_trans₃ (p : (a:α) = b) (p₁ : a = a') (p₂ : b = b') : a' = b' := p₁ ▸ p₂ ▸ p
| Mathlib/Tactic/LinearCombination.lean | 111 | 112 | theorem eq_of_add [AddGroup α] (p : (a:α) = b) (H : (a' - b') - (a - b) = 0) : a' = b' := by |
rw [← sub_eq_zero] at p ⊢; rwa [sub_eq_zero, p] at H
| 1 | 2.718282 | 0 | 0 | 2 | 124 |
import Mathlib.Algebra.TrivSqZeroExt
#align_import algebra.dual_number from "leanprover-community/mathlib"@"b8d2eaa69d69ce8f03179a5cda774fc0cde984e4"
variable {R A B : Type*}
abbrev DualNumber (R : Type*) : Type _ :=
TrivSqZeroExt R R
#align dual_number DualNumber
def DualNumber.eps [Zero R] [One R] : DualNumber R :=
TrivSqZeroExt.inr 1
#align dual_number.eps DualNumber.eps
@[inherit_doc]
scoped[DualNumber] notation "ε" => DualNumber.eps
@[inherit_doc]
scoped[DualNumber] postfix:1024 "[ε]" => DualNumber
open DualNumber
namespace DualNumber
open TrivSqZeroExt
@[simp]
theorem fst_eps [Zero R] [One R] : fst ε = (0 : R) :=
fst_inr _ _
#align dual_number.fst_eps DualNumber.fst_eps
@[simp]
theorem snd_eps [Zero R] [One R] : snd ε = (1 : R) :=
snd_inr _ _
#align dual_number.snd_eps DualNumber.snd_eps
@[simp]
theorem snd_mul [Semiring R] (x y : R[ε]) : snd (x * y) = fst x * snd y + snd x * fst y :=
TrivSqZeroExt.snd_mul _ _
#align dual_number.snd_mul DualNumber.snd_mul
@[simp]
theorem eps_mul_eps [Semiring R] : (ε * ε : R[ε]) = 0 :=
inr_mul_inr _ _ _
#align dual_number.eps_mul_eps DualNumber.eps_mul_eps
@[simp]
theorem inv_eps [DivisionRing R] : (ε : R[ε])⁻¹ = 0 :=
TrivSqZeroExt.inv_inr 1
@[simp]
theorem inr_eq_smul_eps [MulZeroOneClass R] (r : R) : inr r = (r • ε : R[ε]) :=
ext (mul_zero r).symm (mul_one r).symm
#align dual_number.inr_eq_smul_eps DualNumber.inr_eq_smul_eps
| Mathlib/Algebra/DualNumber.lean | 96 | 97 | theorem commute_eps_left [Semiring R] (x : DualNumber R) : Commute ε x := by |
ext <;> simp
| 1 | 2.718282 | 0 | 0 | 1 | 165 |
import Mathlib.Algebra.Polynomial.Degree.Definitions
#align_import ring_theory.polynomial.opposites from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0"
open Polynomial
open Polynomial MulOpposite
variable {R : Type*} [Semiring R]
noncomputable section
namespace Polynomial
def opRingEquiv (R : Type*) [Semiring R] : R[X]ᵐᵒᵖ ≃+* Rᵐᵒᵖ[X] :=
((toFinsuppIso R).op.trans AddMonoidAlgebra.opRingEquiv).trans (toFinsuppIso _).symm
#align polynomial.op_ring_equiv Polynomial.opRingEquiv
@[simp]
theorem opRingEquiv_op_monomial (n : ℕ) (r : R) :
opRingEquiv R (op (monomial n r : R[X])) = monomial n (op r) := by
simp only [opRingEquiv, RingEquiv.coe_trans, Function.comp_apply,
AddMonoidAlgebra.opRingEquiv_apply, RingEquiv.op_apply_apply, toFinsuppIso_apply, unop_op,
toFinsupp_monomial, Finsupp.mapRange_single, toFinsuppIso_symm_apply, ofFinsupp_single]
#align polynomial.op_ring_equiv_op_monomial Polynomial.opRingEquiv_op_monomial
@[simp]
theorem opRingEquiv_op_C (a : R) : opRingEquiv R (op (C a)) = C (op a) :=
opRingEquiv_op_monomial 0 a
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_op_C Polynomial.opRingEquiv_op_C
@[simp]
theorem opRingEquiv_op_X : opRingEquiv R (op (X : R[X])) = X :=
opRingEquiv_op_monomial 1 1
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_op_X Polynomial.opRingEquiv_op_X
| Mathlib/RingTheory/Polynomial/Opposites.lean | 57 | 59 | theorem opRingEquiv_op_C_mul_X_pow (r : R) (n : ℕ) :
opRingEquiv R (op (C r * X ^ n : R[X])) = C (op r) * X ^ n := by |
simp only [X_pow_mul, op_mul, op_pow, map_mul, map_pow, opRingEquiv_op_X, opRingEquiv_op_C]
| 1 | 2.718282 | 0 | 0.714286 | 7 | 643 |
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.HasseDeriv
#align_import data.polynomial.taylor from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
noncomputable section
namespace Polynomial
open Polynomial
variable {R : Type*} [Semiring R] (r : R) (f : R[X])
def taylor (r : R) : R[X] →ₗ[R] R[X] where
toFun f := f.comp (X + C r)
map_add' f g := add_comp
map_smul' c f := by simp only [smul_eq_C_mul, C_mul_comp, RingHom.id_apply]
#align polynomial.taylor Polynomial.taylor
theorem taylor_apply : taylor r f = f.comp (X + C r) :=
rfl
#align polynomial.taylor_apply Polynomial.taylor_apply
@[simp]
theorem taylor_X : taylor r X = X + C r := by simp only [taylor_apply, X_comp]
set_option linter.uppercaseLean3 false in
#align polynomial.taylor_X Polynomial.taylor_X
@[simp]
theorem taylor_C (x : R) : taylor r (C x) = C x := by simp only [taylor_apply, C_comp]
set_option linter.uppercaseLean3 false in
#align polynomial.taylor_C Polynomial.taylor_C
@[simp]
theorem taylor_zero' : taylor (0 : R) = LinearMap.id := by
ext
simp only [taylor_apply, add_zero, comp_X, _root_.map_zero, LinearMap.id_comp,
Function.comp_apply, LinearMap.coe_comp]
#align polynomial.taylor_zero' Polynomial.taylor_zero'
theorem taylor_zero (f : R[X]) : taylor 0 f = f := by rw [taylor_zero', LinearMap.id_apply]
#align polynomial.taylor_zero Polynomial.taylor_zero
@[simp]
theorem taylor_one : taylor r (1 : R[X]) = C 1 := by rw [← C_1, taylor_C]
#align polynomial.taylor_one Polynomial.taylor_one
@[simp]
theorem taylor_monomial (i : ℕ) (k : R) : taylor r (monomial i k) = C k * (X + C r) ^ i := by
simp [taylor_apply]
#align polynomial.taylor_monomial Polynomial.taylor_monomial
theorem taylor_coeff (n : ℕ) : (taylor r f).coeff n = (hasseDeriv n f).eval r :=
show (lcoeff R n).comp (taylor r) f = (leval r).comp (hasseDeriv n) f by
congr 1; clear! f; ext i
simp only [leval_apply, mul_one, one_mul, eval_monomial, LinearMap.comp_apply, coeff_C_mul,
hasseDeriv_monomial, taylor_apply, monomial_comp, C_1, (commute_X (C r)).add_pow i,
map_sum]
simp only [lcoeff_apply, ← C_eq_natCast, mul_assoc, ← C_pow, ← C_mul, coeff_mul_C,
(Nat.cast_commute _ _).eq, coeff_X_pow, boole_mul, Finset.sum_ite_eq, Finset.mem_range]
split_ifs with h; · rfl
push_neg at h; rw [Nat.choose_eq_zero_of_lt h, Nat.cast_zero, mul_zero]
#align polynomial.taylor_coeff Polynomial.taylor_coeff
@[simp]
theorem taylor_coeff_zero : (taylor r f).coeff 0 = f.eval r := by
rw [taylor_coeff, hasseDeriv_zero, LinearMap.id_apply]
#align polynomial.taylor_coeff_zero Polynomial.taylor_coeff_zero
@[simp]
| Mathlib/Algebra/Polynomial/Taylor.lean | 93 | 94 | theorem taylor_coeff_one : (taylor r f).coeff 1 = f.derivative.eval r := by |
rw [taylor_coeff, hasseDeriv_one]
| 1 | 2.718282 | 0 | 0.466667 | 15 | 415 |
import Mathlib.CategoryTheory.Subobject.Lattice
#align_import category_theory.subobject.limits from "leanprover-community/mathlib"@"956af7c76589f444f2e1313911bad16366ea476d"
universe v u
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Subobject Opposite
variable {C : Type u} [Category.{v} C] {X Y Z : C}
namespace CategoryTheory
namespace Limits
section Equalizer
variable (f g : X ⟶ Y) [HasEqualizer f g]
abbrev equalizerSubobject : Subobject X :=
Subobject.mk (equalizer.ι f g)
#align category_theory.limits.equalizer_subobject CategoryTheory.Limits.equalizerSubobject
def equalizerSubobjectIso : (equalizerSubobject f g : C) ≅ equalizer f g :=
Subobject.underlyingIso (equalizer.ι f g)
#align category_theory.limits.equalizer_subobject_iso CategoryTheory.Limits.equalizerSubobjectIso
@[reassoc (attr := simp)]
theorem equalizerSubobject_arrow :
(equalizerSubobjectIso f g).hom ≫ equalizer.ι f g = (equalizerSubobject f g).arrow := by
simp [equalizerSubobjectIso]
#align category_theory.limits.equalizer_subobject_arrow CategoryTheory.Limits.equalizerSubobject_arrow
@[reassoc (attr := simp)]
theorem equalizerSubobject_arrow' :
(equalizerSubobjectIso f g).inv ≫ (equalizerSubobject f g).arrow = equalizer.ι f g := by
simp [equalizerSubobjectIso]
#align category_theory.limits.equalizer_subobject_arrow' CategoryTheory.Limits.equalizerSubobject_arrow'
@[reassoc]
| Mathlib/CategoryTheory/Subobject/Limits.lean | 62 | 64 | theorem equalizerSubobject_arrow_comp :
(equalizerSubobject f g).arrow ≫ f = (equalizerSubobject f g).arrow ≫ g := by |
rw [← equalizerSubobject_arrow, Category.assoc, Category.assoc, equalizer.condition]
| 1 | 2.718282 | 0 | 0.263158 | 19 | 308 |
import Mathlib.Data.Vector.Basic
import Mathlib.Data.Vector.Snoc
set_option autoImplicit true
namespace Vector
section Fold
section Binary
variable (xs : Vector α n) (ys : Vector β n)
@[simp]
theorem mapAccumr₂_mapAccumr_left (f₁ : γ → β → σ₁ → σ₁ × ζ) (f₂ : α → σ₂ → σ₂ × γ) :
(mapAccumr₂ f₁ (mapAccumr f₂ xs s₂).snd ys s₁)
= let m := (mapAccumr₂ (fun x y s =>
let r₂ := f₂ x s.snd
let r₁ := f₁ r₂.snd y s.fst
((r₁.fst, r₂.fst), r₁.snd)
) xs ys (s₁, s₂))
(m.fst.fst, m.snd) := by
induction xs, ys using Vector.revInductionOn₂ generalizing s₁ s₂ <;> simp_all
@[simp]
theorem map₂_map_left (f₁ : γ → β → ζ) (f₂ : α → γ) :
map₂ f₁ (map f₂ xs) ys = map₂ (fun x y => f₁ (f₂ x) y) xs ys := by
induction xs, ys using Vector.revInductionOn₂ <;> simp_all
@[simp]
theorem mapAccumr₂_mapAccumr_right (f₁ : α → γ → σ₁ → σ₁ × ζ) (f₂ : β → σ₂ → σ₂ × γ) :
(mapAccumr₂ f₁ xs (mapAccumr f₂ ys s₂).snd s₁)
= let m := (mapAccumr₂ (fun x y s =>
let r₂ := f₂ y s.snd
let r₁ := f₁ x r₂.snd s.fst
((r₁.fst, r₂.fst), r₁.snd)
) xs ys (s₁, s₂))
(m.fst.fst, m.snd) := by
induction xs, ys using Vector.revInductionOn₂ generalizing s₁ s₂ <;> simp_all
@[simp]
theorem map₂_map_right (f₁ : α → γ → ζ) (f₂ : β → γ) :
map₂ f₁ xs (map f₂ ys) = map₂ (fun x y => f₁ x (f₂ y)) xs ys := by
induction xs, ys using Vector.revInductionOn₂ <;> simp_all
@[simp]
| Mathlib/Data/Vector/MapLemmas.lean | 92 | 100 | theorem mapAccumr_mapAccumr₂ (f₁ : γ → σ₁ → σ₁ × ζ) (f₂ : α → β → σ₂ → σ₂ × γ) :
(mapAccumr f₁ (mapAccumr₂ f₂ xs ys s₂).snd s₁)
= let m := mapAccumr₂ (fun x y s =>
let r₂ := f₂ x y s.snd
let r₁ := f₁ r₂.snd s.fst
((r₁.fst, r₂.fst), r₁.snd)
) xs ys (s₁, s₂)
(m.fst.fst, m.snd) := by |
induction xs, ys using Vector.revInductionOn₂ generalizing s₁ s₂ <;> simp_all
| 1 | 2.718282 | 0 | 0.333333 | 24 | 337 |
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.Data.Nat.Factorial.BigOperators
import Mathlib.Data.Fin.VecNotation
import Mathlib.Data.Finset.Sym
import Mathlib.Data.Finsupp.Multiset
#align_import data.nat.choose.multinomial from "leanprover-community/mathlib"@"2738d2ca56cbc63be80c3bd48e9ed90ad94e947d"
open Finset
open scoped Nat
namespace Nat
variable {α : Type*} (s : Finset α) (f : α → ℕ) {a b : α} (n : ℕ)
def multinomial : ℕ :=
(∑ i ∈ s, f i)! / ∏ i ∈ s, (f i)!
#align nat.multinomial Nat.multinomial
theorem multinomial_pos : 0 < multinomial s f :=
Nat.div_pos (le_of_dvd (factorial_pos _) (prod_factorial_dvd_factorial_sum s f))
(prod_factorial_pos s f)
#align nat.multinomial_pos Nat.multinomial_pos
theorem multinomial_spec : (∏ i ∈ s, (f i)!) * multinomial s f = (∑ i ∈ s, f i)! :=
Nat.mul_div_cancel' (prod_factorial_dvd_factorial_sum s f)
#align nat.multinomial_spec Nat.multinomial_spec
@[simp] lemma multinomial_empty : multinomial ∅ f = 1 := by simp [multinomial]
#align nat.multinomial_nil Nat.multinomial_empty
@[deprecated (since := "2024-06-01")] alias multinomial_nil := multinomial_empty
variable {s f}
lemma multinomial_cons (ha : a ∉ s) (f : α → ℕ) :
multinomial (s.cons a ha) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f := by
rw [multinomial, Nat.div_eq_iff_eq_mul_left _ (prod_factorial_dvd_factorial_sum _ _), prod_cons,
multinomial, mul_assoc, mul_left_comm _ (f a)!,
Nat.div_mul_cancel (prod_factorial_dvd_factorial_sum _ _), ← mul_assoc, Nat.choose_symm_add,
Nat.add_choose_mul_factorial_mul_factorial, Finset.sum_cons]
positivity
lemma multinomial_insert [DecidableEq α] (ha : a ∉ s) (f : α → ℕ) :
multinomial (insert a s) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f := by
rw [← cons_eq_insert _ _ ha, multinomial_cons]
#align nat.multinomial_insert Nat.multinomial_insert
@[simp] lemma multinomial_singleton (a : α) (f : α → ℕ) : multinomial {a} f = 1 := by
rw [← cons_empty, multinomial_cons]; simp
#align nat.multinomial_singleton Nat.multinomial_singleton
@[simp]
theorem multinomial_insert_one [DecidableEq α] (h : a ∉ s) (h₁ : f a = 1) :
multinomial (insert a s) f = (s.sum f).succ * multinomial s f := by
simp only [multinomial, one_mul, factorial]
rw [Finset.sum_insert h, Finset.prod_insert h, h₁, add_comm, ← succ_eq_add_one, factorial_succ]
simp only [factorial_one, one_mul, Function.comp_apply, factorial, mul_one, ← one_eq_succ_zero]
rw [Nat.mul_div_assoc _ (prod_factorial_dvd_factorial_sum _ _)]
#align nat.multinomial_insert_one Nat.multinomial_insert_one
theorem multinomial_congr {f g : α → ℕ} (h : ∀ a ∈ s, f a = g a) :
multinomial s f = multinomial s g := by
simp only [multinomial]; congr 1
· rw [Finset.sum_congr rfl h]
· exact Finset.prod_congr rfl fun a ha => by rw [h a ha]
#align nat.multinomial_congr Nat.multinomial_congr
theorem binomial_eq [DecidableEq α] (h : a ≠ b) :
multinomial {a, b} f = (f a + f b)! / ((f a)! * (f b)!) := by
simp [multinomial, Finset.sum_pair h, Finset.prod_pair h]
#align nat.binomial_eq Nat.binomial_eq
theorem binomial_eq_choose [DecidableEq α] (h : a ≠ b) :
multinomial {a, b} f = (f a + f b).choose (f a) := by
simp [binomial_eq h, choose_eq_factorial_div_factorial (Nat.le_add_right _ _)]
#align nat.binomial_eq_choose Nat.binomial_eq_choose
| Mathlib/Data/Nat/Choose/Multinomial.lean | 112 | 114 | theorem binomial_spec [DecidableEq α] (hab : a ≠ b) :
(f a)! * (f b)! * multinomial {a, b} f = (f a + f b)! := by |
simpa [Finset.sum_pair hab, Finset.prod_pair hab] using multinomial_spec {a, b} f
| 1 | 2.718282 | 0 | 0.777778 | 9 | 694 |
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Reverse
import Mathlib.Algebra.Polynomial.Inductions
import Mathlib.RingTheory.Localization.Basic
#align_import data.polynomial.laurent from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86"
open Polynomial Function AddMonoidAlgebra Finsupp
noncomputable section
variable {R : Type*}
abbrev LaurentPolynomial (R : Type*) [Semiring R] :=
AddMonoidAlgebra R ℤ
#align laurent_polynomial LaurentPolynomial
@[nolint docBlame]
scoped[LaurentPolynomial] notation:9000 R "[T;T⁻¹]" => LaurentPolynomial R
open LaurentPolynomial
-- Porting note: `ext` no longer applies `Finsupp.ext` automatically
@[ext]
theorem LaurentPolynomial.ext [Semiring R] {p q : R[T;T⁻¹]} (h : ∀ a, p a = q a) : p = q :=
Finsupp.ext h
def Polynomial.toLaurent [Semiring R] : R[X] →+* R[T;T⁻¹] :=
(mapDomainRingHom R Int.ofNatHom).comp (toFinsuppIso R)
#align polynomial.to_laurent Polynomial.toLaurent
theorem Polynomial.toLaurent_apply [Semiring R] (p : R[X]) :
toLaurent p = p.toFinsupp.mapDomain (↑) :=
rfl
#align polynomial.to_laurent_apply Polynomial.toLaurent_apply
def Polynomial.toLaurentAlg [CommSemiring R] : R[X] →ₐ[R] R[T;T⁻¹] :=
(mapDomainAlgHom R R Int.ofNatHom).comp (toFinsuppIsoAlg R).toAlgHom
#align polynomial.to_laurent_alg Polynomial.toLaurentAlg
@[simp] lemma Polynomial.coe_toLaurentAlg [CommSemiring R] :
(toLaurentAlg : R[X] → R[T;T⁻¹]) = toLaurent :=
rfl
theorem Polynomial.toLaurentAlg_apply [CommSemiring R] (f : R[X]) : toLaurentAlg f = toLaurent f :=
rfl
#align polynomial.to_laurent_alg_apply Polynomial.toLaurentAlg_apply
namespace LaurentPolynomial
section Semiring
variable [Semiring R]
theorem single_zero_one_eq_one : (Finsupp.single 0 1 : R[T;T⁻¹]) = (1 : R[T;T⁻¹]) :=
rfl
#align laurent_polynomial.single_zero_one_eq_one LaurentPolynomial.single_zero_one_eq_one
def C : R →+* R[T;T⁻¹] :=
singleZeroRingHom
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.C LaurentPolynomial.C
theorem algebraMap_apply {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] (r : R) :
algebraMap R (LaurentPolynomial A) r = C (algebraMap R A r) :=
rfl
#align laurent_polynomial.algebra_map_apply LaurentPolynomial.algebraMap_apply
theorem C_eq_algebraMap {R : Type*} [CommSemiring R] (r : R) : C r = algebraMap R R[T;T⁻¹] r :=
rfl
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.C_eq_algebra_map LaurentPolynomial.C_eq_algebraMap
theorem single_eq_C (r : R) : Finsupp.single 0 r = C r := rfl
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.single_eq_C LaurentPolynomial.single_eq_C
@[simp] lemma C_apply (t : R) (n : ℤ) : C t n = if n = 0 then t else 0 := by
rw [← single_eq_C, Finsupp.single_apply]; aesop
def T (n : ℤ) : R[T;T⁻¹] :=
Finsupp.single n 1
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T LaurentPolynomial.T
@[simp] lemma T_apply (m n : ℤ) : (T n : R[T;T⁻¹]) m = if n = m then 1 else 0 :=
Finsupp.single_apply
@[simp]
theorem T_zero : (T 0 : R[T;T⁻¹]) = 1 :=
rfl
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_zero LaurentPolynomial.T_zero
theorem T_add (m n : ℤ) : (T (m + n) : R[T;T⁻¹]) = T m * T n := by
-- Porting note: was `convert single_mul_single.symm`
simp [T, single_mul_single]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_add LaurentPolynomial.T_add
theorem T_sub (m n : ℤ) : (T (m - n) : R[T;T⁻¹]) = T m * T (-n) := by rw [← T_add, sub_eq_add_neg]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_sub LaurentPolynomial.T_sub
@[simp]
theorem T_pow (m : ℤ) (n : ℕ) : (T m ^ n : R[T;T⁻¹]) = T (n * m) := by
rw [T, T, single_pow n, one_pow, nsmul_eq_mul]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_pow LaurentPolynomial.T_pow
@[simp]
| Mathlib/Algebra/Polynomial/Laurent.lean | 203 | 204 | theorem mul_T_assoc (f : R[T;T⁻¹]) (m n : ℤ) : f * T m * T n = f * T (m + n) := by |
simp [← T_add, mul_assoc]
| 1 | 2.718282 | 0 | 0.4 | 5 | 393 |
import Mathlib.Algebra.Group.Hom.Defs
import Mathlib.Algebra.Group.Units
#align_import algebra.hom.units from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c"
assert_not_exists MonoidWithZero
assert_not_exists DenselyOrdered
open Function
universe u v w
namespace Units
variable {α : Type*} {M : Type u} {N : Type v} {P : Type w} [Monoid M] [Monoid N] [Monoid P]
@[to_additive "The additive homomorphism on `AddUnit`s induced by an `AddMonoidHom`."]
def map (f : M →* N) : Mˣ →* Nˣ :=
MonoidHom.mk'
(fun u => ⟨f u.val, f u.inv,
by rw [← f.map_mul, u.val_inv, f.map_one],
by rw [← f.map_mul, u.inv_val, f.map_one]⟩)
fun x y => ext (f.map_mul x y)
#align units.map Units.map
#align add_units.map AddUnits.map
@[to_additive (attr := simp)]
theorem coe_map (f : M →* N) (x : Mˣ) : ↑(map f x) = f x := rfl
#align units.coe_map Units.coe_map
#align add_units.coe_map AddUnits.coe_map
@[to_additive (attr := simp)]
theorem coe_map_inv (f : M →* N) (u : Mˣ) : ↑(map f u)⁻¹ = f ↑u⁻¹ := rfl
#align units.coe_map_inv Units.coe_map_inv
#align add_units.coe_map_neg AddUnits.coe_map_neg
@[to_additive (attr := simp)]
theorem map_comp (f : M →* N) (g : N →* P) : map (g.comp f) = (map g).comp (map f) := rfl
#align units.map_comp Units.map_comp
#align add_units.map_comp AddUnits.map_comp
@[to_additive]
lemma map_injective {f : M →* N} (hf : Function.Injective f) :
Function.Injective (map f) := fun _ _ e => ext (hf (congr_arg val e))
variable (M)
@[to_additive (attr := simp)]
theorem map_id : map (MonoidHom.id M) = MonoidHom.id Mˣ := by ext; rfl
#align units.map_id Units.map_id
#align add_units.map_id AddUnits.map_id
@[to_additive "Coercion `AddUnits M → M` as an AddMonoid homomorphism."]
def coeHom : Mˣ →* M where
toFun := Units.val; map_one' := val_one; map_mul' := val_mul
#align units.coe_hom Units.coeHom
#align add_units.coe_hom AddUnits.coeHom
variable {M}
@[to_additive (attr := simp)]
theorem coeHom_apply (x : Mˣ) : coeHom M x = ↑x := rfl
#align units.coe_hom_apply Units.coeHom_apply
#align add_units.coe_hom_apply AddUnits.coeHom_apply
@[to_additive
"If a map `g : M → AddUnits N` agrees with a homomorphism `f : M →+ N`, then this map
is an AddMonoid homomorphism too."]
def liftRight (f : M →* N) (g : M → Nˣ) (h : ∀ x, ↑(g x) = f x) : M →* Nˣ where
toFun := g
map_one' := by ext; rw [h 1]; exact f.map_one
map_mul' x y := Units.ext <| by simp only [h, val_mul, f.map_mul]
#align units.lift_right Units.liftRight
#align add_units.lift_right AddUnits.liftRight
@[to_additive (attr := simp)]
theorem coe_liftRight {f : M →* N} {g : M → Nˣ} (h : ∀ x, ↑(g x) = f x) (x) :
(liftRight f g h x : N) = f x := h x
#align units.coe_lift_right Units.coe_liftRight
#align add_units.coe_lift_right AddUnits.coe_liftRight
@[to_additive (attr := simp)]
theorem mul_liftRight_inv {f : M →* N} {g : M → Nˣ} (h : ∀ x, ↑(g x) = f x) (x) :
f x * ↑(liftRight f g h x)⁻¹ = 1 := by
rw [Units.mul_inv_eq_iff_eq_mul, one_mul, coe_liftRight]
#align units.mul_lift_right_inv Units.mul_liftRight_inv
#align add_units.add_lift_right_neg AddUnits.add_liftRight_neg
@[to_additive (attr := simp)]
| Mathlib/Algebra/Group/Units/Hom.lean | 157 | 159 | theorem liftRight_inv_mul {f : M →* N} {g : M → Nˣ} (h : ∀ x, ↑(g x) = f x) (x) :
↑(liftRight f g h x)⁻¹ * f x = 1 := by |
rw [Units.inv_mul_eq_iff_eq_mul, mul_one, coe_liftRight]
| 1 | 2.718282 | 0 | 0 | 4 | 43 |
import Mathlib.Data.Setoid.Partition
import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.GroupTheory.GroupAction.Pointwise
import Mathlib.GroupTheory.GroupAction.SubMulAction
open scoped BigOperators Pointwise
namespace MulAction
section SMul
variable (G : Type*) {X : Type*} [SMul G X]
-- Change terminology : is_fully_invariant ?
def IsFixedBlock (B : Set X) := ∀ g : G, g • B = B
def IsInvariantBlock (B : Set X) := ∀ g : G, g • B ⊆ B
def IsTrivialBlock (B : Set X) := B.Subsingleton ∨ B = ⊤
def IsBlock (B : Set X) := (Set.range fun g : G => g • B).PairwiseDisjoint id
variable {G}
theorem IsBlock.def {B : Set X} :
IsBlock G B ↔ ∀ g g' : G, g • B = g' • B ∨ Disjoint (g • B) (g' • B) := by
apply Set.pairwiseDisjoint_range_iff
theorem IsBlock.mk_notempty {B : Set X} :
IsBlock G B ↔ ∀ g g' : G, g • B ∩ g' • B ≠ ∅ → g • B = g' • B := by
simp_rw [IsBlock.def, or_iff_not_imp_right, Set.disjoint_iff_inter_eq_empty]
theorem IsFixedBlock.isBlock {B : Set X} (hfB : IsFixedBlock G B) :
IsBlock G B := by
simp [IsBlock.def, hfB _]
variable (X)
theorem isBlock_empty : IsBlock G (⊥ : Set X) := by
simp [IsBlock.def, Set.bot_eq_empty, Set.smul_set_empty]
variable {X}
| Mathlib/GroupTheory/GroupAction/Blocks.lean | 107 | 108 | theorem isBlock_singleton (a : X) : IsBlock G ({a} : Set X) := by |
simp [IsBlock.def, Classical.or_iff_not_imp_left]
| 1 | 2.718282 | 0 | 0.5 | 8 | 486 |
import Mathlib.Algebra.Order.Ring.Cast
import Mathlib.Data.Int.Cast.Lemmas
import Mathlib.Data.Nat.Bitwise
import Mathlib.Data.Nat.PSub
import Mathlib.Data.Nat.Size
import Mathlib.Data.Num.Bitwise
#align_import data.num.lemmas from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
set_option linter.deprecated false
-- Porting note: Required for the notation `-[n+1]`.
open Int Function
attribute [local simp] add_assoc
namespace PosNum
variable {α : Type*}
@[simp, norm_cast]
theorem cast_one [One α] [Add α] : ((1 : PosNum) : α) = 1 :=
rfl
#align pos_num.cast_one PosNum.cast_one
@[simp]
theorem cast_one' [One α] [Add α] : (PosNum.one : α) = 1 :=
rfl
#align pos_num.cast_one' PosNum.cast_one'
@[simp, norm_cast]
theorem cast_bit0 [One α] [Add α] (n : PosNum) : (n.bit0 : α) = _root_.bit0 (n : α) :=
rfl
#align pos_num.cast_bit0 PosNum.cast_bit0
@[simp, norm_cast]
theorem cast_bit1 [One α] [Add α] (n : PosNum) : (n.bit1 : α) = _root_.bit1 (n : α) :=
rfl
#align pos_num.cast_bit1 PosNum.cast_bit1
@[simp, norm_cast]
theorem cast_to_nat [AddMonoidWithOne α] : ∀ n : PosNum, ((n : ℕ) : α) = n
| 1 => Nat.cast_one
| bit0 p => (Nat.cast_bit0 _).trans <| congr_arg _root_.bit0 p.cast_to_nat
| bit1 p => (Nat.cast_bit1 _).trans <| congr_arg _root_.bit1 p.cast_to_nat
#align pos_num.cast_to_nat PosNum.cast_to_nat
@[norm_cast] -- @[simp] -- Porting note (#10618): simp can prove this
theorem to_nat_to_int (n : PosNum) : ((n : ℕ) : ℤ) = n :=
cast_to_nat _
#align pos_num.to_nat_to_int PosNum.to_nat_to_int
@[simp, norm_cast]
theorem cast_to_int [AddGroupWithOne α] (n : PosNum) : ((n : ℤ) : α) = n := by
rw [← to_nat_to_int, Int.cast_natCast, cast_to_nat]
#align pos_num.cast_to_int PosNum.cast_to_int
theorem succ_to_nat : ∀ n, (succ n : ℕ) = n + 1
| 1 => rfl
| bit0 p => rfl
| bit1 p =>
(congr_arg _root_.bit0 (succ_to_nat p)).trans <|
show ↑p + 1 + ↑p + 1 = ↑p + ↑p + 1 + 1 by simp [add_left_comm]
#align pos_num.succ_to_nat PosNum.succ_to_nat
theorem one_add (n : PosNum) : 1 + n = succ n := by cases n <;> rfl
#align pos_num.one_add PosNum.one_add
| Mathlib/Data/Num/Lemmas.lean | 84 | 84 | theorem add_one (n : PosNum) : n + 1 = succ n := by | cases n <;> rfl
| 1 | 2.718282 | 0 | 0 | 9 | 38 |
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.RingTheory.Coprime.Basic
import Mathlib.Tactic.AdaptationNote
#align_import ring_theory.polynomial.scale_roots from "leanprover-community/mathlib"@"40ac1b258344e0c2b4568dc37bfad937ec35a727"
variable {R S A K : Type*}
namespace Polynomial
open Polynomial
section Semiring
variable [Semiring R] [Semiring S]
noncomputable def scaleRoots (p : R[X]) (s : R) : R[X] :=
∑ i ∈ p.support, monomial i (p.coeff i * s ^ (p.natDegree - i))
#align polynomial.scale_roots Polynomial.scaleRoots
@[simp]
theorem coeff_scaleRoots (p : R[X]) (s : R) (i : ℕ) :
(scaleRoots p s).coeff i = coeff p i * s ^ (p.natDegree - i) := by
simp (config := { contextual := true }) [scaleRoots, coeff_monomial]
#align polynomial.coeff_scale_roots Polynomial.coeff_scaleRoots
theorem coeff_scaleRoots_natDegree (p : R[X]) (s : R) :
(scaleRoots p s).coeff p.natDegree = p.leadingCoeff := by
rw [leadingCoeff, coeff_scaleRoots, tsub_self, pow_zero, mul_one]
#align polynomial.coeff_scale_roots_nat_degree Polynomial.coeff_scaleRoots_natDegree
@[simp]
theorem zero_scaleRoots (s : R) : scaleRoots 0 s = 0 := by
ext
simp
#align polynomial.zero_scale_roots Polynomial.zero_scaleRoots
theorem scaleRoots_ne_zero {p : R[X]} (hp : p ≠ 0) (s : R) : scaleRoots p s ≠ 0 := by
intro h
have : p.coeff p.natDegree ≠ 0 := mt leadingCoeff_eq_zero.mp hp
have : (scaleRoots p s).coeff p.natDegree = 0 :=
congr_fun (congr_arg (coeff : R[X] → ℕ → R) h) p.natDegree
rw [coeff_scaleRoots_natDegree] at this
contradiction
#align polynomial.scale_roots_ne_zero Polynomial.scaleRoots_ne_zero
theorem support_scaleRoots_le (p : R[X]) (s : R) : (scaleRoots p s).support ≤ p.support := by
intro
simpa using left_ne_zero_of_mul
#align polynomial.support_scale_roots_le Polynomial.support_scaleRoots_le
theorem support_scaleRoots_eq (p : R[X]) {s : R} (hs : s ∈ nonZeroDivisors R) :
(scaleRoots p s).support = p.support :=
le_antisymm (support_scaleRoots_le p s)
(by intro i
simp only [coeff_scaleRoots, Polynomial.mem_support_iff]
intro p_ne_zero ps_zero
have := pow_mem hs (p.natDegree - i) _ ps_zero
contradiction)
#align polynomial.support_scale_roots_eq Polynomial.support_scaleRoots_eq
@[simp]
theorem degree_scaleRoots (p : R[X]) {s : R} : degree (scaleRoots p s) = degree p := by
haveI := Classical.propDecidable
by_cases hp : p = 0
· rw [hp, zero_scaleRoots]
refine le_antisymm (Finset.sup_mono (support_scaleRoots_le p s)) (degree_le_degree ?_)
rw [coeff_scaleRoots_natDegree]
intro h
have := leadingCoeff_eq_zero.mp h
contradiction
#align polynomial.degree_scale_roots Polynomial.degree_scaleRoots
@[simp]
| Mathlib/RingTheory/Polynomial/ScaleRoots.lean | 90 | 91 | theorem natDegree_scaleRoots (p : R[X]) (s : R) : natDegree (scaleRoots p s) = natDegree p := by |
simp only [natDegree, degree_scaleRoots]
| 1 | 2.718282 | 0 | 0.777778 | 9 | 688 |
import Mathlib.Algebra.Ring.Prod
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Tactic.FinCases
#align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7"
assert_not_exists Submodule
open Function
namespace ZMod
instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ)
def val : ∀ {n : ℕ}, ZMod n → ℕ
| 0 => Int.natAbs
| n + 1 => ((↑) : Fin (n + 1) → ℕ)
#align zmod.val ZMod.val
theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by
cases n
· cases NeZero.ne 0 rfl
exact Fin.is_lt a
#align zmod.val_lt ZMod.val_lt
theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n :=
a.val_lt.le
#align zmod.val_le ZMod.val_le
@[simp]
theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0
| 0 => rfl
| _ + 1 => rfl
#align zmod.val_zero ZMod.val_zero
@[simp]
theorem val_one' : (1 : ZMod 0).val = 1 :=
rfl
#align zmod.val_one' ZMod.val_one'
@[simp]
theorem val_neg' {n : ZMod 0} : (-n).val = n.val :=
Int.natAbs_neg n
#align zmod.val_neg' ZMod.val_neg'
@[simp]
theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val :=
Int.natAbs_mul m n
#align zmod.val_mul' ZMod.val_mul'
@[simp]
theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by
cases n
· rw [Nat.mod_zero]
exact Int.natAbs_ofNat a
· apply Fin.val_natCast
#align zmod.val_nat_cast ZMod.val_natCast
@[deprecated (since := "2024-04-17")]
alias val_nat_cast := val_natCast
theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by
simp only [val]
rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one]
lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by
rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h]
| Mathlib/Data/ZMod/Basic.lean | 101 | 102 | theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by |
rwa [val_natCast, Nat.mod_eq_of_lt]
| 1 | 2.718282 | 0 | 1 | 11 | 900 |
import Mathlib.Init.Control.Combinators
import Mathlib.Data.Option.Defs
import Mathlib.Logic.IsEmpty
import Mathlib.Logic.Relator
import Mathlib.Util.CompileInductive
import Aesop
#align_import data.option.basic from "leanprover-community/mathlib"@"f340f229b1f461aa1c8ee11e0a172d0a3b301a4a"
universe u
namespace Option
variable {α β γ δ : Type*}
theorem coe_def : (fun a ↦ ↑a : α → Option α) = some :=
rfl
#align option.coe_def Option.coe_def
theorem mem_map {f : α → β} {y : β} {o : Option α} : y ∈ o.map f ↔ ∃ x ∈ o, f x = y := by simp
#align option.mem_map Option.mem_map
-- The simpNF linter says that the LHS can be simplified via `Option.mem_def`.
-- However this is a higher priority lemma.
-- https://github.com/leanprover/std4/issues/207
@[simp 1100, nolint simpNF]
| Mathlib/Data/Option/Basic.lean | 53 | 55 | theorem mem_map_of_injective {f : α → β} (H : Function.Injective f) {a : α} {o : Option α} :
f a ∈ o.map f ↔ a ∈ o := by |
aesop
| 1 | 2.718282 | 0 | 0 | 8 | 110 |
import Mathlib.LinearAlgebra.AffineSpace.AffineMap
import Mathlib.Tactic.FieldSimp
#align_import linear_algebra.affine_space.slope from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
open AffineMap
variable {k E PE : Type*} [Field k] [AddCommGroup E] [Module k E] [AddTorsor E PE]
def slope (f : k → PE) (a b : k) : E :=
(b - a)⁻¹ • (f b -ᵥ f a)
#align slope slope
theorem slope_fun_def (f : k → PE) : slope f = fun a b => (b - a)⁻¹ • (f b -ᵥ f a) :=
rfl
#align slope_fun_def slope_fun_def
theorem slope_def_field (f : k → k) (a b : k) : slope f a b = (f b - f a) / (b - a) :=
(div_eq_inv_mul _ _).symm
#align slope_def_field slope_def_field
theorem slope_fun_def_field (f : k → k) (a : k) : slope f a = fun b => (f b - f a) / (b - a) :=
(div_eq_inv_mul _ _).symm
#align slope_fun_def_field slope_fun_def_field
@[simp]
theorem slope_same (f : k → PE) (a : k) : (slope f a a : E) = 0 := by
rw [slope, sub_self, inv_zero, zero_smul]
#align slope_same slope_same
theorem slope_def_module (f : k → E) (a b : k) : slope f a b = (b - a)⁻¹ • (f b - f a) :=
rfl
#align slope_def_module slope_def_module
@[simp]
theorem sub_smul_slope (f : k → PE) (a b : k) : (b - a) • slope f a b = f b -ᵥ f a := by
rcases eq_or_ne a b with (rfl | hne)
· rw [sub_self, zero_smul, vsub_self]
· rw [slope, smul_inv_smul₀ (sub_ne_zero.2 hne.symm)]
#align sub_smul_slope sub_smul_slope
theorem sub_smul_slope_vadd (f : k → PE) (a b : k) : (b - a) • slope f a b +ᵥ f a = f b := by
rw [sub_smul_slope, vsub_vadd]
#align sub_smul_slope_vadd sub_smul_slope_vadd
@[simp]
theorem slope_vadd_const (f : k → E) (c : PE) : (slope fun x => f x +ᵥ c) = slope f := by
ext a b
simp only [slope, vadd_vsub_vadd_cancel_right, vsub_eq_sub]
#align slope_vadd_const slope_vadd_const
@[simp]
theorem slope_sub_smul (f : k → E) {a b : k} (h : a ≠ b) :
slope (fun x => (x - a) • f x) a b = f b := by
simp [slope, inv_smul_smul₀ (sub_ne_zero.2 h.symm)]
#align slope_sub_smul slope_sub_smul
| Mathlib/LinearAlgebra/AffineSpace/Slope.lean | 78 | 79 | theorem eq_of_slope_eq_zero {f : k → PE} {a b : k} (h : slope f a b = (0 : E)) : f a = f b := by |
rw [← sub_smul_slope_vadd f a b, h, smul_zero, zero_vadd]
| 1 | 2.718282 | 0 | 0.7 | 10 | 639 |
import Mathlib.Algebra.DirectSum.Internal
import Mathlib.Algebra.GradedMonoid
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.MvPolynomial.Equiv
import Mathlib.Algebra.MvPolynomial.Variables
import Mathlib.RingTheory.MvPolynomial.WeightedHomogeneous
import Mathlib.Algebra.Polynomial.Roots
#align_import ring_theory.mv_polynomial.homogeneous from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
namespace MvPolynomial
variable {σ : Type*} {τ : Type*} {R : Type*} {S : Type*}
def degree (d : σ →₀ ℕ) := ∑ i ∈ d.support, d i
| Mathlib/RingTheory/MvPolynomial/Homogeneous.lean | 45 | 47 | theorem weightedDegree_one (d : σ →₀ ℕ) :
weightedDegree 1 d = degree d := by |
simp [weightedDegree, degree, Finsupp.total, Finsupp.sum]
| 1 | 2.718282 | 0 | 0.888889 | 9 | 767 |
import Mathlib.Algebra.Algebra.Spectrum
import Mathlib.LinearAlgebra.GeneralLinearGroup
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.RingTheory.Nilpotent.Basic
#align_import linear_algebra.eigenspace.basic from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1"
universe u v w
namespace Module
namespace End
open FiniteDimensional Set
variable {K R : Type v} {V M : Type w} [CommRing R] [AddCommGroup M] [Module R M] [Field K]
[AddCommGroup V] [Module K V]
def eigenspace (f : End R M) (μ : R) : Submodule R M :=
LinearMap.ker (f - algebraMap R (End R M) μ)
#align module.End.eigenspace Module.End.eigenspace
@[simp]
theorem eigenspace_zero (f : End R M) : f.eigenspace 0 = LinearMap.ker f := by simp [eigenspace]
#align module.End.eigenspace_zero Module.End.eigenspace_zero
def HasEigenvector (f : End R M) (μ : R) (x : M) : Prop :=
x ∈ eigenspace f μ ∧ x ≠ 0
#align module.End.has_eigenvector Module.End.HasEigenvector
def HasEigenvalue (f : End R M) (a : R) : Prop :=
eigenspace f a ≠ ⊥
#align module.End.has_eigenvalue Module.End.HasEigenvalue
def Eigenvalues (f : End R M) : Type _ :=
{ μ : R // f.HasEigenvalue μ }
#align module.End.eigenvalues Module.End.Eigenvalues
@[coe]
def Eigenvalues.val (f : Module.End R M) : Eigenvalues f → R := Subtype.val
instance Eigenvalues.instCoeOut {f : Module.End R M} : CoeOut (Eigenvalues f) R where
coe := Eigenvalues.val f
instance Eigenvalues.instDecidableEq [DecidableEq R] (f : Module.End R M) :
DecidableEq (Eigenvalues f) :=
inferInstanceAs (DecidableEq (Subtype (fun x : R => HasEigenvalue f x)))
theorem hasEigenvalue_of_hasEigenvector {f : End R M} {μ : R} {x : M} (h : HasEigenvector f μ x) :
HasEigenvalue f μ := by
rw [HasEigenvalue, Submodule.ne_bot_iff]
use x; exact h
#align module.End.has_eigenvalue_of_has_eigenvector Module.End.hasEigenvalue_of_hasEigenvector
theorem mem_eigenspace_iff {f : End R M} {μ : R} {x : M} : x ∈ eigenspace f μ ↔ f x = μ • x := by
rw [eigenspace, LinearMap.mem_ker, LinearMap.sub_apply, algebraMap_end_apply, sub_eq_zero]
#align module.End.mem_eigenspace_iff Module.End.mem_eigenspace_iff
theorem HasEigenvector.apply_eq_smul {f : End R M} {μ : R} {x : M} (hx : f.HasEigenvector μ x) :
f x = μ • x :=
mem_eigenspace_iff.mp hx.1
#align module.End.has_eigenvector.apply_eq_smul Module.End.HasEigenvector.apply_eq_smul
theorem HasEigenvector.pow_apply {f : End R M} {μ : R} {v : M} (hv : f.HasEigenvector μ v) (n : ℕ) :
(f ^ n) v = μ ^ n • v := by
induction n <;> simp [*, pow_succ f, hv.apply_eq_smul, smul_smul, pow_succ' μ]
theorem HasEigenvalue.exists_hasEigenvector {f : End R M} {μ : R} (hμ : f.HasEigenvalue μ) :
∃ v, f.HasEigenvector μ v :=
Submodule.exists_mem_ne_zero_of_ne_bot hμ
#align module.End.has_eigenvalue.exists_has_eigenvector Module.End.HasEigenvalue.exists_hasEigenvector
lemma HasEigenvalue.pow {f : End R M} {μ : R} (h : f.HasEigenvalue μ) (n : ℕ) :
(f ^ n).HasEigenvalue (μ ^ n) := by
rw [HasEigenvalue, Submodule.ne_bot_iff]
obtain ⟨m : M, hm⟩ := h.exists_hasEigenvector
exact ⟨m, by simpa [mem_eigenspace_iff] using hm.pow_apply n, hm.2⟩
lemma HasEigenvalue.isNilpotent_of_isNilpotent [NoZeroSMulDivisors R M] {f : End R M}
(hfn : IsNilpotent f) {μ : R} (hf : f.HasEigenvalue μ) :
IsNilpotent μ := by
obtain ⟨m : M, hm⟩ := hf.exists_hasEigenvector
obtain ⟨n : ℕ, hn : f ^ n = 0⟩ := hfn
exact ⟨n, by simpa [hn, hm.2, eq_comm (a := (0 : M))] using hm.pow_apply n⟩
theorem HasEigenvalue.mem_spectrum {f : End R M} {μ : R} (hμ : HasEigenvalue f μ) :
μ ∈ spectrum R f := by
refine spectrum.mem_iff.mpr fun h_unit => ?_
set f' := LinearMap.GeneralLinearGroup.toLinearEquiv h_unit.unit
rcases hμ.exists_hasEigenvector with ⟨v, hv⟩
refine hv.2 ((LinearMap.ker_eq_bot'.mp f'.ker) v (?_ : μ • v - f v = 0))
rw [hv.apply_eq_smul, sub_self]
#align module.End.mem_spectrum_of_has_eigenvalue Module.End.HasEigenvalue.mem_spectrum
| Mathlib/LinearAlgebra/Eigenspace/Basic.lean | 147 | 149 | theorem hasEigenvalue_iff_mem_spectrum [FiniteDimensional K V] {f : End K V} {μ : K} :
f.HasEigenvalue μ ↔ μ ∈ spectrum K f := by |
rw [spectrum.mem_iff, IsUnit.sub_iff, LinearMap.isUnit_iff_ker_eq_bot, HasEigenvalue, eigenspace]
| 1 | 2.718282 | 0 | 0.714286 | 7 | 644 |
import Mathlib.Order.BooleanAlgebra
import Mathlib.Logic.Equiv.Basic
#align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904"
open Function OrderDual
variable {ι α β : Type*} {π : ι → Type*}
def symmDiff [Sup α] [SDiff α] (a b : α) : α :=
a \ b ⊔ b \ a
#align symm_diff symmDiff
def bihimp [Inf α] [HImp α] (a b : α) : α :=
(b ⇨ a) ⊓ (a ⇨ b)
#align bihimp bihimp
scoped[symmDiff] infixl:100 " ∆ " => symmDiff
scoped[symmDiff] infixl:100 " ⇔ " => bihimp
open scoped symmDiff
theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a :=
rfl
#align symm_diff_def symmDiff_def
theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) :=
rfl
#align bihimp_def bihimp_def
theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q :=
rfl
#align symm_diff_eq_xor symmDiff_eq_Xor'
@[simp]
theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) :=
(iff_iff_implies_and_implies _ _).symm.trans Iff.comm
#align bihimp_iff_iff bihimp_iff_iff
@[simp]
theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide
#align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor
section GeneralizedHeytingAlgebra
variable [GeneralizedHeytingAlgebra α] (a b c d : α)
@[simp]
theorem toDual_bihimp : toDual (a ⇔ b) = toDual a ∆ toDual b :=
rfl
#align to_dual_bihimp toDual_bihimp
@[simp]
theorem ofDual_symmDiff (a b : αᵒᵈ) : ofDual (a ∆ b) = ofDual a ⇔ ofDual b :=
rfl
#align of_dual_symm_diff ofDual_symmDiff
theorem bihimp_comm : a ⇔ b = b ⇔ a := by simp only [(· ⇔ ·), inf_comm]
#align bihimp_comm bihimp_comm
instance bihimp_isCommutative : Std.Commutative (α := α) (· ⇔ ·) :=
⟨bihimp_comm⟩
#align bihimp_is_comm bihimp_isCommutative
@[simp]
theorem bihimp_self : a ⇔ a = ⊤ := by rw [bihimp, inf_idem, himp_self]
#align bihimp_self bihimp_self
@[simp]
theorem bihimp_top : a ⇔ ⊤ = a := by rw [bihimp, himp_top, top_himp, inf_top_eq]
#align bihimp_top bihimp_top
@[simp]
| Mathlib/Order/SymmDiff.lean | 256 | 256 | theorem top_bihimp : ⊤ ⇔ a = a := by | rw [bihimp_comm, bihimp_top]
| 1 | 2.718282 | 0 | 0.181818 | 22 | 266 |
import Mathlib.Tactic.CategoryTheory.Coherence
import Mathlib.CategoryTheory.Monoidal.Free.Coherence
#align_import category_theory.monoidal.coherence_lemmas from "leanprover-community/mathlib"@"b8b8bf3ea0c625fa1f950034a184e07c67f7bcfe"
open CategoryTheory Category Iso
namespace CategoryTheory.MonoidalCategory
variable {C : Type*} [Category C] [MonoidalCategory C]
-- See Proposition 2.2.4 of <http://www-math.mit.edu/~etingof/egnobookfinal.pdf>
@[reassoc]
| Mathlib/CategoryTheory/Monoidal/CoherenceLemmas.lean | 30 | 32 | theorem leftUnitor_tensor'' (X Y : C) :
(α_ (𝟙_ C) X Y).hom ≫ (λ_ (X ⊗ Y)).hom = (λ_ X).hom ⊗ 𝟙 Y := by |
coherence
| 1 | 2.718282 | 0 | 0 | 10 | 21 |
import Mathlib.Data.Multiset.Nodup
import Mathlib.Data.List.NatAntidiagonal
#align_import data.multiset.nat_antidiagonal from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
namespace Multiset
namespace Nat
def antidiagonal (n : ℕ) : Multiset (ℕ × ℕ) :=
List.Nat.antidiagonal n
#align multiset.nat.antidiagonal Multiset.Nat.antidiagonal
@[simp]
theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} : x ∈ antidiagonal n ↔ x.1 + x.2 = n := by
rw [antidiagonal, mem_coe, List.Nat.mem_antidiagonal]
#align multiset.nat.mem_antidiagonal Multiset.Nat.mem_antidiagonal
@[simp]
theorem card_antidiagonal (n : ℕ) : card (antidiagonal n) = n + 1 := by
rw [antidiagonal, coe_card, List.Nat.length_antidiagonal]
#align multiset.nat.card_antidiagonal Multiset.Nat.card_antidiagonal
@[simp]
theorem antidiagonal_zero : antidiagonal 0 = {(0, 0)} :=
rfl
#align multiset.nat.antidiagonal_zero Multiset.Nat.antidiagonal_zero
@[simp]
theorem nodup_antidiagonal (n : ℕ) : Nodup (antidiagonal n) :=
coe_nodup.2 <| List.Nat.nodup_antidiagonal n
#align multiset.nat.nodup_antidiagonal Multiset.Nat.nodup_antidiagonal
@[simp]
theorem antidiagonal_succ {n : ℕ} :
antidiagonal (n + 1) = (0, n + 1) ::ₘ (antidiagonal n).map (Prod.map Nat.succ id) := by
simp only [antidiagonal, List.Nat.antidiagonal_succ, map_coe, cons_coe]
#align multiset.nat.antidiagonal_succ Multiset.Nat.antidiagonal_succ
theorem antidiagonal_succ' {n : ℕ} :
antidiagonal (n + 1) = (n + 1, 0) ::ₘ (antidiagonal n).map (Prod.map id Nat.succ) := by
rw [antidiagonal, List.Nat.antidiagonal_succ', ← coe_add, add_comm, antidiagonal, map_coe,
coe_add, List.singleton_append, cons_coe]
#align multiset.nat.antidiagonal_succ' Multiset.Nat.antidiagonal_succ'
theorem antidiagonal_succ_succ' {n : ℕ} :
antidiagonal (n + 2) =
(0, n + 2) ::ₘ (n + 2, 0) ::ₘ (antidiagonal n).map (Prod.map Nat.succ Nat.succ) := by
rw [antidiagonal_succ, antidiagonal_succ', map_cons, map_map, Prod.map_apply]
rfl
#align multiset.nat.antidiagonal_succ_succ' Multiset.Nat.antidiagonal_succ_succ'
| Mathlib/Data/Multiset/NatAntidiagonal.lean | 77 | 78 | theorem map_swap_antidiagonal {n : ℕ} : (antidiagonal n).map Prod.swap = antidiagonal n := by |
rw [antidiagonal, map_coe, List.Nat.map_swap_antidiagonal, coe_reverse]
| 1 | 2.718282 | 0 | 0.333333 | 6 | 362 |
import Mathlib.Init.Algebra.Classes
import Mathlib.Logic.Nontrivial.Basic
import Mathlib.Order.BoundedOrder
import Mathlib.Data.Option.NAry
import Mathlib.Tactic.Lift
import Mathlib.Data.Option.Basic
#align_import order.with_bot from "leanprover-community/mathlib"@"0111834459f5d7400215223ea95ae38a1265a907"
variable {α β γ δ : Type*}
def WithBot (α : Type*) :=
Option α
#align with_bot WithBot
namespace WithBot
variable {a b : α}
instance [Repr α] : Repr (WithBot α) :=
⟨fun o _ =>
match o with
| none => "⊥"
| some a => "↑" ++ repr a⟩
@[coe, match_pattern] def some : α → WithBot α :=
Option.some
-- Porting note: changed this from `CoeTC` to `Coe` but I am not 100% confident that's correct.
instance coe : Coe α (WithBot α) :=
⟨some⟩
instance bot : Bot (WithBot α) :=
⟨none⟩
instance inhabited : Inhabited (WithBot α) :=
⟨⊥⟩
instance nontrivial [Nonempty α] : Nontrivial (WithBot α) :=
Option.nontrivial
open Function
theorem coe_injective : Injective ((↑) : α → WithBot α) :=
Option.some_injective _
#align with_bot.coe_injective WithBot.coe_injective
@[simp, norm_cast]
theorem coe_inj : (a : WithBot α) = b ↔ a = b :=
Option.some_inj
#align with_bot.coe_inj WithBot.coe_inj
protected theorem «forall» {p : WithBot α → Prop} : (∀ x, p x) ↔ p ⊥ ∧ ∀ x : α, p x :=
Option.forall
#align with_bot.forall WithBot.forall
protected theorem «exists» {p : WithBot α → Prop} : (∃ x, p x) ↔ p ⊥ ∨ ∃ x : α, p x :=
Option.exists
#align with_bot.exists WithBot.exists
theorem none_eq_bot : (none : WithBot α) = (⊥ : WithBot α) :=
rfl
#align with_bot.none_eq_bot WithBot.none_eq_bot
theorem some_eq_coe (a : α) : (Option.some a : WithBot α) = (↑a : WithBot α) :=
rfl
#align with_bot.some_eq_coe WithBot.some_eq_coe
@[simp]
theorem bot_ne_coe : ⊥ ≠ (a : WithBot α) :=
nofun
#align with_bot.bot_ne_coe WithBot.bot_ne_coe
@[simp]
theorem coe_ne_bot : (a : WithBot α) ≠ ⊥ :=
nofun
#align with_bot.coe_ne_bot WithBot.coe_ne_bot
@[elab_as_elim, induction_eliminator, cases_eliminator]
def recBotCoe {C : WithBot α → Sort*} (bot : C ⊥) (coe : ∀ a : α, C a) : ∀ n : WithBot α, C n
| ⊥ => bot
| (a : α) => coe a
#align with_bot.rec_bot_coe WithBot.recBotCoe
@[simp]
theorem recBotCoe_bot {C : WithBot α → Sort*} (d : C ⊥) (f : ∀ a : α, C a) :
@recBotCoe _ C d f ⊥ = d :=
rfl
#align with_bot.rec_bot_coe_bot WithBot.recBotCoe_bot
@[simp]
theorem recBotCoe_coe {C : WithBot α → Sort*} (d : C ⊥) (f : ∀ a : α, C a) (x : α) :
@recBotCoe _ C d f ↑x = f x :=
rfl
#align with_bot.rec_bot_coe_coe WithBot.recBotCoe_coe
def unbot' (d : α) (x : WithBot α) : α :=
recBotCoe d id x
#align with_bot.unbot' WithBot.unbot'
@[simp]
theorem unbot'_bot {α} (d : α) : unbot' d ⊥ = d :=
rfl
#align with_bot.unbot'_bot WithBot.unbot'_bot
@[simp]
theorem unbot'_coe {α} (d x : α) : unbot' d x = x :=
rfl
#align with_bot.unbot'_coe WithBot.unbot'_coe
theorem coe_eq_coe : (a : WithBot α) = b ↔ a = b := coe_inj
#align with_bot.coe_eq_coe WithBot.coe_eq_coe
| Mathlib/Order/WithBot.lean | 135 | 136 | theorem unbot'_eq_iff {d y : α} {x : WithBot α} : unbot' d x = y ↔ x = y ∨ x = ⊥ ∧ y = d := by |
induction x <;> simp [@eq_comm _ d]
| 1 | 2.718282 | 0 | 0 | 2 | 213 |
import Mathlib.Data.Multiset.Sum
import Mathlib.Data.Finset.Card
#align_import data.finset.sum from "leanprover-community/mathlib"@"48a058d7e39a80ed56858505719a0b2197900999"
open Function Multiset Sum
namespace Finset
variable {α β : Type*} (s : Finset α) (t : Finset β)
def disjSum : Finset (Sum α β) :=
⟨s.1.disjSum t.1, s.2.disjSum t.2⟩
#align finset.disj_sum Finset.disjSum
@[simp]
theorem val_disjSum : (s.disjSum t).1 = s.1.disjSum t.1 :=
rfl
#align finset.val_disj_sum Finset.val_disjSum
@[simp]
theorem empty_disjSum : (∅ : Finset α).disjSum t = t.map Embedding.inr :=
val_inj.1 <| Multiset.zero_disjSum _
#align finset.empty_disj_sum Finset.empty_disjSum
@[simp]
theorem disjSum_empty : s.disjSum (∅ : Finset β) = s.map Embedding.inl :=
val_inj.1 <| Multiset.disjSum_zero _
#align finset.disj_sum_empty Finset.disjSum_empty
@[simp]
theorem card_disjSum : (s.disjSum t).card = s.card + t.card :=
Multiset.card_disjSum _ _
#align finset.card_disj_sum Finset.card_disjSum
theorem disjoint_map_inl_map_inr : Disjoint (s.map Embedding.inl) (t.map Embedding.inr) := by
simp_rw [disjoint_left, mem_map]
rintro x ⟨a, _, rfl⟩ ⟨b, _, ⟨⟩⟩
#align finset.disjoint_map_inl_map_inr Finset.disjoint_map_inl_map_inr
@[simp]
theorem map_inl_disjUnion_map_inr :
(s.map Embedding.inl).disjUnion (t.map Embedding.inr) (disjoint_map_inl_map_inr _ _) =
s.disjSum t :=
rfl
#align finset.map_inl_disj_union_map_inr Finset.map_inl_disjUnion_map_inr
variable {s t} {s₁ s₂ : Finset α} {t₁ t₂ : Finset β} {a : α} {b : β} {x : Sum α β}
theorem mem_disjSum : x ∈ s.disjSum t ↔ (∃ a, a ∈ s ∧ inl a = x) ∨ ∃ b, b ∈ t ∧ inr b = x :=
Multiset.mem_disjSum
#align finset.mem_disj_sum Finset.mem_disjSum
@[simp]
theorem inl_mem_disjSum : inl a ∈ s.disjSum t ↔ a ∈ s :=
Multiset.inl_mem_disjSum
#align finset.inl_mem_disj_sum Finset.inl_mem_disjSum
@[simp]
theorem inr_mem_disjSum : inr b ∈ s.disjSum t ↔ b ∈ t :=
Multiset.inr_mem_disjSum
#align finset.inr_mem_disj_sum Finset.inr_mem_disjSum
@[simp]
| Mathlib/Data/Finset/Sum.lean | 83 | 83 | theorem disjSum_eq_empty : s.disjSum t = ∅ ↔ s = ∅ ∧ t = ∅ := by | simp [ext_iff]
| 1 | 2.718282 | 0 | 0.5 | 2 | 500 |
import Mathlib.Algebra.FreeMonoid.Basic
import Mathlib.Algebra.Group.Submonoid.MulOpposite
import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Data.Finset.NoncommProd
import Mathlib.Data.Int.Order.Lemmas
#align_import group_theory.submonoid.membership from "leanprover-community/mathlib"@"e655e4ea5c6d02854696f97494997ba4c31be802"
variable {M A B : Type*}
section Assoc
variable [Monoid M] [SetLike B M] [SubmonoidClass B M] {S : B}
namespace Submonoid
variable [Monoid M] {a : M}
open MonoidHom
theorem closure_singleton_eq (x : M) : closure ({x} : Set M) = mrange (powersHom M x) :=
closure_eq_of_le (Set.singleton_subset_iff.2 ⟨Multiplicative.ofAdd 1, pow_one x⟩) fun _ ⟨_, hn⟩ =>
hn ▸ pow_mem (subset_closure <| Set.mem_singleton _) _
#align submonoid.closure_singleton_eq Submonoid.closure_singleton_eq
theorem mem_closure_singleton {x y : M} : y ∈ closure ({x} : Set M) ↔ ∃ n : ℕ, x ^ n = y := by
rw [closure_singleton_eq, mem_mrange]; rfl
#align submonoid.mem_closure_singleton Submonoid.mem_closure_singleton
theorem mem_closure_singleton_self {y : M} : y ∈ closure ({y} : Set M) :=
mem_closure_singleton.2 ⟨1, pow_one y⟩
#align submonoid.mem_closure_singleton_self Submonoid.mem_closure_singleton_self
| Mathlib/Algebra/Group/Submonoid/Membership.lean | 340 | 341 | theorem closure_singleton_one : closure ({1} : Set M) = ⊥ := by |
simp [eq_bot_iff_forall, mem_closure_singleton]
| 1 | 2.718282 | 0 | 0.875 | 8 | 759 |
import Mathlib.Combinatorics.SimpleGraph.Dart
import Mathlib.Data.FunLike.Fintype
open Function
namespace SimpleGraph
variable {V W X : Type*} (G : SimpleGraph V) (G' : SimpleGraph W) {u v : V}
protected def map (f : V ↪ W) (G : SimpleGraph V) : SimpleGraph W where
Adj := Relation.Map G.Adj f f
symm a b := by -- Porting note: `obviously` used to handle this
rintro ⟨v, w, h, rfl, rfl⟩
use w, v, h.symm, rfl
loopless a := by -- Porting note: `obviously` used to handle this
rintro ⟨v, w, h, rfl, h'⟩
exact h.ne (f.injective h'.symm)
#align simple_graph.map SimpleGraph.map
instance instDecidableMapAdj {f : V ↪ W} {a b} [Decidable (Relation.Map G.Adj f f a b)] :
Decidable ((G.map f).Adj a b) := ‹Decidable (Relation.Map G.Adj f f a b)›
#align simple_graph.decidable_map SimpleGraph.instDecidableMapAdj
@[simp]
theorem map_adj (f : V ↪ W) (G : SimpleGraph V) (u v : W) :
(G.map f).Adj u v ↔ ∃ u' v' : V, G.Adj u' v' ∧ f u' = u ∧ f v' = v :=
Iff.rfl
#align simple_graph.map_adj SimpleGraph.map_adj
lemma map_adj_apply {G : SimpleGraph V} {f : V ↪ W} {a b : V} :
(G.map f).Adj (f a) (f b) ↔ G.Adj a b := by simp
#align simple_graph.map_adj_apply SimpleGraph.map_adj_apply
theorem map_monotone (f : V ↪ W) : Monotone (SimpleGraph.map f) := by
rintro G G' h _ _ ⟨u, v, ha, rfl, rfl⟩
exact ⟨_, _, h ha, rfl, rfl⟩
#align simple_graph.map_monotone SimpleGraph.map_monotone
@[simp] lemma map_id : G.map (Function.Embedding.refl _) = G :=
SimpleGraph.ext _ _ <| Relation.map_id_id _
#align simple_graph.map_id SimpleGraph.map_id
@[simp] lemma map_map (f : V ↪ W) (g : W ↪ X) : (G.map f).map g = G.map (f.trans g) :=
SimpleGraph.ext _ _ <| Relation.map_map _ _ _ _ _
#align simple_graph.map_map SimpleGraph.map_map
protected def comap (f : V → W) (G : SimpleGraph W) : SimpleGraph V where
Adj u v := G.Adj (f u) (f v)
symm _ _ h := h.symm
loopless _ := G.loopless _
#align simple_graph.comap SimpleGraph.comap
@[simp] lemma comap_adj {G : SimpleGraph W} {f : V → W} :
(G.comap f).Adj u v ↔ G.Adj (f u) (f v) := Iff.rfl
@[simp] lemma comap_id {G : SimpleGraph V} : G.comap id = G := SimpleGraph.ext _ _ rfl
#align simple_graph.comap_id SimpleGraph.comap_id
@[simp] lemma comap_comap {G : SimpleGraph X} (f : V → W) (g : W → X) :
(G.comap g).comap f = G.comap (g ∘ f) := rfl
#align simple_graph.comap_comap SimpleGraph.comap_comap
instance instDecidableComapAdj (f : V → W) (G : SimpleGraph W) [DecidableRel G.Adj] :
DecidableRel (G.comap f).Adj := fun _ _ ↦ ‹DecidableRel G.Adj› _ _
lemma comap_symm (G : SimpleGraph V) (e : V ≃ W) :
G.comap e.symm.toEmbedding = G.map e.toEmbedding := by
ext; simp only [Equiv.apply_eq_iff_eq_symm_apply, comap_adj, map_adj, Equiv.toEmbedding_apply,
exists_eq_right_right, exists_eq_right]
#align simple_graph.comap_symm SimpleGraph.comap_symm
lemma map_symm (G : SimpleGraph W) (e : V ≃ W) :
G.map e.symm.toEmbedding = G.comap e.toEmbedding := by rw [← comap_symm, e.symm_symm]
#align simple_graph.map_symm SimpleGraph.map_symm
theorem comap_monotone (f : V ↪ W) : Monotone (SimpleGraph.comap f) := by
intro G G' h _ _ ha
exact h ha
#align simple_graph.comap_monotone SimpleGraph.comap_monotone
@[simp]
theorem comap_map_eq (f : V ↪ W) (G : SimpleGraph V) : (G.map f).comap f = G := by
ext
simp
#align simple_graph.comap_map_eq SimpleGraph.comap_map_eq
theorem leftInverse_comap_map (f : V ↪ W) :
Function.LeftInverse (SimpleGraph.comap f) (SimpleGraph.map f) :=
comap_map_eq f
#align simple_graph.left_inverse_comap_map SimpleGraph.leftInverse_comap_map
theorem map_injective (f : V ↪ W) : Function.Injective (SimpleGraph.map f) :=
(leftInverse_comap_map f).injective
#align simple_graph.map_injective SimpleGraph.map_injective
theorem comap_surjective (f : V ↪ W) : Function.Surjective (SimpleGraph.comap f) :=
(leftInverse_comap_map f).surjective
#align simple_graph.comap_surjective SimpleGraph.comap_surjective
theorem map_le_iff_le_comap (f : V ↪ W) (G : SimpleGraph V) (G' : SimpleGraph W) :
G.map f ≤ G' ↔ G ≤ G'.comap f :=
⟨fun h u v ha => h ⟨_, _, ha, rfl, rfl⟩, by
rintro h _ _ ⟨u, v, ha, rfl, rfl⟩
exact h ha⟩
#align simple_graph.map_le_iff_le_comap SimpleGraph.map_le_iff_le_comap
| Mathlib/Combinatorics/SimpleGraph/Maps.lean | 154 | 155 | theorem map_comap_le (f : V ↪ W) (G : SimpleGraph W) : (G.comap f).map f ≤ G := by |
rw [map_le_iff_le_comap]
| 1 | 2.718282 | 0 | 0.75 | 4 | 677 |
import Mathlib.Control.Functor
import Mathlib.Tactic.Common
#align_import control.bifunctor from "leanprover-community/mathlib"@"dc1525fb3ef6eb4348fb1749c302d8abc303d34a"
universe u₀ u₁ u₂ v₀ v₁ v₂
open Function
class Bifunctor (F : Type u₀ → Type u₁ → Type u₂) where
bimap : ∀ {α α' β β'}, (α → α') → (β → β') → F α β → F α' β'
#align bifunctor Bifunctor
export Bifunctor (bimap)
class LawfulBifunctor (F : Type u₀ → Type u₁ → Type u₂) [Bifunctor F] : Prop where
id_bimap : ∀ {α β} (x : F α β), bimap id id x = x
bimap_bimap :
∀ {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀),
bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x
#align is_lawful_bifunctor LawfulBifunctor
export LawfulBifunctor (id_bimap bimap_bimap)
attribute [higher_order bimap_id_id] id_bimap
#align is_lawful_bifunctor.bimap_id_id LawfulBifunctor.bimap_id_id
attribute [higher_order bimap_comp_bimap] bimap_bimap
#align is_lawful_bifunctor.bimap_comp_bimap LawfulBifunctor.bimap_comp_bimap
export LawfulBifunctor (bimap_id_id bimap_comp_bimap)
variable {F : Type u₀ → Type u₁ → Type u₂} [Bifunctor F]
namespace Bifunctor
abbrev fst {α α' β} (f : α → α') : F α β → F α' β :=
bimap f id
#align bifunctor.fst Bifunctor.fst
abbrev snd {α β β'} (f : β → β') : F α β → F α β' :=
bimap id f
#align bifunctor.snd Bifunctor.snd
variable [LawfulBifunctor F]
@[higher_order fst_id]
theorem id_fst : ∀ {α β} (x : F α β), fst id x = x :=
@id_bimap _ _ _
#align bifunctor.id_fst Bifunctor.id_fst
#align bifunctor.fst_id Bifunctor.fst_id
@[higher_order snd_id]
theorem id_snd : ∀ {α β} (x : F α β), snd id x = x :=
@id_bimap _ _ _
#align bifunctor.id_snd Bifunctor.id_snd
#align bifunctor.snd_id Bifunctor.snd_id
@[higher_order fst_comp_fst]
theorem comp_fst {α₀ α₁ α₂ β} (f : α₀ → α₁) (f' : α₁ → α₂) (x : F α₀ β) :
fst f' (fst f x) = fst (f' ∘ f) x := by simp [fst, bimap_bimap]
#align bifunctor.comp_fst Bifunctor.comp_fst
#align bifunctor.fst_comp_fst Bifunctor.fst_comp_fst
@[higher_order fst_comp_snd]
| Mathlib/Control/Bifunctor.lean | 92 | 93 | theorem fst_snd {α₀ α₁ β₀ β₁} (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :
fst f (snd f' x) = bimap f f' x := by | simp [fst, bimap_bimap]
| 1 | 2.718282 | 0 | 0 | 4 | 164 |
import Mathlib.Data.Multiset.Nodup
#align_import data.multiset.sum from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
open Sum
namespace Multiset
variable {α β : Type*} (s : Multiset α) (t : Multiset β)
def disjSum : Multiset (Sum α β) :=
s.map inl + t.map inr
#align multiset.disj_sum Multiset.disjSum
@[simp]
theorem zero_disjSum : (0 : Multiset α).disjSum t = t.map inr :=
zero_add _
#align multiset.zero_disj_sum Multiset.zero_disjSum
@[simp]
theorem disjSum_zero : s.disjSum (0 : Multiset β) = s.map inl :=
add_zero _
#align multiset.disj_sum_zero Multiset.disjSum_zero
@[simp]
theorem card_disjSum : Multiset.card (s.disjSum t) = Multiset.card s + Multiset.card t := by
rw [disjSum, card_add, card_map, card_map]
#align multiset.card_disj_sum Multiset.card_disjSum
variable {s t} {s₁ s₂ : Multiset α} {t₁ t₂ : Multiset β} {a : α} {b : β} {x : Sum α β}
| Mathlib/Data/Multiset/Sum.lean | 50 | 51 | theorem mem_disjSum : x ∈ s.disjSum t ↔ (∃ a, a ∈ s ∧ inl a = x) ∨ ∃ b, b ∈ t ∧ inr b = x := by |
simp_rw [disjSum, mem_add, mem_map]
| 1 | 2.718282 | 0 | 1 | 4 | 1,085 |
import Mathlib.MeasureTheory.Function.LpOrder
#align_import measure_theory.function.l1_space from "leanprover-community/mathlib"@"ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f"
noncomputable section
open scoped Classical
open Topology ENNReal MeasureTheory NNReal
open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory
variable {α β γ δ : Type*} {m : MeasurableSpace α} {μ ν : Measure α} [MeasurableSpace δ]
variable [NormedAddCommGroup β]
variable [NormedAddCommGroup γ]
namespace MeasureTheory
theorem lintegral_nnnorm_eq_lintegral_edist (f : α → β) :
∫⁻ a, ‖f a‖₊ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [edist_eq_coe_nnnorm]
#align measure_theory.lintegral_nnnorm_eq_lintegral_edist MeasureTheory.lintegral_nnnorm_eq_lintegral_edist
theorem lintegral_norm_eq_lintegral_edist (f : α → β) :
∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by
simp only [ofReal_norm_eq_coe_nnnorm, edist_eq_coe_nnnorm]
#align measure_theory.lintegral_norm_eq_lintegral_edist MeasureTheory.lintegral_norm_eq_lintegral_edist
theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ)
(hh : AEStronglyMeasurable h μ) :
(∫⁻ a, edist (f a) (g a) ∂μ) ≤ (∫⁻ a, edist (f a) (h a) ∂μ) + ∫⁻ a, edist (g a) (h a) ∂μ := by
rw [← lintegral_add_left' (hf.edist hh)]
refine lintegral_mono fun a => ?_
apply edist_triangle_right
#align measure_theory.lintegral_edist_triangle MeasureTheory.lintegral_edist_triangle
theorem lintegral_nnnorm_zero : (∫⁻ _ : α, ‖(0 : β)‖₊ ∂μ) = 0 := by simp
#align measure_theory.lintegral_nnnorm_zero MeasureTheory.lintegral_nnnorm_zero
theorem lintegral_nnnorm_add_left {f : α → β} (hf : AEStronglyMeasurable f μ) (g : α → γ) :
∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ :=
lintegral_add_left' hf.ennnorm _
#align measure_theory.lintegral_nnnorm_add_left MeasureTheory.lintegral_nnnorm_add_left
theorem lintegral_nnnorm_add_right (f : α → β) {g : α → γ} (hg : AEStronglyMeasurable g μ) :
∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ :=
lintegral_add_right' _ hg.ennnorm
#align measure_theory.lintegral_nnnorm_add_right MeasureTheory.lintegral_nnnorm_add_right
| Mathlib/MeasureTheory/Function/L1Space.lean | 96 | 97 | theorem lintegral_nnnorm_neg {f : α → β} : (∫⁻ a, ‖(-f) a‖₊ ∂μ) = ∫⁻ a, ‖f a‖₊ ∂μ := by |
simp only [Pi.neg_apply, nnnorm_neg]
| 1 | 2.718282 | 0 | 0.3 | 10 | 320 |
import Mathlib.Topology.Algebra.InfiniteSum.Basic
import Mathlib.Topology.Algebra.UniformGroup
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
section TopologicalGroup
variable [CommGroup α] [TopologicalSpace α] [TopologicalGroup α]
variable {f g : β → α} {a a₁ a₂ : α}
-- `by simpa using` speeds up elaboration. Why?
@[to_additive]
theorem HasProd.inv (h : HasProd f a) : HasProd (fun b ↦ (f b)⁻¹) a⁻¹ := by
simpa only using h.map (MonoidHom.id α)⁻¹ continuous_inv
#align has_sum.neg HasSum.neg
@[to_additive]
theorem Multipliable.inv (hf : Multipliable f) : Multipliable fun b ↦ (f b)⁻¹ :=
hf.hasProd.inv.multipliable
#align summable.neg Summable.neg
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Group.lean | 40 | 41 | theorem Multipliable.of_inv (hf : Multipliable fun b ↦ (f b)⁻¹) : Multipliable f := by |
simpa only [inv_inv] using hf.inv
| 1 | 2.718282 | 0 | 0.833333 | 6 | 738 |
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
theorem mul : mapFun f (x * y) = mapFun f x * mapFun f y := by map_fun_tac
#align witt_vector.map_fun.mul WittVector.mapFun.mul
theorem neg : mapFun f (-x) = -mapFun f x := by map_fun_tac
#align witt_vector.map_fun.neg WittVector.mapFun.neg
| Mathlib/RingTheory/WittVector/Basic.lean | 120 | 120 | theorem nsmul (n : ℕ) (x : WittVector p R) : mapFun f (n • x) = n • mapFun f x := by | map_fun_tac
| 1 | 2.718282 | 0 | 0.090909 | 11 | 242 |
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.SetTheory.Ordinal.Basic
import Mathlib.Topology.ContinuousFunction.Algebra
import Mathlib.Topology.Compactness.Paracompact
import Mathlib.Topology.ShrinkingLemma
import Mathlib.Topology.UrysohnsLemma
#align_import topology.partition_of_unity from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
universe u v
open Function Set Filter
open scoped Classical
open Topology
noncomputable section
structure PartitionOfUnity (ι X : Type*) [TopologicalSpace X] (s : Set X := univ) where
toFun : ι → C(X, ℝ)
locallyFinite' : LocallyFinite fun i => support (toFun i)
nonneg' : 0 ≤ toFun
sum_eq_one' : ∀ x ∈ s, ∑ᶠ i, toFun i x = 1
sum_le_one' : ∀ x, ∑ᶠ i, toFun i x ≤ 1
#align partition_of_unity PartitionOfUnity
structure BumpCovering (ι X : Type*) [TopologicalSpace X] (s : Set X := univ) where
toFun : ι → C(X, ℝ)
locallyFinite' : LocallyFinite fun i => support (toFun i)
nonneg' : 0 ≤ toFun
le_one' : toFun ≤ 1
eventuallyEq_one' : ∀ x ∈ s, ∃ i, toFun i =ᶠ[𝓝 x] 1
#align bump_covering BumpCovering
variable {ι : Type u} {X : Type v} [TopologicalSpace X]
namespace PartitionOfUnity
variable {E : Type*} [AddCommMonoid E] [SMulWithZero ℝ E] [TopologicalSpace E] [ContinuousSMul ℝ E]
{s : Set X} (f : PartitionOfUnity ι X s)
instance : FunLike (PartitionOfUnity ι X s) ι C(X, ℝ) where
coe := toFun
coe_injective' := fun f g h ↦ by cases f; cases g; congr
protected theorem locallyFinite : LocallyFinite fun i => support (f i) :=
f.locallyFinite'
#align partition_of_unity.locally_finite PartitionOfUnity.locallyFinite
theorem locallyFinite_tsupport : LocallyFinite fun i => tsupport (f i) :=
f.locallyFinite.closure
#align partition_of_unity.locally_finite_tsupport PartitionOfUnity.locallyFinite_tsupport
theorem nonneg (i : ι) (x : X) : 0 ≤ f i x :=
f.nonneg' i x
#align partition_of_unity.nonneg PartitionOfUnity.nonneg
theorem sum_eq_one {x : X} (hx : x ∈ s) : ∑ᶠ i, f i x = 1 :=
f.sum_eq_one' x hx
#align partition_of_unity.sum_eq_one PartitionOfUnity.sum_eq_one
theorem exists_pos {x : X} (hx : x ∈ s) : ∃ i, 0 < f i x := by
have H := f.sum_eq_one hx
contrapose! H
simpa only [fun i => (H i).antisymm (f.nonneg i x), finsum_zero] using zero_ne_one
#align partition_of_unity.exists_pos PartitionOfUnity.exists_pos
theorem sum_le_one (x : X) : ∑ᶠ i, f i x ≤ 1 :=
f.sum_le_one' x
#align partition_of_unity.sum_le_one PartitionOfUnity.sum_le_one
theorem sum_nonneg (x : X) : 0 ≤ ∑ᶠ i, f i x :=
finsum_nonneg fun i => f.nonneg i x
#align partition_of_unity.sum_nonneg PartitionOfUnity.sum_nonneg
theorem le_one (i : ι) (x : X) : f i x ≤ 1 :=
(single_le_finsum i (f.locallyFinite.point_finite x) fun j => f.nonneg j x).trans (f.sum_le_one x)
#align partition_of_unity.le_one PartitionOfUnity.le_one
section finsupport
variable {s : Set X} (ρ : PartitionOfUnity ι X s) (x₀ : X)
def finsupport : Finset ι := (ρ.locallyFinite.point_finite x₀).toFinset
@[simp]
| Mathlib/Topology/PartitionOfUnity.lean | 188 | 190 | theorem mem_finsupport (x₀ : X) {i} :
i ∈ ρ.finsupport x₀ ↔ i ∈ support fun i ↦ ρ i x₀ := by |
simp only [finsupport, mem_support, Finite.mem_toFinset, mem_setOf_eq]
| 1 | 2.718282 | 0 | 1.3 | 10 | 1,365 |
import Mathlib.Data.List.Range
import Mathlib.Algebra.Order.Ring.Nat
variable {α : Type*}
namespace List
@[simp]
theorem length_iterate (f : α → α) (a : α) (n : ℕ) : length (iterate f a n) = n := by
induction n generalizing a <;> simp [*]
@[simp]
theorem iterate_eq_nil {f : α → α} {a : α} {n : ℕ} : iterate f a n = [] ↔ n = 0 := by
rw [← length_eq_zero, length_iterate]
theorem get?_iterate (f : α → α) (a : α) :
∀ (n i : ℕ), i < n → get? (iterate f a n) i = f^[i] a
| n + 1, 0 , _ => rfl
| n + 1, i + 1, h => by simp [get?_iterate f (f a) n i (by simpa using h)]
@[simp]
theorem get_iterate (f : α → α) (a : α) (n : ℕ) (i : Fin (iterate f a n).length) :
get (iterate f a n) i = f^[↑i] a :=
(get?_eq_some.1 <| get?_iterate f a n i.1 (by simpa using i.2)).2
@[simp]
theorem mem_iterate {f : α → α} {a : α} {n : ℕ} {b : α} :
b ∈ iterate f a n ↔ ∃ m < n, b = f^[m] a := by
simp [List.mem_iff_get, Fin.exists_iff, eq_comm (b := b)]
@[simp]
theorem range_map_iterate (n : ℕ) (f : α → α) (a : α) :
(List.range n).map (f^[·] a) = List.iterate f a n := by
apply List.ext_get <;> simp
theorem iterate_add (f : α → α) (a : α) (m n : ℕ) :
iterate f a (m + n) = iterate f a m ++ iterate f (f^[m] a) n := by
induction m generalizing a with
| zero => simp
| succ n ih => rw [iterate, add_right_comm, iterate, ih, Nat.iterate, cons_append]
| Mathlib/Data/List/Iterate.lean | 54 | 56 | theorem take_iterate (f : α → α) (a : α) (m n : ℕ) :
take m (iterate f a n) = iterate f a (min m n) := by |
rw [← range_map_iterate, ← range_map_iterate, ← map_take, take_range]
| 1 | 2.718282 | 0 | 0.166667 | 6 | 264 |
import Mathlib.Combinatorics.SimpleGraph.Basic
import Mathlib.Combinatorics.SimpleGraph.Connectivity
import Mathlib.LinearAlgebra.Matrix.Trace
import Mathlib.LinearAlgebra.Matrix.Symmetric
#align_import combinatorics.simple_graph.adj_matrix from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
open Matrix
open Finset Matrix SimpleGraph
variable {V α β : Type*}
namespace Matrix
structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where
zero_or_one : ∀ i j, A i j = 0 ∨ A i j = 1 := by aesop
symm : A.IsSymm := by aesop
apply_diag : ∀ i, A i i = 0 := by aesop
#align matrix.is_adj_matrix Matrix.IsAdjMatrix
def compl [Zero α] [One α] [DecidableEq α] [DecidableEq V] (A : Matrix V V α) : Matrix V V α :=
fun i j => ite (i = j) 0 (ite (A i j = 0) 1 0)
#align matrix.compl Matrix.compl
section Compl
variable [DecidableEq α] [DecidableEq V] (A : Matrix V V α)
@[simp]
theorem compl_apply_diag [Zero α] [One α] (i : V) : A.compl i i = 0 := by simp [compl]
#align matrix.compl_apply_diag Matrix.compl_apply_diag
@[simp]
theorem compl_apply [Zero α] [One α] (i j : V) : A.compl i j = 0 ∨ A.compl i j = 1 := by
unfold compl
split_ifs <;> simp
#align matrix.compl_apply Matrix.compl_apply
@[simp]
theorem isSymm_compl [Zero α] [One α] (h : A.IsSymm) : A.compl.IsSymm := by
ext
simp [compl, h.apply, eq_comm]
#align matrix.is_symm_compl Matrix.isSymm_compl
@[simp]
| Mathlib/Combinatorics/SimpleGraph/AdjMatrix.lean | 121 | 122 | theorem isAdjMatrix_compl [Zero α] [One α] (h : A.IsSymm) : IsAdjMatrix A.compl :=
{ symm := by | simp [h] }
| 1 | 2.718282 | 0 | 0.285714 | 7 | 315 |
import Mathlib.Data.Nat.Defs
import Mathlib.Tactic.GCongr.Core
import Mathlib.Tactic.Common
import Mathlib.Tactic.Monotonicity.Attr
#align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105"
namespace Nat
def factorial : ℕ → ℕ
| 0 => 1
| succ n => succ n * factorial n
#align nat.factorial Nat.factorial
scoped notation:10000 n "!" => Nat.factorial n
section DescFactorial
def descFactorial (n : ℕ) : ℕ → ℕ
| 0 => 1
| k + 1 => (n - k) * descFactorial n k
#align nat.desc_factorial Nat.descFactorial
@[simp]
theorem descFactorial_zero (n : ℕ) : n.descFactorial 0 = 1 :=
rfl
#align nat.desc_factorial_zero Nat.descFactorial_zero
@[simp]
theorem descFactorial_succ (n k : ℕ) : n.descFactorial (k + 1) = (n - k) * n.descFactorial k :=
rfl
#align nat.desc_factorial_succ Nat.descFactorial_succ
| Mathlib/Data/Nat/Factorial/Basic.lean | 340 | 341 | theorem zero_descFactorial_succ (k : ℕ) : (0 : ℕ).descFactorial (k + 1) = 0 := by |
rw [descFactorial_succ, Nat.zero_sub, Nat.zero_mul]
| 1 | 2.718282 | 0 | 1.333333 | 9 | 1,434 |
import Mathlib.Topology.Algebra.InfiniteSum.Defs
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Topology.Algebra.Monoid
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
section HasProd
variable [CommMonoid α] [TopologicalSpace α]
variable {f g : β → α} {a b : α} {s : Finset β}
@[to_additive "Constant zero function has sum `0`"]
theorem hasProd_one : HasProd (fun _ ↦ 1 : β → α) 1 := by simp [HasProd, tendsto_const_nhds]
#align has_sum_zero hasSum_zero
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Basic.lean | 39 | 40 | theorem hasProd_empty [IsEmpty β] : HasProd f 1 := by |
convert @hasProd_one α β _ _
| 1 | 2.718282 | 0 | 0.2 | 5 | 271 |
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Dynamics.FixedPoints.Basic
open Finset Function
section AddCommMonoid
variable {α M : Type*} [AddCommMonoid M]
def birkhoffSum (f : α → α) (g : α → M) (n : ℕ) (x : α) : M := ∑ k ∈ range n, g (f^[k] x)
theorem birkhoffSum_zero (f : α → α) (g : α → M) (x : α) : birkhoffSum f g 0 x = 0 :=
sum_range_zero _
@[simp]
theorem birkhoffSum_zero' (f : α → α) (g : α → M) : birkhoffSum f g 0 = 0 :=
funext <| birkhoffSum_zero _ _
theorem birkhoffSum_one (f : α → α) (g : α → M) (x : α) : birkhoffSum f g 1 x = g x :=
sum_range_one _
@[simp]
theorem birkhoffSum_one' (f : α → α) (g : α → M) : birkhoffSum f g 1 = g :=
funext <| birkhoffSum_one f g
theorem birkhoffSum_succ (f : α → α) (g : α → M) (n : ℕ) (x : α) :
birkhoffSum f g (n + 1) x = birkhoffSum f g n x + g (f^[n] x) :=
sum_range_succ _ _
theorem birkhoffSum_succ' (f : α → α) (g : α → M) (n : ℕ) (x : α) :
birkhoffSum f g (n + 1) x = g x + birkhoffSum f g n (f x) :=
(sum_range_succ' _ _).trans (add_comm _ _)
| Mathlib/Dynamics/BirkhoffSum/Basic.lean | 51 | 53 | theorem birkhoffSum_add (f : α → α) (g : α → M) (m n : ℕ) (x : α) :
birkhoffSum f g (m + n) x = birkhoffSum f g m x + birkhoffSum f g n (f^[m] x) := by |
simp_rw [birkhoffSum, sum_range_add, add_comm m, iterate_add_apply]
| 1 | 2.718282 | 0 | 0 | 2 | 59 |
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
import Mathlib.CategoryTheory.Conj
import Mathlib.CategoryTheory.Functor.ReflectsIso
#align_import category_theory.adjunction.reflective from "leanprover-community/mathlib"@"239d882c4fb58361ee8b3b39fb2091320edef10a"
universe v₁ v₂ v₃ u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
open Category Adjunction
variable {C : Type u₁} {D : Type u₂} {E : Type u₃}
variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E]
class Reflective (R : D ⥤ C) extends R.Full, R.Faithful where
L : C ⥤ D
adj : L ⊣ R
#align category_theory.reflective CategoryTheory.Reflective
variable (i : D ⥤ C)
def reflector [Reflective i] : C ⥤ D := Reflective.L (R := i)
def reflectorAdjunction [Reflective i] : reflector i ⊣ i := Reflective.adj
instance [Reflective i] : i.IsRightAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
instance [Reflective i] : (reflector i).IsLeftAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
def Functor.fullyFaithfulOfReflective [Reflective i] : i.FullyFaithful :=
(reflectorAdjunction i).fullyFaithfulROfIsIsoCounit
-- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions.
theorem unit_obj_eq_map_unit [Reflective i] (X : C) :
(reflectorAdjunction i).unit.app (i.obj ((reflector i).obj X)) =
i.map ((reflector i).map ((reflectorAdjunction i).unit.app X)) := by
rw [← cancel_mono (i.map ((reflectorAdjunction i).counit.app ((reflector i).obj X))),
← i.map_comp]
simp
#align category_theory.unit_obj_eq_map_unit CategoryTheory.unit_obj_eq_map_unit
example [Reflective i] {B : D} : IsIso ((reflectorAdjunction i).unit.app (i.obj B)) :=
inferInstance
variable {i}
theorem Functor.essImage.unit_isIso [Reflective i] {A : C} (h : A ∈ i.essImage) :
IsIso ((reflectorAdjunction i).unit.app A) := by
rwa [isIso_unit_app_iff_mem_essImage]
#align category_theory.functor.ess_image.unit_is_iso CategoryTheory.Functor.essImage.unit_isIso
theorem mem_essImage_of_unit_isIso {L : C ⥤ D} (adj : L ⊣ i) (A : C)
[IsIso (adj.unit.app A)] : A ∈ i.essImage :=
⟨L.obj A, ⟨(asIso (adj.unit.app A)).symm⟩⟩
#align category_theory.mem_ess_image_of_unit_is_iso CategoryTheory.mem_essImage_of_unit_isIso
theorem mem_essImage_of_unit_isSplitMono [Reflective i] {A : C}
[IsSplitMono ((reflectorAdjunction i).unit.app A)] : A ∈ i.essImage := by
let η : 𝟭 C ⟶ reflector i ⋙ i := (reflectorAdjunction i).unit
haveI : IsIso (η.app (i.obj ((reflector i).obj A))) :=
Functor.essImage.unit_isIso ((i.obj_mem_essImage _))
have : Epi (η.app A) := by
refine @epi_of_epi _ _ _ _ _ (retraction (η.app A)) (η.app A) ?_
rw [show retraction _ ≫ η.app A = _ from η.naturality (retraction (η.app A))]
apply epi_comp (η.app (i.obj ((reflector i).obj A)))
haveI := isIso_of_epi_of_isSplitMono (η.app A)
exact mem_essImage_of_unit_isIso (reflectorAdjunction i) A
#align category_theory.mem_ess_image_of_unit_is_split_mono CategoryTheory.mem_essImage_of_unit_isSplitMono
instance Reflective.comp (F : C ⥤ D) (G : D ⥤ E) [Reflective F] [Reflective G] :
Reflective (F ⋙ G) where
L := reflector G ⋙ reflector F
adj := (reflectorAdjunction G).comp (reflectorAdjunction F)
#align category_theory.reflective.comp CategoryTheory.Reflective.comp
def unitCompPartialBijectiveAux [Reflective i] (A : C) (B : D) :
(A ⟶ i.obj B) ≃ (i.obj ((reflector i).obj A) ⟶ i.obj B) :=
((reflectorAdjunction i).homEquiv _ _).symm.trans
(Functor.FullyFaithful.ofFullyFaithful i).homEquiv
#align category_theory.unit_comp_partial_bijective_aux CategoryTheory.unitCompPartialBijectiveAux
| Mathlib/CategoryTheory/Adjunction/Reflective.lean | 127 | 130 | theorem unitCompPartialBijectiveAux_symm_apply [Reflective i] {A : C} {B : D}
(f : i.obj ((reflector i).obj A) ⟶ i.obj B) :
(unitCompPartialBijectiveAux _ _).symm f = (reflectorAdjunction i).unit.app A ≫ f := by |
simp [unitCompPartialBijectiveAux]
| 1 | 2.718282 | 0 | 0.6 | 5 | 538 |
import Mathlib.Data.List.Forall2
#align_import data.list.zip from "leanprover-community/mathlib"@"134625f523e737f650a6ea7f0c82a6177e45e622"
-- Make sure we don't import algebra
assert_not_exists Monoid
universe u
open Nat
namespace List
variable {α : Type u} {β γ δ ε : Type*}
#align list.zip_with_cons_cons List.zipWith_cons_cons
#align list.zip_cons_cons List.zip_cons_cons
#align list.zip_with_nil_left List.zipWith_nil_left
#align list.zip_with_nil_right List.zipWith_nil_right
#align list.zip_with_eq_nil_iff List.zipWith_eq_nil_iff
#align list.zip_nil_left List.zip_nil_left
#align list.zip_nil_right List.zip_nil_right
@[simp]
theorem zip_swap : ∀ (l₁ : List α) (l₂ : List β), (zip l₁ l₂).map Prod.swap = zip l₂ l₁
| [], l₂ => zip_nil_right.symm
| l₁, [] => by rw [zip_nil_right]; rfl
| a :: l₁, b :: l₂ => by
simp only [zip_cons_cons, map_cons, zip_swap l₁ l₂, Prod.swap_prod_mk]
#align list.zip_swap List.zip_swap
#align list.length_zip_with List.length_zipWith
#align list.length_zip List.length_zip
theorem forall_zipWith {f : α → β → γ} {p : γ → Prop} :
∀ {l₁ : List α} {l₂ : List β}, length l₁ = length l₂ →
(Forall p (zipWith f l₁ l₂) ↔ Forall₂ (fun x y => p (f x y)) l₁ l₂)
| [], [], _ => by simp
| a :: l₁, b :: l₂, h => by
simp only [length_cons, succ_inj'] at h
simp [forall_zipWith h]
#align list.all₂_zip_with List.forall_zipWith
theorem lt_length_left_of_zipWith {f : α → β → γ} {i : ℕ} {l : List α} {l' : List β}
(h : i < (zipWith f l l').length) : i < l.length := by rw [length_zipWith] at h; omega
#align list.lt_length_left_of_zip_with List.lt_length_left_of_zipWith
theorem lt_length_right_of_zipWith {f : α → β → γ} {i : ℕ} {l : List α} {l' : List β}
(h : i < (zipWith f l l').length) : i < l'.length := by rw [length_zipWith] at h; omega
#align list.lt_length_right_of_zip_with List.lt_length_right_of_zipWith
theorem lt_length_left_of_zip {i : ℕ} {l : List α} {l' : List β} (h : i < (zip l l').length) :
i < l.length :=
lt_length_left_of_zipWith h
#align list.lt_length_left_of_zip List.lt_length_left_of_zip
theorem lt_length_right_of_zip {i : ℕ} {l : List α} {l' : List β} (h : i < (zip l l').length) :
i < l'.length :=
lt_length_right_of_zipWith h
#align list.lt_length_right_of_zip List.lt_length_right_of_zip
#align list.zip_append List.zip_append
#align list.zip_map List.zip_map
#align list.zip_map_left List.zip_map_left
#align list.zip_map_right List.zip_map_right
#align list.zip_with_map List.zipWith_map
#align list.zip_with_map_left List.zipWith_map_left
#align list.zip_with_map_right List.zipWith_map_right
#align list.zip_map' List.zip_map'
#align list.map_zip_with List.map_zipWith
theorem mem_zip {a b} : ∀ {l₁ : List α} {l₂ : List β}, (a, b) ∈ zip l₁ l₂ → a ∈ l₁ ∧ b ∈ l₂
| _ :: l₁, _ :: l₂, h => by
cases' h with _ _ _ h
· simp
· have := mem_zip h
exact ⟨Mem.tail _ this.1, Mem.tail _ this.2⟩
#align list.mem_zip List.mem_zip
#align list.map_fst_zip List.map_fst_zip
#align list.map_snd_zip List.map_snd_zip
#align list.unzip_nil List.unzip_nil
#align list.unzip_cons List.unzip_cons
theorem unzip_eq_map : ∀ l : List (α × β), unzip l = (l.map Prod.fst, l.map Prod.snd)
| [] => rfl
| (a, b) :: l => by simp only [unzip_cons, map_cons, unzip_eq_map l]
#align list.unzip_eq_map List.unzip_eq_map
theorem unzip_left (l : List (α × β)) : (unzip l).1 = l.map Prod.fst := by simp only [unzip_eq_map]
#align list.unzip_left List.unzip_left
theorem unzip_right (l : List (α × β)) : (unzip l).2 = l.map Prod.snd := by simp only [unzip_eq_map]
#align list.unzip_right List.unzip_right
theorem unzip_swap (l : List (α × β)) : unzip (l.map Prod.swap) = (unzip l).swap := by
simp only [unzip_eq_map, map_map]
rfl
#align list.unzip_swap List.unzip_swap
theorem zip_unzip : ∀ l : List (α × β), zip (unzip l).1 (unzip l).2 = l
| [] => rfl
| (a, b) :: l => by simp only [unzip_cons, zip_cons_cons, zip_unzip l]
#align list.zip_unzip List.zip_unzip
theorem unzip_zip_left :
∀ {l₁ : List α} {l₂ : List β}, length l₁ ≤ length l₂ → (unzip (zip l₁ l₂)).1 = l₁
| [], l₂, _ => rfl
| l₁, [], h => by rw [eq_nil_of_length_eq_zero (Nat.eq_zero_of_le_zero h)]; rfl
| a :: l₁, b :: l₂, h => by
simp only [zip_cons_cons, unzip_cons, unzip_zip_left (le_of_succ_le_succ h)]
#align list.unzip_zip_left List.unzip_zip_left
| Mathlib/Data/List/Zip.lean | 133 | 134 | theorem unzip_zip_right {l₁ : List α} {l₂ : List β} (h : length l₂ ≤ length l₁) :
(unzip (zip l₁ l₂)).2 = l₂ := by | rw [← zip_swap, unzip_swap]; exact unzip_zip_left h
| 1 | 2.718282 | 0 | 0.166667 | 6 | 259 |
import Mathlib.CategoryTheory.Limits.Shapes.WideEqualizers
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
#align_import category_theory.limits.constructions.weakly_initial from "leanprover-community/mathlib"@"239d882c4fb58361ee8b3b39fb2091320edef10a"
universe v u
namespace CategoryTheory
open Limits
variable {C : Type u} [Category.{v} C]
theorem has_weakly_initial_of_weakly_initial_set_and_hasProducts [HasProducts.{v} C] {ι : Type v}
{B : ι → C} (hB : ∀ A : C, ∃ i, Nonempty (B i ⟶ A)) : ∃ T : C, ∀ X, Nonempty (T ⟶ X) :=
⟨∏ᶜ B, fun X => ⟨Pi.π _ _ ≫ (hB X).choose_spec.some⟩⟩
#align category_theory.has_weakly_initial_of_weakly_initial_set_and_has_products CategoryTheory.has_weakly_initial_of_weakly_initial_set_and_hasProducts
| Mathlib/CategoryTheory/Limits/Constructions/WeaklyInitial.lean | 46 | 64 | theorem hasInitial_of_weakly_initial_and_hasWideEqualizers [HasWideEqualizers.{v} C] {T : C}
(hT : ∀ X, Nonempty (T ⟶ X)) : HasInitial C := by |
let endos := T ⟶ T
let i := wideEqualizer.ι (id : endos → endos)
haveI : Nonempty endos := ⟨𝟙 _⟩
have : ∀ X : C, Unique (wideEqualizer (id : endos → endos) ⟶ X) := by
intro X
refine ⟨⟨i ≫ Classical.choice (hT X)⟩, fun a => ?_⟩
let E := equalizer a (i ≫ Classical.choice (hT _))
let e : E ⟶ wideEqualizer id := equalizer.ι _ _
let h : T ⟶ E := Classical.choice (hT E)
have : ((i ≫ h) ≫ e) ≫ i = i ≫ 𝟙 _ := by
rw [Category.assoc, Category.assoc]
apply wideEqualizer.condition (id : endos → endos) (h ≫ e ≫ i)
rw [Category.comp_id, cancel_mono_id i] at this
haveI : IsSplitEpi e := IsSplitEpi.mk' ⟨i ≫ h, this⟩
rw [← cancel_epi e]
apply equalizer.condition
exact hasInitial_of_unique (wideEqualizer (id : endos → endos))
| 17 | 24,154,952.753575 | 2 | 2 | 1 | 2,183 |
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Data.Finset.NatAntidiagonal
import Mathlib.Data.Nat.GCD.Basic
import Mathlib.Init.Data.Nat.Lemmas
import Mathlib.Logic.Function.Iterate
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Zify
#align_import data.nat.fib from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
namespace Nat
-- Porting note: Lean cannot find pp_nodot at the time of this port.
-- @[pp_nodot]
def fib (n : ℕ) : ℕ :=
((fun p : ℕ × ℕ => (p.snd, p.fst + p.snd))^[n] (0, 1)).fst
#align nat.fib Nat.fib
@[simp]
theorem fib_zero : fib 0 = 0 :=
rfl
#align nat.fib_zero Nat.fib_zero
@[simp]
theorem fib_one : fib 1 = 1 :=
rfl
#align nat.fib_one Nat.fib_one
@[simp]
theorem fib_two : fib 2 = 1 :=
rfl
#align nat.fib_two Nat.fib_two
theorem fib_add_two {n : ℕ} : fib (n + 2) = fib n + fib (n + 1) := by
simp [fib, Function.iterate_succ_apply']
#align nat.fib_add_two Nat.fib_add_two
lemma fib_add_one : ∀ {n}, n ≠ 0 → fib (n + 1) = fib (n - 1) + fib n
| _n + 1, _ => fib_add_two
| Mathlib/Data/Nat/Fib/Basic.lean | 94 | 94 | theorem fib_le_fib_succ {n : ℕ} : fib n ≤ fib (n + 1) := by | cases n <;> simp [fib_add_two]
| 1 | 2.718282 | 0 | 1.181818 | 11 | 1,246 |
import Mathlib.RingTheory.Polynomial.Basic
import Mathlib.RingTheory.Ideal.LocalRing
#align_import data.polynomial.expand from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
universe u v w
open Polynomial
open Finset
namespace Polynomial
section CommSemiring
variable (R : Type u) [CommSemiring R] {S : Type v} [CommSemiring S] (p q : ℕ)
noncomputable def expand : R[X] →ₐ[R] R[X] :=
{ (eval₂RingHom C (X ^ p) : R[X] →+* R[X]) with commutes' := fun _ => eval₂_C _ _ }
#align polynomial.expand Polynomial.expand
theorem coe_expand : (expand R p : R[X] → R[X]) = eval₂ C (X ^ p) :=
rfl
#align polynomial.coe_expand Polynomial.coe_expand
variable {R}
theorem expand_eq_comp_X_pow {f : R[X]} : expand R p f = f.comp (X ^ p) := rfl
theorem expand_eq_sum {f : R[X]} : expand R p f = f.sum fun e a => C a * (X ^ p) ^ e := by
simp [expand, eval₂]
#align polynomial.expand_eq_sum Polynomial.expand_eq_sum
@[simp]
theorem expand_C (r : R) : expand R p (C r) = C r :=
eval₂_C _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_C Polynomial.expand_C
@[simp]
theorem expand_X : expand R p X = X ^ p :=
eval₂_X _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_X Polynomial.expand_X
@[simp]
theorem expand_monomial (r : R) : expand R p (monomial q r) = monomial (q * p) r := by
simp_rw [← smul_X_eq_monomial, AlgHom.map_smul, AlgHom.map_pow, expand_X, mul_comm, pow_mul]
#align polynomial.expand_monomial Polynomial.expand_monomial
theorem expand_expand (f : R[X]) : expand R p (expand R q f) = expand R (p * q) f :=
Polynomial.induction_on f (fun r => by simp_rw [expand_C])
(fun f g ihf ihg => by simp_rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
simp_rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, AlgHom.map_pow, expand_X, pow_mul]
#align polynomial.expand_expand Polynomial.expand_expand
theorem expand_mul (f : R[X]) : expand R (p * q) f = expand R p (expand R q f) :=
(expand_expand p q f).symm
#align polynomial.expand_mul Polynomial.expand_mul
@[simp]
theorem expand_zero (f : R[X]) : expand R 0 f = C (eval 1 f) := by simp [expand]
#align polynomial.expand_zero Polynomial.expand_zero
@[simp]
theorem expand_one (f : R[X]) : expand R 1 f = f :=
Polynomial.induction_on f (fun r => by rw [expand_C])
(fun f g ihf ihg => by rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, pow_one]
#align polynomial.expand_one Polynomial.expand_one
theorem expand_pow (f : R[X]) : expand R (p ^ q) f = (expand R p)^[q] f :=
Nat.recOn q (by rw [pow_zero, expand_one, Function.iterate_zero, id]) fun n ih => by
rw [Function.iterate_succ_apply', pow_succ', expand_mul, ih]
#align polynomial.expand_pow Polynomial.expand_pow
| Mathlib/Algebra/Polynomial/Expand.lean | 95 | 97 | theorem derivative_expand (f : R[X]) : Polynomial.derivative (expand R p f) =
expand R p (Polynomial.derivative f) * (p * (X ^ (p - 1) : R[X])) := by |
rw [coe_expand, derivative_eval₂_C, derivative_pow, C_eq_natCast, derivative_X, mul_one]
| 1 | 2.718282 | 0 | 0.285714 | 7 | 311 |
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]
theorem one_lt_cast : 1 < (n : α) ↔ 1 < n := by rw [← cast_one, cast_lt]
#align nat.one_lt_cast Nat.one_lt_cast
@[simp, norm_cast]
| Mathlib/Data/Nat/Cast/Order.lean | 138 | 138 | theorem one_le_cast : 1 ≤ (n : α) ↔ 1 ≤ n := by | rw [← cast_one, cast_le]
| 1 | 2.718282 | 0 | 0.166667 | 6 | 261 |
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.Order.Ring.Nat
import Mathlib.Tactic.NthRewrite
#align_import data.nat.gcd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
namespace Nat
theorem gcd_greatest {a b d : ℕ} (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : ℕ, e ∣ a → e ∣ b → e ∣ d) :
d = a.gcd b :=
(dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm
#align nat.gcd_greatest Nat.gcd_greatest
@[simp]
theorem gcd_add_mul_right_right (m n k : ℕ) : gcd m (n + k * m) = gcd m n := by
simp [gcd_rec m (n + k * m), gcd_rec m n]
#align nat.gcd_add_mul_right_right Nat.gcd_add_mul_right_right
@[simp]
theorem gcd_add_mul_left_right (m n k : ℕ) : gcd m (n + m * k) = gcd m n := by
simp [gcd_rec m (n + m * k), gcd_rec m n]
#align nat.gcd_add_mul_left_right Nat.gcd_add_mul_left_right
@[simp]
theorem gcd_mul_right_add_right (m n k : ℕ) : gcd m (k * m + n) = gcd m n := by simp [add_comm _ n]
#align nat.gcd_mul_right_add_right Nat.gcd_mul_right_add_right
@[simp]
theorem gcd_mul_left_add_right (m n k : ℕ) : gcd m (m * k + n) = gcd m n := by simp [add_comm _ n]
#align nat.gcd_mul_left_add_right Nat.gcd_mul_left_add_right
@[simp]
theorem gcd_add_mul_right_left (m n k : ℕ) : gcd (m + k * n) n = gcd m n := by
rw [gcd_comm, gcd_add_mul_right_right, gcd_comm]
#align nat.gcd_add_mul_right_left Nat.gcd_add_mul_right_left
@[simp]
| Mathlib/Data/Nat/GCD/Basic.lean | 58 | 59 | theorem gcd_add_mul_left_left (m n k : ℕ) : gcd (m + n * k) n = gcd m n := by |
rw [gcd_comm, gcd_add_mul_left_right, gcd_comm]
| 1 | 2.718282 | 0 | 0.352941 | 17 | 375 |
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
theorem not_mem_support {x : α} : x ∉ f.support ↔ f x = x := by simp
#align equiv.perm.not_mem_support Equiv.Perm.not_mem_support
theorem coe_support_eq_set_support (f : Perm α) : (f.support : Set α) = { x | f x ≠ x } := by
ext
simp
#align equiv.perm.coe_support_eq_set_support Equiv.Perm.coe_support_eq_set_support
@[simp]
theorem support_eq_empty_iff {σ : Perm α} : σ.support = ∅ ↔ σ = 1 := by
simp_rw [Finset.ext_iff, mem_support, Finset.not_mem_empty, iff_false_iff, not_not,
Equiv.Perm.ext_iff, one_apply]
#align equiv.perm.support_eq_empty_iff Equiv.Perm.support_eq_empty_iff
@[simp]
| Mathlib/GroupTheory/Perm/Support.lean | 316 | 316 | theorem support_one : (1 : Perm α).support = ∅ := by | rw [support_eq_empty_iff]
| 1 | 2.718282 | 0 | 0.944444 | 18 | 795 |
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.Div
#align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8"
noncomputable section
open Polynomial
open Finset
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R]
theorem le_rootMultiplicity_iff {p : R[X]} (p0 : p ≠ 0) {a : R} {n : ℕ} :
n ≤ rootMultiplicity a p ↔ (X - C a) ^ n ∣ p := by
classical
rw [rootMultiplicity_eq_nat_find_of_nonzero p0, @Nat.le_find_iff _ (_)]
simp_rw [Classical.not_not]
refine ⟨fun h => ?_, fun h m hm => (pow_dvd_pow _ hm).trans h⟩
cases' n with n;
· rw [pow_zero]
apply one_dvd;
· exact h n n.lt_succ_self
#align polynomial.le_root_multiplicity_iff Polynomial.le_rootMultiplicity_iff
| Mathlib/Algebra/Polynomial/RingDivision.lean | 439 | 441 | theorem rootMultiplicity_le_iff {p : R[X]} (p0 : p ≠ 0) (a : R) (n : ℕ) :
rootMultiplicity a p ≤ n ↔ ¬(X - C a) ^ (n + 1) ∣ p := by |
rw [← (le_rootMultiplicity_iff p0).not, not_le, Nat.lt_add_one_iff]
| 1 | 2.718282 | 0 | 1.5 | 32 | 1,561 |
import Mathlib.Topology.MetricSpace.ProperSpace
import Mathlib.Topology.MetricSpace.Cauchy
open Set Filter Bornology
open scoped ENNReal Uniformity Topology Pointwise
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
variable [PseudoMetricSpace α]
namespace Metric
#align metric.bounded Bornology.IsBounded
section Bounded
variable {x : α} {s t : Set α} {r : ℝ}
#noalign metric.bounded_iff_is_bounded
#align metric.bounded_empty Bornology.isBounded_empty
#align metric.bounded_iff_mem_bounded Bornology.isBounded_iff_forall_mem
#align metric.bounded.mono Bornology.IsBounded.subset
theorem isBounded_closedBall : IsBounded (closedBall x r) :=
isBounded_iff.2 ⟨r + r, fun y hy z hz =>
calc dist y z ≤ dist y x + dist z x := dist_triangle_right _ _ _
_ ≤ r + r := add_le_add hy hz⟩
#align metric.bounded_closed_ball Metric.isBounded_closedBall
theorem isBounded_ball : IsBounded (ball x r) :=
isBounded_closedBall.subset ball_subset_closedBall
#align metric.bounded_ball Metric.isBounded_ball
theorem isBounded_sphere : IsBounded (sphere x r) :=
isBounded_closedBall.subset sphere_subset_closedBall
#align metric.bounded_sphere Metric.isBounded_sphere
theorem isBounded_iff_subset_closedBall (c : α) : IsBounded s ↔ ∃ r, s ⊆ closedBall c r :=
⟨fun h ↦ (isBounded_iff.1 (h.insert c)).imp fun _r hr _x hx ↦ hr (.inr hx) (mem_insert _ _),
fun ⟨_r, hr⟩ ↦ isBounded_closedBall.subset hr⟩
#align metric.bounded_iff_subset_ball Metric.isBounded_iff_subset_closedBall
theorem _root_.Bornology.IsBounded.subset_closedBall (h : IsBounded s) (c : α) :
∃ r, s ⊆ closedBall c r :=
(isBounded_iff_subset_closedBall c).1 h
#align metric.bounded.subset_ball Bornology.IsBounded.subset_closedBall
theorem _root_.Bornology.IsBounded.subset_ball_lt (h : IsBounded s) (a : ℝ) (c : α) :
∃ r, a < r ∧ s ⊆ ball c r :=
let ⟨r, hr⟩ := h.subset_closedBall c
⟨max r a + 1, (le_max_right _ _).trans_lt (lt_add_one _), hr.trans <| closedBall_subset_ball <|
(le_max_left _ _).trans_lt (lt_add_one _)⟩
theorem _root_.Bornology.IsBounded.subset_ball (h : IsBounded s) (c : α) : ∃ r, s ⊆ ball c r :=
(h.subset_ball_lt 0 c).imp fun _ ↦ And.right
theorem isBounded_iff_subset_ball (c : α) : IsBounded s ↔ ∃ r, s ⊆ ball c r :=
⟨(IsBounded.subset_ball · c), fun ⟨_r, hr⟩ ↦ isBounded_ball.subset hr⟩
theorem _root_.Bornology.IsBounded.subset_closedBall_lt (h : IsBounded s) (a : ℝ) (c : α) :
∃ r, a < r ∧ s ⊆ closedBall c r :=
let ⟨r, har, hr⟩ := h.subset_ball_lt a c
⟨r, har, hr.trans ball_subset_closedBall⟩
#align metric.bounded.subset_ball_lt Bornology.IsBounded.subset_closedBall_lt
theorem isBounded_closure_of_isBounded (h : IsBounded s) : IsBounded (closure s) :=
let ⟨C, h⟩ := isBounded_iff.1 h
isBounded_iff.2 ⟨C, fun _a ha _b hb => isClosed_Iic.closure_subset <|
map_mem_closure₂ continuous_dist ha hb h⟩
#align metric.bounded_closure_of_bounded Metric.isBounded_closure_of_isBounded
protected theorem _root_.Bornology.IsBounded.closure (h : IsBounded s) : IsBounded (closure s) :=
isBounded_closure_of_isBounded h
#align metric.bounded.closure Bornology.IsBounded.closure
@[simp]
theorem isBounded_closure_iff : IsBounded (closure s) ↔ IsBounded s :=
⟨fun h => h.subset subset_closure, fun h => h.closure⟩
#align metric.bounded_closure_iff Metric.isBounded_closure_iff
#align metric.bounded_union Bornology.isBounded_union
#align metric.bounded.union Bornology.IsBounded.union
#align metric.bounded_bUnion Bornology.isBounded_biUnion
#align metric.bounded.prod Bornology.IsBounded.prod
theorem hasBasis_cobounded_compl_closedBall (c : α) :
(cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (closedBall c r)ᶜ) :=
⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_closedBall c).trans <| by simp⟩
theorem hasBasis_cobounded_compl_ball (c : α) :
(cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (ball c r)ᶜ) :=
⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_ball c).trans <| by simp⟩
@[simp]
theorem comap_dist_right_atTop (c : α) : comap (dist · c) atTop = cobounded α :=
(atTop_basis.comap _).eq_of_same_basis <| by
simpa only [compl_def, mem_ball, not_lt] using hasBasis_cobounded_compl_ball c
@[simp]
theorem comap_dist_left_atTop (c : α) : comap (dist c) atTop = cobounded α := by
simpa only [dist_comm _ c] using comap_dist_right_atTop c
@[simp]
theorem tendsto_dist_right_atTop_iff (c : α) {f : β → α} {l : Filter β} :
Tendsto (fun x ↦ dist (f x) c) l atTop ↔ Tendsto f l (cobounded α) := by
rw [← comap_dist_right_atTop c, tendsto_comap_iff, Function.comp_def]
@[simp]
| Mathlib/Topology/MetricSpace/Bounded.lean | 142 | 144 | theorem tendsto_dist_left_atTop_iff (c : α) {f : β → α} {l : Filter β} :
Tendsto (fun x ↦ dist c (f x)) l atTop ↔ Tendsto f l (cobounded α) := by |
simp only [dist_comm c, tendsto_dist_right_atTop_iff]
| 1 | 2.718282 | 0 | 0 | 3 | 140 |
import Mathlib.Data.Matrix.Block
import Mathlib.Data.Matrix.Notation
import Mathlib.Data.Matrix.RowCol
import Mathlib.GroupTheory.GroupAction.Ring
import Mathlib.GroupTheory.Perm.Fin
import Mathlib.LinearAlgebra.Alternating.Basic
#align_import linear_algebra.matrix.determinant from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395"
universe u v w z
open Equiv Equiv.Perm Finset Function
namespace Matrix
open Matrix
variable {m n : Type*} [DecidableEq n] [Fintype n] [DecidableEq m] [Fintype m]
variable {R : Type v} [CommRing R]
local notation "ε " σ:arg => ((sign σ : ℤ) : R)
def detRowAlternating : (n → R) [⋀^n]→ₗ[R] R :=
MultilinearMap.alternatization ((MultilinearMap.mkPiAlgebra R n R).compLinearMap LinearMap.proj)
#align matrix.det_row_alternating Matrix.detRowAlternating
abbrev det (M : Matrix n n R) : R :=
detRowAlternating M
#align matrix.det Matrix.det
theorem det_apply (M : Matrix n n R) : M.det = ∑ σ : Perm n, Equiv.Perm.sign σ • ∏ i, M (σ i) i :=
MultilinearMap.alternatization_apply _ M
#align matrix.det_apply Matrix.det_apply
-- This is what the old definition was. We use it to avoid having to change the old proofs below
theorem det_apply' (M : Matrix n n R) : M.det = ∑ σ : Perm n, ε σ * ∏ i, M (σ i) i := by
simp [det_apply, Units.smul_def]
#align matrix.det_apply' Matrix.det_apply'
@[simp]
theorem det_diagonal {d : n → R} : det (diagonal d) = ∏ i, d i := by
rw [det_apply']
refine (Finset.sum_eq_single 1 ?_ ?_).trans ?_
· rintro σ - h2
cases' not_forall.1 (mt Equiv.ext h2) with x h3
convert mul_zero (ε σ)
apply Finset.prod_eq_zero (mem_univ x)
exact if_neg h3
· simp
· simp
#align matrix.det_diagonal Matrix.det_diagonal
-- @[simp] -- Porting note (#10618): simp can prove this
theorem det_zero (_ : Nonempty n) : det (0 : Matrix n n R) = 0 :=
(detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_zero
#align matrix.det_zero Matrix.det_zero
@[simp]
theorem det_one : det (1 : Matrix n n R) = 1 := by rw [← diagonal_one]; simp [-diagonal_one]
#align matrix.det_one Matrix.det_one
| Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean | 94 | 94 | theorem det_isEmpty [IsEmpty n] {A : Matrix n n R} : det A = 1 := by | simp [det_apply]
| 1 | 2.718282 | 0 | 0.888889 | 9 | 771 |
import Mathlib.Data.Multiset.Bind
#align_import data.multiset.fold from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
namespace Multiset
variable {α β : Type*}
section Fold
variable (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op]
local notation a " * " b => op a b
def fold : α → Multiset α → α :=
foldr op (left_comm _ hc.comm ha.assoc)
#align multiset.fold Multiset.fold
theorem fold_eq_foldr (b : α) (s : Multiset α) :
fold op b s = foldr op (left_comm _ hc.comm ha.assoc) b s :=
rfl
#align multiset.fold_eq_foldr Multiset.fold_eq_foldr
@[simp]
theorem coe_fold_r (b : α) (l : List α) : fold op b l = l.foldr op b :=
rfl
#align multiset.coe_fold_r Multiset.coe_fold_r
theorem coe_fold_l (b : α) (l : List α) : fold op b l = l.foldl op b :=
(coe_foldr_swap op _ b l).trans <| by simp [hc.comm]
#align multiset.coe_fold_l Multiset.coe_fold_l
theorem fold_eq_foldl (b : α) (s : Multiset α) :
fold op b s = foldl op (right_comm _ hc.comm ha.assoc) b s :=
Quot.inductionOn s fun _ => coe_fold_l _ _ _
#align multiset.fold_eq_foldl Multiset.fold_eq_foldl
@[simp]
theorem fold_zero (b : α) : (0 : Multiset α).fold op b = b :=
rfl
#align multiset.fold_zero Multiset.fold_zero
@[simp]
theorem fold_cons_left : ∀ (b a : α) (s : Multiset α), (a ::ₘ s).fold op b = a * s.fold op b :=
foldr_cons _ _
#align multiset.fold_cons_left Multiset.fold_cons_left
theorem fold_cons_right (b a : α) (s : Multiset α) : (a ::ₘ s).fold op b = s.fold op b * a := by
simp [hc.comm]
#align multiset.fold_cons_right Multiset.fold_cons_right
theorem fold_cons'_right (b a : α) (s : Multiset α) : (a ::ₘ s).fold op b = s.fold op (b * a) := by
rw [fold_eq_foldl, foldl_cons, ← fold_eq_foldl]
#align multiset.fold_cons'_right Multiset.fold_cons'_right
theorem fold_cons'_left (b a : α) (s : Multiset α) : (a ::ₘ s).fold op b = s.fold op (a * b) := by
rw [fold_cons'_right, hc.comm]
#align multiset.fold_cons'_left Multiset.fold_cons'_left
theorem fold_add (b₁ b₂ : α) (s₁ s₂ : Multiset α) :
(s₁ + s₂).fold op (b₁ * b₂) = s₁.fold op b₁ * s₂.fold op b₂ :=
Multiset.induction_on s₂ (by rw [add_zero, fold_zero, ← fold_cons'_right, ← fold_cons_right op])
(fun a b h => by rw [fold_cons_left, add_cons, fold_cons_left, h, ← ha.assoc, hc.comm a,
ha.assoc])
#align multiset.fold_add Multiset.fold_add
theorem fold_bind {ι : Type*} (s : Multiset ι) (t : ι → Multiset α) (b : ι → α) (b₀ : α) :
(s.bind t).fold op ((s.map b).fold op b₀) =
(s.map fun i => (t i).fold op (b i)).fold op b₀ := by
induction' s using Multiset.induction_on with a ha ih
· rw [zero_bind, map_zero, map_zero, fold_zero]
· rw [cons_bind, map_cons, map_cons, fold_cons_left, fold_cons_left, fold_add, ih]
#align multiset.fold_bind Multiset.fold_bind
theorem fold_singleton (b a : α) : ({a} : Multiset α).fold op b = a * b :=
foldr_singleton _ _ _ _
#align multiset.fold_singleton Multiset.fold_singleton
theorem fold_distrib {f g : β → α} (u₁ u₂ : α) (s : Multiset β) :
(s.map fun x => f x * g x).fold op (u₁ * u₂) = (s.map f).fold op u₁ * (s.map g).fold op u₂ :=
Multiset.induction_on s (by simp) (fun a b h => by
rw [map_cons, fold_cons_left, h, map_cons, fold_cons_left, map_cons,
fold_cons_right, ha.assoc, ← ha.assoc (g a), hc.comm (g a),
ha.assoc, hc.comm (g a), ha.assoc])
#align multiset.fold_distrib Multiset.fold_distrib
theorem fold_hom {op' : β → β → β} [Std.Commutative op'] [Std.Associative op'] {m : α → β}
(hm : ∀ x y, m (op x y) = op' (m x) (m y)) (b : α) (s : Multiset α) :
(s.map m).fold op' (m b) = m (s.fold op b) :=
Multiset.induction_on s (by simp) (by simp (config := { contextual := true }) [hm])
#align multiset.fold_hom Multiset.fold_hom
| Mathlib/Data/Multiset/Fold.lean | 108 | 110 | theorem fold_union_inter [DecidableEq α] (s₁ s₂ : Multiset α) (b₁ b₂ : α) :
((s₁ ∪ s₂).fold op b₁ * (s₁ ∩ s₂).fold op b₂) = s₁.fold op b₁ * s₂.fold op b₂ := by |
rw [← fold_add op, union_add_inter, fold_add op]
| 1 | 2.718282 | 0 | 0.2 | 5 | 270 |
import Mathlib.Algebra.Group.Basic
import Mathlib.Algebra.Group.Hom.Defs
import Mathlib.Algebra.GroupWithZero.NeZero
import Mathlib.Algebra.Opposites
import Mathlib.Algebra.Ring.Defs
#align_import algebra.ring.basic from "leanprover-community/mathlib"@"2ed7e4aec72395b6a7c3ac4ac7873a7a43ead17c"
variable {R : Type*}
open Function
namespace AddHom
@[simps (config := .asFn)]
def mulLeft [Distrib R] (r : R) : AddHom R R where
toFun := (r * ·)
map_add' := mul_add r
#align add_hom.mul_left AddHom.mulLeft
#align add_hom.mul_left_apply AddHom.mulLeft_apply
@[simps (config := .asFn)]
def mulRight [Distrib R] (r : R) : AddHom R R where
toFun a := a * r
map_add' _ _ := add_mul _ _ r
#align add_hom.mul_right AddHom.mulRight
#align add_hom.mul_right_apply AddHom.mulRight_apply
end AddHom
section HasDistribNeg
section Group
variable {α : Type*} [Group α] [HasDistribNeg α]
@[simp]
| Mathlib/Algebra/Ring/Basic.lean | 112 | 113 | theorem inv_neg' (a : α) : (-a)⁻¹ = -a⁻¹ := by |
rw [eq_comm, eq_inv_iff_mul_eq_one, neg_mul, mul_neg, neg_neg, mul_left_inv]
| 1 | 2.718282 | 0 | 0.5 | 2 | 477 |
import Mathlib.Data.Int.GCD
import Mathlib.Tactic.NormNum
namespace Tactic
namespace NormNum
theorem int_gcd_helper' {d : ℕ} {x y : ℤ} (a b : ℤ) (h₁ : (d : ℤ) ∣ x) (h₂ : (d : ℤ) ∣ y)
(h₃ : x * a + y * b = d) : Int.gcd x y = d := by
refine Nat.dvd_antisymm ?_ (Int.natCast_dvd_natCast.1 (Int.dvd_gcd h₁ h₂))
rw [← Int.natCast_dvd_natCast, ← h₃]
apply dvd_add
· exact Int.gcd_dvd_left.mul_right _
· exact Int.gcd_dvd_right.mul_right _
theorem nat_gcd_helper_dvd_left (x y : ℕ) (h : y % x = 0) : Nat.gcd x y = x :=
Nat.gcd_eq_left (Nat.dvd_of_mod_eq_zero h)
theorem nat_gcd_helper_dvd_right (x y : ℕ) (h : x % y = 0) : Nat.gcd x y = y :=
Nat.gcd_eq_right (Nat.dvd_of_mod_eq_zero h)
theorem nat_gcd_helper_2 (d x y a b : ℕ) (hu : x % d = 0) (hv : y % d = 0)
(h : x * a = y * b + d) : Nat.gcd x y = d := by
rw [← Int.gcd_natCast_natCast]
apply int_gcd_helper' a (-b)
(Int.natCast_dvd_natCast.mpr (Nat.dvd_of_mod_eq_zero hu))
(Int.natCast_dvd_natCast.mpr (Nat.dvd_of_mod_eq_zero hv))
rw [mul_neg, ← sub_eq_add_neg, sub_eq_iff_eq_add']
exact mod_cast h
theorem nat_gcd_helper_1 (d x y a b : ℕ) (hu : x % d = 0) (hv : y % d = 0)
(h : y * b = x * a + d) : Nat.gcd x y = d :=
(Nat.gcd_comm _ _).trans <| nat_gcd_helper_2 _ _ _ _ _ hv hu h
theorem nat_gcd_helper_1' (x y a b : ℕ) (h : y * b = x * a + 1) :
Nat.gcd x y = 1 :=
nat_gcd_helper_1 1 _ _ _ _ (Nat.mod_one _) (Nat.mod_one _) h
theorem nat_gcd_helper_2' (x y a b : ℕ) (h : x * a = y * b + 1) :
Nat.gcd x y = 1 :=
nat_gcd_helper_2 1 _ _ _ _ (Nat.mod_one _) (Nat.mod_one _) h
theorem nat_lcm_helper (x y d m : ℕ) (hd : Nat.gcd x y = d)
(d0 : Nat.beq d 0 = false)
(dm : x * y = d * m) : Nat.lcm x y = m :=
mul_right_injective₀ (Nat.ne_of_beq_eq_false d0) <| by
dsimp only -- Porting note: the `dsimp only` was not necessary in Lean3.
rw [← dm, ← hd, Nat.gcd_mul_lcm]
| Mathlib/Tactic/NormNum/GCD.lean | 64 | 66 | theorem int_gcd_helper {x y : ℤ} {x' y' d : ℕ}
(hx : x.natAbs = x') (hy : y.natAbs = y') (h : Nat.gcd x' y' = d) :
Int.gcd x y = d := by | subst_vars; rw [Int.gcd_def]
| 1 | 2.718282 | 0 | 1 | 4 | 950 |
import Mathlib.Data.Finset.Image
import Mathlib.Data.List.FinRange
#align_import data.fintype.basic from "leanprover-community/mathlib"@"d78597269638367c3863d40d45108f52207e03cf"
assert_not_exists MonoidWithZero
assert_not_exists MulAction
open Function
open Nat
universe u v
variable {α β γ : Type*}
class Fintype (α : Type*) where
elems : Finset α
complete : ∀ x : α, x ∈ elems
#align fintype Fintype
namespace Finset
variable [Fintype α] {s t : Finset α}
def univ : Finset α :=
@Fintype.elems α _
#align finset.univ Finset.univ
@[simp]
theorem mem_univ (x : α) : x ∈ (univ : Finset α) :=
Fintype.complete x
#align finset.mem_univ Finset.mem_univ
-- Porting note: removing @[simp], simp can prove it
theorem mem_univ_val : ∀ x, x ∈ (univ : Finset α).1 :=
mem_univ
#align finset.mem_univ_val Finset.mem_univ_val
theorem eq_univ_iff_forall : s = univ ↔ ∀ x, x ∈ s := by simp [ext_iff]
#align finset.eq_univ_iff_forall Finset.eq_univ_iff_forall
theorem eq_univ_of_forall : (∀ x, x ∈ s) → s = univ :=
eq_univ_iff_forall.2
#align finset.eq_univ_of_forall Finset.eq_univ_of_forall
@[simp, norm_cast]
theorem coe_univ : ↑(univ : Finset α) = (Set.univ : Set α) := by ext; simp
#align finset.coe_univ Finset.coe_univ
@[simp, norm_cast]
| Mathlib/Data/Fintype/Basic.lean | 96 | 96 | theorem coe_eq_univ : (s : Set α) = Set.univ ↔ s = univ := by | rw [← coe_univ, coe_inj]
| 1 | 2.718282 | 0 | 0.111111 | 9 | 248 |
import Mathlib.Data.Set.Pointwise.Interval
import Mathlib.Topology.Algebra.Field
import Mathlib.Topology.Algebra.Order.Group
#align_import topology.algebra.order.field from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd"
open Set Filter TopologicalSpace Function
open scoped Pointwise Topology
open OrderDual (toDual ofDual)
theorem TopologicalRing.of_norm {R 𝕜 : Type*} [NonUnitalNonAssocRing R] [LinearOrderedField 𝕜]
[TopologicalSpace R] [TopologicalAddGroup R] (norm : R → 𝕜)
(norm_nonneg : ∀ x, 0 ≤ norm x) (norm_mul_le : ∀ x y, norm (x * y) ≤ norm x * norm y)
(nhds_basis : (𝓝 (0 : R)).HasBasis ((0 : 𝕜) < ·) (fun ε ↦ { x | norm x < ε })) :
TopologicalRing R := by
have h0 : ∀ f : R → R, ∀ c ≥ (0 : 𝕜), (∀ x, norm (f x) ≤ c * norm x) →
Tendsto f (𝓝 0) (𝓝 0) := by
refine fun f c c0 hf ↦ (nhds_basis.tendsto_iff nhds_basis).2 fun ε ε0 ↦ ?_
rcases exists_pos_mul_lt ε0 c with ⟨δ, δ0, hδ⟩
refine ⟨δ, δ0, fun x hx ↦ (hf _).trans_lt ?_⟩
exact (mul_le_mul_of_nonneg_left (le_of_lt hx) c0).trans_lt hδ
apply TopologicalRing.of_addGroup_of_nhds_zero
case hmul =>
refine ((nhds_basis.prod nhds_basis).tendsto_iff nhds_basis).2 fun ε ε0 ↦ ?_
refine ⟨(1, ε), ⟨one_pos, ε0⟩, fun (x, y) ⟨hx, hy⟩ => ?_⟩
simp only [sub_zero] at *
calc norm (x * y) ≤ norm x * norm y := norm_mul_le _ _
_ < ε := mul_lt_of_le_one_of_lt_of_nonneg hx.le hy (norm_nonneg _)
case hmul_left => exact fun x => h0 _ (norm x) (norm_nonneg _) (norm_mul_le x)
case hmul_right =>
exact fun y => h0 (· * y) (norm y) (norm_nonneg y) fun x =>
(norm_mul_le x y).trans_eq (mul_comm _ _)
variable {𝕜 α : Type*} [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜]
{l : Filter α} {f g : α → 𝕜}
-- see Note [lower instance priority]
instance (priority := 100) LinearOrderedField.topologicalRing : TopologicalRing 𝕜 :=
.of_norm abs abs_nonneg (fun _ _ ↦ (abs_mul _ _).le) <| by
simpa using nhds_basis_abs_sub_lt (0 : 𝕜)
theorem Filter.Tendsto.atTop_mul {C : 𝕜} (hC : 0 < C) (hf : Tendsto f l atTop)
(hg : Tendsto g l (𝓝 C)) : Tendsto (fun x => f x * g x) l atTop := by
refine tendsto_atTop_mono' _ ?_ (hf.atTop_mul_const (half_pos hC))
filter_upwards [hg.eventually (lt_mem_nhds (half_lt_self hC)), hf.eventually_ge_atTop 0]
with x hg hf using mul_le_mul_of_nonneg_left hg.le hf
#align filter.tendsto.at_top_mul Filter.Tendsto.atTop_mul
theorem Filter.Tendsto.mul_atTop {C : 𝕜} (hC : 0 < C) (hf : Tendsto f l (𝓝 C))
(hg : Tendsto g l atTop) : Tendsto (fun x => f x * g x) l atTop := by
simpa only [mul_comm] using hg.atTop_mul hC hf
#align filter.tendsto.mul_at_top Filter.Tendsto.mul_atTop
theorem Filter.Tendsto.atTop_mul_neg {C : 𝕜} (hC : C < 0) (hf : Tendsto f l atTop)
(hg : Tendsto g l (𝓝 C)) : Tendsto (fun x => f x * g x) l atBot := by
have := hf.atTop_mul (neg_pos.2 hC) hg.neg
simpa only [(· ∘ ·), neg_mul_eq_mul_neg, neg_neg] using tendsto_neg_atTop_atBot.comp this
#align filter.tendsto.at_top_mul_neg Filter.Tendsto.atTop_mul_neg
theorem Filter.Tendsto.neg_mul_atTop {C : 𝕜} (hC : C < 0) (hf : Tendsto f l (𝓝 C))
(hg : Tendsto g l atTop) : Tendsto (fun x => f x * g x) l atBot := by
simpa only [mul_comm] using hg.atTop_mul_neg hC hf
#align filter.tendsto.neg_mul_at_top Filter.Tendsto.neg_mul_atTop
theorem Filter.Tendsto.atBot_mul {C : 𝕜} (hC : 0 < C) (hf : Tendsto f l atBot)
(hg : Tendsto g l (𝓝 C)) : Tendsto (fun x => f x * g x) l atBot := by
have := (tendsto_neg_atBot_atTop.comp hf).atTop_mul hC hg
simpa [(· ∘ ·)] using tendsto_neg_atTop_atBot.comp this
#align filter.tendsto.at_bot_mul Filter.Tendsto.atBot_mul
theorem Filter.Tendsto.atBot_mul_neg {C : 𝕜} (hC : C < 0) (hf : Tendsto f l atBot)
(hg : Tendsto g l (𝓝 C)) : Tendsto (fun x => f x * g x) l atTop := by
have := (tendsto_neg_atBot_atTop.comp hf).atTop_mul_neg hC hg
simpa [(· ∘ ·)] using tendsto_neg_atBot_atTop.comp this
#align filter.tendsto.at_bot_mul_neg Filter.Tendsto.atBot_mul_neg
theorem Filter.Tendsto.mul_atBot {C : 𝕜} (hC : 0 < C) (hf : Tendsto f l (𝓝 C))
(hg : Tendsto g l atBot) : Tendsto (fun x => f x * g x) l atBot := by
simpa only [mul_comm] using hg.atBot_mul hC hf
#align filter.tendsto.mul_at_bot Filter.Tendsto.mul_atBot
| Mathlib/Topology/Algebra/Order/Field.lean | 117 | 119 | theorem Filter.Tendsto.neg_mul_atBot {C : 𝕜} (hC : C < 0) (hf : Tendsto f l (𝓝 C))
(hg : Tendsto g l atBot) : Tendsto (fun x => f x * g x) l atTop := by |
simpa only [mul_comm] using hg.atBot_mul_neg hC hf
| 1 | 2.718282 | 0 | 0.666667 | 9 | 577 |
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.RingTheory.PowerSeries.Basic
#align_import ring_theory.power_series.well_known from "leanprover-community/mathlib"@"8199f6717c150a7fe91c4534175f4cf99725978f"
namespace PowerSeries
section Ring
variable {R S : Type*} [Ring R] [Ring S]
def invUnitsSub (u : Rˣ) : PowerSeries R :=
mk fun n => 1 /ₚ u ^ (n + 1)
#align power_series.inv_units_sub PowerSeries.invUnitsSub
@[simp]
theorem coeff_invUnitsSub (u : Rˣ) (n : ℕ) : coeff R n (invUnitsSub u) = 1 /ₚ u ^ (n + 1) :=
coeff_mk _ _
#align power_series.coeff_inv_units_sub PowerSeries.coeff_invUnitsSub
@[simp]
| Mathlib/RingTheory/PowerSeries/WellKnown.lean | 47 | 48 | theorem constantCoeff_invUnitsSub (u : Rˣ) : constantCoeff R (invUnitsSub u) = 1 /ₚ u := by |
rw [← coeff_zero_eq_constantCoeff_apply, coeff_invUnitsSub, zero_add, pow_one]
| 1 | 2.718282 | 0 | 0.857143 | 14 | 748 |
import Mathlib.GroupTheory.Coprod.Basic
import Mathlib.GroupTheory.Complement
open Monoid Coprod Multiplicative Subgroup Function
def HNNExtension.con (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) :
Con (G ∗ Multiplicative ℤ) :=
conGen (fun x y => ∃ (a : A),
x = inr (ofAdd 1) * inl (a : G) ∧
y = inl (φ a : G) * inr (ofAdd 1))
def HNNExtension (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Type _ :=
(HNNExtension.con G A B φ).Quotient
variable {G : Type*} [Group G] {A B : Subgroup G} {φ : A ≃* B} {H : Type*}
[Group H] {M : Type*} [Monoid M]
instance : Group (HNNExtension G A B φ) := by
delta HNNExtension; infer_instance
namespace HNNExtension
def of : G →* HNNExtension G A B φ :=
(HNNExtension.con G A B φ).mk'.comp inl
def t : HNNExtension G A B φ :=
(HNNExtension.con G A B φ).mk'.comp inr (ofAdd 1)
theorem t_mul_of (a : A) :
t * (of (a : G) : HNNExtension G A B φ) = of (φ a : G) * t :=
(Con.eq _).2 <| ConGen.Rel.of _ _ <| ⟨a, by simp⟩
theorem of_mul_t (b : B) :
(of (b : G) : HNNExtension G A B φ) * t = t * of (φ.symm b : G) := by
rw [t_mul_of]; simp
theorem equiv_eq_conj (a : A) :
(of (φ a : G) : HNNExtension G A B φ) = t * of (a : G) * t⁻¹ := by
rw [t_mul_of]; simp
theorem equiv_symm_eq_conj (b : B) :
(of (φ.symm b : G) : HNNExtension G A B φ) = t⁻¹ * of (b : G) * t := by
rw [mul_assoc, of_mul_t]; simp
| Mathlib/GroupTheory/HNNExtension.lean | 81 | 83 | theorem inv_t_mul_of (b : B) :
t⁻¹ * (of (b : G) : HNNExtension G A B φ) = of (φ.symm b : G) * t⁻¹ := by |
rw [equiv_symm_eq_conj]; simp
| 1 | 2.718282 | 0 | 0.444444 | 9 | 413 |
import Mathlib.Algebra.FreeMonoid.Basic
#align_import algebra.free_monoid.count from "leanprover-community/mathlib"@"a2d2e18906e2b62627646b5d5be856e6a642062f"
variable {α : Type*} (p : α → Prop) [DecidablePred p]
namespace FreeAddMonoid
def countP : FreeAddMonoid α →+ ℕ where
toFun := List.countP p
map_zero' := List.countP_nil _
map_add' := List.countP_append _
#align free_add_monoid.countp FreeAddMonoid.countP
| Mathlib/Algebra/FreeMonoid/Count.lean | 31 | 32 | theorem countP_of (x : α) : countP p (of x) = if p x = true then 1 else 0 := by |
simp [countP, List.countP, List.countP.go]
| 1 | 2.718282 | 0 | 0.5 | 2 | 429 |
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]
| Mathlib/Order/Interval/Set/OrderIso.lean | 68 | 69 | 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]
| 1 | 2.718282 | 0 | 0.285714 | 14 | 310 |
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Combinatorics.Additive.AP.Three.Defs
import Mathlib.Combinatorics.Pigeonhole
import Mathlib.Data.Complex.ExponentialBounds
#align_import combinatorics.additive.behrend from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8"
open Nat hiding log
open Finset Metric Real
open scoped Pointwise
lemma threeAPFree_frontier {𝕜 E : Type*} [LinearOrderedField 𝕜] [TopologicalSpace E]
[AddCommMonoid E] [Module 𝕜 E] {s : Set E} (hs₀ : IsClosed s) (hs₁ : StrictConvex 𝕜 s) :
ThreeAPFree (frontier s) := by
intro a ha b hb c hc habc
obtain rfl : (1 / 2 : 𝕜) • a + (1 / 2 : 𝕜) • c = b := by
rwa [← smul_add, one_div, inv_smul_eq_iff₀ (show (2 : 𝕜) ≠ 0 by norm_num), two_smul]
have :=
hs₁.eq (hs₀.frontier_subset ha) (hs₀.frontier_subset hc) one_half_pos one_half_pos
(add_halves _) hb.2
simp [this, ← add_smul]
ring_nf
simp
#align add_salem_spencer_frontier threeAPFree_frontier
lemma threeAPFree_sphere {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[StrictConvexSpace ℝ E] (x : E) (r : ℝ) : ThreeAPFree (sphere x r) := by
obtain rfl | hr := eq_or_ne r 0
· rw [sphere_zero]
exact threeAPFree_singleton _
· convert threeAPFree_frontier isClosed_ball (strictConvex_closedBall ℝ x r)
exact (frontier_closedBall _ hr).symm
#align add_salem_spencer_sphere threeAPFree_sphere
namespace Behrend
variable {α β : Type*} {n d k N : ℕ} {x : Fin n → ℕ}
def box (n d : ℕ) : Finset (Fin n → ℕ) :=
Fintype.piFinset fun _ => range d
#align behrend.box Behrend.box
theorem mem_box : x ∈ box n d ↔ ∀ i, x i < d := by simp only [box, Fintype.mem_piFinset, mem_range]
#align behrend.mem_box Behrend.mem_box
@[simp]
theorem card_box : (box n d).card = d ^ n := by simp [box]
#align behrend.card_box Behrend.card_box
@[simp]
theorem box_zero : box (n + 1) 0 = ∅ := by simp [box]
#align behrend.box_zero Behrend.box_zero
def sphere (n d k : ℕ) : Finset (Fin n → ℕ) :=
(box n d).filter fun x => ∑ i, x i ^ 2 = k
#align behrend.sphere Behrend.sphere
theorem sphere_zero_subset : sphere n d 0 ⊆ 0 := fun x => by simp [sphere, Function.funext_iff]
#align behrend.sphere_zero_subset Behrend.sphere_zero_subset
@[simp]
| Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean | 118 | 118 | theorem sphere_zero_right (n k : ℕ) : sphere (n + 1) 0 k = ∅ := by | simp [sphere]
| 1 | 2.718282 | 0 | 0.125 | 8 | 252 |
import Mathlib.Algebra.Quaternion
import Mathlib.Tactic.Ring
#align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d"
open Quaternion
namespace QuaternionAlgebra
structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where
(i j k : A)
i_mul_i : i * i = c₁ • (1 : A)
j_mul_j : j * j = c₂ • (1 : A)
i_mul_j : i * j = k
j_mul_i : j * i = -k
#align quaternion_algebra.basis QuaternionAlgebra.Basis
variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B]
variable {c₁ c₂ : R}
namespace Basis
@[ext]
protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by
cases q₁; rename_i q₁_i_mul_j _
cases q₂; rename_i q₂_i_mul_j _
congr
rw [← q₁_i_mul_j, ← q₂_i_mul_j]
congr
#align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext
variable (R)
@[simps i j k]
protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where
i := ⟨0, 1, 0, 0⟩
i_mul_i := by ext <;> simp
j := ⟨0, 0, 1, 0⟩
j_mul_j := by ext <;> simp
k := ⟨0, 0, 0, 1⟩
i_mul_j := by ext <;> simp
j_mul_i := by ext <;> simp
#align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self
variable {R}
instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) :=
⟨Basis.self R⟩
variable (q : Basis A c₁ c₂)
attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i
@[simp]
theorem i_mul_k : q.i * q.k = c₁ • q.j := by
rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul]
#align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k
@[simp]
theorem k_mul_i : q.k * q.i = -c₁ • q.j := by
rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul]
#align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i
@[simp]
theorem k_mul_j : q.k * q.j = c₂ • q.i := by
rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one]
#align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j
@[simp]
| Mathlib/Algebra/QuaternionBasis.lean | 99 | 100 | theorem j_mul_k : q.j * q.k = -c₂ • q.i := by |
rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul]
| 1 | 2.718282 | 0 | 0.4 | 10 | 394 |
import Mathlib.Algebra.IsPrimePow
import Mathlib.SetTheory.Cardinal.Ordinal
import Mathlib.Tactic.WLOG
#align_import set_theory.cardinal.divisibility from "leanprover-community/mathlib"@"ea050b44c0f9aba9d16a948c7cc7d2e7c8493567"
namespace Cardinal
open Cardinal
universe u
variable {a b : Cardinal.{u}} {n m : ℕ}
@[simp]
| Mathlib/SetTheory/Cardinal/Divisibility.lean | 43 | 58 | theorem isUnit_iff : IsUnit a ↔ a = 1 := by |
refine
⟨fun h => ?_, by
rintro rfl
exact isUnit_one⟩
rcases eq_or_ne a 0 with (rfl | ha)
· exact (not_isUnit_zero h).elim
rw [isUnit_iff_forall_dvd] at h
cases' h 1 with t ht
rw [eq_comm, mul_eq_one_iff'] at ht
· exact ht.1
· exact one_le_iff_ne_zero.mpr ha
· apply one_le_iff_ne_zero.mpr
intro h
rw [h, mul_zero] at ht
exact zero_ne_one ht
| 15 | 3,269,017.372472 | 2 | 2 | 7 | 2,430 |
import Mathlib.Analysis.SpecialFunctions.Integrals
#align_import data.real.pi.wallis from "leanprover-community/mathlib"@"980755c33b9168bc82f774f665eaa27878140fac"
open scoped Real Topology Nat
open Filter Finset intervalIntegral
namespace Real
namespace Wallis
set_option linter.uppercaseLean3 false
noncomputable def W (k : ℕ) : ℝ :=
∏ i ∈ range k, (2 * i + 2) / (2 * i + 1) * ((2 * i + 2) / (2 * i + 3))
#align real.wallis.W Real.Wallis.W
theorem W_succ (k : ℕ) :
W (k + 1) = W k * ((2 * k + 2) / (2 * k + 1) * ((2 * k + 2) / (2 * k + 3))) :=
prod_range_succ _ _
#align real.wallis.W_succ Real.Wallis.W_succ
| Mathlib/Data/Real/Pi/Wallis.lean | 55 | 59 | theorem W_pos (k : ℕ) : 0 < W k := by |
induction' k with k hk
· unfold W; simp
· rw [W_succ]
refine mul_pos hk (mul_pos (div_pos ?_ ?_) (div_pos ?_ ?_)) <;> positivity
| 4 | 54.59815 | 2 | 1.666667 | 6 | 1,817 |
import Mathlib.Data.Stream.Defs
import Mathlib.Logic.Function.Basic
import Mathlib.Init.Data.List.Basic
import Mathlib.Data.List.Basic
#align_import data.stream.init from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
set_option autoImplicit true
open Nat Function Option
namespace Stream'
variable {α : Type u} {β : Type v} {δ : Type w}
instance [Inhabited α] : Inhabited (Stream' α) :=
⟨Stream'.const default⟩
protected theorem eta (s : Stream' α) : (head s::tail s) = s :=
funext fun i => by cases i <;> rfl
#align stream.eta Stream'.eta
@[ext]
protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, get s₁ n = get s₂ n) → s₁ = s₂ :=
fun h => funext h
#align stream.ext Stream'.ext
@[simp]
theorem get_zero_cons (a : α) (s : Stream' α) : get (a::s) 0 = a :=
rfl
#align stream.nth_zero_cons Stream'.get_zero_cons
@[simp]
theorem head_cons (a : α) (s : Stream' α) : head (a::s) = a :=
rfl
#align stream.head_cons Stream'.head_cons
@[simp]
theorem tail_cons (a : α) (s : Stream' α) : tail (a::s) = s :=
rfl
#align stream.tail_cons Stream'.tail_cons
@[simp]
theorem get_drop (n m : Nat) (s : Stream' α) : get (drop m s) n = get s (n + m) :=
rfl
#align stream.nth_drop Stream'.get_drop
theorem tail_eq_drop (s : Stream' α) : tail s = drop 1 s :=
rfl
#align stream.tail_eq_drop Stream'.tail_eq_drop
@[simp]
| Mathlib/Data/Stream/Init.lean | 65 | 66 | theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m) s := by |
ext; simp [Nat.add_assoc]
| 1 | 2.718282 | 0 | 0.2 | 5 | 275 |
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.MeasureTheory.Measure.MeasureSpaceDef
#align_import measure_theory.function.ae_measurable_sequence from "leanprover-community/mathlib"@"d003c55042c3cd08aefd1ae9a42ef89441cdaaf3"
open MeasureTheory
open scoped Classical
variable {ι : Sort*} {α β γ : Type*} [MeasurableSpace α] [MeasurableSpace β] {f : ι → α → β}
{μ : Measure α} {p : α → (ι → β) → Prop}
def aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : Set α :=
(toMeasurable μ { x | (∀ i, f i x = (hf i).mk (f i) x) ∧ p x fun n => f n x }ᶜ)ᶜ
#align ae_seq_set aeSeqSet
noncomputable def aeSeq (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : ι → α → β :=
fun i x => ite (x ∈ aeSeqSet hf p) ((hf i).mk (f i) x) (⟨f i x⟩ : Nonempty β).some
#align ae_seq aeSeq
namespace aeSeq
section MemAESeqSet
theorem mk_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p)
(i : ι) : (hf i).mk (f i) x = f i x :=
haveI h_ss : aeSeqSet hf p ⊆ { x | ∀ i, f i x = (hf i).mk (f i) x } := by
rw [aeSeqSet, ← compl_compl { x | ∀ i, f i x = (hf i).mk (f i) x }, Set.compl_subset_compl]
refine Set.Subset.trans (Set.compl_subset_compl.mpr fun x h => ?_) (subset_toMeasurable _ _)
exact h.1
(h_ss hx i).symm
#align ae_seq.mk_eq_fun_of_mem_ae_seq_set aeSeq.mk_eq_fun_of_mem_aeSeqSet
theorem aeSeq_eq_mk_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α}
(hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = (hf i).mk (f i) x := by
simp only [aeSeq, hx, if_true]
#align ae_seq.ae_seq_eq_mk_of_mem_ae_seq_set aeSeq.aeSeq_eq_mk_of_mem_aeSeqSet
| Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean | 64 | 66 | theorem aeSeq_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α}
(hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = f i x := by |
simp only [aeSeq_eq_mk_of_mem_aeSeqSet hf hx i, mk_eq_fun_of_mem_aeSeqSet hf hx i]
| 1 | 2.718282 | 0 | 1.333333 | 6 | 1,404 |
import Mathlib.Algebra.Module.Zlattice.Basic
import Mathlib.NumberTheory.NumberField.Embeddings
import Mathlib.NumberTheory.NumberField.FractionalIdeal
#align_import number_theory.number_field.canonical_embedding from "leanprover-community/mathlib"@"60da01b41bbe4206f05d34fd70c8dd7498717a30"
variable (K : Type*) [Field K]
namespace NumberField.canonicalEmbedding
open NumberField
def _root_.NumberField.canonicalEmbedding : K →+* ((K →+* ℂ) → ℂ) := Pi.ringHom fun φ => φ
theorem _root_.NumberField.canonicalEmbedding_injective [NumberField K] :
Function.Injective (NumberField.canonicalEmbedding K) := RingHom.injective _
variable {K}
@[simp]
theorem apply_at (φ : K →+* ℂ) (x : K) : (NumberField.canonicalEmbedding K x) φ = φ x := rfl
open scoped ComplexConjugate
theorem conj_apply {x : ((K →+* ℂ) → ℂ)} (φ : K →+* ℂ)
(hx : x ∈ Submodule.span ℝ (Set.range (canonicalEmbedding K))) :
conj (x φ) = x (ComplexEmbedding.conjugate φ) := by
refine Submodule.span_induction hx ?_ ?_ (fun _ _ hx hy => ?_) (fun a _ hx => ?_)
· rintro _ ⟨x, rfl⟩
rw [apply_at, apply_at, ComplexEmbedding.conjugate_coe_eq]
· rw [Pi.zero_apply, Pi.zero_apply, map_zero]
· rw [Pi.add_apply, Pi.add_apply, map_add, hx, hy]
· rw [Pi.smul_apply, Complex.real_smul, map_mul, Complex.conj_ofReal]
exact congrArg ((a : ℂ) * ·) hx
| Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean | 72 | 74 | theorem nnnorm_eq [NumberField K] (x : K) :
‖canonicalEmbedding K x‖₊ = Finset.univ.sup (fun φ : K →+* ℂ => ‖φ x‖₊) := by |
simp_rw [Pi.nnnorm_def, apply_at]
| 1 | 2.718282 | 0 | 1.1875 | 16 | 1,249 |
import Mathlib.Algebra.Order.Interval.Set.Instances
import Mathlib.Order.Interval.Set.ProjIcc
import Mathlib.Topology.Instances.Real
#align_import topology.unit_interval from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open scoped Classical
open Topology Filter
open Set Int Set.Icc
abbrev unitInterval : Set ℝ :=
Set.Icc 0 1
#align unit_interval unitInterval
@[inherit_doc]
scoped[unitInterval] notation "I" => unitInterval
section partition
@[simp]
theorem projIcc_eq_zero {x : ℝ} : projIcc (0 : ℝ) 1 zero_le_one x = 0 ↔ x ≤ 0 :=
projIcc_eq_left zero_lt_one
#align proj_Icc_eq_zero projIcc_eq_zero
@[simp]
theorem projIcc_eq_one {x : ℝ} : projIcc (0 : ℝ) 1 zero_le_one x = 1 ↔ 1 ≤ x :=
projIcc_eq_right zero_lt_one
#align proj_Icc_eq_one projIcc_eq_one
section
variable {𝕜 : Type*} [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [TopologicalRing 𝕜]
-- We only need the ordering on `𝕜` here to avoid talking about flipping the interval over.
-- At the end of the day I only care about `ℝ`, so I'm hesitant to put work into generalizing.
| Mathlib/Topology/UnitInterval.lean | 323 | 324 | theorem affineHomeomorph_image_I (a b : 𝕜) (h : 0 < a) :
affineHomeomorph a b h.ne.symm '' Set.Icc 0 1 = Set.Icc b (a + b) := by | simp [h]
| 1 | 2.718282 | 0 | 0.25 | 4 | 303 |
import Mathlib.Data.Finsupp.Basic
import Mathlib.Data.Finsupp.Order
#align_import data.finsupp.multiset from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf"
open Finset
variable {α β ι : Type*}
namespace Finsupp
def toMultiset : (α →₀ ℕ) →+ Multiset α where
toFun f := Finsupp.sum f fun a n => n • {a}
-- Porting note: times out if h is not specified
map_add' _f _g := sum_add_index' (h := fun a n => n • ({a} : Multiset α))
(fun _ ↦ zero_nsmul _) (fun _ ↦ add_nsmul _)
map_zero' := sum_zero_index
theorem toMultiset_zero : toMultiset (0 : α →₀ ℕ) = 0 :=
rfl
#align finsupp.to_multiset_zero Finsupp.toMultiset_zero
theorem toMultiset_add (m n : α →₀ ℕ) : toMultiset (m + n) = toMultiset m + toMultiset n :=
toMultiset.map_add m n
#align finsupp.to_multiset_add Finsupp.toMultiset_add
theorem toMultiset_apply (f : α →₀ ℕ) : toMultiset f = f.sum fun a n => n • {a} :=
rfl
#align finsupp.to_multiset_apply Finsupp.toMultiset_apply
@[simp]
theorem toMultiset_single (a : α) (n : ℕ) : toMultiset (single a n) = n • {a} := by
rw [toMultiset_apply, sum_single_index]; apply zero_nsmul
#align finsupp.to_multiset_single Finsupp.toMultiset_single
theorem toMultiset_sum {f : ι → α →₀ ℕ} (s : Finset ι) :
Finsupp.toMultiset (∑ i ∈ s, f i) = ∑ i ∈ s, Finsupp.toMultiset (f i) :=
map_sum Finsupp.toMultiset _ _
#align finsupp.to_multiset_sum Finsupp.toMultiset_sum
| Mathlib/Data/Finsupp/Multiset.lean | 61 | 63 | theorem toMultiset_sum_single (s : Finset ι) (n : ℕ) :
Finsupp.toMultiset (∑ i ∈ s, single i n) = n • s.val := by |
simp_rw [toMultiset_sum, Finsupp.toMultiset_single, sum_nsmul, sum_multiset_singleton]
| 1 | 2.718282 | 0 | 1.111111 | 9 | 1,194 |
import Mathlib.Topology.MetricSpace.ProperSpace
import Mathlib.Topology.MetricSpace.Cauchy
open Set Filter Bornology
open scoped ENNReal Uniformity Topology Pointwise
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
variable [PseudoMetricSpace α]
namespace Metric
#align metric.bounded Bornology.IsBounded
section Bounded
variable {x : α} {s t : Set α} {r : ℝ}
#noalign metric.bounded_iff_is_bounded
#align metric.bounded_empty Bornology.isBounded_empty
#align metric.bounded_iff_mem_bounded Bornology.isBounded_iff_forall_mem
#align metric.bounded.mono Bornology.IsBounded.subset
theorem isBounded_closedBall : IsBounded (closedBall x r) :=
isBounded_iff.2 ⟨r + r, fun y hy z hz =>
calc dist y z ≤ dist y x + dist z x := dist_triangle_right _ _ _
_ ≤ r + r := add_le_add hy hz⟩
#align metric.bounded_closed_ball Metric.isBounded_closedBall
theorem isBounded_ball : IsBounded (ball x r) :=
isBounded_closedBall.subset ball_subset_closedBall
#align metric.bounded_ball Metric.isBounded_ball
theorem isBounded_sphere : IsBounded (sphere x r) :=
isBounded_closedBall.subset sphere_subset_closedBall
#align metric.bounded_sphere Metric.isBounded_sphere
theorem isBounded_iff_subset_closedBall (c : α) : IsBounded s ↔ ∃ r, s ⊆ closedBall c r :=
⟨fun h ↦ (isBounded_iff.1 (h.insert c)).imp fun _r hr _x hx ↦ hr (.inr hx) (mem_insert _ _),
fun ⟨_r, hr⟩ ↦ isBounded_closedBall.subset hr⟩
#align metric.bounded_iff_subset_ball Metric.isBounded_iff_subset_closedBall
theorem _root_.Bornology.IsBounded.subset_closedBall (h : IsBounded s) (c : α) :
∃ r, s ⊆ closedBall c r :=
(isBounded_iff_subset_closedBall c).1 h
#align metric.bounded.subset_ball Bornology.IsBounded.subset_closedBall
theorem _root_.Bornology.IsBounded.subset_ball_lt (h : IsBounded s) (a : ℝ) (c : α) :
∃ r, a < r ∧ s ⊆ ball c r :=
let ⟨r, hr⟩ := h.subset_closedBall c
⟨max r a + 1, (le_max_right _ _).trans_lt (lt_add_one _), hr.trans <| closedBall_subset_ball <|
(le_max_left _ _).trans_lt (lt_add_one _)⟩
theorem _root_.Bornology.IsBounded.subset_ball (h : IsBounded s) (c : α) : ∃ r, s ⊆ ball c r :=
(h.subset_ball_lt 0 c).imp fun _ ↦ And.right
theorem isBounded_iff_subset_ball (c : α) : IsBounded s ↔ ∃ r, s ⊆ ball c r :=
⟨(IsBounded.subset_ball · c), fun ⟨_r, hr⟩ ↦ isBounded_ball.subset hr⟩
theorem _root_.Bornology.IsBounded.subset_closedBall_lt (h : IsBounded s) (a : ℝ) (c : α) :
∃ r, a < r ∧ s ⊆ closedBall c r :=
let ⟨r, har, hr⟩ := h.subset_ball_lt a c
⟨r, har, hr.trans ball_subset_closedBall⟩
#align metric.bounded.subset_ball_lt Bornology.IsBounded.subset_closedBall_lt
theorem isBounded_closure_of_isBounded (h : IsBounded s) : IsBounded (closure s) :=
let ⟨C, h⟩ := isBounded_iff.1 h
isBounded_iff.2 ⟨C, fun _a ha _b hb => isClosed_Iic.closure_subset <|
map_mem_closure₂ continuous_dist ha hb h⟩
#align metric.bounded_closure_of_bounded Metric.isBounded_closure_of_isBounded
protected theorem _root_.Bornology.IsBounded.closure (h : IsBounded s) : IsBounded (closure s) :=
isBounded_closure_of_isBounded h
#align metric.bounded.closure Bornology.IsBounded.closure
@[simp]
theorem isBounded_closure_iff : IsBounded (closure s) ↔ IsBounded s :=
⟨fun h => h.subset subset_closure, fun h => h.closure⟩
#align metric.bounded_closure_iff Metric.isBounded_closure_iff
#align metric.bounded_union Bornology.isBounded_union
#align metric.bounded.union Bornology.IsBounded.union
#align metric.bounded_bUnion Bornology.isBounded_biUnion
#align metric.bounded.prod Bornology.IsBounded.prod
theorem hasBasis_cobounded_compl_closedBall (c : α) :
(cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (closedBall c r)ᶜ) :=
⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_closedBall c).trans <| by simp⟩
theorem hasBasis_cobounded_compl_ball (c : α) :
(cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (ball c r)ᶜ) :=
⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_ball c).trans <| by simp⟩
@[simp]
theorem comap_dist_right_atTop (c : α) : comap (dist · c) atTop = cobounded α :=
(atTop_basis.comap _).eq_of_same_basis <| by
simpa only [compl_def, mem_ball, not_lt] using hasBasis_cobounded_compl_ball c
@[simp]
theorem comap_dist_left_atTop (c : α) : comap (dist c) atTop = cobounded α := by
simpa only [dist_comm _ c] using comap_dist_right_atTop c
@[simp]
| Mathlib/Topology/MetricSpace/Bounded.lean | 137 | 139 | theorem tendsto_dist_right_atTop_iff (c : α) {f : β → α} {l : Filter β} :
Tendsto (fun x ↦ dist (f x) c) l atTop ↔ Tendsto f l (cobounded α) := by |
rw [← comap_dist_right_atTop c, tendsto_comap_iff, Function.comp_def]
| 1 | 2.718282 | 0 | 0 | 3 | 140 |
import Mathlib.Combinatorics.SimpleGraph.Subgraph
import Mathlib.Data.List.Rotate
#align_import combinatorics.simple_graph.connectivity from "leanprover-community/mathlib"@"b99e2d58a5e6861833fa8de11e51a81144258db4"
open Function
universe u v w
namespace SimpleGraph
variable {V : Type u} {V' : Type v} {V'' : Type w}
variable (G : SimpleGraph V) (G' : SimpleGraph V') (G'' : SimpleGraph V'')
inductive Walk : V → V → Type u
| nil {u : V} : Walk u u
| cons {u v w : V} (h : G.Adj u v) (p : Walk v w) : Walk u w
deriving DecidableEq
#align simple_graph.walk SimpleGraph.Walk
attribute [refl] Walk.nil
@[simps]
instance Walk.instInhabited (v : V) : Inhabited (G.Walk v v) := ⟨Walk.nil⟩
#align simple_graph.walk.inhabited SimpleGraph.Walk.instInhabited
@[match_pattern, reducible]
def Adj.toWalk {G : SimpleGraph V} {u v : V} (h : G.Adj u v) : G.Walk u v :=
Walk.cons h Walk.nil
#align simple_graph.adj.to_walk SimpleGraph.Adj.toWalk
namespace Walk
variable {G}
@[match_pattern]
abbrev nil' (u : V) : G.Walk u u := Walk.nil
#align simple_graph.walk.nil' SimpleGraph.Walk.nil'
@[match_pattern]
abbrev cons' (u v w : V) (h : G.Adj u v) (p : G.Walk v w) : G.Walk u w := Walk.cons h p
#align simple_graph.walk.cons' SimpleGraph.Walk.cons'
protected def copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') : G.Walk u' v' :=
hu ▸ hv ▸ p
#align simple_graph.walk.copy SimpleGraph.Walk.copy
@[simp]
theorem copy_rfl_rfl {u v} (p : G.Walk u v) : p.copy rfl rfl = p := rfl
#align simple_graph.walk.copy_rfl_rfl SimpleGraph.Walk.copy_rfl_rfl
@[simp]
theorem copy_copy {u v u' v' u'' v''} (p : G.Walk u v)
(hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') :
(p.copy hu hv).copy hu' hv' = p.copy (hu.trans hu') (hv.trans hv') := by
subst_vars
rfl
#align simple_graph.walk.copy_copy SimpleGraph.Walk.copy_copy
@[simp]
theorem copy_nil {u u'} (hu : u = u') : (Walk.nil : G.Walk u u).copy hu hu = Walk.nil := by
subst_vars
rfl
#align simple_graph.walk.copy_nil SimpleGraph.Walk.copy_nil
theorem copy_cons {u v w u' w'} (h : G.Adj u v) (p : G.Walk v w) (hu : u = u') (hw : w = w') :
(Walk.cons h p).copy hu hw = Walk.cons (hu ▸ h) (p.copy rfl hw) := by
subst_vars
rfl
#align simple_graph.walk.copy_cons SimpleGraph.Walk.copy_cons
@[simp]
theorem cons_copy {u v w v' w'} (h : G.Adj u v) (p : G.Walk v' w') (hv : v' = v) (hw : w' = w) :
Walk.cons h (p.copy hv hw) = (Walk.cons (hv ▸ h) p).copy rfl hw := by
subst_vars
rfl
#align simple_graph.walk.cons_copy SimpleGraph.Walk.cons_copy
theorem exists_eq_cons_of_ne {u v : V} (hne : u ≠ v) :
∀ (p : G.Walk u v), ∃ (w : V) (h : G.Adj u w) (p' : G.Walk w v), p = cons h p'
| nil => (hne rfl).elim
| cons h p' => ⟨_, h, p', rfl⟩
#align simple_graph.walk.exists_eq_cons_of_ne SimpleGraph.Walk.exists_eq_cons_of_ne
def length {u v : V} : G.Walk u v → ℕ
| nil => 0
| cons _ q => q.length.succ
#align simple_graph.walk.length SimpleGraph.Walk.length
@[trans]
def append {u v w : V} : G.Walk u v → G.Walk v w → G.Walk u w
| nil, q => q
| cons h p, q => cons h (p.append q)
#align simple_graph.walk.append SimpleGraph.Walk.append
def concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) : G.Walk u w := p.append (cons h nil)
#align simple_graph.walk.concat SimpleGraph.Walk.concat
theorem concat_eq_append {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
p.concat h = p.append (cons h nil) := rfl
#align simple_graph.walk.concat_eq_append SimpleGraph.Walk.concat_eq_append
protected def reverseAux {u v w : V} : G.Walk u v → G.Walk u w → G.Walk v w
| nil, q => q
| cons h p, q => Walk.reverseAux p (cons (G.symm h) q)
#align simple_graph.walk.reverse_aux SimpleGraph.Walk.reverseAux
@[symm]
def reverse {u v : V} (w : G.Walk u v) : G.Walk v u := w.reverseAux nil
#align simple_graph.walk.reverse SimpleGraph.Walk.reverse
def getVert {u v : V} : G.Walk u v → ℕ → V
| nil, _ => u
| cons _ _, 0 => u
| cons _ q, n + 1 => q.getVert n
#align simple_graph.walk.get_vert SimpleGraph.Walk.getVert
@[simp]
| Mathlib/Combinatorics/SimpleGraph/Connectivity.lean | 208 | 208 | theorem getVert_zero {u v} (w : G.Walk u v) : w.getVert 0 = u := by | cases w <;> rfl
| 1 | 2.718282 | 0 | 1 | 6 | 918 |
import Mathlib.Algebra.MvPolynomial.Degrees
#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 Vars
def vars (p : MvPolynomial σ R) : Finset σ :=
letI := Classical.decEq σ
p.degrees.toFinset
#align mv_polynomial.vars MvPolynomial.vars
theorem vars_def [DecidableEq σ] (p : MvPolynomial σ R) : p.vars = p.degrees.toFinset := by
rw [vars]
convert rfl
#align mv_polynomial.vars_def MvPolynomial.vars_def
@[simp]
theorem vars_0 : (0 : MvPolynomial σ R).vars = ∅ := by
classical rw [vars_def, degrees_zero, Multiset.toFinset_zero]
#align mv_polynomial.vars_0 MvPolynomial.vars_0
@[simp]
theorem vars_monomial (h : r ≠ 0) : (monomial s r).vars = s.support := by
classical rw [vars_def, degrees_monomial_eq _ _ h, Finsupp.toFinset_toMultiset]
#align mv_polynomial.vars_monomial MvPolynomial.vars_monomial
@[simp]
theorem vars_C : (C r : MvPolynomial σ R).vars = ∅ := by
classical rw [vars_def, degrees_C, Multiset.toFinset_zero]
set_option linter.uppercaseLean3 false in
#align mv_polynomial.vars_C MvPolynomial.vars_C
@[simp]
| Mathlib/Algebra/MvPolynomial/Variables.lean | 93 | 94 | theorem vars_X [Nontrivial R] : (X n : MvPolynomial σ R).vars = {n} := by |
rw [X, vars_monomial (one_ne_zero' R), Finsupp.support_single_ne_zero _ (one_ne_zero' ℕ)]
| 1 | 2.718282 | 0 | 0.9 | 20 | 778 |
import Mathlib.MeasureTheory.PiSystem
import Mathlib.Order.OmegaCompletePartialOrder
import Mathlib.Topology.Constructions
import Mathlib.MeasureTheory.MeasurableSpace.Basic
open Set
namespace MeasureTheory
variable {ι : Type _} {α : ι → Type _}
section cylinder
def cylinder (s : Finset ι) (S : Set (∀ i : s, α i)) : Set (∀ i, α i) :=
(fun (f : ∀ i, α i) (i : s) ↦ f i) ⁻¹' S
@[simp]
theorem mem_cylinder (s : Finset ι) (S : Set (∀ i : s, α i)) (f : ∀ i, α i) :
f ∈ cylinder s S ↔ (fun i : s ↦ f i) ∈ S :=
mem_preimage
@[simp]
theorem cylinder_empty (s : Finset ι) : cylinder s (∅ : Set (∀ i : s, α i)) = ∅ := by
rw [cylinder, preimage_empty]
@[simp]
theorem cylinder_univ (s : Finset ι) : cylinder s (univ : Set (∀ i : s, α i)) = univ := by
rw [cylinder, preimage_univ]
@[simp]
theorem cylinder_eq_empty_iff [h_nonempty : Nonempty (∀ i, α i)] (s : Finset ι)
(S : Set (∀ i : s, α i)) :
cylinder s S = ∅ ↔ S = ∅ := by
refine ⟨fun h ↦ ?_, fun h ↦ by (rw [h]; exact cylinder_empty _)⟩
by_contra hS
rw [← Ne, ← nonempty_iff_ne_empty] at hS
let f := hS.some
have hf : f ∈ S := hS.choose_spec
classical
let f' : ∀ i, α i := fun i ↦ if hi : i ∈ s then f ⟨i, hi⟩ else h_nonempty.some i
have hf' : f' ∈ cylinder s S := by
rw [mem_cylinder]
simpa only [f', Finset.coe_mem, dif_pos]
rw [h] at hf'
exact not_mem_empty _ hf'
theorem inter_cylinder (s₁ s₂ : Finset ι) (S₁ : Set (∀ i : s₁, α i)) (S₂ : Set (∀ i : s₂, α i))
[DecidableEq ι] :
cylinder s₁ S₁ ∩ cylinder s₂ S₂ =
cylinder (s₁ ∪ s₂)
((fun f ↦ fun j : s₁ ↦ f ⟨j, Finset.mem_union_left s₂ j.prop⟩) ⁻¹' S₁ ∩
(fun f ↦ fun j : s₂ ↦ f ⟨j, Finset.mem_union_right s₁ j.prop⟩) ⁻¹' S₂) := by
ext1 f; simp only [mem_inter_iff, mem_cylinder, mem_setOf_eq]; rfl
theorem inter_cylinder_same (s : Finset ι) (S₁ : Set (∀ i : s, α i)) (S₂ : Set (∀ i : s, α i)) :
cylinder s S₁ ∩ cylinder s S₂ = cylinder s (S₁ ∩ S₂) := by
classical rw [inter_cylinder]; rfl
theorem union_cylinder (s₁ s₂ : Finset ι) (S₁ : Set (∀ i : s₁, α i)) (S₂ : Set (∀ i : s₂, α i))
[DecidableEq ι] :
cylinder s₁ S₁ ∪ cylinder s₂ S₂ =
cylinder (s₁ ∪ s₂)
((fun f ↦ fun j : s₁ ↦ f ⟨j, Finset.mem_union_left s₂ j.prop⟩) ⁻¹' S₁ ∪
(fun f ↦ fun j : s₂ ↦ f ⟨j, Finset.mem_union_right s₁ j.prop⟩) ⁻¹' S₂) := by
ext1 f; simp only [mem_union, mem_cylinder, mem_setOf_eq]; rfl
| Mathlib/MeasureTheory/Constructions/Cylinders.lean | 205 | 207 | theorem union_cylinder_same (s : Finset ι) (S₁ : Set (∀ i : s, α i)) (S₂ : Set (∀ i : s, α i)) :
cylinder s S₁ ∪ cylinder s S₂ = cylinder s (S₁ ∪ S₂) := by |
classical rw [union_cylinder]; rfl
| 1 | 2.718282 | 0 | 0.6875 | 16 | 636 |
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
| Mathlib/Algebra/Order/Interval/Set/Monoid.lean | 44 | 48 | 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
| 4 | 54.59815 | 2 | 1.090909 | 11 | 1,187 |
import Mathlib.Algebra.Order.Monoid.Defs
import Mathlib.Algebra.Order.Sub.Defs
import Mathlib.Util.AssertExists
#align_import algebra.order.group.defs from "leanprover-community/mathlib"@"b599f4e4e5cf1fbcb4194503671d3d9e569c1fce"
open Function
universe u
variable {α : Type u}
class OrderedAddCommGroup (α : Type u) extends AddCommGroup α, PartialOrder α where
protected add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b
#align ordered_add_comm_group OrderedAddCommGroup
class OrderedCommGroup (α : Type u) extends CommGroup α, PartialOrder α where
protected mul_le_mul_left : ∀ a b : α, a ≤ b → ∀ c : α, c * a ≤ c * b
#align ordered_comm_group OrderedCommGroup
attribute [to_additive] OrderedCommGroup
@[to_additive]
instance OrderedCommGroup.to_covariantClass_left_le (α : Type u) [OrderedCommGroup α] :
CovariantClass α α (· * ·) (· ≤ ·) where
elim a b c bc := OrderedCommGroup.mul_le_mul_left b c bc a
#align ordered_comm_group.to_covariant_class_left_le OrderedCommGroup.to_covariantClass_left_le
#align ordered_add_comm_group.to_covariant_class_left_le OrderedAddCommGroup.to_covariantClass_left_le
-- See note [lower instance priority]
@[to_additive OrderedAddCommGroup.toOrderedCancelAddCommMonoid]
instance (priority := 100) OrderedCommGroup.toOrderedCancelCommMonoid [OrderedCommGroup α] :
OrderedCancelCommMonoid α :=
{ ‹OrderedCommGroup α› with le_of_mul_le_mul_left := fun a b c ↦ le_of_mul_le_mul_left' }
#align ordered_comm_group.to_ordered_cancel_comm_monoid OrderedCommGroup.toOrderedCancelCommMonoid
#align ordered_add_comm_group.to_ordered_cancel_add_comm_monoid OrderedAddCommGroup.toOrderedCancelAddCommMonoid
example (α : Type u) [OrderedAddCommGroup α] : CovariantClass α α (swap (· + ·)) (· < ·) :=
IsRightCancelAdd.covariant_swap_add_lt_of_covariant_swap_add_le α
-- Porting note: this instance is not used,
-- and causes timeouts after lean4#2210.
-- It was introduced in https://github.com/leanprover-community/mathlib/pull/17564
-- but without the motivation clearly explained.
@[to_additive "A choice-free shortcut instance."]
theorem OrderedCommGroup.to_contravariantClass_left_le (α : Type u) [OrderedCommGroup α] :
ContravariantClass α α (· * ·) (· ≤ ·) where
elim a b c bc := by simpa using mul_le_mul_left' bc a⁻¹
#align ordered_comm_group.to_contravariant_class_left_le OrderedCommGroup.to_contravariantClass_left_le
#align ordered_add_comm_group.to_contravariant_class_left_le OrderedAddCommGroup.to_contravariantClass_left_le
-- Porting note: this instance is not used,
-- and causes timeouts after lean4#2210.
-- See further explanation on `OrderedCommGroup.to_contravariantClass_left_le`.
@[to_additive "A choice-free shortcut instance."]
theorem OrderedCommGroup.to_contravariantClass_right_le (α : Type u) [OrderedCommGroup α] :
ContravariantClass α α (swap (· * ·)) (· ≤ ·) where
elim a b c bc := by simpa using mul_le_mul_right' bc a⁻¹
#align ordered_comm_group.to_contravariant_class_right_le OrderedCommGroup.to_contravariantClass_right_le
#align ordered_add_comm_group.to_contravariant_class_right_le OrderedAddCommGroup.to_contravariantClass_right_le
section Group
variable [Group α]
section TypeclassesLeftLT
variable [LT α] [CovariantClass α α (· * ·) (· < ·)] {a b c : α}
@[to_additive (attr := simp) Left.neg_pos_iff "Uses `left` co(ntra)variant."]
theorem Left.one_lt_inv_iff : 1 < a⁻¹ ↔ a < 1 := by
rw [← mul_lt_mul_iff_left a, mul_inv_self, mul_one]
#align left.one_lt_inv_iff Left.one_lt_inv_iff
#align left.neg_pos_iff Left.neg_pos_iff
@[to_additive (attr := simp) "Uses `left` co(ntra)variant."]
| Mathlib/Algebra/Order/Group/Defs.lean | 165 | 166 | theorem Left.inv_lt_one_iff : a⁻¹ < 1 ↔ 1 < a := by |
rw [← mul_lt_mul_iff_left a, mul_inv_self, mul_one]
| 1 | 2.718282 | 0 | 0.4 | 25 | 400 |
import Mathlib.Data.Bool.Set
import Mathlib.Data.Nat.Set
import Mathlib.Data.Set.Prod
import Mathlib.Data.ULift
import Mathlib.Order.Bounds.Basic
import Mathlib.Order.Hom.Set
import Mathlib.Order.SetNotation
#align_import order.complete_lattice from "leanprover-community/mathlib"@"5709b0d8725255e76f47debca6400c07b5c2d8e6"
open Function OrderDual Set
variable {α β β₂ γ : Type*} {ι ι' : Sort*} {κ : ι → Sort*} {κ' : ι' → Sort*}
instance OrderDual.supSet (α) [InfSet α] : SupSet αᵒᵈ :=
⟨(sInf : Set α → α)⟩
instance OrderDual.infSet (α) [SupSet α] : InfSet αᵒᵈ :=
⟨(sSup : Set α → α)⟩
class CompleteSemilatticeSup (α : Type*) extends PartialOrder α, SupSet α where
le_sSup : ∀ s, ∀ a ∈ s, a ≤ sSup s
sSup_le : ∀ s a, (∀ b ∈ s, b ≤ a) → sSup s ≤ a
#align complete_semilattice_Sup CompleteSemilatticeSup
section
variable [CompleteSemilatticeSup α] {s t : Set α} {a b : α}
theorem le_sSup : a ∈ s → a ≤ sSup s :=
CompleteSemilatticeSup.le_sSup s a
#align le_Sup le_sSup
theorem sSup_le : (∀ b ∈ s, b ≤ a) → sSup s ≤ a :=
CompleteSemilatticeSup.sSup_le s a
#align Sup_le sSup_le
theorem isLUB_sSup (s : Set α) : IsLUB s (sSup s) :=
⟨fun _ ↦ le_sSup, fun _ ↦ sSup_le⟩
#align is_lub_Sup isLUB_sSup
lemma isLUB_iff_sSup_eq : IsLUB s a ↔ sSup s = a :=
⟨(isLUB_sSup s).unique, by rintro rfl; exact isLUB_sSup _⟩
alias ⟨IsLUB.sSup_eq, _⟩ := isLUB_iff_sSup_eq
#align is_lub.Sup_eq IsLUB.sSup_eq
theorem le_sSup_of_le (hb : b ∈ s) (h : a ≤ b) : a ≤ sSup s :=
le_trans h (le_sSup hb)
#align le_Sup_of_le le_sSup_of_le
@[gcongr]
theorem sSup_le_sSup (h : s ⊆ t) : sSup s ≤ sSup t :=
(isLUB_sSup s).mono (isLUB_sSup t) h
#align Sup_le_Sup sSup_le_sSup
@[simp]
theorem sSup_le_iff : sSup s ≤ a ↔ ∀ b ∈ s, b ≤ a :=
isLUB_le_iff (isLUB_sSup s)
#align Sup_le_iff sSup_le_iff
theorem le_sSup_iff : a ≤ sSup s ↔ ∀ b ∈ upperBounds s, a ≤ b :=
⟨fun h _ hb => le_trans h (sSup_le hb), fun hb => hb _ fun _ => le_sSup⟩
#align le_Sup_iff le_sSup_iff
| Mathlib/Order/CompleteLattice.lean | 110 | 111 | theorem le_iSup_iff {s : ι → α} : a ≤ iSup s ↔ ∀ b, (∀ i, s i ≤ b) → a ≤ b := by |
simp [iSup, le_sSup_iff, upperBounds]
| 1 | 2.718282 | 0 | 0 | 2 | 192 |
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
| Mathlib/Init/Data/Bool/Lemmas.lean | 68 | 69 | theorem and_eq_true_eq_eq_true_and_eq_true (a b : Bool) :
((a && b) = true) = (a = true ∧ b = true) := by | simp
| 1 | 2.718282 | 0 | 0 | 7 | 206 |
import Mathlib.RingTheory.WittVector.Frobenius
import Mathlib.RingTheory.WittVector.Verschiebung
import Mathlib.RingTheory.WittVector.MulP
#align_import ring_theory.witt_vector.identities from "leanprover-community/mathlib"@"0798037604b2d91748f9b43925fb7570a5f3256c"
namespace WittVector
variable {p : ℕ} {R : Type*} [hp : Fact p.Prime] [CommRing R]
-- type as `\bbW`
local notation "𝕎" => WittVector p
noncomputable section
-- Porting note: `ghost_calc` failure: `simp only []` and the manual instances had to be added.
theorem frobenius_verschiebung (x : 𝕎 R) : frobenius (verschiebung x) = x * p := by
have : IsPoly p fun {R} [CommRing R] x ↦ frobenius (verschiebung x) :=
IsPoly.comp (hg := frobenius_isPoly p) (hf := verschiebung_isPoly)
have : IsPoly p fun {R} [CommRing R] x ↦ x * p := mulN_isPoly p p
ghost_calc x
ghost_simp [mul_comm]
#align witt_vector.frobenius_verschiebung WittVector.frobenius_verschiebung
theorem verschiebung_zmod (x : 𝕎 (ZMod p)) : verschiebung x = x * p := by
rw [← frobenius_verschiebung, frobenius_zmodp]
#align witt_vector.verschiebung_zmod WittVector.verschiebung_zmod
variable (p R)
theorem coeff_p_pow [CharP R p] (i : ℕ) : ((p : 𝕎 R) ^ i).coeff i = 1 := by
induction' i with i h
· simp only [Nat.zero_eq, one_coeff_zero, Ne, pow_zero]
· rw [pow_succ, ← frobenius_verschiebung, coeff_frobenius_charP,
verschiebung_coeff_succ, h, one_pow]
#align witt_vector.coeff_p_pow WittVector.coeff_p_pow
theorem coeff_p_pow_eq_zero [CharP R p] {i j : ℕ} (hj : j ≠ i) : ((p : 𝕎 R) ^ i).coeff j = 0 := by
induction' i with i hi generalizing j
· rw [pow_zero, one_coeff_eq_of_pos]
exact Nat.pos_of_ne_zero hj
· rw [pow_succ, ← frobenius_verschiebung, coeff_frobenius_charP]
cases j
· rw [verschiebung_coeff_zero, zero_pow hp.out.ne_zero]
· rw [verschiebung_coeff_succ, hi (ne_of_apply_ne _ hj), zero_pow hp.out.ne_zero]
#align witt_vector.coeff_p_pow_eq_zero WittVector.coeff_p_pow_eq_zero
theorem coeff_p [CharP R p] (i : ℕ) : (p : 𝕎 R).coeff i = if i = 1 then 1 else 0 := by
split_ifs with hi
· simpa only [hi, pow_one] using coeff_p_pow p R 1
· simpa only [pow_one] using coeff_p_pow_eq_zero p R hi
#align witt_vector.coeff_p WittVector.coeff_p
@[simp]
theorem coeff_p_zero [CharP R p] : (p : 𝕎 R).coeff 0 = 0 := by
rw [coeff_p, if_neg]
exact zero_ne_one
#align witt_vector.coeff_p_zero WittVector.coeff_p_zero
@[simp]
theorem coeff_p_one [CharP R p] : (p : 𝕎 R).coeff 1 = 1 := by rw [coeff_p, if_pos rfl]
#align witt_vector.coeff_p_one WittVector.coeff_p_one
theorem p_nonzero [Nontrivial R] [CharP R p] : (p : 𝕎 R) ≠ 0 := by
intro h
simpa only [h, zero_coeff, zero_ne_one] using coeff_p_one p R
#align witt_vector.p_nonzero WittVector.p_nonzero
| Mathlib/RingTheory/WittVector/Identities.lean | 95 | 96 | theorem FractionRing.p_nonzero [Nontrivial R] [CharP R p] : (p : FractionRing (𝕎 R)) ≠ 0 := by |
simpa using (IsFractionRing.injective (𝕎 R) (FractionRing (𝕎 R))).ne (WittVector.p_nonzero _ _)
| 1 | 2.718282 | 0 | 1 | 13 | 1,103 |
import Mathlib.LinearAlgebra.Quotient
import Mathlib.RingTheory.Ideal.Operations
namespace Submodule
open Pointwise
variable {R M M' F G : Type*} [CommRing R] [AddCommGroup M] [Module R M]
variable {N N₁ N₂ P P₁ P₂ : Submodule R M}
def colon (N P : Submodule R M) : Ideal R :=
annihilator (P.map N.mkQ)
#align submodule.colon Submodule.colon
theorem mem_colon {r} : r ∈ N.colon P ↔ ∀ p ∈ P, r • p ∈ N :=
mem_annihilator.trans
⟨fun H p hp => (Quotient.mk_eq_zero N).1 (H (Quotient.mk p) (mem_map_of_mem hp)),
fun H _ ⟨p, hp, hpm⟩ => hpm ▸ ((Quotient.mk_eq_zero N).2 <| H p hp)⟩
#align submodule.mem_colon Submodule.mem_colon
theorem mem_colon' {r} : r ∈ N.colon P ↔ P ≤ comap (r • (LinearMap.id : M →ₗ[R] M)) N :=
mem_colon
#align submodule.mem_colon' Submodule.mem_colon'
@[simp]
theorem colon_top {I : Ideal R} : I.colon ⊤ = I := by
simp_rw [SetLike.ext_iff, mem_colon, smul_eq_mul]
exact fun x ↦ ⟨fun h ↦ mul_one x ▸ h 1 trivial, fun h _ _ ↦ I.mul_mem_right _ h⟩
@[simp]
| Mathlib/RingTheory/Ideal/Colon.lean | 45 | 46 | theorem colon_bot : colon ⊥ N = N.annihilator := by |
simp_rw [SetLike.ext_iff, mem_colon, mem_annihilator, mem_bot, forall_const]
| 1 | 2.718282 | 0 | 0.5 | 6 | 471 |
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.Order.Ring.Nat
import Mathlib.Tactic.NthRewrite
#align_import data.nat.gcd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
namespace Nat
theorem gcd_greatest {a b d : ℕ} (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : ℕ, e ∣ a → e ∣ b → e ∣ d) :
d = a.gcd b :=
(dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm
#align nat.gcd_greatest Nat.gcd_greatest
@[simp]
| Mathlib/Data/Nat/GCD/Basic.lean | 35 | 36 | theorem gcd_add_mul_right_right (m n k : ℕ) : gcd m (n + k * m) = gcd m n := by |
simp [gcd_rec m (n + k * m), gcd_rec m n]
| 1 | 2.718282 | 0 | 0.352941 | 17 | 375 |
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]
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]
#align set.Union_Ico_eq_Iio_self_iff Set.iUnion_Ico_eq_Iio_self_iff
@[simp]
| Mathlib/Order/Interval/Set/Disjoint.lean | 176 | 178 | theorem iUnion_Ioc_eq_Ioi_self_iff {f : ι → α} {a : α} :
⋃ i, Ioc a (f i) = Ioi a ↔ ∀ x, a < x → ∃ i, x ≤ f i := by |
simp [← Ioi_inter_Iic, ← inter_iUnion, subset_def]
| 1 | 2.718282 | 0 | 0.333333 | 18 | 364 |
import Mathlib.LinearAlgebra.Projectivization.Basic
#align_import linear_algebra.projective_space.independence from "leanprover-community/mathlib"@"1e82f5ec4645f6a92bb9e02fce51e44e3bc3e1fe"
open scoped LinearAlgebra.Projectivization
variable {ι K V : Type*} [DivisionRing K] [AddCommGroup V] [Module K V] {f : ι → ℙ K V}
namespace Projectivization
inductive Independent : (ι → ℙ K V) → Prop
| mk (f : ι → V) (hf : ∀ i : ι, f i ≠ 0) (hl : LinearIndependent K f) :
Independent fun i => mk K (f i) (hf i)
#align projectivization.independent Projectivization.Independent
theorem independent_iff : Independent f ↔ LinearIndependent K (Projectivization.rep ∘ f) := by
refine ⟨?_, fun h => ?_⟩
· rintro ⟨ff, hff, hh⟩
choose a ha using fun i : ι => exists_smul_eq_mk_rep K (ff i) (hff i)
convert hh.units_smul a
ext i
exact (ha i).symm
· convert Independent.mk _ _ h
· simp only [mk_rep, Function.comp_apply]
· intro i
apply rep_nonzero
#align projectivization.independent_iff Projectivization.independent_iff
theorem independent_iff_completeLattice_independent :
Independent f ↔ CompleteLattice.Independent fun i => (f i).submodule := by
refine ⟨?_, fun h => ?_⟩
· rintro ⟨f, hf, hi⟩
simp only [submodule_mk]
exact (CompleteLattice.independent_iff_linearIndependent_of_ne_zero (R := K) hf).mpr hi
· rw [independent_iff]
refine h.linearIndependent (Projectivization.submodule ∘ f) (fun i => ?_) fun i => ?_
· simpa only [Function.comp_apply, submodule_eq] using Submodule.mem_span_singleton_self _
· exact rep_nonzero (f i)
#align projectivization.independent_iff_complete_lattice_independent Projectivization.independent_iff_completeLattice_independent
inductive Dependent : (ι → ℙ K V) → Prop
| mk (f : ι → V) (hf : ∀ i : ι, f i ≠ 0) (h : ¬LinearIndependent K f) :
Dependent fun i => mk K (f i) (hf i)
#align projectivization.dependent Projectivization.Dependent
theorem dependent_iff : Dependent f ↔ ¬LinearIndependent K (Projectivization.rep ∘ f) := by
refine ⟨?_, fun h => ?_⟩
· rintro ⟨ff, hff, hh1⟩
contrapose! hh1
choose a ha using fun i : ι => exists_smul_eq_mk_rep K (ff i) (hff i)
convert hh1.units_smul a⁻¹
ext i
simp only [← ha, inv_smul_smul, Pi.smul_apply', Pi.inv_apply, Function.comp_apply]
· convert Dependent.mk _ _ h
· simp only [mk_rep, Function.comp_apply]
· exact fun i => rep_nonzero (f i)
#align projectivization.dependent_iff Projectivization.dependent_iff
| Mathlib/LinearAlgebra/Projectivization/Independence.lean | 98 | 99 | theorem dependent_iff_not_independent : Dependent f ↔ ¬Independent f := by |
rw [dependent_iff, independent_iff]
| 1 | 2.718282 | 0 | 1.142857 | 7 | 1,223 |
import Mathlib.Algebra.Group.Equiv.Basic
import Mathlib.Data.ENat.Lattice
import Mathlib.Data.Part
import Mathlib.Tactic.NormNum
#align_import data.nat.part_enat from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8"
open Part hiding some
def PartENat : Type :=
Part ℕ
#align part_enat PartENat
namespace PartENat
@[coe]
def some : ℕ → PartENat :=
Part.some
#align part_enat.some PartENat.some
instance : Zero PartENat :=
⟨some 0⟩
instance : Inhabited PartENat :=
⟨0⟩
instance : One PartENat :=
⟨some 1⟩
instance : Add PartENat :=
⟨fun x y => ⟨x.Dom ∧ y.Dom, fun h => get x h.1 + get y h.2⟩⟩
instance (n : ℕ) : Decidable (some n).Dom :=
isTrue trivial
@[simp]
theorem dom_some (x : ℕ) : (some x).Dom :=
trivial
#align part_enat.dom_some PartENat.dom_some
instance addCommMonoid : AddCommMonoid PartENat where
add := (· + ·)
zero := 0
add_comm x y := Part.ext' and_comm fun _ _ => add_comm _ _
zero_add x := Part.ext' (true_and_iff _) fun _ _ => zero_add _
add_zero x := Part.ext' (and_true_iff _) fun _ _ => add_zero _
add_assoc x y z := Part.ext' and_assoc fun _ _ => add_assoc _ _ _
nsmul := nsmulRec
instance : AddCommMonoidWithOne PartENat :=
{ PartENat.addCommMonoid with
one := 1
natCast := some
natCast_zero := rfl
natCast_succ := fun _ => Part.ext' (true_and_iff _).symm fun _ _ => rfl }
theorem some_eq_natCast (n : ℕ) : some n = n :=
rfl
#align part_enat.some_eq_coe PartENat.some_eq_natCast
instance : CharZero PartENat where
cast_injective := Part.some_injective
theorem natCast_inj {x y : ℕ} : (x : PartENat) = y ↔ x = y :=
Nat.cast_inj
#align part_enat.coe_inj PartENat.natCast_inj
@[simp]
theorem dom_natCast (x : ℕ) : (x : PartENat).Dom :=
trivial
#align part_enat.dom_coe PartENat.dom_natCast
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem dom_ofNat (x : ℕ) [x.AtLeastTwo] : (no_index (OfNat.ofNat x : PartENat)).Dom :=
trivial
@[simp]
theorem dom_zero : (0 : PartENat).Dom :=
trivial
@[simp]
theorem dom_one : (1 : PartENat).Dom :=
trivial
instance : CanLift PartENat ℕ (↑) Dom :=
⟨fun n hn => ⟨n.get hn, Part.some_get _⟩⟩
instance : LE PartENat :=
⟨fun x y => ∃ h : y.Dom → x.Dom, ∀ hy : y.Dom, x.get (h hy) ≤ y.get hy⟩
instance : Top PartENat :=
⟨none⟩
instance : Bot PartENat :=
⟨0⟩
instance : Sup PartENat :=
⟨fun x y => ⟨x.Dom ∧ y.Dom, fun h => x.get h.1 ⊔ y.get h.2⟩⟩
theorem le_def (x y : PartENat) :
x ≤ y ↔ ∃ h : y.Dom → x.Dom, ∀ hy : y.Dom, x.get (h hy) ≤ y.get hy :=
Iff.rfl
#align part_enat.le_def PartENat.le_def
@[elab_as_elim]
protected theorem casesOn' {P : PartENat → Prop} :
∀ a : PartENat, P ⊤ → (∀ n : ℕ, P (some n)) → P a :=
Part.induction_on
#align part_enat.cases_on' PartENat.casesOn'
@[elab_as_elim]
protected theorem casesOn {P : PartENat → Prop} : ∀ a : PartENat, P ⊤ → (∀ n : ℕ, P n) → P a := by
exact PartENat.casesOn'
#align part_enat.cases_on PartENat.casesOn
-- not a simp lemma as we will provide a `LinearOrderedAddCommMonoidWithTop` instance later
theorem top_add (x : PartENat) : ⊤ + x = ⊤ :=
Part.ext' (false_and_iff _) fun h => h.left.elim
#align part_enat.top_add PartENat.top_add
-- not a simp lemma as we will provide a `LinearOrderedAddCommMonoidWithTop` instance later
theorem add_top (x : PartENat) : x + ⊤ = ⊤ := by rw [add_comm, top_add]
#align part_enat.add_top PartENat.add_top
@[simp]
theorem natCast_get {x : PartENat} (h : x.Dom) : (x.get h : PartENat) = x := by
exact Part.ext' (iff_of_true trivial h) fun _ _ => rfl
#align part_enat.coe_get PartENat.natCast_get
@[simp, norm_cast]
theorem get_natCast' (x : ℕ) (h : (x : PartENat).Dom) : get (x : PartENat) h = x := by
rw [← natCast_inj, natCast_get]
#align part_enat.get_coe' PartENat.get_natCast'
theorem get_natCast {x : ℕ} : get (x : PartENat) (dom_natCast x) = x :=
get_natCast' _ _
#align part_enat.get_coe PartENat.get_natCast
| Mathlib/Data/Nat/PartENat.lean | 192 | 194 | theorem coe_add_get {x : ℕ} {y : PartENat} (h : ((x : PartENat) + y).Dom) :
get ((x : PartENat) + y) h = x + get y h.2 := by |
rfl
| 1 | 2.718282 | 0 | 0 | 4 | 215 |
import Mathlib.Topology.Order.Basic
#align_import topology.algebra.order.monotone_convergence from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
open Filter Set Function
open scoped Classical
open Filter Topology
variable {α β : Type*}
class SupConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where
tendsto_coe_atTop_isLUB :
∀ (a : α) (s : Set α), IsLUB s a → Tendsto (CoeTC.coe : s → α) atTop (𝓝 a)
#align Sup_convergence_class SupConvergenceClass
class InfConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where
tendsto_coe_atBot_isGLB :
∀ (a : α) (s : Set α), IsGLB s a → Tendsto (CoeTC.coe : s → α) atBot (𝓝 a)
#align Inf_convergence_class InfConvergenceClass
instance OrderDual.supConvergenceClass [Preorder α] [TopologicalSpace α] [InfConvergenceClass α] :
SupConvergenceClass αᵒᵈ :=
⟨‹InfConvergenceClass α›.1⟩
#align order_dual.Sup_convergence_class OrderDual.supConvergenceClass
instance OrderDual.infConvergenceClass [Preorder α] [TopologicalSpace α] [SupConvergenceClass α] :
InfConvergenceClass αᵒᵈ :=
⟨‹SupConvergenceClass α›.1⟩
#align order_dual.Inf_convergence_class OrderDual.infConvergenceClass
-- see Note [lower instance priority]
instance (priority := 100) LinearOrder.supConvergenceClass [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] : SupConvergenceClass α := by
refine ⟨fun a s ha => tendsto_order.2 ⟨fun b hb => ?_, fun b hb => ?_⟩⟩
· rcases ha.exists_between hb with ⟨c, hcs, bc, bca⟩
lift c to s using hcs
exact (eventually_ge_atTop c).mono fun x hx => bc.trans_le hx
· exact eventually_of_forall fun x => (ha.1 x.2).trans_lt hb
#align linear_order.Sup_convergence_class LinearOrder.supConvergenceClass
-- see Note [lower instance priority]
instance (priority := 100) LinearOrder.infConvergenceClass [TopologicalSpace α] [LinearOrder α]
[OrderTopology α] : InfConvergenceClass α :=
show InfConvergenceClass αᵒᵈᵒᵈ from OrderDual.infConvergenceClass
#align linear_order.Inf_convergence_class LinearOrder.infConvergenceClass
section
variable {ι : Type*} [Preorder ι] [TopologicalSpace α]
section IsLUB
variable [Preorder α] [SupConvergenceClass α] {f : ι → α} {a : α}
theorem tendsto_atTop_isLUB (h_mono : Monotone f) (ha : IsLUB (Set.range f) a) :
Tendsto f atTop (𝓝 a) := by
suffices Tendsto (rangeFactorization f) atTop atTop from
(SupConvergenceClass.tendsto_coe_atTop_isLUB _ _ ha).comp this
exact h_mono.rangeFactorization.tendsto_atTop_atTop fun b => b.2.imp fun a ha => ha.ge
#align tendsto_at_top_is_lub tendsto_atTop_isLUB
| Mathlib/Topology/Order/MonotoneConvergence.lean | 103 | 104 | theorem tendsto_atBot_isLUB (h_anti : Antitone f) (ha : IsLUB (Set.range f) a) :
Tendsto f atBot (𝓝 a) := by | convert tendsto_atTop_isLUB h_anti.dual_left ha using 1
| 1 | 2.718282 | 0 | 0.5 | 2 | 462 |
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
| Mathlib/Init/Data/Bool/Lemmas.lean | 51 | 51 | theorem false_eq_true_eq_False : ¬false = true := by | decide
| 1 | 2.718282 | 0 | 0 | 7 | 206 |
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Finset.Sort
import Mathlib.Data.Set.Subsingleton
#align_import combinatorics.composition from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
open List
variable {n : ℕ}
@[ext]
structure Composition (n : ℕ) where
blocks : List ℕ
blocks_pos : ∀ {i}, i ∈ blocks → 0 < i
blocks_sum : blocks.sum = n
#align composition Composition
@[ext]
structure CompositionAsSet (n : ℕ) where
boundaries : Finset (Fin n.succ)
zero_mem : (0 : Fin n.succ) ∈ boundaries
getLast_mem : Fin.last n ∈ boundaries
#align composition_as_set CompositionAsSet
instance {n : ℕ} : Inhabited (CompositionAsSet n) :=
⟨⟨Finset.univ, Finset.mem_univ _, Finset.mem_univ _⟩⟩
namespace Composition
variable (c : Composition n)
instance (n : ℕ) : ToString (Composition n) :=
⟨fun c => toString c.blocks⟩
abbrev length : ℕ :=
c.blocks.length
#align composition.length Composition.length
theorem blocks_length : c.blocks.length = c.length :=
rfl
#align composition.blocks_length Composition.blocks_length
def blocksFun : Fin c.length → ℕ := c.blocks.get
#align composition.blocks_fun Composition.blocksFun
theorem ofFn_blocksFun : ofFn c.blocksFun = c.blocks :=
ofFn_get _
#align composition.of_fn_blocks_fun Composition.ofFn_blocksFun
theorem sum_blocksFun : ∑ i, c.blocksFun i = n := by
conv_rhs => rw [← c.blocks_sum, ← ofFn_blocksFun, sum_ofFn]
#align composition.sum_blocks_fun Composition.sum_blocksFun
theorem blocksFun_mem_blocks (i : Fin c.length) : c.blocksFun i ∈ c.blocks :=
get_mem _ _ _
#align composition.blocks_fun_mem_blocks Composition.blocksFun_mem_blocks
@[simp]
theorem one_le_blocks {i : ℕ} (h : i ∈ c.blocks) : 1 ≤ i :=
c.blocks_pos h
#align composition.one_le_blocks Composition.one_le_blocks
@[simp]
theorem one_le_blocks' {i : ℕ} (h : i < c.length) : 1 ≤ c.blocks.get ⟨i, h⟩ :=
c.one_le_blocks (get_mem (blocks c) i h)
#align composition.one_le_blocks' Composition.one_le_blocks'
@[simp]
theorem blocks_pos' (i : ℕ) (h : i < c.length) : 0 < c.blocks.get ⟨i, h⟩ :=
c.one_le_blocks' h
#align composition.blocks_pos' Composition.blocks_pos'
theorem one_le_blocksFun (i : Fin c.length) : 1 ≤ c.blocksFun i :=
c.one_le_blocks (c.blocksFun_mem_blocks i)
#align composition.one_le_blocks_fun Composition.one_le_blocksFun
theorem length_le : c.length ≤ n := by
conv_rhs => rw [← c.blocks_sum]
exact length_le_sum_of_one_le _ fun i hi => c.one_le_blocks hi
#align composition.length_le Composition.length_le
theorem length_pos_of_pos (h : 0 < n) : 0 < c.length := by
apply length_pos_of_sum_pos
convert h
exact c.blocks_sum
#align composition.length_pos_of_pos Composition.length_pos_of_pos
def sizeUpTo (i : ℕ) : ℕ :=
(c.blocks.take i).sum
#align composition.size_up_to Composition.sizeUpTo
@[simp]
theorem sizeUpTo_zero : c.sizeUpTo 0 = 0 := by simp [sizeUpTo]
#align composition.size_up_to_zero Composition.sizeUpTo_zero
theorem sizeUpTo_ofLength_le (i : ℕ) (h : c.length ≤ i) : c.sizeUpTo i = n := by
dsimp [sizeUpTo]
convert c.blocks_sum
exact take_all_of_le h
#align composition.size_up_to_of_length_le Composition.sizeUpTo_ofLength_le
@[simp]
theorem sizeUpTo_length : c.sizeUpTo c.length = n :=
c.sizeUpTo_ofLength_le c.length le_rfl
#align composition.size_up_to_length Composition.sizeUpTo_length
theorem sizeUpTo_le (i : ℕ) : c.sizeUpTo i ≤ n := by
conv_rhs => rw [← c.blocks_sum, ← sum_take_add_sum_drop _ i]
exact Nat.le_add_right _ _
#align composition.size_up_to_le Composition.sizeUpTo_le
theorem sizeUpTo_succ {i : ℕ} (h : i < c.length) :
c.sizeUpTo (i + 1) = c.sizeUpTo i + c.blocks.get ⟨i, h⟩ := by
simp only [sizeUpTo]
rw [sum_take_succ _ _ h]
#align composition.size_up_to_succ Composition.sizeUpTo_succ
theorem sizeUpTo_succ' (i : Fin c.length) :
c.sizeUpTo ((i : ℕ) + 1) = c.sizeUpTo i + c.blocksFun i :=
c.sizeUpTo_succ i.2
#align composition.size_up_to_succ' Composition.sizeUpTo_succ'
theorem sizeUpTo_strict_mono {i : ℕ} (h : i < c.length) : c.sizeUpTo i < c.sizeUpTo (i + 1) := by
rw [c.sizeUpTo_succ h]
simp
#align composition.size_up_to_strict_mono Composition.sizeUpTo_strict_mono
theorem monotone_sizeUpTo : Monotone c.sizeUpTo :=
monotone_sum_take _
#align composition.monotone_size_up_to Composition.monotone_sizeUpTo
def boundary : Fin (c.length + 1) ↪o Fin (n + 1) :=
(OrderEmbedding.ofStrictMono fun i => ⟨c.sizeUpTo i, Nat.lt_succ_of_le (c.sizeUpTo_le i)⟩) <|
Fin.strictMono_iff_lt_succ.2 fun ⟨_, hi⟩ => c.sizeUpTo_strict_mono hi
#align composition.boundary Composition.boundary
@[simp]
theorem boundary_zero : c.boundary 0 = 0 := by simp [boundary, Fin.ext_iff]
#align composition.boundary_zero Composition.boundary_zero
@[simp]
| Mathlib/Combinatorics/Enumerative/Composition.lean | 256 | 257 | theorem boundary_last : c.boundary (Fin.last c.length) = Fin.last n := by |
simp [boundary, Fin.ext_iff]
| 1 | 2.718282 | 0 | 0.642857 | 14 | 553 |
import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor
import Mathlib.CategoryTheory.Monoidal.Functor
#align_import category_theory.monoidal.preadditive from "leanprover-community/mathlib"@"986c4d5761f938b2e1c43c01f001b6d9d88c2055"
noncomputable section
open scoped Classical
namespace CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.MonoidalCategory
variable (C : Type*) [Category C] [Preadditive C] [MonoidalCategory C]
class MonoidalPreadditive : Prop where
whiskerLeft_zero : ∀ {X Y Z : C}, X ◁ (0 : Y ⟶ Z) = 0 := by aesop_cat
zero_whiskerRight : ∀ {X Y Z : C}, (0 : Y ⟶ Z) ▷ X = 0 := by aesop_cat
whiskerLeft_add : ∀ {X Y Z : C} (f g : Y ⟶ Z), X ◁ (f + g) = X ◁ f + X ◁ g := by aesop_cat
add_whiskerRight : ∀ {X Y Z : C} (f g : Y ⟶ Z), (f + g) ▷ X = f ▷ X + g ▷ X := by aesop_cat
#align category_theory.monoidal_preadditive CategoryTheory.MonoidalPreadditive
attribute [simp] MonoidalPreadditive.whiskerLeft_zero MonoidalPreadditive.zero_whiskerRight
attribute [simp] MonoidalPreadditive.whiskerLeft_add MonoidalPreadditive.add_whiskerRight
variable {C}
variable [MonoidalPreadditive C]
instance tensorLeft_additive (X : C) : (tensorLeft X).Additive where
#align category_theory.tensor_left_additive CategoryTheory.tensorLeft_additive
instance tensorRight_additive (X : C) : (tensorRight X).Additive where
#align category_theory.tensor_right_additive CategoryTheory.tensorRight_additive
instance tensoringLeft_additive (X : C) : ((tensoringLeft C).obj X).Additive where
#align category_theory.tensoring_left_additive CategoryTheory.tensoringLeft_additive
instance tensoringRight_additive (X : C) : ((tensoringRight C).obj X).Additive where
#align category_theory.tensoring_right_additive CategoryTheory.tensoringRight_additive
theorem monoidalPreadditive_of_faithful {D} [Category D] [Preadditive D] [MonoidalCategory D]
(F : MonoidalFunctor D C) [F.Faithful] [F.Additive] :
MonoidalPreadditive D :=
{ whiskerLeft_zero := by
intros
apply F.toFunctor.map_injective
simp [F.map_whiskerLeft]
zero_whiskerRight := by
intros
apply F.toFunctor.map_injective
simp [F.map_whiskerRight]
whiskerLeft_add := by
intros
apply F.toFunctor.map_injective
simp only [F.map_whiskerLeft, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,
MonoidalPreadditive.whiskerLeft_add]
add_whiskerRight := by
intros
apply F.toFunctor.map_injective
simp only [F.map_whiskerRight, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,
MonoidalPreadditive.add_whiskerRight] }
#align category_theory.monoidal_preadditive_of_faithful CategoryTheory.monoidalPreadditive_of_faithful
theorem whiskerLeft_sum (P : C) {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) :
P ◁ ∑ j ∈ s, g j = ∑ j ∈ s, P ◁ g j :=
map_sum ((tensoringLeft C).obj P).mapAddHom g s
theorem sum_whiskerRight {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) (P : C) :
(∑ j ∈ s, g j) ▷ P = ∑ j ∈ s, g j ▷ P :=
map_sum ((tensoringRight C).obj P).mapAddHom g s
| Mathlib/CategoryTheory/Monoidal/Preadditive.lean | 113 | 115 | theorem tensor_sum {P Q R S : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :
(f ⊗ ∑ j ∈ s, g j) = ∑ j ∈ s, f ⊗ g j := by |
simp only [tensorHom_def, whiskerLeft_sum, Preadditive.comp_sum]
| 1 | 2.718282 | 0 | 0.5 | 8 | 481 |
import Mathlib.Algebra.Polynomial.Expand
import Mathlib.Algebra.Polynomial.Laurent
import Mathlib.LinearAlgebra.Matrix.Charpoly.Basic
import Mathlib.LinearAlgebra.Matrix.Reindex
import Mathlib.RingTheory.Polynomial.Nilpotent
#align_import linear_algebra.matrix.charpoly.coeff from "leanprover-community/mathlib"@"9745b093210e9dac443af24da9dba0f9e2b6c912"
noncomputable section
-- porting note: whenever there was `∏ i : n, X - C (M i i)`, I replaced it with
-- `∏ i : n, (X - C (M i i))`, since otherwise Lean would parse as `(∏ i : n, X) - C (M i i)`
universe u v w z
open Finset Matrix Polynomial
variable {R : Type u} [CommRing R]
variable {n G : Type v} [DecidableEq n] [Fintype n]
variable {α β : Type v} [DecidableEq α]
variable {M : Matrix n n R}
namespace Matrix
theorem charmatrix_apply_natDegree [Nontrivial R] (i j : n) :
(charmatrix M i j).natDegree = ite (i = j) 1 0 := by
by_cases h : i = j <;> simp [h, ← degree_eq_iff_natDegree_eq_of_pos (Nat.succ_pos 0)]
#align charmatrix_apply_nat_degree Matrix.charmatrix_apply_natDegree
| Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean | 54 | 56 | theorem charmatrix_apply_natDegree_le (i j : n) :
(charmatrix M i j).natDegree ≤ ite (i = j) 1 0 := by |
split_ifs with h <;> simp [h, natDegree_X_le]
| 1 | 2.718282 | 0 | 1.5 | 8 | 1,666 |
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Data.Nat.GCD.BigOperators
import Mathlib.Data.Nat.PrimeFin
import Mathlib.NumberTheory.Padics.PadicVal
import Mathlib.Order.Interval.Finset.Nat
#align_import data.nat.factorization.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
-- Workaround for lean4#2038
attribute [-instance] instBEqNat
open Nat Finset List Finsupp
namespace Nat
variable {a b m n p : ℕ}
def factorization (n : ℕ) : ℕ →₀ ℕ where
support := n.primeFactors
toFun p := if p.Prime then padicValNat p n else 0
mem_support_toFun := by simp [not_or]; aesop
#align nat.factorization Nat.factorization
@[simp] lemma support_factorization (n : ℕ) : (factorization n).support = n.primeFactors := rfl
theorem factorization_def (n : ℕ) {p : ℕ} (pp : p.Prime) : n.factorization p = padicValNat p n := by
simpa [factorization] using absurd pp
#align nat.factorization_def Nat.factorization_def
@[simp]
theorem factors_count_eq {n p : ℕ} : n.factors.count p = n.factorization p := by
rcases n.eq_zero_or_pos with (rfl | hn0)
· simp [factorization, count]
if pp : p.Prime then ?_ else
rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)]
simp [factorization, pp]
simp only [factorization_def _ pp]
apply _root_.le_antisymm
· rw [le_padicValNat_iff_replicate_subperm_factors pp hn0.ne']
exact List.le_count_iff_replicate_sublist.mp le_rfl |>.subperm
· rw [← lt_add_one_iff, lt_iff_not_ge, ge_iff_le,
le_padicValNat_iff_replicate_subperm_factors pp hn0.ne']
intro h
have := h.count_le p
simp at this
#align nat.factors_count_eq Nat.factors_count_eq
theorem factorization_eq_factors_multiset (n : ℕ) :
n.factorization = Multiset.toFinsupp (n.factors : Multiset ℕ) := by
ext p
simp
#align nat.factorization_eq_factors_multiset Nat.factorization_eq_factors_multiset
theorem multiplicity_eq_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) :
multiplicity p n = n.factorization p := by
simp [factorization, pp, padicValNat_def' pp.ne_one hn.bot_lt]
#align nat.multiplicity_eq_factorization Nat.multiplicity_eq_factorization
@[simp]
theorem factorization_prod_pow_eq_self {n : ℕ} (hn : n ≠ 0) : n.factorization.prod (· ^ ·) = n := by
rw [factorization_eq_factors_multiset n]
simp only [← prod_toMultiset, factorization, Multiset.prod_coe, Multiset.toFinsupp_toMultiset]
exact prod_factors hn
#align nat.factorization_prod_pow_eq_self Nat.factorization_prod_pow_eq_self
theorem eq_of_factorization_eq {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0)
(h : ∀ p : ℕ, a.factorization p = b.factorization p) : a = b :=
eq_of_perm_factors ha hb (by simpa only [List.perm_iff_count, factors_count_eq] using h)
#align nat.eq_of_factorization_eq Nat.eq_of_factorization_eq
theorem factorization_inj : Set.InjOn factorization { x : ℕ | x ≠ 0 } := fun a ha b hb h =>
eq_of_factorization_eq ha hb fun p => by simp [h]
#align nat.factorization_inj Nat.factorization_inj
@[simp]
theorem factorization_zero : factorization 0 = 0 := by ext; simp [factorization]
#align nat.factorization_zero Nat.factorization_zero
@[simp]
| Mathlib/Data/Nat/Factorization/Basic.lean | 120 | 120 | theorem factorization_one : factorization 1 = 0 := by | ext; simp [factorization]
| 1 | 2.718282 | 0 | 0.4 | 10 | 388 |
import Mathlib.Algebra.Group.Nat
import Mathlib.Algebra.Order.Sub.Canonical
import Mathlib.Data.List.Perm
import Mathlib.Data.Set.List
import Mathlib.Init.Quot
import Mathlib.Order.Hom.Basic
#align_import data.multiset.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
universe v
open List Subtype Nat Function
variable {α : Type*} {β : Type v} {γ : Type*}
def Multiset.{u} (α : Type u) : Type u :=
Quotient (List.isSetoid α)
#align multiset Multiset
namespace Multiset
-- Porting note: new
@[coe]
def ofList : List α → Multiset α :=
Quot.mk _
instance : Coe (List α) (Multiset α) :=
⟨ofList⟩
@[simp]
theorem quot_mk_to_coe (l : List α) : @Eq (Multiset α) ⟦l⟧ l :=
rfl
#align multiset.quot_mk_to_coe Multiset.quot_mk_to_coe
@[simp]
theorem quot_mk_to_coe' (l : List α) : @Eq (Multiset α) (Quot.mk (· ≈ ·) l) l :=
rfl
#align multiset.quot_mk_to_coe' Multiset.quot_mk_to_coe'
@[simp]
theorem quot_mk_to_coe'' (l : List α) : @Eq (Multiset α) (Quot.mk Setoid.r l) l :=
rfl
#align multiset.quot_mk_to_coe'' Multiset.quot_mk_to_coe''
@[simp]
theorem coe_eq_coe {l₁ l₂ : List α} : (l₁ : Multiset α) = l₂ ↔ l₁ ~ l₂ :=
Quotient.eq
#align multiset.coe_eq_coe Multiset.coe_eq_coe
-- Porting note: new instance;
-- Porting note (#11215): TODO: move to better place
instance [DecidableEq α] (l₁ l₂ : List α) : Decidable (l₁ ≈ l₂) :=
inferInstanceAs (Decidable (l₁ ~ l₂))
-- Porting note: `Quotient.recOnSubsingleton₂ s₁ s₂` was in parens which broke elaboration
instance decidableEq [DecidableEq α] : DecidableEq (Multiset α)
| s₁, s₂ => Quotient.recOnSubsingleton₂ s₁ s₂ fun _ _ => decidable_of_iff' _ Quotient.eq
#align multiset.has_decidable_eq Multiset.decidableEq
protected
def sizeOf [SizeOf α] (s : Multiset α) : ℕ :=
(Quot.liftOn s SizeOf.sizeOf) fun _ _ => Perm.sizeOf_eq_sizeOf
#align multiset.sizeof Multiset.sizeOf
instance [SizeOf α] : SizeOf (Multiset α) :=
⟨Multiset.sizeOf⟩
protected def zero : Multiset α :=
@nil α
#align multiset.zero Multiset.zero
instance : Zero (Multiset α) :=
⟨Multiset.zero⟩
instance : EmptyCollection (Multiset α) :=
⟨0⟩
instance inhabitedMultiset : Inhabited (Multiset α) :=
⟨0⟩
#align multiset.inhabited_multiset Multiset.inhabitedMultiset
instance [IsEmpty α] : Unique (Multiset α) where
default := 0
uniq := by rintro ⟨_ | ⟨a, l⟩⟩; exacts [rfl, isEmptyElim a]
@[simp]
theorem coe_nil : (@nil α : Multiset α) = 0 :=
rfl
#align multiset.coe_nil Multiset.coe_nil
@[simp]
theorem empty_eq_zero : (∅ : Multiset α) = 0 :=
rfl
#align multiset.empty_eq_zero Multiset.empty_eq_zero
@[simp]
theorem coe_eq_zero (l : List α) : (l : Multiset α) = 0 ↔ l = [] :=
Iff.trans coe_eq_coe perm_nil
#align multiset.coe_eq_zero Multiset.coe_eq_zero
theorem coe_eq_zero_iff_isEmpty (l : List α) : (l : Multiset α) = 0 ↔ l.isEmpty :=
Iff.trans (coe_eq_zero l) isEmpty_iff_eq_nil.symm
#align multiset.coe_eq_zero_iff_empty Multiset.coe_eq_zero_iff_isEmpty
def cons (a : α) (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => (a :: l : Multiset α)) fun _ _ p => Quot.sound (p.cons a)
#align multiset.cons Multiset.cons
@[inherit_doc Multiset.cons]
infixr:67 " ::ₘ " => Multiset.cons
instance : Insert α (Multiset α) :=
⟨cons⟩
@[simp]
theorem insert_eq_cons (a : α) (s : Multiset α) : insert a s = a ::ₘ s :=
rfl
#align multiset.insert_eq_cons Multiset.insert_eq_cons
@[simp]
theorem cons_coe (a : α) (l : List α) : (a ::ₘ l : Multiset α) = (a :: l : List α) :=
rfl
#align multiset.cons_coe Multiset.cons_coe
@[simp]
theorem cons_inj_left {a b : α} (s : Multiset α) : a ::ₘ s = b ::ₘ s ↔ a = b :=
⟨Quot.inductionOn s fun l e =>
have : [a] ++ l ~ [b] ++ l := Quotient.exact e
singleton_perm_singleton.1 <| (perm_append_right_iff _).1 this,
congr_arg (· ::ₘ _)⟩
#align multiset.cons_inj_left Multiset.cons_inj_left
@[simp]
| Mathlib/Data/Multiset/Basic.lean | 157 | 158 | theorem cons_inj_right (a : α) : ∀ {s t : Multiset α}, a ::ₘ s = a ::ₘ t ↔ s = t := by |
rintro ⟨l₁⟩ ⟨l₂⟩; simp
| 1 | 2.718282 | 0 | 0 | 1 | 106 |
import Mathlib.LinearAlgebra.Dimension.DivisionRing
import Mathlib.LinearAlgebra.Dimension.FreeAndStrongRankCondition
noncomputable section
universe u v v' v''
variable {K : Type u} {V V₁ : Type v} {V' V'₁ : Type v'} {V'' : Type v''}
open Cardinal Basis Submodule Function Set
namespace LinearMap
section Ring
variable [Ring K] [AddCommGroup V] [Module K V] [AddCommGroup V₁] [Module K V₁]
variable [AddCommGroup V'] [Module K V']
abbrev rank (f : V →ₗ[K] V') : Cardinal :=
Module.rank K (LinearMap.range f)
#align linear_map.rank LinearMap.rank
theorem rank_le_range (f : V →ₗ[K] V') : rank f ≤ Module.rank K V' :=
rank_submodule_le _
#align linear_map.rank_le_range LinearMap.rank_le_range
theorem rank_le_domain (f : V →ₗ[K] V₁) : rank f ≤ Module.rank K V :=
rank_range_le _
#align linear_map.rank_le_domain LinearMap.rank_le_domain
@[simp]
theorem rank_zero [Nontrivial K] : rank (0 : V →ₗ[K] V') = 0 := by
rw [rank, LinearMap.range_zero, rank_bot]
#align linear_map.rank_zero LinearMap.rank_zero
variable [AddCommGroup V''] [Module K V'']
theorem rank_comp_le_left (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') : rank (f.comp g) ≤ rank f := by
refine rank_le_of_submodule _ _ ?_
rw [LinearMap.range_comp]
exact LinearMap.map_le_range
#align linear_map.rank_comp_le_left LinearMap.rank_comp_le_left
| Mathlib/LinearAlgebra/Dimension/LinearMap.lean | 58 | 60 | theorem lift_rank_comp_le_right (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') :
Cardinal.lift.{v'} (rank (f.comp g)) ≤ Cardinal.lift.{v''} (rank g) := by |
rw [rank, rank, LinearMap.range_comp]; exact lift_rank_map_le _ _
| 1 | 2.718282 | 0 | 0.2 | 5 | 277 |
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
| Mathlib/Analysis/Calculus/Deriv/Comp.lean | 404 | 408 | 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
| 1 | 2.718282 | 0 | 0 | 14 | 81 |
import Mathlib.Analysis.Convex.Basic
import Mathlib.Analysis.NormedSpace.Basic
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import analysis.convex.body from "leanprover-community/mathlib"@"858a10cf68fd6c06872950fc58c4dcc68d465591"
open scoped Pointwise Topology NNReal
variable {V : Type*}
structure ConvexBody (V : Type*) [TopologicalSpace V] [AddCommMonoid V] [SMul ℝ V] where
carrier : Set V
convex' : Convex ℝ carrier
isCompact' : IsCompact carrier
nonempty' : carrier.Nonempty
#align convex_body ConvexBody
namespace ConvexBody
section TVS
variable [TopologicalSpace V] [AddCommGroup V] [Module ℝ V]
instance : SetLike (ConvexBody V) V where
coe := ConvexBody.carrier
coe_injective' K L h := by
cases K
cases L
congr
protected theorem convex (K : ConvexBody V) : Convex ℝ (K : Set V) :=
K.convex'
#align convex_body.convex ConvexBody.convex
protected theorem isCompact (K : ConvexBody V) : IsCompact (K : Set V) :=
K.isCompact'
#align convex_body.is_compact ConvexBody.isCompact
-- Porting note (#10756): new theorem
protected theorem isClosed [T2Space V] (K : ConvexBody V) : IsClosed (K : Set V) :=
K.isCompact.isClosed
protected theorem nonempty (K : ConvexBody V) : (K : Set V).Nonempty :=
K.nonempty'
#align convex_body.nonempty ConvexBody.nonempty
@[ext]
protected theorem ext {K L : ConvexBody V} (h : (K : Set V) = L) : K = L :=
SetLike.ext' h
#align convex_body.ext ConvexBody.ext
@[simp]
theorem coe_mk (s : Set V) (h₁ h₂ h₃) : (mk s h₁ h₂ h₃ : Set V) = s :=
rfl
#align convex_body.coe_mk ConvexBody.coe_mk
| Mathlib/Analysis/Convex/Body.lean | 93 | 97 | theorem zero_mem_of_symmetric (K : ConvexBody V) (h_symm : ∀ x ∈ K, - x ∈ K) : 0 ∈ K := by |
obtain ⟨x, hx⟩ := K.nonempty
rw [show 0 = (1/2 : ℝ) • x + (1/2 : ℝ) • (- x) by field_simp]
apply convex_iff_forall_pos.mp K.convex hx (h_symm x hx)
all_goals linarith
| 4 | 54.59815 | 2 | 2 | 1 | 2,065 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.