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 | eval_complexity float64 0 1 |
|---|---|---|---|---|---|---|
import Batteries.Classes.SatisfiesM
namespace Array
theorem SatisfiesM_foldlM [Monad m] [LawfulMonad m]
{as : Array α} (motive : Nat → β → Prop) {init : β} (h0 : motive 0 init) {f : β → α → m β}
(hf : ∀ i : Fin as.size, ∀ b, motive i.1 b → SatisfiesM (motive (i.1 + 1)) (f b as[i])) :
SatisfiesM (motive as.size) (as.foldlM f init) := by
let rec go {i j b} (h₁ : j ≤ as.size) (h₂ : as.size ≤ i + j) (H : motive j b) :
SatisfiesM (motive as.size) (foldlM.loop f as as.size (Nat.le_refl _) i j b) := by
unfold foldlM.loop; split
· next hj =>
split
· cases Nat.not_le_of_gt (by simp [hj]) h₂
· exact (hf ⟨j, hj⟩ b H).bind fun _ => go hj (by rwa [Nat.succ_add] at h₂)
· next hj => exact Nat.le_antisymm h₁ (Nat.ge_of_not_lt hj) ▸ .pure H
simp [foldlM]; exact go (Nat.zero_le _) (Nat.le_refl _) h0
theorem SatisfiesM_mapM [Monad m] [LawfulMonad m] (as : Array α) (f : α → m β)
(motive : Nat → Prop) (h0 : motive 0)
(p : Fin as.size → β → Prop)
(hs : ∀ i, motive i.1 → SatisfiesM (p i · ∧ motive (i + 1)) (f as[i])) :
SatisfiesM
(fun arr => motive as.size ∧ ∃ eq : arr.size = as.size, ∀ i h, p ⟨i, h⟩ arr[i])
(Array.mapM f as) := by
rw [mapM_eq_foldlM]
refine SatisfiesM_foldlM (m := m) (β := Array β)
(motive := fun i arr => motive i ∧ arr.size = i ∧ ∀ i h2, p i (arr[i.1]'h2)) ?z ?s
|>.imp fun ⟨h₁, eq, h₂⟩ => ⟨h₁, eq, fun _ _ => h₂ ..⟩
· case z => exact ⟨h0, rfl, nofun⟩
· case s =>
intro ⟨i, hi⟩ arr ⟨ih₁, eq, ih₂⟩
refine (hs _ ih₁).map fun ⟨h₁, h₂⟩ => ⟨h₂, by simp [eq], fun j hj => ?_⟩
simp [get_push] at hj ⊢; split; {apply ih₂}
cases j; cases (Nat.le_or_eq_of_le_succ hj).resolve_left ‹_›; cases eq; exact h₁
theorem SatisfiesM_mapM' [Monad m] [LawfulMonad m] (as : Array α) (f : α → m β)
(p : Fin as.size → β → Prop)
(hs : ∀ i, SatisfiesM (p i) (f as[i])) :
SatisfiesM
(fun arr => ∃ eq : arr.size = as.size, ∀ i h, p ⟨i, h⟩ arr[i])
(Array.mapM f as) :=
(SatisfiesM_mapM _ _ (fun _ => True) trivial _ (fun _ h => (hs _).imp (⟨·, h⟩))).imp (·.2)
theorem size_mapM [Monad m] [LawfulMonad m] (f : α → m β) (as : Array α) :
SatisfiesM (fun arr => arr.size = as.size) (Array.mapM f as) :=
(SatisfiesM_mapM' _ _ (fun _ _ => True) (fun _ => .trivial)).imp (·.1)
theorem SatisfiesM_anyM [Monad m] [LawfulMonad m] (p : α → m Bool) (as : Array α) (start stop)
(hstart : start ≤ min stop as.size) (tru : Prop) (fal : Nat → Prop) (h0 : fal start)
(hp : ∀ i : Fin as.size, i.1 < stop → fal i.1 →
SatisfiesM (bif · then tru else fal (i + 1)) (p as[i])) :
SatisfiesM
(fun res => bif res then tru else fal (min stop as.size))
(anyM p as start stop) := by
let rec go {stop j} (hj' : j ≤ stop) (hstop : stop ≤ as.size) (h0 : fal j)
(hp : ∀ i : Fin as.size, i.1 < stop → fal i.1 →
SatisfiesM (bif · then tru else fal (i + 1)) (p as[i])) :
SatisfiesM
(fun res => bif res then tru else fal stop)
(anyM.loop p as stop hstop j) := by
unfold anyM.loop; split
· next hj =>
exact (hp ⟨j, Nat.lt_of_lt_of_le hj hstop⟩ hj h0).bind fun
| true, h => .pure h
| false, h => go hj hstop h hp
· next hj => exact .pure <| Nat.le_antisymm hj' (Nat.ge_of_not_lt hj) ▸ h0
termination_by stop - j
simp only [Array.anyM_eq_anyM_loop]
exact go hstart _ h0 fun i hi => hp i <| Nat.lt_of_lt_of_le hi <| Nat.min_le_left ..
| .lake/packages/batteries/Batteries/Data/Array/Monadic.lean | 85 | 110 | theorem SatisfiesM_anyM_iff_exists [Monad m] [LawfulMonad m]
(p : α → m Bool) (as : Array α) (start stop) (q : Fin as.size → Prop)
(hp : ∀ i : Fin as.size, start ≤ i.1 → i.1 < stop → SatisfiesM (· = true ↔ q i) (p as[i])) :
SatisfiesM
(fun res => res = true ↔ ∃ i : Fin as.size, start ≤ i.1 ∧ i.1 < stop ∧ q i)
(anyM p as start stop) := by |
cases Nat.le_total start (min stop as.size) with
| inl hstart =>
refine (SatisfiesM_anyM _ _ _ _ hstart
(fal := fun j => start ≤ j ∧ ¬ ∃ i : Fin as.size, start ≤ i.1 ∧ i.1 < j ∧ q i)
(tru := ∃ i : Fin as.size, start ≤ i.1 ∧ i.1 < stop ∧ q i) ?_ ?_).imp ?_
· exact ⟨Nat.le_refl _, fun ⟨i, h₁, h₂, _⟩ => (Nat.not_le_of_gt h₂ h₁).elim⟩
· refine fun i h₂ ⟨h₁, h₃⟩ => (hp _ h₁ h₂).imp fun hq => ?_
unfold cond; split <;> simp at hq
· exact ⟨_, h₁, h₂, hq⟩
· refine ⟨Nat.le_succ_of_le h₁, h₃.imp fun ⟨j, h₃, h₄, h₅⟩ => ⟨j, h₃, ?_, h₅⟩⟩
refine Nat.lt_of_le_of_ne (Nat.le_of_lt_succ h₄) fun e => hq (Fin.eq_of_val_eq e ▸ h₅)
· intro
| true, h => simp only [true_iff]; exact h
| false, h =>
simp only [false_iff]
exact h.2.imp fun ⟨j, h₁, h₂, hq⟩ => ⟨j, h₁, Nat.lt_min.2 ⟨h₂, j.2⟩, hq⟩
| inr hstart =>
rw [anyM_stop_le_start (h := hstart)]
refine .pure ?_; simp; intro j h₁ h₂
cases Nat.not_lt.2 (Nat.le_trans hstart h₁) (Nat.lt_min.2 ⟨h₂, j.2⟩)
| 0 |
import Mathlib.RingTheory.SimpleModule
import Mathlib.Topology.Algebra.Module.Basic
#align_import topology.algebra.module.simple from "leanprover-community/mathlib"@"f430769b562e0cedef59ee1ed968d67e0e0c86ba"
universe u v w
variable {R : Type u} {M : Type v} {N : Type w} [Ring R] [TopologicalSpace R] [TopologicalSpace M]
[AddCommGroup M] [AddCommGroup N] [Module R M] [ContinuousSMul R M] [Module R N] [ContinuousAdd M]
[IsSimpleModule R N]
| Mathlib/Topology/Algebra/Module/Simple.lean | 28 | 34 | theorem LinearMap.isClosed_or_dense_ker (l : M →ₗ[R] N) :
IsClosed (LinearMap.ker l : Set M) ∨ Dense (LinearMap.ker l : Set M) := by |
rcases l.surjective_or_eq_zero with (hl | rfl)
· exact l.ker.isClosed_or_dense_of_isCoatom (LinearMap.isCoatom_ker_of_surjective hl)
· rw [LinearMap.ker_zero]
left
exact isClosed_univ
| 0 |
import Mathlib.MeasureTheory.Integral.Lebesgue
import Mathlib.Topology.MetricSpace.ThickenedIndicator
open MeasureTheory Topology Metric Filter Set ENNReal NNReal
open scoped Topology ENNReal NNReal BoundedContinuousFunction
section auxiliary
namespace MeasureTheory
variable {Ω : Type*} [TopologicalSpace Ω] [MeasurableSpace Ω] [OpensMeasurableSpace Ω]
theorem tendsto_lintegral_nn_filter_of_le_const {ι : Type*} {L : Filter ι} [L.IsCountablyGenerated]
(μ : Measure Ω) [IsFiniteMeasure μ] {fs : ι → Ω →ᵇ ℝ≥0} {c : ℝ≥0}
(fs_le_const : ∀ᶠ i in L, ∀ᵐ ω : Ω ∂μ, fs i ω ≤ c) {f : Ω → ℝ≥0}
(fs_lim : ∀ᵐ ω : Ω ∂μ, Tendsto (fun i ↦ fs i ω) L (𝓝 (f ω))) :
Tendsto (fun i ↦ ∫⁻ ω, fs i ω ∂μ) L (𝓝 (∫⁻ ω, f ω ∂μ)) := by
refine tendsto_lintegral_filter_of_dominated_convergence (fun _ ↦ c)
(eventually_of_forall fun i ↦ (ENNReal.continuous_coe.comp (fs i).continuous).measurable) ?_
(@lintegral_const_lt_top _ _ μ _ _ (@ENNReal.coe_ne_top c)).ne ?_
· simpa only [Function.comp_apply, ENNReal.coe_le_coe] using fs_le_const
· simpa only [Function.comp_apply, ENNReal.tendsto_coe] using fs_lim
#align measure_theory.finite_measure.tendsto_lintegral_nn_filter_of_le_const MeasureTheory.tendsto_lintegral_nn_filter_of_le_const
| Mathlib/MeasureTheory/Measure/HasOuterApproxClosed.lean | 75 | 85 | theorem measure_of_cont_bdd_of_tendsto_filter_indicator {ι : Type*} {L : Filter ι}
[L.IsCountablyGenerated] [TopologicalSpace Ω] [OpensMeasurableSpace Ω] (μ : Measure Ω)
[IsFiniteMeasure μ] {c : ℝ≥0} {E : Set Ω} (E_mble : MeasurableSet E) (fs : ι → Ω →ᵇ ℝ≥0)
(fs_bdd : ∀ᶠ i in L, ∀ᵐ ω : Ω ∂μ, fs i ω ≤ c)
(fs_lim : ∀ᵐ ω ∂μ, Tendsto (fun i ↦ fs i ω) L (𝓝 (indicator E (fun _ ↦ (1 : ℝ≥0)) ω))) :
Tendsto (fun n ↦ lintegral μ fun ω ↦ fs n ω) L (𝓝 (μ E)) := by |
convert tendsto_lintegral_nn_filter_of_le_const μ fs_bdd fs_lim
have aux : ∀ ω, indicator E (fun _ ↦ (1 : ℝ≥0∞)) ω = ↑(indicator E (fun _ ↦ (1 : ℝ≥0)) ω) :=
fun ω ↦ by simp only [ENNReal.coe_indicator, ENNReal.coe_one]
simp_rw [← aux, lintegral_indicator _ E_mble]
simp only [lintegral_one, Measure.restrict_apply, MeasurableSet.univ, univ_inter]
| 0 |
import Mathlib.Topology.Algebra.InfiniteSum.Group
import Mathlib.Topology.Algebra.Star
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
section ProdCodomain
variable [CommMonoid α] [TopologicalSpace α] [CommMonoid γ] [TopologicalSpace γ]
@[to_additive HasSum.prod_mk]
| Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean | 68 | 70 | theorem HasProd.prod_mk {f : β → α} {g : β → γ} {a : α} {b : γ}
(hf : HasProd f a) (hg : HasProd g b) : HasProd (fun x ↦ (⟨f x, g x⟩ : α × γ)) ⟨a, b⟩ := by |
simp [HasProd, ← prod_mk_prod, Filter.Tendsto.prod_mk_nhds hf hg]
| 0 |
import Mathlib.Order.Interval.Set.OrdConnectedComponent
import Mathlib.Topology.Order.Basic
#align_import topology.algebra.order.t5 from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
open Filter Set Function OrderDual Topology Interval
variable {X : Type*} [LinearOrder X] [TopologicalSpace X] [OrderTopology X] {a b c : X}
{s t : Set X}
namespace Set
@[simp]
theorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a ↔ s ∈ 𝓝 a := by
refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩
rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩
exact mem_of_superset ha' (subset_ordConnectedComponent ha hs)
#align set.ord_connected_component_mem_nhds Set.ordConnectedComponent_mem_nhds
| Mathlib/Topology/Order/T5.lean | 33 | 63 | theorem compl_section_ordSeparatingSet_mem_nhdsWithin_Ici (hd : Disjoint s (closure t))
(ha : a ∈ s) : (ordConnectedSection (ordSeparatingSet s t))ᶜ ∈ 𝓝[≥] a := by |
have hmem : tᶜ ∈ 𝓝[≥] a := by
refine mem_nhdsWithin_of_mem_nhds ?_
rw [← mem_interior_iff_mem_nhds, interior_compl]
exact disjoint_left.1 hd ha
rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici hmem with ⟨b, hab, hmem', hsub⟩
by_cases H : Disjoint (Icc a b) (ordConnectedSection <| ordSeparatingSet s t)
· exact mem_of_superset hmem' (disjoint_left.1 H)
· simp only [Set.disjoint_left, not_forall, Classical.not_not] at H
rcases H with ⟨c, ⟨hac, hcb⟩, hc⟩
have hsub' : Icc a b ⊆ ordConnectedComponent tᶜ a :=
subset_ordConnectedComponent (left_mem_Icc.2 hab) hsub
have hd : Disjoint s (ordConnectedSection (ordSeparatingSet s t)) :=
disjoint_left_ordSeparatingSet.mono_right ordConnectedSection_subset
replace hac : a < c := hac.lt_of_ne <| Ne.symm <| ne_of_mem_of_not_mem hc <|
disjoint_left.1 hd ha
refine mem_of_superset (Ico_mem_nhdsWithin_Ici (left_mem_Ico.2 hac)) fun x hx hx' => ?_
refine hx.2.ne (eq_of_mem_ordConnectedSection_of_uIcc_subset hx' hc ?_)
refine subset_inter (subset_iUnion₂_of_subset a ha ?_) ?_
· exact OrdConnected.uIcc_subset inferInstance (hsub' ⟨hx.1, hx.2.le.trans hcb⟩)
(hsub' ⟨hac.le, hcb⟩)
· rcases mem_iUnion₂.1 (ordConnectedSection_subset hx').2 with ⟨y, hyt, hxy⟩
refine subset_iUnion₂_of_subset y hyt (OrdConnected.uIcc_subset inferInstance hxy ?_)
refine subset_ordConnectedComponent left_mem_uIcc hxy ?_
suffices c < y by
rw [uIcc_of_ge (hx.2.trans this).le]
exact ⟨hx.2.le, this.le⟩
refine lt_of_not_le fun hyc => ?_
have hya : y < a := not_le.1 fun hay => hsub ⟨hay, hyc.trans hcb⟩ hyt
exact hxy (Icc_subset_uIcc ⟨hya.le, hx.1⟩) ha
| 0 |
import Mathlib.Data.Set.Lattice
import Mathlib.Order.Directed
#align_import data.set.Union_lift from "leanprover-community/mathlib"@"5a4ea8453f128345f73cc656e80a49de2a54f481"
variable {α : Type*} {ι β : Sort _}
namespace Set
section UnionLift
@[nolint unusedArguments]
noncomputable def iUnionLift (S : ι → Set α) (f : ∀ i, S i → β)
(_ : ∀ (i j) (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩) (T : Set α)
(hT : T ⊆ iUnion S) (x : T) : β :=
let i := Classical.indefiniteDescription _ (mem_iUnion.1 (hT x.prop))
f i ⟨x, i.prop⟩
#align set.Union_lift Set.iUnionLift
variable {S : ι → Set α} {f : ∀ i, S i → β}
{hf : ∀ (i j) (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩} {T : Set α}
{hT : T ⊆ iUnion S} (hT' : T = iUnion S)
@[simp]
theorem iUnionLift_mk {i : ι} (x : S i) (hx : (x : α) ∈ T) :
iUnionLift S f hf T hT ⟨x, hx⟩ = f i x := hf _ i x _ _
#align set.Union_lift_mk Set.iUnionLift_mk
@[simp]
theorem iUnionLift_inclusion {i : ι} (x : S i) (h : S i ⊆ T) :
iUnionLift S f hf T hT (Set.inclusion h x) = f i x :=
iUnionLift_mk x _
#align set.Union_lift_inclusion Set.iUnionLift_inclusion
theorem iUnionLift_of_mem (x : T) {i : ι} (hx : (x : α) ∈ S i) :
iUnionLift S f hf T hT x = f i ⟨x, hx⟩ := by cases' x with x hx; exact hf _ _ _ _ _
#align set.Union_lift_of_mem Set.iUnionLift_of_mem
theorem preimage_iUnionLift (t : Set β) :
iUnionLift S f hf T hT ⁻¹' t =
inclusion hT ⁻¹' (⋃ i, inclusion (subset_iUnion S i) '' (f i ⁻¹' t)) := by
ext x
simp only [mem_preimage, mem_iUnion, mem_image]
constructor
· rcases mem_iUnion.1 (hT x.prop) with ⟨i, hi⟩
refine fun h => ⟨i, ⟨x, hi⟩, ?_, rfl⟩
rwa [iUnionLift_of_mem x hi] at h
· rintro ⟨i, ⟨y, hi⟩, h, hxy⟩
obtain rfl : y = x := congr_arg Subtype.val hxy
rwa [iUnionLift_of_mem x hi]
theorem iUnionLift_const (c : T) (ci : ∀ i, S i) (hci : ∀ i, (ci i : α) = c) (cβ : β)
(h : ∀ i, f i (ci i) = cβ) : iUnionLift S f hf T hT c = cβ := by
let ⟨i, hi⟩ := Set.mem_iUnion.1 (hT c.prop)
have : ci i = ⟨c, hi⟩ := Subtype.ext (hci i)
rw [iUnionLift_of_mem _ hi, ← this, h]
#align set.Union_lift_const Set.iUnionLift_const
theorem iUnionLift_unary (u : T → T) (ui : ∀ i, S i → S i)
(hui :
∀ (i) (x : S i),
u (Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) x) =
Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) (ui i x))
(uβ : β → β) (h : ∀ (i) (x : S i), f i (ui i x) = uβ (f i x)) (x : T) :
iUnionLift S f hf T (le_of_eq hT') (u x) = uβ (iUnionLift S f hf T (le_of_eq hT') x) := by
subst hT'
cases' Set.mem_iUnion.1 x.prop with i hi
rw [iUnionLift_of_mem x hi, ← h i]
have : x = Set.inclusion (Set.subset_iUnion S i) ⟨x, hi⟩ := by
cases x
rfl
conv_lhs => rw [this, hui, iUnionLift_inclusion]
#align set.Union_lift_unary Set.iUnionLift_unary
| Mathlib/Data/Set/UnionLift.lean | 127 | 150 | theorem iUnionLift_binary (dir : Directed (· ≤ ·) S) (op : T → T → T) (opi : ∀ i, S i → S i → S i)
(hopi :
∀ i x y,
Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) (opi i x y) =
op (Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) x)
(Set.inclusion (show S i ⊆ T from hT'.symm ▸ Set.subset_iUnion S i) y))
(opβ : β → β → β) (h : ∀ (i) (x y : S i), f i (opi i x y) = opβ (f i x) (f i y)) (x y : T) :
iUnionLift S f hf T (le_of_eq hT') (op x y) =
opβ (iUnionLift S f hf T (le_of_eq hT') x) (iUnionLift S f hf T (le_of_eq hT') y) := by |
subst hT'
cases' Set.mem_iUnion.1 x.prop with i hi
cases' Set.mem_iUnion.1 y.prop with j hj
rcases dir i j with ⟨k, hik, hjk⟩
rw [iUnionLift_of_mem x (hik hi), iUnionLift_of_mem y (hjk hj), ← h k]
have hx : x = Set.inclusion (Set.subset_iUnion S k) ⟨x, hik hi⟩ := by
cases x
rfl
have hy : y = Set.inclusion (Set.subset_iUnion S k) ⟨y, hjk hj⟩ := by
cases y
rfl
have hxy : (Set.inclusion (Set.subset_iUnion S k) (opi k ⟨x, hik hi⟩ ⟨y, hjk hj⟩) : α) ∈ S k :=
(opi k ⟨x, hik hi⟩ ⟨y, hjk hj⟩).prop
conv_lhs => rw [hx, hy, ← hopi, iUnionLift_of_mem _ hxy]
rfl
| 0 |
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 fintsupport -- partitions of unity have locally finite `tsupport`
variable {s : Set X} (ρ : PartitionOfUnity ι X s) (x₀ : X)
theorem finite_tsupport : {i | x₀ ∈ tsupport (ρ i)}.Finite := by
rcases ρ.locallyFinite x₀ with ⟨t, t_in, ht⟩
apply ht.subset
rintro i hi
simp only [inter_comm]
exact mem_closure_iff_nhds.mp hi t t_in
def fintsupport (x₀ : X) : Finset ι :=
(ρ.finite_tsupport x₀).toFinset
theorem mem_fintsupport_iff (i : ι) : i ∈ ρ.fintsupport x₀ ↔ x₀ ∈ tsupport (ρ i) :=
Finite.mem_toFinset _
| Mathlib/Topology/PartitionOfUnity.lean | 244 | 249 | theorem eventually_fintsupport_subset :
∀ᶠ y in 𝓝 x₀, ρ.fintsupport y ⊆ ρ.fintsupport x₀ := by |
apply (ρ.locallyFinite.closure.eventually_subset (fun _ ↦ isClosed_closure) x₀).mono
intro y hy z hz
rw [PartitionOfUnity.mem_fintsupport_iff] at *
exact hy hz
| 0 |
import Mathlib.Data.Finset.Lattice
#align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
variable {α : Type*} [DecidableEq α] {𝒜 ℬ : Finset (Finset α)} {s : Finset α} {a : α}
open Finset
-- The namespace is here to distinguish from other compressions.
namespace Down
def compression (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) :=
(𝒜.filter fun s => erase s a ∈ 𝒜).disjUnion
((𝒜.image fun s => erase s a).filter fun s => s ∉ 𝒜) <|
disjoint_left.2 fun s h₁ h₂ => by
have := (mem_filter.1 h₂).2
exact this (mem_filter.1 h₁).1
#align down.compression Down.compression
@[inherit_doc]
scoped[FinsetFamily] notation "𝓓 " => Down.compression
-- Porting note: had to open this
open FinsetFamily
| Mathlib/Combinatorics/SetFamily/Compression/Down.lean | 241 | 248 | theorem mem_compression : s ∈ 𝓓 a 𝒜 ↔ s ∈ 𝒜 ∧ s.erase a ∈ 𝒜 ∨ s ∉ 𝒜 ∧ insert a s ∈ 𝒜 := by |
simp_rw [compression, mem_disjUnion, mem_filter, mem_image, and_comm (a := (¬ s ∈ 𝒜))]
refine
or_congr_right
(and_congr_left fun hs =>
⟨?_, fun h => ⟨_, h, erase_insert <| insert_ne_self.1 <| ne_of_mem_of_not_mem h hs⟩⟩)
rintro ⟨t, ht, rfl⟩
rwa [insert_erase (erase_ne_self.1 (ne_of_mem_of_not_mem ht hs).symm)]
| 0 |
import Mathlib.Algebra.Module.Card
import Mathlib.SetTheory.Cardinal.CountableCover
import Mathlib.SetTheory.Cardinal.Continuum
import Mathlib.Analysis.SpecificLimits.Normed
import Mathlib.Topology.MetricSpace.Perfect
universe u v
open Filter Pointwise Set Function Cardinal
open scoped Cardinal Topology
theorem continuum_le_cardinal_of_nontriviallyNormedField
(𝕜 : Type*) [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] : 𝔠 ≤ #𝕜 := by
suffices ∃ f : (ℕ → Bool) → 𝕜, range f ⊆ univ ∧ Continuous f ∧ Injective f by
rcases this with ⟨f, -, -, f_inj⟩
simpa using lift_mk_le_lift_mk_of_injective f_inj
apply Perfect.exists_nat_bool_injection _ univ_nonempty
refine ⟨isClosed_univ, preperfect_iff_nhds.2 (fun x _ U hU ↦ ?_)⟩
rcases NormedField.exists_norm_lt_one 𝕜 with ⟨c, c_pos, hc⟩
have A : Tendsto (fun n ↦ x + c^n) atTop (𝓝 (x + 0)) :=
tendsto_const_nhds.add (tendsto_pow_atTop_nhds_zero_of_norm_lt_one hc)
rw [add_zero] at A
have B : ∀ᶠ n in atTop, x + c^n ∈ U := tendsto_def.1 A U hU
rcases B.exists with ⟨n, hn⟩
refine ⟨x + c^n, by simpa using hn, ?_⟩
simp only [ne_eq, add_right_eq_self]
apply pow_ne_zero
simpa using c_pos
theorem continuum_le_cardinal_of_module
(𝕜 : Type u) (E : Type v) [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜]
[AddCommGroup E] [Module 𝕜 E] [Nontrivial E] : 𝔠 ≤ #E := by
have A : lift.{v} (𝔠 : Cardinal.{u}) ≤ lift.{v} (#𝕜) := by
simpa using continuum_le_cardinal_of_nontriviallyNormedField 𝕜
simpa using A.trans (Cardinal.mk_le_of_module 𝕜 E)
lemma cardinal_eq_of_mem_nhds_zero
{E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
[TopologicalSpace E] [ContinuousSMul 𝕜 E] {s : Set E} (hs : s ∈ 𝓝 (0 : E)) : #s = #E := by
obtain ⟨c, hc⟩ : ∃ x : 𝕜 , 1 < ‖x‖ := NormedField.exists_lt_norm 𝕜 1
have cn_ne : ∀ n, c^n ≠ 0 := by
intro n
apply pow_ne_zero
rintro rfl
simp only [norm_zero] at hc
exact lt_irrefl _ (hc.trans zero_lt_one)
have A : ∀ (x : E), ∀ᶠ n in (atTop : Filter ℕ), x ∈ c^n • s := by
intro x
have : Tendsto (fun n ↦ (c^n) ⁻¹ • x) atTop (𝓝 ((0 : 𝕜) • x)) := by
have : Tendsto (fun n ↦ (c^n)⁻¹) atTop (𝓝 0) := by
simp_rw [← inv_pow]
apply tendsto_pow_atTop_nhds_zero_of_norm_lt_one
rw [norm_inv]
exact inv_lt_one hc
exact Tendsto.smul_const this x
rw [zero_smul] at this
filter_upwards [this hs] with n (hn : (c ^ n)⁻¹ • x ∈ s)
exact (mem_smul_set_iff_inv_smul_mem₀ (cn_ne n) _ _).2 hn
have B : ∀ n, #(c^n • s :) = #s := by
intro n
have : (c^n • s :) ≃ s :=
{ toFun := fun x ↦ ⟨(c^n)⁻¹ • x.1, (mem_smul_set_iff_inv_smul_mem₀ (cn_ne n) _ _).1 x.2⟩
invFun := fun x ↦ ⟨(c^n) • x.1, smul_mem_smul_set x.2⟩
left_inv := fun x ↦ by simp [smul_smul, mul_inv_cancel (cn_ne n)]
right_inv := fun x ↦ by simp [smul_smul, inv_mul_cancel (cn_ne n)] }
exact Cardinal.mk_congr this
apply (Cardinal.mk_of_countable_eventually_mem A B).symm
| Mathlib/Topology/Algebra/Module/Cardinality.lean | 97 | 106 | theorem cardinal_eq_of_mem_nhds
{E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
[TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul 𝕜 E]
{s : Set E} {x : E} (hs : s ∈ 𝓝 x) : #s = #E := by |
let g := Homeomorph.addLeft x
let t := g ⁻¹' s
have : t ∈ 𝓝 0 := g.continuous.continuousAt.preimage_mem_nhds (by simpa [g] using hs)
have A : #t = #E := cardinal_eq_of_mem_nhds_zero 𝕜 this
have B : #t = #s := Cardinal.mk_subtype_of_equiv s g.toEquiv
rwa [B] at A
| 0 |
import Mathlib.Algebra.ContinuedFractions.Computation.CorrectnessTerminating
import Mathlib.Algebra.Order.Group.Basic
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Data.Nat.Fib.Basic
import Mathlib.Tactic.Monotonicity
#align_import algebra.continued_fractions.computation.approximations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace GeneralizedContinuedFraction
open GeneralizedContinuedFraction (of)
open Int
variable {K : Type*} {v : K} {n : ℕ} [LinearOrderedField K] [FloorRing K]
namespace IntFractPair
theorem nth_stream_fr_nonneg_lt_one {ifp_n : IntFractPair K}
(nth_stream_eq : IntFractPair.stream v n = some ifp_n) : 0 ≤ ifp_n.fr ∧ ifp_n.fr < 1 := by
cases n with
| zero =>
have : IntFractPair.of v = ifp_n := by injection nth_stream_eq
rw [← this, IntFractPair.of]
exact ⟨fract_nonneg _, fract_lt_one _⟩
| succ =>
rcases succ_nth_stream_eq_some_iff.1 nth_stream_eq with ⟨_, _, _, ifp_of_eq_ifp_n⟩
rw [← ifp_of_eq_ifp_n, IntFractPair.of]
exact ⟨fract_nonneg _, fract_lt_one _⟩
#align generalized_continued_fraction.int_fract_pair.nth_stream_fr_nonneg_lt_one GeneralizedContinuedFraction.IntFractPair.nth_stream_fr_nonneg_lt_one
theorem nth_stream_fr_nonneg {ifp_n : IntFractPair K}
(nth_stream_eq : IntFractPair.stream v n = some ifp_n) : 0 ≤ ifp_n.fr :=
(nth_stream_fr_nonneg_lt_one nth_stream_eq).left
#align generalized_continued_fraction.int_fract_pair.nth_stream_fr_nonneg GeneralizedContinuedFraction.IntFractPair.nth_stream_fr_nonneg
theorem nth_stream_fr_lt_one {ifp_n : IntFractPair K}
(nth_stream_eq : IntFractPair.stream v n = some ifp_n) : ifp_n.fr < 1 :=
(nth_stream_fr_nonneg_lt_one nth_stream_eq).right
#align generalized_continued_fraction.int_fract_pair.nth_stream_fr_lt_one GeneralizedContinuedFraction.IntFractPair.nth_stream_fr_lt_one
| Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean | 96 | 107 | theorem one_le_succ_nth_stream_b {ifp_succ_n : IntFractPair K}
(succ_nth_stream_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n) : 1 ≤ ifp_succ_n.b := by |
obtain ⟨ifp_n, nth_stream_eq, stream_nth_fr_ne_zero, ⟨-⟩⟩ :
∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0
∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n :=
succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq
suffices 1 ≤ ifp_n.fr⁻¹ by rwa [IntFractPair.of, le_floor, cast_one]
suffices ifp_n.fr ≤ 1 by
have h : 0 < ifp_n.fr :=
lt_of_le_of_ne (nth_stream_fr_nonneg nth_stream_eq) stream_nth_fr_ne_zero.symm
apply one_le_inv h this
simp only [le_of_lt (nth_stream_fr_lt_one nth_stream_eq)]
| 0 |
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.Tactic.ComputeDegree
#align_import linear_algebra.matrix.polynomial from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
set_option linter.uppercaseLean3 false
open Matrix Polynomial
variable {n α : Type*} [DecidableEq n] [Fintype n] [CommRing α]
open Polynomial Matrix Equiv.Perm
namespace Polynomial
theorem natDegree_det_X_add_C_le (A B : Matrix n n α) :
natDegree (det ((X : α[X]) • A.map C + B.map C : Matrix n n α[X])) ≤ Fintype.card n := by
rw [det_apply]
refine (natDegree_sum_le _ _).trans ?_
refine Multiset.max_le_of_forall_le _ _ ?_
simp only [forall_apply_eq_imp_iff, true_and_iff, Function.comp_apply, Multiset.map_map,
Multiset.mem_map, exists_imp, Finset.mem_univ_val]
intro g
calc
natDegree (sign g • ∏ i : n, (X • A.map C + B.map C : Matrix n n α[X]) (g i) i) ≤
natDegree (∏ i : n, (X • A.map C + B.map C : Matrix n n α[X]) (g i) i) := by
cases' Int.units_eq_one_or (sign g) with sg sg
· rw [sg, one_smul]
· rw [sg, Units.neg_smul, one_smul, natDegree_neg]
_ ≤ ∑ i : n, natDegree (((X : α[X]) • A.map C + B.map C : Matrix n n α[X]) (g i) i) :=
(natDegree_prod_le (Finset.univ : Finset n) fun i : n =>
(X • A.map C + B.map C : Matrix n n α[X]) (g i) i)
_ ≤ Finset.univ.card • 1 := (Finset.sum_le_card_nsmul _ _ 1 fun (i : n) _ => ?_)
_ ≤ Fintype.card n := by simp [mul_one, Algebra.id.smul_eq_mul, Finset.card_univ]
dsimp only [add_apply, smul_apply, map_apply, smul_eq_mul]
compute_degree
#align polynomial.nat_degree_det_X_add_C_le Polynomial.natDegree_det_X_add_C_le
| Mathlib/LinearAlgebra/Matrix/Polynomial.lean | 62 | 70 | theorem coeff_det_X_add_C_zero (A B : Matrix n n α) :
coeff (det ((X : α[X]) • A.map C + B.map C)) 0 = det B := by |
rw [det_apply, finset_sum_coeff, det_apply]
refine Finset.sum_congr rfl ?_
rintro g -
convert coeff_smul (R := α) (sign g) _ 0
rw [coeff_zero_prod]
refine Finset.prod_congr rfl ?_
simp
| 0 |
import Mathlib.Analysis.Calculus.FormalMultilinearSeries
import Mathlib.Analysis.SpecificLimits.Normed
import Mathlib.Logic.Equiv.Fin
import Mathlib.Topology.Algebra.InfiniteSum.Module
#align_import analysis.analytic.basic from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514"
noncomputable section
variable {𝕜 E F G : Type*}
open scoped Classical
open Topology NNReal Filter ENNReal
open Set Filter Asymptotics
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G]
namespace FormalMultilinearSeries
variable (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0}
def radius (p : FormalMultilinearSeries 𝕜 E F) : ℝ≥0∞ :=
⨆ (r : ℝ≥0) (C : ℝ) (_ : ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C), (r : ℝ≥0∞)
#align formal_multilinear_series.radius FormalMultilinearSeries.radius
theorem le_radius_of_bound (C : ℝ) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖ * (r : ℝ) ^ n ≤ C) :
(r : ℝ≥0∞) ≤ p.radius :=
le_iSup_of_le r <| le_iSup_of_le C <| le_iSup (fun _ => (r : ℝ≥0∞)) h
#align formal_multilinear_series.le_radius_of_bound FormalMultilinearSeries.le_radius_of_bound
theorem le_radius_of_bound_nnreal (C : ℝ≥0) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖₊ * r ^ n ≤ C) :
(r : ℝ≥0∞) ≤ p.radius :=
p.le_radius_of_bound C fun n => mod_cast h n
#align formal_multilinear_series.le_radius_of_bound_nnreal FormalMultilinearSeries.le_radius_of_bound_nnreal
theorem le_radius_of_isBigO (h : (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) :
↑r ≤ p.radius :=
Exists.elim (isBigO_one_nat_atTop_iff.1 h) fun C hC =>
p.le_radius_of_bound C fun n => (le_abs_self _).trans (hC n)
set_option linter.uppercaseLean3 false in
#align formal_multilinear_series.le_radius_of_is_O FormalMultilinearSeries.le_radius_of_isBigO
theorem le_radius_of_eventually_le (C) (h : ∀ᶠ n in atTop, ‖p n‖ * (r : ℝ) ^ n ≤ C) :
↑r ≤ p.radius :=
p.le_radius_of_isBigO <| IsBigO.of_bound C <| h.mono fun n hn => by simpa
#align formal_multilinear_series.le_radius_of_eventually_le FormalMultilinearSeries.le_radius_of_eventually_le
theorem le_radius_of_summable_nnnorm (h : Summable fun n => ‖p n‖₊ * r ^ n) : ↑r ≤ p.radius :=
p.le_radius_of_bound_nnreal (∑' n, ‖p n‖₊ * r ^ n) fun _ => le_tsum' h _
#align formal_multilinear_series.le_radius_of_summable_nnnorm FormalMultilinearSeries.le_radius_of_summable_nnnorm
theorem le_radius_of_summable (h : Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : ↑r ≤ p.radius :=
p.le_radius_of_summable_nnnorm <| by
simp only [← coe_nnnorm] at h
exact mod_cast h
#align formal_multilinear_series.le_radius_of_summable FormalMultilinearSeries.le_radius_of_summable
theorem radius_eq_top_of_forall_nnreal_isBigO
(h : ∀ r : ℝ≥0, (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) : p.radius = ∞ :=
ENNReal.eq_top_of_forall_nnreal_le fun r => p.le_radius_of_isBigO (h r)
set_option linter.uppercaseLean3 false in
#align formal_multilinear_series.radius_eq_top_of_forall_nnreal_is_O FormalMultilinearSeries.radius_eq_top_of_forall_nnreal_isBigO
theorem radius_eq_top_of_eventually_eq_zero (h : ∀ᶠ n in atTop, p n = 0) : p.radius = ∞ :=
p.radius_eq_top_of_forall_nnreal_isBigO fun r =>
(isBigO_zero _ _).congr' (h.mono fun n hn => by simp [hn]) EventuallyEq.rfl
#align formal_multilinear_series.radius_eq_top_of_eventually_eq_zero FormalMultilinearSeries.radius_eq_top_of_eventually_eq_zero
theorem radius_eq_top_of_forall_image_add_eq_zero (n : ℕ) (hn : ∀ m, p (m + n) = 0) :
p.radius = ∞ :=
p.radius_eq_top_of_eventually_eq_zero <|
mem_atTop_sets.2 ⟨n, fun _ hk => tsub_add_cancel_of_le hk ▸ hn _⟩
#align formal_multilinear_series.radius_eq_top_of_forall_image_add_eq_zero FormalMultilinearSeries.radius_eq_top_of_forall_image_add_eq_zero
@[simp]
theorem constFormalMultilinearSeries_radius {v : F} :
(constFormalMultilinearSeries 𝕜 E v).radius = ⊤ :=
(constFormalMultilinearSeries 𝕜 E v).radius_eq_top_of_forall_image_add_eq_zero 1
(by simp [constFormalMultilinearSeries])
#align formal_multilinear_series.const_formal_multilinear_series_radius FormalMultilinearSeries.constFormalMultilinearSeries_radius
| Mathlib/Analysis/Analytic/Basic.lean | 187 | 202 | theorem isLittleO_of_lt_radius (h : ↑r < p.radius) :
∃ a ∈ Ioo (0 : ℝ) 1, (fun n => ‖p n‖ * (r : ℝ) ^ n) =o[atTop] (a ^ ·) := by |
have := (TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4
rw [this]
-- Porting note: was
-- rw [(TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4]
simp only [radius, lt_iSup_iff] at h
rcases h with ⟨t, C, hC, rt⟩
rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at rt
have : 0 < (t : ℝ) := r.coe_nonneg.trans_lt rt
rw [← div_lt_one this] at rt
refine ⟨_, rt, C, Or.inr zero_lt_one, fun n => ?_⟩
calc
|‖p n‖ * (r : ℝ) ^ n| = ‖p n‖ * (t : ℝ) ^ n * (r / t : ℝ) ^ n := by
field_simp [mul_right_comm, abs_mul]
_ ≤ C * (r / t : ℝ) ^ n := by gcongr; apply hC
| 0 |
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.GeomSum
import Mathlib.Data.Fintype.BigOperators
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.RingTheory.PowerSeries.WellKnown
import Mathlib.Tactic.FieldSimp
#align_import number_theory.bernoulli from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Nat Finset Finset.Nat PowerSeries
variable (A : Type*) [CommRing A] [Algebra ℚ A]
def bernoulli' : ℕ → ℚ :=
WellFounded.fix Nat.lt_wfRel.wf fun n bernoulli' =>
1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k k.2
#align bernoulli' bernoulli'
theorem bernoulli'_def' (n : ℕ) :
bernoulli' n = 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k :=
WellFounded.fix_eq _ _ _
#align bernoulli'_def' bernoulli'_def'
theorem bernoulli'_def (n : ℕ) :
bernoulli' n = 1 - ∑ k ∈ range n, n.choose k / (n - k + 1) * bernoulli' k := by
rw [bernoulli'_def', ← Fin.sum_univ_eq_sum_range]
#align bernoulli'_def bernoulli'_def
theorem bernoulli'_spec (n : ℕ) :
(∑ k ∈ range n.succ, (n.choose (n - k) : ℚ) / (n - k + 1) * bernoulli' k) = 1 := by
rw [sum_range_succ_comm, bernoulli'_def n, tsub_self, choose_zero_right, sub_self, zero_add,
div_one, cast_one, one_mul, sub_add, ← sum_sub_distrib, ← sub_eq_zero, sub_sub_cancel_left,
neg_eq_zero]
exact Finset.sum_eq_zero (fun x hx => by rw [choose_symm (le_of_lt (mem_range.1 hx)), sub_self])
#align bernoulli'_spec bernoulli'_spec
theorem bernoulli'_spec' (n : ℕ) :
(∑ k ∈ antidiagonal n, ((k.1 + k.2).choose k.2 : ℚ) / (k.2 + 1) * bernoulli' k.1) = 1 := by
refine ((sum_antidiagonal_eq_sum_range_succ_mk _ n).trans ?_).trans (bernoulli'_spec n)
refine sum_congr rfl fun x hx => ?_
simp only [add_tsub_cancel_of_le, mem_range_succ_iff.mp hx, cast_sub]
#align bernoulli'_spec' bernoulli'_spec'
@[simp]
theorem sum_bernoulli' (n : ℕ) : (∑ k ∈ range n, (n.choose k : ℚ) * bernoulli' k) = n := by
cases' n with n
· simp
suffices
((n + 1 : ℚ) * ∑ k ∈ range n, ↑(n.choose k) / (n - k + 1) * bernoulli' k) =
∑ x ∈ range n, ↑(n.succ.choose x) * bernoulli' x by
rw_mod_cast [sum_range_succ, bernoulli'_def, ← this, choose_succ_self_right]
ring
simp_rw [mul_sum, ← mul_assoc]
refine sum_congr rfl fun k hk => ?_
congr
have : ((n - k : ℕ) : ℚ) + 1 ≠ 0 := by norm_cast
field_simp [← cast_sub (mem_range.1 hk).le, mul_comm]
rw_mod_cast [tsub_add_eq_add_tsub (mem_range.1 hk).le, choose_mul_succ_eq]
#align sum_bernoulli' sum_bernoulli'
def bernoulli'PowerSeries :=
mk fun n => algebraMap ℚ A (bernoulli' n / n !)
#align bernoulli'_power_series bernoulli'PowerSeries
theorem bernoulli'PowerSeries_mul_exp_sub_one :
bernoulli'PowerSeries A * (exp A - 1) = X * exp A := by
ext n
-- constant coefficient is a special case
cases' n with n
· simp
rw [bernoulli'PowerSeries, coeff_mul, mul_comm X, sum_antidiagonal_succ']
suffices (∑ p ∈ antidiagonal n,
bernoulli' p.1 / p.1! * ((p.2 + 1) * p.2! : ℚ)⁻¹) = (n ! : ℚ)⁻¹ by
simpa [map_sum, Nat.factorial] using congr_arg (algebraMap ℚ A) this
apply eq_inv_of_mul_eq_one_left
rw [sum_mul]
convert bernoulli'_spec' n using 1
apply sum_congr rfl
simp_rw [mem_antidiagonal]
rintro ⟨i, j⟩ rfl
have := factorial_mul_factorial_dvd_factorial_add i j
field_simp [mul_comm _ (bernoulli' i), mul_assoc, add_choose]
norm_cast
simp [mul_comm (j + 1)]
#align bernoulli'_power_series_mul_exp_sub_one bernoulli'PowerSeries_mul_exp_sub_one
| Mathlib/NumberTheory/Bernoulli.lean | 181 | 196 | theorem bernoulli'_odd_eq_zero {n : ℕ} (h_odd : Odd n) (hlt : 1 < n) : bernoulli' n = 0 := by |
let B := mk fun n => bernoulli' n / (n ! : ℚ)
suffices (B - evalNegHom B) * (exp ℚ - 1) = X * (exp ℚ - 1) by
cases' mul_eq_mul_right_iff.mp this with h h <;>
simp only [PowerSeries.ext_iff, evalNegHom, coeff_X] at h
· apply eq_zero_of_neg_eq
specialize h n
split_ifs at h <;> simp_all [B, h_odd.neg_one_pow, factorial_ne_zero]
· simpa (config := {decide := true}) [Nat.factorial] using h 1
have h : B * (exp ℚ - 1) = X * exp ℚ := by
simpa [bernoulli'PowerSeries] using bernoulli'PowerSeries_mul_exp_sub_one ℚ
rw [sub_mul, h, mul_sub X, sub_right_inj, ← neg_sub, mul_neg, neg_eq_iff_eq_neg]
suffices evalNegHom (B * (exp ℚ - 1)) * exp ℚ = evalNegHom (X * exp ℚ) * exp ℚ by
rw [map_mul, map_mul] at this -- Porting note: Why doesn't simp do this?
simpa [mul_assoc, sub_mul, mul_comm (evalNegHom (exp ℚ)), exp_mul_exp_neg_eq_one]
congr
| 0 |
import Mathlib.LinearAlgebra.LinearPMap
import Mathlib.Topology.Algebra.Module.Basic
#align_import topology.algebra.module.linear_pmap from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Topology
variable {R E F : Type*}
variable [CommRing R] [AddCommGroup E] [AddCommGroup F]
variable [Module R E] [Module R F]
variable [TopologicalSpace E] [TopologicalSpace F]
namespace LinearPMap
def IsClosed (f : E →ₗ.[R] F) : Prop :=
_root_.IsClosed (f.graph : Set (E × F))
#align linear_pmap.is_closed LinearPMap.IsClosed
variable [ContinuousAdd E] [ContinuousAdd F]
variable [TopologicalSpace R] [ContinuousSMul R E] [ContinuousSMul R F]
def IsClosable (f : E →ₗ.[R] F) : Prop :=
∃ f' : LinearPMap R E F, f.graph.topologicalClosure = f'.graph
#align linear_pmap.is_closable LinearPMap.IsClosable
theorem IsClosed.isClosable {f : E →ₗ.[R] F} (hf : f.IsClosed) : f.IsClosable :=
⟨f, hf.submodule_topologicalClosure_eq⟩
#align linear_pmap.is_closed.is_closable LinearPMap.IsClosed.isClosable
theorem IsClosable.leIsClosable {f g : E →ₗ.[R] F} (hf : f.IsClosable) (hfg : g ≤ f) :
g.IsClosable := by
cases' hf with f' hf
have : g.graph.topologicalClosure ≤ f'.graph := by
rw [← hf]
exact Submodule.topologicalClosure_mono (le_graph_of_le hfg)
use g.graph.topologicalClosure.toLinearPMap
rw [Submodule.toLinearPMap_graph_eq]
exact fun _ hx hx' => f'.graph_fst_eq_zero_snd (this hx) hx'
#align linear_pmap.is_closable.le_is_closable LinearPMap.IsClosable.leIsClosable
theorem IsClosable.existsUnique {f : E →ₗ.[R] F} (hf : f.IsClosable) :
∃! f' : E →ₗ.[R] F, f.graph.topologicalClosure = f'.graph := by
refine exists_unique_of_exists_of_unique hf fun _ _ hy₁ hy₂ => eq_of_eq_graph ?_
rw [← hy₁, ← hy₂]
#align linear_pmap.is_closable.exists_unique LinearPMap.IsClosable.existsUnique
open scoped Classical
noncomputable def closure (f : E →ₗ.[R] F) : E →ₗ.[R] F :=
if hf : f.IsClosable then hf.choose else f
#align linear_pmap.closure LinearPMap.closure
theorem closure_def {f : E →ₗ.[R] F} (hf : f.IsClosable) : f.closure = hf.choose := by
simp [closure, hf]
#align linear_pmap.closure_def LinearPMap.closure_def
theorem closure_def' {f : E →ₗ.[R] F} (hf : ¬f.IsClosable) : f.closure = f := by simp [closure, hf]
#align linear_pmap.closure_def' LinearPMap.closure_def'
theorem IsClosable.graph_closure_eq_closure_graph {f : E →ₗ.[R] F} (hf : f.IsClosable) :
f.graph.topologicalClosure = f.closure.graph := by
rw [closure_def hf]
exact hf.choose_spec
#align linear_pmap.is_closable.graph_closure_eq_closure_graph LinearPMap.IsClosable.graph_closure_eq_closure_graph
| Mathlib/Topology/Algebra/Module/LinearPMap.lean | 119 | 124 | theorem le_closure (f : E →ₗ.[R] F) : f ≤ f.closure := by |
by_cases hf : f.IsClosable
· refine le_of_le_graph ?_
rw [← hf.graph_closure_eq_closure_graph]
exact (graph f).le_topologicalClosure
rw [closure_def' hf]
| 0 |
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 squareCylinders
def squareCylinders (C : ∀ i, Set (Set (α i))) : Set (Set (∀ i, α i)) :=
{S | ∃ s : Finset ι, ∃ t ∈ univ.pi C, S = (s : Set ι).pi t}
theorem squareCylinders_eq_iUnion_image (C : ∀ i, Set (Set (α i))) :
squareCylinders C = ⋃ s : Finset ι, (fun t ↦ (s : Set ι).pi t) '' univ.pi C := by
ext1 f
simp only [squareCylinders, mem_iUnion, mem_image, mem_univ_pi, exists_prop, mem_setOf_eq,
eq_comm (a := f)]
theorem isPiSystem_squareCylinders {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsPiSystem (C i))
(hC_univ : ∀ i, univ ∈ C i) :
IsPiSystem (squareCylinders C) := by
rintro S₁ ⟨s₁, t₁, h₁, rfl⟩ S₂ ⟨s₂, t₂, h₂, rfl⟩ hst_nonempty
classical
let t₁' := s₁.piecewise t₁ (fun i ↦ univ)
let t₂' := s₂.piecewise t₂ (fun i ↦ univ)
have h1 : ∀ i ∈ (s₁ : Set ι), t₁ i = t₁' i :=
fun i hi ↦ (Finset.piecewise_eq_of_mem _ _ _ hi).symm
have h1' : ∀ i ∉ (s₁ : Set ι), t₁' i = univ :=
fun i hi ↦ Finset.piecewise_eq_of_not_mem _ _ _ hi
have h2 : ∀ i ∈ (s₂ : Set ι), t₂ i = t₂' i :=
fun i hi ↦ (Finset.piecewise_eq_of_mem _ _ _ hi).symm
have h2' : ∀ i ∉ (s₂ : Set ι), t₂' i = univ :=
fun i hi ↦ Finset.piecewise_eq_of_not_mem _ _ _ hi
rw [Set.pi_congr rfl h1, Set.pi_congr rfl h2, ← union_pi_inter h1' h2']
refine ⟨s₁ ∪ s₂, fun i ↦ t₁' i ∩ t₂' i, ?_, ?_⟩
· rw [mem_univ_pi]
intro i
have : (t₁' i ∩ t₂' i).Nonempty := by
obtain ⟨f, hf⟩ := hst_nonempty
rw [Set.pi_congr rfl h1, Set.pi_congr rfl h2, mem_inter_iff, mem_pi, mem_pi] at hf
refine ⟨f i, ⟨?_, ?_⟩⟩
· by_cases hi₁ : i ∈ s₁
· exact hf.1 i hi₁
· rw [h1' i hi₁]
exact mem_univ _
· by_cases hi₂ : i ∈ s₂
· exact hf.2 i hi₂
· rw [h2' i hi₂]
exact mem_univ _
refine hC i _ ?_ _ ?_ this
· by_cases hi₁ : i ∈ s₁
· rw [← h1 i hi₁]
exact h₁ i (mem_univ _)
· rw [h1' i hi₁]
exact hC_univ i
· by_cases hi₂ : i ∈ s₂
· rw [← h2 i hi₂]
exact h₂ i (mem_univ _)
· rw [h2' i hi₂]
exact hC_univ i
· rw [Finset.coe_union]
theorem comap_eval_le_generateFrom_squareCylinders_singleton
(α : ι → Type*) [m : ∀ i, MeasurableSpace (α i)] (i : ι) :
MeasurableSpace.comap (Function.eval i) (m i) ≤
MeasurableSpace.generateFrom
((fun t ↦ ({i} : Set ι).pi t) '' univ.pi fun i ↦ {s : Set (α i) | MeasurableSet s}) := by
simp only [Function.eval, singleton_pi, ge_iff_le]
rw [MeasurableSpace.comap_eq_generateFrom]
refine MeasurableSpace.generateFrom_mono fun S ↦ ?_
simp only [mem_setOf_eq, mem_image, mem_univ_pi, forall_exists_index, and_imp]
intro t ht h
classical
refine ⟨fun j ↦ if hji : j = i then by convert t else univ, fun j ↦ ?_, ?_⟩
· by_cases hji : j = i
· simp only [hji, eq_self_iff_true, eq_mpr_eq_cast, dif_pos]
convert ht
simp only [id_eq, cast_heq]
· simp only [hji, not_false_iff, dif_neg, MeasurableSet.univ]
· simp only [id_eq, eq_mpr_eq_cast, ← h]
ext1 x
simp only [singleton_pi, Function.eval, cast_eq, dite_eq_ite, ite_true, mem_preimage]
| Mathlib/MeasureTheory/Constructions/Cylinders.lean | 129 | 144 | theorem generateFrom_squareCylinders [∀ i, MeasurableSpace (α i)] :
MeasurableSpace.generateFrom (squareCylinders fun i ↦ {s : Set (α i) | MeasurableSet s}) =
MeasurableSpace.pi := by |
apply le_antisymm
· rw [MeasurableSpace.generateFrom_le_iff]
rintro S ⟨s, t, h, rfl⟩
simp only [mem_univ_pi, mem_setOf_eq] at h
exact MeasurableSet.pi (Finset.countable_toSet _) (fun i _ ↦ h i)
· refine iSup_le fun i ↦ ?_
refine (comap_eval_le_generateFrom_squareCylinders_singleton α i).trans ?_
refine MeasurableSpace.generateFrom_mono ?_
rw [← Finset.coe_singleton, squareCylinders_eq_iUnion_image]
exact subset_iUnion
(fun (s : Finset ι) ↦
(fun t : ∀ i, Set (α i) ↦ (s : Set ι).pi t) '' univ.pi (fun i ↦ setOf MeasurableSet))
({i} : Finset ι)
| 0 |
import Mathlib.Computability.Halting
import Mathlib.Computability.TuringMachine
import Mathlib.Data.Num.Lemmas
import Mathlib.Tactic.DeriveFintype
#align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"6155d4351090a6fad236e3d2e4e0e4e7342668e8"
open Function (update)
open Relation
namespace Turing
namespace ToPartrec
inductive Code
| zero'
| succ
| tail
| cons : Code → Code → Code
| comp : Code → Code → Code
| case : Code → Code → Code
| fix : Code → Code
deriving DecidableEq, Inhabited
#align turing.to_partrec.code Turing.ToPartrec.Code
#align turing.to_partrec.code.zero' Turing.ToPartrec.Code.zero'
#align turing.to_partrec.code.succ Turing.ToPartrec.Code.succ
#align turing.to_partrec.code.tail Turing.ToPartrec.Code.tail
#align turing.to_partrec.code.cons Turing.ToPartrec.Code.cons
#align turing.to_partrec.code.comp Turing.ToPartrec.Code.comp
#align turing.to_partrec.code.case Turing.ToPartrec.Code.case
#align turing.to_partrec.code.fix Turing.ToPartrec.Code.fix
def Code.eval : Code → List ℕ →. List ℕ
| Code.zero' => fun v => pure (0 :: v)
| Code.succ => fun v => pure [v.headI.succ]
| Code.tail => fun v => pure v.tail
| Code.cons f fs => fun v => do
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns)
| Code.comp f g => fun v => g.eval v >>= f.eval
| Code.case f g => fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail)
| Code.fix f =>
PFun.fix fun v => (f.eval v).map fun v => if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail
#align turing.to_partrec.code.eval Turing.ToPartrec.Code.eval
namespace Code
@[simp]
theorem zero'_eval : zero'.eval = fun v => pure (0 :: v) := by simp [eval]
@[simp]
theorem succ_eval : succ.eval = fun v => pure [v.headI.succ] := by simp [eval]
@[simp]
theorem tail_eval : tail.eval = fun v => pure v.tail := by simp [eval]
@[simp]
theorem cons_eval (f fs) : (cons f fs).eval = fun v => do {
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns) } := by simp [eval]
@[simp]
theorem comp_eval (f g) : (comp f g).eval = fun v => g.eval v >>= f.eval := by simp [eval]
@[simp]
theorem case_eval (f g) :
(case f g).eval = fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail) := by
simp [eval]
@[simp]
theorem fix_eval (f) : (fix f).eval =
PFun.fix fun v => (f.eval v).map fun v =>
if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail := by
simp [eval]
def nil : Code :=
tail.comp succ
#align turing.to_partrec.code.nil Turing.ToPartrec.Code.nil
@[simp]
theorem nil_eval (v) : nil.eval v = pure [] := by simp [nil]
#align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_eval
def id : Code :=
tail.comp zero'
#align turing.to_partrec.code.id Turing.ToPartrec.Code.id
@[simp]
theorem id_eval (v) : id.eval v = pure v := by simp [id]
#align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_eval
def head : Code :=
cons id nil
#align turing.to_partrec.code.head Turing.ToPartrec.Code.head
@[simp]
theorem head_eval (v) : head.eval v = pure [v.headI] := by simp [head]
#align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_eval
def zero : Code :=
cons zero' nil
#align turing.to_partrec.code.zero Turing.ToPartrec.Code.zero
@[simp]
theorem zero_eval (v) : zero.eval v = pure [0] := by simp [zero]
#align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_eval
def pred : Code :=
case zero head
#align turing.to_partrec.code.pred Turing.ToPartrec.Code.pred
@[simp]
theorem pred_eval (v) : pred.eval v = pure [v.headI.pred] := by
simp [pred]; cases v.headI <;> simp
#align turing.to_partrec.code.pred_eval Turing.ToPartrec.Code.pred_eval
def rfind (f : Code) : Code :=
comp pred <| comp (fix <| cons f <| cons succ tail) zero'
#align turing.to_partrec.code.rfind Turing.ToPartrec.Code.rfind
def prec (f g : Code) : Code :=
let G :=
cons tail <|
cons succ <|
cons (comp pred tail) <|
cons (comp g <| cons id <| comp tail tail) <| comp tail <| comp tail tail
let F := case id <| comp (comp (comp tail tail) (fix G)) zero'
cons (comp F (cons head <| cons (comp f tail) tail)) nil
#align turing.to_partrec.code.prec Turing.ToPartrec.Code.prec
attribute [-simp] Part.bind_eq_bind Part.map_eq_map Part.pure_eq_some
| Mathlib/Computability/TMToPartrec.lean | 264 | 282 | theorem exists_code.comp {m n} {f : Vector ℕ n →. ℕ} {g : Fin n → Vector ℕ m →. ℕ}
(hf : ∃ c : Code, ∀ v : Vector ℕ n, c.eval v.1 = pure <$> f v)
(hg : ∀ i, ∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> g i v) :
∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = pure <$> ((Vector.mOfFn fun i => g i v) >>= f) := by |
rsuffices ⟨cg, hg⟩ :
∃ c : Code, ∀ v : Vector ℕ m, c.eval v.1 = Subtype.val <$> Vector.mOfFn fun i => g i v
· obtain ⟨cf, hf⟩ := hf
exact
⟨cf.comp cg, fun v => by
simp [hg, hf, map_bind, seq_bind_eq, Function.comp]
rfl⟩
clear hf f; induction' n with n IH
· exact ⟨nil, fun v => by simp [Vector.mOfFn, Bind.bind]; rfl⟩
· obtain ⟨cg, hg₁⟩ := hg 0
obtain ⟨cl, hl⟩ := IH fun i => hg i.succ
exact
⟨cons cg cl, fun v => by
simp [Vector.mOfFn, hg₁, map_bind, seq_bind_eq, bind_assoc, (· ∘ ·), hl]
rfl⟩
| 0 |
import Mathlib.SetTheory.Ordinal.Arithmetic
namespace OrdinalApprox
universe u
variable {α : Type u}
variable [CompleteLattice α] (f : α →o α) (x : α)
open Function fixedPoints Cardinal Order OrderHom
set_option linter.unusedVariables false in
def lfpApprox (a : Ordinal.{u}) : α :=
sSup ({ f (lfpApprox b) | (b : Ordinal) (h : b < a) } ∪ {x})
termination_by a
decreasing_by exact h
theorem lfpApprox_monotone : Monotone (lfpApprox f x) := by
unfold Monotone; intros a b h; unfold lfpApprox
refine sSup_le_sSup ?h
apply sup_le_sup_right
simp only [exists_prop, Set.le_eq_subset, Set.setOf_subset_setOf, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intros a' h'
use a'
exact ⟨lt_of_lt_of_le h' h, rfl⟩
theorem le_lfpApprox {a : Ordinal} : x ≤ lfpApprox f x a := by
unfold lfpApprox
apply le_sSup
simp only [exists_prop, Set.union_singleton, Set.mem_insert_iff, Set.mem_setOf_eq, true_or]
| Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean | 92 | 112 | theorem lfpApprox_add_one (h : x ≤ f x) (a : Ordinal) :
lfpApprox f x (a+1) = f (lfpApprox f x a) := by |
apply le_antisymm
· conv => left; unfold lfpApprox
apply sSup_le
simp only [Ordinal.add_one_eq_succ, lt_succ_iff, exists_prop, Set.union_singleton,
Set.mem_insert_iff, Set.mem_setOf_eq, forall_eq_or_imp, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
apply And.intro
· apply le_trans h
apply Monotone.imp f.monotone
exact le_lfpApprox f x
· intros a' h
apply f.2; apply lfpApprox_monotone; exact h
· conv => right; unfold lfpApprox
apply le_sSup
simp only [Ordinal.add_one_eq_succ, lt_succ_iff, exists_prop]
rw [Set.mem_union]
apply Or.inl
simp only [Set.mem_setOf_eq]
use a
| 0 |
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.NormedSpace.Real
#align_import analysis.normed_space.pointwise from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156"
open Metric Set
open Pointwise Topology
variable {𝕜 E : Type*}
variable [NormedField 𝕜]
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
theorem smul_ball {c : 𝕜} (hc : c ≠ 0) (x : E) (r : ℝ) : c • ball x r = ball (c • x) (‖c‖ * r) := by
ext y
rw [mem_smul_set_iff_inv_smul_mem₀ hc]
conv_lhs => rw [← inv_smul_smul₀ hc x]
simp [← div_eq_inv_mul, div_lt_iff (norm_pos_iff.2 hc), mul_comm _ r, dist_smul₀]
#align smul_ball smul_ball
theorem smul_unitBall {c : 𝕜} (hc : c ≠ 0) : c • ball (0 : E) (1 : ℝ) = ball (0 : E) ‖c‖ := by
rw [_root_.smul_ball hc, smul_zero, mul_one]
#align smul_unit_ball smul_unitBall
| Mathlib/Analysis/NormedSpace/Pointwise.lean | 95 | 101 | theorem smul_sphere' {c : 𝕜} (hc : c ≠ 0) (x : E) (r : ℝ) :
c • sphere x r = sphere (c • x) (‖c‖ * r) := by |
ext y
rw [mem_smul_set_iff_inv_smul_mem₀ hc]
conv_lhs => rw [← inv_smul_smul₀ hc x]
simp only [mem_sphere, dist_smul₀, norm_inv, ← div_eq_inv_mul, div_eq_iff (norm_pos_iff.2 hc).ne',
mul_comm r]
| 0 |
import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic
suppress_compilation
open Bornology
open Filter hiding map_smul
open scoped Classical NNReal Topology Uniformity
-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*}
section SemiNormed
open Metric ContinuousLinearMap
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup Eₗ] [SeminormedAddCommGroup F]
[SeminormedAddCommGroup Fₗ] [SeminormedAddCommGroup G] [SeminormedAddCommGroup Gₗ]
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜 Eₗ] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜 Fₗ] [NormedSpace 𝕜₃ G]
[NormedSpace 𝕜 Gₗ] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃}
[RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]
variable [FunLike 𝓕 E F]
namespace ContinuousLinearMap
section OpNorm
open Set Real
section
variable [RingHomIsometric σ₁₂] [RingHomIsometric σ₂₃] (f g : E →SL[σ₁₂] F) (h : F →SL[σ₂₃] G)
(x : E)
| Mathlib/Analysis/NormedSpace/OperatorNorm/NNNorm.lean | 49 | 53 | theorem nnnorm_def (f : E →SL[σ₁₂] F) : ‖f‖₊ = sInf { c | ∀ x, ‖f x‖₊ ≤ c * ‖x‖₊ } := by |
ext
rw [NNReal.coe_sInf, coe_nnnorm, norm_def, NNReal.coe_image]
simp_rw [← NNReal.coe_le_coe, NNReal.coe_mul, coe_nnnorm, mem_setOf_eq, NNReal.coe_mk,
exists_prop]
| 0 |
import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.CategoryTheory.Limits.Preserves.Basic
import Mathlib.CategoryTheory.Limits.TypesFiltered
import Mathlib.CategoryTheory.Limits.Yoneda
import Mathlib.Tactic.ApplyFun
#align_import category_theory.limits.concrete_category from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395"
universe t w v u r
open CategoryTheory
namespace CategoryTheory.Limits
attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort
section Colimits
section
variable {C : Type u} [Category.{v} C] [ConcreteCategory.{t} C] {J : Type w} [Category.{r} J]
(F : J ⥤ C) [PreservesColimit F (forget C)]
theorem Concrete.from_union_surjective_of_isColimit {D : Cocone F} (hD : IsColimit D) :
let ff : (Σj : J, F.obj j) → D.pt := fun a => D.ι.app a.1 a.2
Function.Surjective ff := by
intro ff x
let E : Cocone (F ⋙ forget C) := (forget C).mapCocone D
let hE : IsColimit E := isColimitOfPreserves (forget C) hD
obtain ⟨j, y, hy⟩ := Types.jointly_surjective_of_isColimit hE x
exact ⟨⟨j, y⟩, hy⟩
#align category_theory.limits.concrete.from_union_surjective_of_is_colimit CategoryTheory.Limits.Concrete.from_union_surjective_of_isColimit
theorem Concrete.isColimit_exists_rep {D : Cocone F} (hD : IsColimit D) (x : D.pt) :
∃ (j : J) (y : F.obj j), D.ι.app j y = x := by
obtain ⟨a, rfl⟩ := Concrete.from_union_surjective_of_isColimit F hD x
exact ⟨a.1, a.2, rfl⟩
#align category_theory.limits.concrete.is_colimit_exists_rep CategoryTheory.Limits.Concrete.isColimit_exists_rep
theorem Concrete.colimit_exists_rep [HasColimit F] (x : ↑(colimit F)) :
∃ (j : J) (y : F.obj j), colimit.ι F j y = x :=
Concrete.isColimit_exists_rep F (colimit.isColimit _) x
#align category_theory.limits.concrete.colimit_exists_rep CategoryTheory.Limits.Concrete.colimit_exists_rep
theorem Concrete.isColimit_rep_eq_of_exists {D : Cocone F} {i j : J} (x : F.obj i) (y : F.obj j)
(h : ∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f x = F.map g y) :
D.ι.app i x = D.ι.app j y := by
let E := (forget C).mapCocone D
obtain ⟨k, f, g, (hfg : (F ⋙ forget C).map f x = F.map g y)⟩ := h
let h1 : (F ⋙ forget C).map f ≫ E.ι.app k = E.ι.app i := E.ι.naturality f
let h2 : (F ⋙ forget C).map g ≫ E.ι.app k = E.ι.app j := E.ι.naturality g
show E.ι.app i x = E.ι.app j y
rw [← h1, types_comp_apply, hfg]
exact congrFun h2 y
#align category_theory.limits.concrete.is_colimit_rep_eq_of_exists CategoryTheory.Limits.Concrete.isColimit_rep_eq_of_exists
theorem Concrete.colimit_rep_eq_of_exists [HasColimit F] {i j : J} (x : F.obj i) (y : F.obj j)
(h : ∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f x = F.map g y) :
colimit.ι F i x = colimit.ι F j y :=
Concrete.isColimit_rep_eq_of_exists F x y h
#align category_theory.limits.concrete.colimit_rep_eq_of_exists CategoryTheory.Limits.Concrete.colimit_rep_eq_of_exists
end
section FilteredColimits
variable {C : Type u} [Category.{v} C] [ConcreteCategory.{max t w} C] {J : Type w} [Category.{r} J]
(F : J ⥤ C) [PreservesColimit F (forget C)] [IsFiltered J]
| Mathlib/CategoryTheory/Limits/ConcreteCategory.lean | 122 | 127 | theorem Concrete.isColimit_exists_of_rep_eq {D : Cocone F} {i j : J} (hD : IsColimit D)
(x : F.obj i) (y : F.obj j) (h : D.ι.app _ x = D.ι.app _ y) :
∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f x = F.map g y := by |
let E := (forget C).mapCocone D
let hE : IsColimit E := isColimitOfPreserves _ hD
exact (Types.FilteredColimit.isColimit_eq_iff (F ⋙ forget C) hE).mp h
| 0 |
import Mathlib.Algebra.Ring.Int
import Mathlib.Data.Nat.Bitwise
import Mathlib.Data.Nat.Size
#align_import data.int.bitwise from "leanprover-community/mathlib"@"0743cc5d9d86bcd1bba10f480e948a257d65056f"
#align_import init.data.int.bitwise from "leanprover-community/lean"@"855e5b74e3a52a40552e8f067169d747d48743fd"
namespace Int
def div2 : ℤ → ℤ
| (n : ℕ) => n.div2
| -[n +1] => negSucc n.div2
#align int.div2 Int.div2
def bodd : ℤ → Bool
| (n : ℕ) => n.bodd
| -[n +1] => not (n.bodd)
#align int.bodd Int.bodd
-- Porting note: `bit0, bit1` deprecated, do we need to adapt `bit`?
set_option linter.deprecated false in
def bit (b : Bool) : ℤ → ℤ :=
cond b bit1 bit0
#align int.bit Int.bit
def testBit : ℤ → ℕ → Bool
| (m : ℕ), n => Nat.testBit m n
| -[m +1], n => !(Nat.testBit m n)
#align int.test_bit Int.testBit
def natBitwise (f : Bool → Bool → Bool) (m n : ℕ) : ℤ :=
cond (f false false) -[ Nat.bitwise (fun x y => not (f x y)) m n +1] (Nat.bitwise f m n)
#align int.nat_bitwise Int.natBitwise
def bitwise (f : Bool → Bool → Bool) : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => natBitwise f m n
| (m : ℕ), -[n +1] => natBitwise (fun x y => f x (not y)) m n
| -[m +1], (n : ℕ) => natBitwise (fun x y => f (not x) y) m n
| -[m +1], -[n +1] => natBitwise (fun x y => f (not x) (not y)) m n
#align int.bitwise Int.bitwise
def lnot : ℤ → ℤ
| (m : ℕ) => -[m +1]
| -[m +1] => m
#align int.lnot Int.lnot
def lor : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => m ||| n
| (m : ℕ), -[n +1] => -[Nat.ldiff n m +1]
| -[m +1], (n : ℕ) => -[Nat.ldiff m n +1]
| -[m +1], -[n +1] => -[m &&& n +1]
#align int.lor Int.lor
def land : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => m &&& n
| (m : ℕ), -[n +1] => Nat.ldiff m n
| -[m +1], (n : ℕ) => Nat.ldiff n m
| -[m +1], -[n +1] => -[m ||| n +1]
#align int.land Int.land
-- Porting note: I don't know why `Nat.ldiff` got the prime, but I'm matching this change here
def ldiff : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => Nat.ldiff m n
| (m : ℕ), -[n +1] => m &&& n
| -[m +1], (n : ℕ) => -[m ||| n +1]
| -[m +1], -[n +1] => Nat.ldiff n m
#align int.ldiff Int.ldiff
-- Porting note: I don't know why `Nat.xor'` got the prime, but I'm matching this change here
protected def xor : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => (m ^^^ n)
| (m : ℕ), -[n +1] => -[(m ^^^ n) +1]
| -[m +1], (n : ℕ) => -[(m ^^^ n) +1]
| -[m +1], -[n +1] => (m ^^^ n)
#align int.lxor Int.xor
instance : ShiftLeft ℤ where
shiftLeft
| (m : ℕ), (n : ℕ) => Nat.shiftLeft' false m n
| (m : ℕ), -[n +1] => m >>> (Nat.succ n)
| -[m +1], (n : ℕ) => -[Nat.shiftLeft' true m n +1]
| -[m +1], -[n +1] => -[m >>> (Nat.succ n) +1]
#align int.shiftl ShiftLeft.shiftLeft
instance : ShiftRight ℤ where
shiftRight m n := m <<< (-n)
#align int.shiftr ShiftRight.shiftRight
@[simp]
theorem bodd_zero : bodd 0 = false :=
rfl
#align int.bodd_zero Int.bodd_zero
@[simp]
theorem bodd_one : bodd 1 = true :=
rfl
#align int.bodd_one Int.bodd_one
theorem bodd_two : bodd 2 = false :=
rfl
#align int.bodd_two Int.bodd_two
@[simp, norm_cast]
theorem bodd_coe (n : ℕ) : Int.bodd n = Nat.bodd n :=
rfl
#align int.bodd_coe Int.bodd_coe
@[simp]
| Mathlib/Data/Int/Bitwise.lean | 145 | 149 | theorem bodd_subNatNat (m n : ℕ) : bodd (subNatNat m n) = xor m.bodd n.bodd := by |
apply subNatNat_elim m n fun m n i => bodd i = xor m.bodd n.bodd <;>
intros i j <;>
simp only [Int.bodd, Int.bodd_coe, Nat.bodd_add] <;>
cases Nat.bodd i <;> simp
| 0 |
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Data.Finset.Fin
import Mathlib.Data.Finset.Sort
import Mathlib.Data.Int.Order.Units
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Logic.Equiv.Fin
import Mathlib.Tactic.NormNum.Ineq
#align_import group_theory.perm.sign from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
universe u v
open Equiv Function Fintype Finset
variable {α : Type u} [DecidableEq α] {β : Type v}
namespace Equiv.Perm
def modSwap (i j : α) : Setoid (Perm α) :=
⟨fun σ τ => σ = τ ∨ σ = swap i j * τ, fun σ => Or.inl (refl σ), fun {σ τ} h =>
Or.casesOn h (fun h => Or.inl h.symm) fun h => Or.inr (by rw [h, swap_mul_self_mul]),
fun {σ τ υ} hστ hτυ => by
cases' hστ with hστ hστ <;> cases' hτυ with hτυ hτυ <;> try rw [hστ, hτυ, swap_mul_self_mul] <;>
simp [hστ, hτυ] -- Porting note: should close goals, but doesn't
· simp [hστ, hτυ]
· simp [hστ, hτυ]
· simp [hστ, hτυ]⟩
#align equiv.perm.mod_swap Equiv.Perm.modSwap
noncomputable instance {α : Type*} [Fintype α] [DecidableEq α] (i j : α) :
DecidableRel (modSwap i j).r :=
fun _ _ => Or.decidable
def swapFactorsAux :
∀ (l : List α) (f : Perm α),
(∀ {x}, f x ≠ x → x ∈ l) → { l : List (Perm α) // l.prod = f ∧ ∀ g ∈ l, IsSwap g }
| [] => fun f h =>
⟨[],
Equiv.ext fun x => by
rw [List.prod_nil]
exact (Classical.not_not.1 (mt h (List.not_mem_nil _))).symm,
by simp⟩
| x::l => fun f h =>
if hfx : x = f x then
swapFactorsAux l f fun {y} hy =>
List.mem_of_ne_of_mem (fun h : y = x => by simp [h, hfx.symm] at hy) (h hy)
else
let m :=
swapFactorsAux l (swap x (f x) * f) fun {y} hy =>
have : f y ≠ y ∧ y ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hy
List.mem_of_ne_of_mem this.2 (h this.1)
⟨swap x (f x)::m.1, by
rw [List.prod_cons, m.2.1, ← mul_assoc, mul_def (swap x (f x)), swap_swap, ← one_def,
one_mul],
fun {g} hg => ((List.mem_cons).1 hg).elim (fun h => ⟨x, f x, hfx, h⟩) (m.2.2 _)⟩
#align equiv.perm.swap_factors_aux Equiv.Perm.swapFactorsAux
def swapFactors [Fintype α] [LinearOrder α] (f : Perm α) :
{ l : List (Perm α) // l.prod = f ∧ ∀ g ∈ l, IsSwap g } :=
swapFactorsAux ((@univ α _).sort (· ≤ ·)) f fun {_ _} => (mem_sort _).2 (mem_univ _)
#align equiv.perm.swap_factors Equiv.Perm.swapFactors
def truncSwapFactors [Fintype α] (f : Perm α) :
Trunc { l : List (Perm α) // l.prod = f ∧ ∀ g ∈ l, IsSwap g } :=
Quotient.recOnSubsingleton (@univ α _).1 (fun l h => Trunc.mk (swapFactorsAux l f (h _)))
(show ∀ x, f x ≠ x → x ∈ (@univ α _).1 from fun _ _ => mem_univ _)
#align equiv.perm.trunc_swap_factors Equiv.Perm.truncSwapFactors
@[elab_as_elim]
| Mathlib/GroupTheory/Perm/Sign.lean | 99 | 110 | theorem swap_induction_on [Finite α] {P : Perm α → Prop} (f : Perm α) :
P 1 → (∀ f x y, x ≠ y → P f → P (swap x y * f)) → P f := by |
cases nonempty_fintype α
cases' (truncSwapFactors f).out with l hl
induction' l with g l ih generalizing f
· simp (config := { contextual := true }) only [hl.left.symm, List.prod_nil, forall_true_iff]
· intro h1 hmul_swap
rcases hl.2 g (by simp) with ⟨x, y, hxy⟩
rw [← hl.1, List.prod_cons, hxy.2]
exact
hmul_swap _ _ _ hxy.1
(ih _ ⟨rfl, fun v hv => hl.2 _ (List.mem_cons_of_mem _ hv)⟩ h1 hmul_swap)
| 0 |
import Mathlib.Data.Nat.Totient
import Mathlib.Data.Nat.Nth
import Mathlib.NumberTheory.SmoothNumbers
#align_import number_theory.prime_counting from "leanprover-community/mathlib"@"7fdd4f3746cb059edfdb5d52cba98f66fce418c0"
namespace Nat
open Finset
def primeCounting' : ℕ → ℕ :=
Nat.count Prime
#align nat.prime_counting' Nat.primeCounting'
def primeCounting (n : ℕ) : ℕ :=
primeCounting' (n + 1)
#align nat.prime_counting Nat.primeCounting
@[inherit_doc] scoped notation "π" => Nat.primeCounting
@[inherit_doc] scoped notation "π'" => Nat.primeCounting'
theorem monotone_primeCounting' : Monotone primeCounting' :=
count_monotone Prime
#align nat.monotone_prime_counting' Nat.monotone_primeCounting'
theorem monotone_primeCounting : Monotone primeCounting :=
monotone_primeCounting'.comp (monotone_id.add_const _)
#align nat.monotone_prime_counting Nat.monotone_primeCounting
@[simp]
theorem primeCounting'_nth_eq (n : ℕ) : π' (nth Prime n) = n :=
count_nth_of_infinite infinite_setOf_prime _
#align nat.prime_counting'_nth_eq Nat.primeCounting'_nth_eq
@[simp]
theorem prime_nth_prime (n : ℕ) : Prime (nth Prime n) :=
nth_mem_of_infinite infinite_setOf_prime _
#align nat.prime_nth_prime Nat.prime_nth_prime
lemma primesBelow_card_eq_primeCounting' (n : ℕ) : n.primesBelow.card = primeCounting' n := by
simp only [primesBelow, primeCounting']
exact (count_eq_card_filter_range Prime n).symm
| Mathlib/NumberTheory/PrimeCounting.lean | 83 | 102 | theorem primeCounting'_add_le {a k : ℕ} (h0 : 0 < a) (h1 : a < k) (n : ℕ) :
π' (k + n) ≤ π' k + Nat.totient a * (n / a + 1) :=
calc
π' (k + n) ≤ ((range k).filter Prime).card + ((Ico k (k + n)).filter Prime).card := by |
rw [primeCounting', count_eq_card_filter_range, range_eq_Ico, ←
Ico_union_Ico_eq_Ico (zero_le k) le_self_add, filter_union]
apply card_union_le
_ ≤ π' k + ((Ico k (k + n)).filter Prime).card := by
rw [primeCounting', count_eq_card_filter_range]
_ ≤ π' k + ((Ico k (k + n)).filter (Coprime a)).card := by
refine add_le_add_left (card_le_card ?_) k.primeCounting'
simp only [subset_iff, and_imp, mem_filter, mem_Ico]
intro p succ_k_le_p p_lt_n p_prime
constructor
· exact ⟨succ_k_le_p, p_lt_n⟩
· rw [coprime_comm]
exact coprime_of_lt_prime h0 (gt_of_ge_of_gt succ_k_le_p h1) p_prime
_ ≤ π' k + totient a * (n / a + 1) := by
rw [add_le_add_iff_left]
exact Ico_filter_coprime_le k n h0
| 0 |
import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Measure.Haar.NormedSpace
#align_import analysis.mellin_transform from "leanprover-community/mathlib"@"917c3c072e487b3cccdbfeff17e75b40e45f66cb"
open MeasureTheory Set Filter Asymptotics TopologicalSpace
open Real
open Complex hiding exp log abs_of_nonneg
open scoped Topology
noncomputable section
section Defs
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop :=
IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0)
#align mellin_convergent MellinConvergent
theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*}
[NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) :
MellinConvergent (fun t => c • f t) s := by
simpa only [MellinConvergent, smul_comm] using hf.smul c
#align mellin_convergent.const_smul MellinConvergent.const_smul
theorem MellinConvergent.cpow_smul {f : ℝ → E} {s a : ℂ} :
MellinConvergent (fun t => (t : ℂ) ^ a • f t) s ↔ MellinConvergent f (s + a) := by
refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi
simp_rw [← sub_add_eq_add_sub, cpow_add _ _ (ofReal_ne_zero.2 <| ne_of_gt ht), mul_smul]
#align mellin_convergent.cpow_smul MellinConvergent.cpow_smul
nonrec theorem MellinConvergent.div_const {f : ℝ → ℂ} {s : ℂ} (hf : MellinConvergent f s) (a : ℂ) :
MellinConvergent (fun t => f t / a) s := by
simpa only [MellinConvergent, smul_eq_mul, ← mul_div_assoc] using hf.div_const a
#align mellin_convergent.div_const MellinConvergent.div_const
| Mathlib/Analysis/MellinTransform.lean | 64 | 75 | theorem MellinConvergent.comp_mul_left {f : ℝ → E} {s : ℂ} {a : ℝ} (ha : 0 < a) :
MellinConvergent (fun t => f (a * t)) s ↔ MellinConvergent f s := by |
have := integrableOn_Ioi_comp_mul_left_iff (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) 0 ha
rw [mul_zero] at this
have h1 : EqOn (fun t : ℝ => (↑(a * t) : ℂ) ^ (s - 1) • f (a * t))
((a : ℂ) ^ (s - 1) • fun t : ℝ => (t : ℂ) ^ (s - 1) • f (a * t)) (Ioi 0) := fun t ht ↦ by
simp only [ofReal_mul, mul_cpow_ofReal_nonneg ha.le (le_of_lt ht), mul_smul, Pi.smul_apply]
have h2 : (a : ℂ) ^ (s - 1) ≠ 0 := by
rw [Ne, cpow_eq_zero_iff, not_and_or, ofReal_eq_zero]
exact Or.inl ha.ne'
rw [MellinConvergent, MellinConvergent, ← this, integrableOn_congr_fun h1 measurableSet_Ioi,
IntegrableOn, IntegrableOn, integrable_smul_iff h2]
| 0 |
import Mathlib.Analysis.Complex.Basic
import Mathlib.FieldTheory.IntermediateField
import Mathlib.Topology.Algebra.Field
import Mathlib.Topology.Algebra.UniformRing
#align_import topology.instances.complex from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
section ComplexSubfield
open Complex Set
open ComplexConjugate
theorem Complex.subfield_eq_of_closed {K : Subfield ℂ} (hc : IsClosed (K : Set ℂ)) :
K = ofReal.fieldRange ∨ K = ⊤ := by
suffices range (ofReal' : ℝ → ℂ) ⊆ K by
rw [range_subset_iff, ← coe_algebraMap] at this
have :=
(Subalgebra.isSimpleOrder_of_finrank finrank_real_complex).eq_bot_or_eq_top
(Subfield.toIntermediateField K this).toSubalgebra
simp_rw [← SetLike.coe_set_eq, IntermediateField.coe_toSubalgebra] at this ⊢
exact this
suffices range (ofReal' : ℝ → ℂ) ⊆ closure (Set.range ((ofReal' : ℝ → ℂ) ∘ ((↑) : ℚ → ℝ))) by
refine subset_trans this ?_
rw [← IsClosed.closure_eq hc]
apply closure_mono
rintro _ ⟨_, rfl⟩
simp only [Function.comp_apply, ofReal_ratCast, SetLike.mem_coe, SubfieldClass.ratCast_mem]
nth_rw 1 [range_comp]
refine subset_trans ?_ (image_closure_subset_closure_image continuous_ofReal)
rw [DenseRange.closure_range Rat.denseEmbedding_coe_real.dense]
simp only [image_univ]
rfl
#align complex.subfield_eq_of_closed Complex.subfield_eq_of_closed
| Mathlib/Topology/Instances/Complex.lean | 50 | 116 | theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : K →+* ℂ}
(hc : UniformContinuous ψ) : ψ.toFun = K.subtype ∨ ψ.toFun = conj ∘ K.subtype := by |
letI : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
letI : TopologicalRing K.topologicalClosure :=
Subring.instTopologicalRing K.topologicalClosure.toSubring
set ι : K → K.topologicalClosure := ⇑(Subfield.inclusion K.le_topologicalClosure)
have ui : UniformInducing ι :=
⟨by
erw [uniformity_subtype, uniformity_subtype, Filter.comap_comap]
congr ⟩
let di := ui.denseInducing (?_ : DenseRange ι)
· -- extψ : closure(K) →+* ℂ is the extension of ψ : K →+* ℂ
let extψ := DenseInducing.extendRingHom ui di.dense hc
haveI hψ := (uniformContinuous_uniformly_extend ui di.dense hc).continuous
cases' Complex.subfield_eq_of_closed (Subfield.isClosed_topologicalClosure K) with h h
· left
let j := RingEquiv.subfieldCongr h
-- ψ₁ is the continuous ring hom `ℝ →+* ℂ` constructed from `j : closure (K) ≃+* ℝ`
-- and `extψ : closure (K) →+* ℂ`
let ψ₁ := RingHom.comp extψ (RingHom.comp j.symm.toRingHom ofReal.rangeRestrict)
-- Porting note: was `by continuity!` and was used inline
have hψ₁ : Continuous ψ₁ := by
simpa only [RingHom.coe_comp] using hψ.comp ((continuous_algebraMap ℝ ℂ).subtype_mk _)
ext1 x
rsuffices ⟨r, hr⟩ : ∃ r : ℝ, ofReal.rangeRestrict r = j (ι x)
· have :=
RingHom.congr_fun (ringHom_eq_ofReal_of_continuous hψ₁) r
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [RingHom.comp_apply, RingHom.comp_apply, hr, RingEquiv.toRingHom_eq_coe] at this
convert this using 1
· exact (DenseInducing.extend_eq di hc.continuous _).symm
· rw [← ofReal.coe_rangeRestrict, hr]
rfl
obtain ⟨r, hr⟩ := SetLike.coe_mem (j (ι x))
exact ⟨r, Subtype.ext hr⟩
· -- ψ₁ is the continuous ring hom `ℂ →+* ℂ` constructed from `closure (K) ≃+* ℂ`
-- and `extψ : closure (K) →+* ℂ`
let ψ₁ :=
RingHom.comp extψ
(RingHom.comp (RingEquiv.subfieldCongr h).symm.toRingHom
(@Subfield.topEquiv ℂ _).symm.toRingHom)
-- Porting note: was `by continuity!` and was used inline
have hψ₁ : Continuous ψ₁ := by
simpa only [RingHom.coe_comp] using hψ.comp (continuous_id.subtype_mk _)
cases' ringHom_eq_id_or_conj_of_continuous hψ₁ with h h
· left
ext1 z
convert RingHom.congr_fun h z using 1
exact (DenseInducing.extend_eq di hc.continuous z).symm
· right
ext1 z
convert RingHom.congr_fun h z using 1
exact (DenseInducing.extend_eq di hc.continuous z).symm
· let j : { x // x ∈ closure (id '' { x | (K : Set ℂ) x }) } → (K.topologicalClosure : Set ℂ) :=
fun x =>
⟨x, by
convert x.prop
simp only [id, Set.image_id']
rfl ⟩
convert DenseRange.comp (Function.Surjective.denseRange _)
(DenseEmbedding.subtype denseEmbedding_id (K : Set ℂ)).dense (by continuity : Continuous j)
rintro ⟨y, hy⟩
use
⟨y, by
convert hy
simp only [id, Set.image_id']
rfl ⟩
| 0 |
import Mathlib.Data.Finset.Fin
import Mathlib.Data.Int.Order.Units
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Logic.Equiv.Fintype
#align_import group_theory.perm.sign from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
universe u v
open Equiv Function Fintype Finset
variable {α : Type u} {β : Type v}
-- An example on how to determine the order of an element of a finite group.
example : orderOf (-1 : ℤˣ) = 2 :=
orderOf_eq_prime (Int.units_sq _) (by decide)
namespace Equiv.Perm
theorem perm_inv_on_of_perm_on_finset {s : Finset α} {f : Perm α} (h : ∀ x ∈ s, f x ∈ s) {y : α}
(hy : y ∈ s) : f⁻¹ y ∈ s := by
have h0 : ∀ y ∈ s, ∃ (x : _) (hx : x ∈ s), y = (fun i (_ : i ∈ s) => f i) x hx :=
Finset.surj_on_of_inj_on_of_card_le (fun x hx => (fun i _ => f i) x hx) (fun a ha => h a ha)
(fun a₁ a₂ ha₁ ha₂ heq => (Equiv.apply_eq_iff_eq f).mp heq) rfl.ge
obtain ⟨y2, hy2, heq⟩ := h0 y hy
convert hy2
rw [heq]
simp only [inv_apply_self]
#align equiv.perm.perm_inv_on_of_perm_on_finset Equiv.Perm.perm_inv_on_of_perm_on_finset
theorem perm_inv_mapsTo_of_mapsTo (f : Perm α) {s : Set α} [Finite s] (h : Set.MapsTo f s s) :
Set.MapsTo (f⁻¹ : _) s s := by
cases nonempty_fintype s
exact fun x hx =>
Set.mem_toFinset.mp <|
perm_inv_on_of_perm_on_finset
(fun a ha => Set.mem_toFinset.mpr (h (Set.mem_toFinset.mp ha)))
(Set.mem_toFinset.mpr hx)
#align equiv.perm.perm_inv_maps_to_of_maps_to Equiv.Perm.perm_inv_mapsTo_of_mapsTo
@[simp]
theorem perm_inv_mapsTo_iff_mapsTo {f : Perm α} {s : Set α} [Finite s] :
Set.MapsTo (f⁻¹ : _) s s ↔ Set.MapsTo f s s :=
⟨perm_inv_mapsTo_of_mapsTo f⁻¹, perm_inv_mapsTo_of_mapsTo f⟩
#align equiv.perm.perm_inv_maps_to_iff_maps_to Equiv.Perm.perm_inv_mapsTo_iff_mapsTo
theorem perm_inv_on_of_perm_on_finite {f : Perm α} {p : α → Prop} [Finite { x // p x }]
(h : ∀ x, p x → p (f x)) {x : α} (hx : p x) : p (f⁻¹ x) :=
-- Porting note: relies heavily on the definitions of `Subtype` and `setOf` unfolding to their
-- underlying predicate.
have : Finite { x | p x } := ‹_›
perm_inv_mapsTo_of_mapsTo (s := {x | p x}) f h hx
#align equiv.perm.perm_inv_on_of_perm_on_finite Equiv.Perm.perm_inv_on_of_perm_on_finite
abbrev subtypePermOfFintype (f : Perm α) {p : α → Prop} [Finite { x // p x }]
(h : ∀ x, p x → p (f x)) : Perm { x // p x } :=
f.subtypePerm fun x => ⟨h x, fun h₂ => f.inv_apply_self x ▸ perm_inv_on_of_perm_on_finite h h₂⟩
#align equiv.perm.subtype_perm_of_fintype Equiv.Perm.subtypePermOfFintype
@[simp]
theorem subtypePermOfFintype_apply (f : Perm α) {p : α → Prop} [Finite { x // p x }]
(h : ∀ x, p x → p (f x)) (x : { x // p x }) : subtypePermOfFintype f h x = ⟨f x, h x x.2⟩ :=
rfl
#align equiv.perm.subtype_perm_of_fintype_apply Equiv.Perm.subtypePermOfFintype_apply
theorem subtypePermOfFintype_one (p : α → Prop) [Finite { x // p x }]
(h : ∀ x, p x → p ((1 : Perm α) x)) : @subtypePermOfFintype α 1 p _ h = 1 :=
rfl
#align equiv.perm.subtype_perm_of_fintype_one Equiv.Perm.subtypePermOfFintype_one
| Mathlib/GroupTheory/Perm/Finite.lean | 111 | 129 | theorem perm_mapsTo_inl_iff_mapsTo_inr {m n : Type*} [Finite m] [Finite n] (σ : Perm (Sum m n)) :
Set.MapsTo σ (Set.range Sum.inl) (Set.range Sum.inl) ↔
Set.MapsTo σ (Set.range Sum.inr) (Set.range Sum.inr) := by |
constructor <;>
( intro h
classical
rw [← perm_inv_mapsTo_iff_mapsTo] at h
intro x
cases' hx : σ x with l r)
· rintro ⟨a, rfl⟩
obtain ⟨y, hy⟩ := h ⟨l, rfl⟩
rw [← hx, σ.inv_apply_self] at hy
exact absurd hy Sum.inl_ne_inr
· rintro _; exact ⟨r, rfl⟩
· rintro _; exact ⟨l, rfl⟩
· rintro ⟨a, rfl⟩
obtain ⟨y, hy⟩ := h ⟨r, rfl⟩
rw [← hx, σ.inv_apply_self] at hy
exact absurd hy Sum.inr_ne_inl
| 0 |
import Mathlib.Analysis.InnerProductSpace.Projection
import Mathlib.Geometry.Euclidean.PerpBisector
import Mathlib.Algebra.QuadraticDiscriminant
#align_import geometry.euclidean.basic from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
noncomputable section
open scoped Classical
open RealInnerProductSpace
namespace EuclideanGeometry
variable {V : Type*} {P : Type*}
variable [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
variable [NormedAddTorsor V P]
theorem dist_left_midpoint_eq_dist_right_midpoint (p1 p2 : P) :
dist p1 (midpoint ℝ p1 p2) = dist p2 (midpoint ℝ p1 p2) := by
rw [dist_left_midpoint (𝕜 := ℝ) p1 p2, dist_right_midpoint (𝕜 := ℝ) p1 p2]
#align euclidean_geometry.dist_left_midpoint_eq_dist_right_midpoint EuclideanGeometry.dist_left_midpoint_eq_dist_right_midpoint
theorem inner_weightedVSub {ι₁ : Type*} {s₁ : Finset ι₁} {w₁ : ι₁ → ℝ} (p₁ : ι₁ → P)
(h₁ : ∑ i ∈ s₁, w₁ i = 0) {ι₂ : Type*} {s₂ : Finset ι₂} {w₂ : ι₂ → ℝ} (p₂ : ι₂ → P)
(h₂ : ∑ i ∈ s₂, w₂ i = 0) :
⟪s₁.weightedVSub p₁ w₁, s₂.weightedVSub p₂ w₂⟫ =
(-∑ i₁ ∈ s₁, ∑ i₂ ∈ s₂, w₁ i₁ * w₂ i₂ * (dist (p₁ i₁) (p₂ i₂) * dist (p₁ i₁) (p₂ i₂))) /
2 := by
rw [Finset.weightedVSub_apply, Finset.weightedVSub_apply,
inner_sum_smul_sum_smul_of_sum_eq_zero _ h₁ _ h₂]
simp_rw [vsub_sub_vsub_cancel_right]
rcongr (i₁ i₂) <;> rw [dist_eq_norm_vsub V (p₁ i₁) (p₂ i₂)]
#align euclidean_geometry.inner_weighted_vsub EuclideanGeometry.inner_weightedVSub
theorem dist_affineCombination {ι : Type*} {s : Finset ι} {w₁ w₂ : ι → ℝ} (p : ι → P)
(h₁ : ∑ i ∈ s, w₁ i = 1) (h₂ : ∑ i ∈ s, w₂ i = 1) : by
have a₁ := s.affineCombination ℝ p w₁
have a₂ := s.affineCombination ℝ p w₂
exact dist a₁ a₂ * dist a₁ a₂ = (-∑ i₁ ∈ s, ∑ i₂ ∈ s,
(w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2 := by
dsimp only
rw [dist_eq_norm_vsub V (s.affineCombination ℝ p w₁) (s.affineCombination ℝ p w₂), ←
@inner_self_eq_norm_mul_norm ℝ, Finset.affineCombination_vsub]
have h : (∑ i ∈ s, (w₁ - w₂) i) = 0 := by
simp_rw [Pi.sub_apply, Finset.sum_sub_distrib, h₁, h₂, sub_self]
exact inner_weightedVSub p h p h
#align euclidean_geometry.dist_affine_combination EuclideanGeometry.dist_affineCombination
-- Porting note: `inner_vsub_vsub_of_dist_eq_of_dist_eq` moved to `PerpendicularBisector`
theorem dist_smul_vadd_sq (r : ℝ) (v : V) (p₁ p₂ : P) :
dist (r • v +ᵥ p₁) p₂ * dist (r • v +ᵥ p₁) p₂ =
⟪v, v⟫ * r * r + 2 * ⟪v, p₁ -ᵥ p₂⟫ * r + ⟪p₁ -ᵥ p₂, p₁ -ᵥ p₂⟫ := by
rw [dist_eq_norm_vsub V _ p₂, ← real_inner_self_eq_norm_mul_norm, vadd_vsub_assoc,
real_inner_add_add_self, real_inner_smul_left, real_inner_smul_left, real_inner_smul_right]
ring
#align euclidean_geometry.dist_smul_vadd_sq EuclideanGeometry.dist_smul_vadd_sq
| Mathlib/Geometry/Euclidean/Basic.lean | 122 | 134 | theorem dist_smul_vadd_eq_dist {v : V} (p₁ p₂ : P) (hv : v ≠ 0) (r : ℝ) :
dist (r • v +ᵥ p₁) p₂ = dist p₁ p₂ ↔ r = 0 ∨ r = -2 * ⟪v, p₁ -ᵥ p₂⟫ / ⟪v, v⟫ := by |
conv_lhs =>
rw [← mul_self_inj_of_nonneg dist_nonneg dist_nonneg, dist_smul_vadd_sq, ← sub_eq_zero,
add_sub_assoc, dist_eq_norm_vsub V p₁ p₂, ← real_inner_self_eq_norm_mul_norm, sub_self]
have hvi : ⟪v, v⟫ ≠ 0 := by simpa using hv
have hd : discrim ⟪v, v⟫ (2 * ⟪v, p₁ -ᵥ p₂⟫) 0 = 2 * ⟪v, p₁ -ᵥ p₂⟫ * (2 * ⟪v, p₁ -ᵥ p₂⟫) := by
rw [discrim]
ring
rw [quadratic_eq_zero_iff hvi hd, add_left_neg, zero_div, neg_mul_eq_neg_mul, ←
mul_sub_right_distrib, sub_eq_add_neg, ← mul_two, mul_assoc, mul_div_assoc, mul_div_mul_left,
mul_div_assoc]
norm_num
| 0 |
import Mathlib.Algebra.Order.Floor
import Mathlib.Algebra.Order.Field.Power
import Mathlib.Data.Nat.Log
#align_import data.int.log from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58"
variable {R : Type*} [LinearOrderedSemifield R] [FloorSemiring R]
namespace Int
def log (b : ℕ) (r : R) : ℤ :=
if 1 ≤ r then Nat.log b ⌊r⌋₊ else -Nat.clog b ⌈r⁻¹⌉₊
#align int.log Int.log
theorem log_of_one_le_right (b : ℕ) {r : R} (hr : 1 ≤ r) : log b r = Nat.log b ⌊r⌋₊ :=
if_pos hr
#align int.log_of_one_le_right Int.log_of_one_le_right
theorem log_of_right_le_one (b : ℕ) {r : R} (hr : r ≤ 1) : log b r = -Nat.clog b ⌈r⁻¹⌉₊ := by
obtain rfl | hr := hr.eq_or_lt
· rw [log, if_pos hr, inv_one, Nat.ceil_one, Nat.floor_one, Nat.log_one_right, Nat.clog_one_right,
Int.ofNat_zero, neg_zero]
· exact if_neg hr.not_le
#align int.log_of_right_le_one Int.log_of_right_le_one
@[simp, norm_cast]
theorem log_natCast (b : ℕ) (n : ℕ) : log b (n : R) = Nat.log b n := by
cases n
· simp [log_of_right_le_one]
· rw [log_of_one_le_right, Nat.floor_natCast]
simp
#align int.log_nat_cast Int.log_natCast
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem log_ofNat (b : ℕ) (n : ℕ) [n.AtLeastTwo] :
log b (no_index (OfNat.ofNat n : R)) = Nat.log b (OfNat.ofNat n) :=
log_natCast b n
theorem log_of_left_le_one {b : ℕ} (hb : b ≤ 1) (r : R) : log b r = 0 := by
rcases le_total 1 r with h | h
· rw [log_of_one_le_right _ h, Nat.log_of_left_le_one hb, Int.ofNat_zero]
· rw [log_of_right_le_one _ h, Nat.clog_of_left_le_one hb, Int.ofNat_zero, neg_zero]
#align int.log_of_left_le_one Int.log_of_left_le_one
theorem log_of_right_le_zero (b : ℕ) {r : R} (hr : r ≤ 0) : log b r = 0 := by
rw [log_of_right_le_one _ (hr.trans zero_le_one),
Nat.clog_of_right_le_one ((Nat.ceil_eq_zero.mpr <| inv_nonpos.2 hr).trans_le zero_le_one),
Int.ofNat_zero, neg_zero]
#align int.log_of_right_le_zero Int.log_of_right_le_zero
theorem zpow_log_le_self {b : ℕ} {r : R} (hb : 1 < b) (hr : 0 < r) : (b : R) ^ log b r ≤ r := by
rcases le_total 1 r with hr1 | hr1
· rw [log_of_one_le_right _ hr1]
rw [zpow_natCast, ← Nat.cast_pow, ← Nat.le_floor_iff hr.le]
exact Nat.pow_log_le_self b (Nat.floor_pos.mpr hr1).ne'
· rw [log_of_right_le_one _ hr1, zpow_neg, zpow_natCast, ← Nat.cast_pow]
exact inv_le_of_inv_le hr (Nat.ceil_le.1 <| Nat.le_pow_clog hb _)
#align int.zpow_log_le_self Int.zpow_log_le_self
theorem lt_zpow_succ_log_self {b : ℕ} (hb : 1 < b) (r : R) : r < (b : R) ^ (log b r + 1) := by
rcases le_or_lt r 0 with hr | hr
· rw [log_of_right_le_zero _ hr, zero_add, zpow_one]
exact hr.trans_lt (zero_lt_one.trans_le <| mod_cast hb.le)
rcases le_or_lt 1 r with hr1 | hr1
· rw [log_of_one_le_right _ hr1]
rw [Int.ofNat_add_one_out, zpow_natCast, ← Nat.cast_pow]
apply Nat.lt_of_floor_lt
exact Nat.lt_pow_succ_log_self hb _
· rw [log_of_right_le_one _ hr1.le]
have hcri : 1 < r⁻¹ := one_lt_inv hr hr1
have : 1 ≤ Nat.clog b ⌈r⁻¹⌉₊ :=
Nat.succ_le_of_lt (Nat.clog_pos hb <| Nat.one_lt_cast.1 <| hcri.trans_le (Nat.le_ceil _))
rw [neg_add_eq_sub, ← neg_sub, ← Int.ofNat_one, ← Int.ofNat_sub this, zpow_neg, zpow_natCast,
lt_inv hr (pow_pos (Nat.cast_pos.mpr <| zero_lt_one.trans hb) _), ← Nat.cast_pow]
refine Nat.lt_ceil.1 ?_
exact Nat.pow_pred_clog_lt_self hb <| Nat.one_lt_cast.1 <| hcri.trans_le <| Nat.le_ceil _
#align int.lt_zpow_succ_log_self Int.lt_zpow_succ_log_self
@[simp]
theorem log_zero_right (b : ℕ) : log b (0 : R) = 0 :=
log_of_right_le_zero b le_rfl
#align int.log_zero_right Int.log_zero_right
@[simp]
theorem log_one_right (b : ℕ) : log b (1 : R) = 0 := by
rw [log_of_one_le_right _ le_rfl, Nat.floor_one, Nat.log_one_right, Int.ofNat_zero]
#align int.log_one_right Int.log_one_right
-- Porting note: needed to replace b ^ z with (b : R) ^ z in the below
| Mathlib/Data/Int/Log.lean | 138 | 145 | theorem log_zpow {b : ℕ} (hb : 1 < b) (z : ℤ) : log b ((b : R) ^ z : R) = z := by |
obtain ⟨n, rfl | rfl⟩ := Int.eq_nat_or_neg z
· rw [log_of_one_le_right _ (one_le_zpow_of_nonneg _ <| Int.natCast_nonneg _), zpow_natCast, ←
Nat.cast_pow, Nat.floor_natCast, Nat.log_pow hb]
exact mod_cast hb.le
· rw [log_of_right_le_one _ (zpow_le_one_of_nonpos _ <| neg_nonpos.mpr (Int.natCast_nonneg _)),
zpow_neg, inv_inv, zpow_natCast, ← Nat.cast_pow, Nat.ceil_natCast, Nat.clog_pow _ _ hb]
exact mod_cast hb.le
| 0 |
import Mathlib.NumberTheory.NumberField.Basic
import Mathlib.RingTheory.FractionalIdeal.Norm
import Mathlib.RingTheory.FractionalIdeal.Operations
variable (K : Type*) [Field K] [NumberField K]
namespace NumberField
open scoped nonZeroDivisors
section Basis
open Module
-- This is necessary to avoid several timeouts
attribute [local instance 2000] Submodule.module
instance (I : FractionalIdeal (𝓞 K)⁰ K) : Module.Free ℤ I := by
refine Free.of_equiv (LinearEquiv.restrictScalars ℤ (I.equivNum ?_)).symm
exact nonZeroDivisors.coe_ne_zero I.den
instance (I : FractionalIdeal (𝓞 K)⁰ K) : Module.Finite ℤ I := by
refine Module.Finite.of_surjective
(LinearEquiv.restrictScalars ℤ (I.equivNum ?_)).symm.toLinearMap (LinearEquiv.surjective _)
exact nonZeroDivisors.coe_ne_zero I.den
instance (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) :
IsLocalizedModule ℤ⁰ ((Submodule.subtype (I : Submodule (𝓞 K) K)).restrictScalars ℤ) where
map_units x := by
rw [← (Algebra.lmul _ _).commutes, Algebra.lmul_isUnit_iff, isUnit_iff_ne_zero, eq_intCast,
Int.cast_ne_zero]
exact nonZeroDivisors.coe_ne_zero x
surj' x := by
obtain ⟨⟨a, _, d, hd, rfl⟩, h⟩ := IsLocalization.surj (Algebra.algebraMapSubmonoid (𝓞 K) ℤ⁰) x
refine ⟨⟨⟨Ideal.absNorm I.1.num * (algebraMap _ K a), I.1.num_le ?_⟩, d * Ideal.absNorm I.1.num,
?_⟩ , ?_⟩
· simp_rw [FractionalIdeal.val_eq_coe, FractionalIdeal.coe_coeIdeal]
refine (IsLocalization.mem_coeSubmodule _ _).mpr ⟨Ideal.absNorm I.1.num * a, ?_, ?_⟩
· exact Ideal.mul_mem_right _ _ I.1.num.absNorm_mem
· rw [map_mul, map_natCast]
· refine Submonoid.mul_mem _ hd (mem_nonZeroDivisors_of_ne_zero ?_)
rw [Nat.cast_ne_zero, ne_eq, Ideal.absNorm_eq_zero_iff]
exact FractionalIdeal.num_eq_zero_iff.not.mpr <| Units.ne_zero I
· simp_rw [LinearMap.coe_restrictScalars, Submodule.coeSubtype] at h ⊢
rw [← h]
simp only [Submonoid.mk_smul, zsmul_eq_mul, Int.cast_mul, Int.cast_natCast, algebraMap_int_eq,
eq_intCast, map_intCast]
ring
exists_of_eq h :=
⟨1, by rwa [one_smul, one_smul, ← (Submodule.injective_subtype I.1.coeToSubmodule).eq_iff]⟩
noncomputable def fractionalIdealBasis (I : FractionalIdeal (𝓞 K)⁰ K) :
Basis (Free.ChooseBasisIndex ℤ I) ℤ I := Free.chooseBasis ℤ I
noncomputable def basisOfFractionalIdeal (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) :
Basis (Free.ChooseBasisIndex ℤ I) ℚ K :=
(fractionalIdealBasis K I.1).ofIsLocalizedModule ℚ ℤ⁰
((Submodule.subtype (I : Submodule (𝓞 K) K)).restrictScalars ℤ)
theorem basisOfFractionalIdeal_apply (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ)
(i : Free.ChooseBasisIndex ℤ I) :
basisOfFractionalIdeal K I i = fractionalIdealBasis K I.1 i :=
(fractionalIdealBasis K I.1).ofIsLocalizedModule_apply ℚ ℤ⁰ _ i
| Mathlib/NumberTheory/NumberField/FractionalIdeal.lean | 87 | 90 | theorem mem_span_basisOfFractionalIdeal {I : (FractionalIdeal (𝓞 K)⁰ K)ˣ} {x : K} :
x ∈ Submodule.span ℤ (Set.range (basisOfFractionalIdeal K I)) ↔ x ∈ (I : Set K) := by |
rw [basisOfFractionalIdeal, (fractionalIdealBasis K I.1).ofIsLocalizedModule_span ℚ ℤ⁰ _]
simp
| 0 |
import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Measure.Haar.NormedSpace
#align_import analysis.mellin_transform from "leanprover-community/mathlib"@"917c3c072e487b3cccdbfeff17e75b40e45f66cb"
open MeasureTheory Set Filter Asymptotics TopologicalSpace
open Real
open Complex hiding exp log abs_of_nonneg
open scoped Topology
noncomputable section
variable {E : Type*} [NormedAddCommGroup E]
section MellinConvergent
theorem mellin_convergent_iff_norm [NormedSpace ℂ E] {f : ℝ → E} {T : Set ℝ} (hT : T ⊆ Ioi 0)
(hT' : MeasurableSet T) (hfc : AEStronglyMeasurable f <| volume.restrict <| Ioi 0) {s : ℂ} :
IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) T ↔
IntegrableOn (fun t : ℝ => t ^ (s.re - 1) * ‖f t‖) T := by
have : AEStronglyMeasurable (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (volume.restrict T) := by
refine ((ContinuousAt.continuousOn ?_).aestronglyMeasurable hT').smul (hfc.mono_set hT)
exact fun t ht => continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_gt (hT ht))
rw [IntegrableOn, ← integrable_norm_iff this, ← IntegrableOn]
refine integrableOn_congr_fun (fun t ht => ?_) hT'
simp_rw [norm_smul, Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos (hT ht), sub_re, one_re]
#align mellin_convergent_iff_norm mellin_convergent_iff_norm
theorem mellin_convergent_top_of_isBigO {f : ℝ → ℝ}
(hfc : AEStronglyMeasurable f <| volume.restrict (Ioi 0)) {a s : ℝ}
(hf : f =O[atTop] (· ^ (-a))) (hs : s < a) :
∃ c : ℝ, 0 < c ∧ IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioi c) := by
obtain ⟨d, hd'⟩ := hf.isBigOWith
simp_rw [IsBigOWith, eventually_atTop] at hd'
obtain ⟨e, he⟩ := hd'
have he' : 0 < max e 1 := zero_lt_one.trans_le (le_max_right _ _)
refine ⟨max e 1, he', ?_, ?_⟩
· refine AEStronglyMeasurable.mul ?_ (hfc.mono_set (Ioi_subset_Ioi he'.le))
refine (ContinuousAt.continuousOn fun t ht => ?_).aestronglyMeasurable measurableSet_Ioi
exact continuousAt_rpow_const _ _ (Or.inl <| (he'.trans ht).ne')
· have : ∀ᵐ t : ℝ ∂volume.restrict (Ioi <| max e 1),
‖t ^ (s - 1) * f t‖ ≤ t ^ (s - 1 + -a) * d := by
refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht => ?_
have ht' : 0 < t := he'.trans ht
rw [norm_mul, rpow_add ht', ← norm_of_nonneg (rpow_nonneg ht'.le (-a)), mul_assoc,
mul_comm _ d, norm_of_nonneg (rpow_nonneg ht'.le _)]
gcongr
exact he t ((le_max_left e 1).trans_lt ht).le
refine (HasFiniteIntegral.mul_const ?_ _).mono' this
exact (integrableOn_Ioi_rpow_of_lt (by linarith) he').hasFiniteIntegral
set_option linter.uppercaseLean3 false in
#align mellin_convergent_top_of_is_O mellin_convergent_top_of_isBigO
| Mathlib/Analysis/MellinTransform.lean | 237 | 264 | theorem mellin_convergent_zero_of_isBigO {b : ℝ} {f : ℝ → ℝ}
(hfc : AEStronglyMeasurable f <| volume.restrict (Ioi 0))
(hf : f =O[𝓝[>] 0] (· ^ (-b))) {s : ℝ} (hs : b < s) :
∃ c : ℝ, 0 < c ∧ IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioc 0 c) := by |
obtain ⟨d, _, hd'⟩ := hf.exists_pos
simp_rw [IsBigOWith, eventually_nhdsWithin_iff, Metric.eventually_nhds_iff, gt_iff_lt] at hd'
obtain ⟨ε, hε, hε'⟩ := hd'
refine ⟨ε, hε, integrableOn_Ioc_iff_integrableOn_Ioo.mpr ⟨?_, ?_⟩⟩
· refine AEStronglyMeasurable.mul ?_ (hfc.mono_set Ioo_subset_Ioi_self)
refine (ContinuousAt.continuousOn fun t ht => ?_).aestronglyMeasurable measurableSet_Ioo
exact continuousAt_rpow_const _ _ (Or.inl ht.1.ne')
· apply HasFiniteIntegral.mono'
· show HasFiniteIntegral (fun t => d * t ^ (s - b - 1)) _
refine (Integrable.hasFiniteIntegral ?_).const_mul _
rw [← IntegrableOn, ← integrableOn_Ioc_iff_integrableOn_Ioo, ←
intervalIntegrable_iff_integrableOn_Ioc_of_le hε.le]
exact intervalIntegral.intervalIntegrable_rpow' (by linarith)
· refine (ae_restrict_iff' measurableSet_Ioo).mpr (eventually_of_forall fun t ht => ?_)
rw [mul_comm, norm_mul]
specialize hε' _ ht.1
· rw [dist_eq_norm, sub_zero, norm_of_nonneg (le_of_lt ht.1)]
exact ht.2
· calc _ ≤ d * ‖t ^ (-b)‖ * ‖t ^ (s - 1)‖ := by gcongr
_ = d * t ^ (s - b - 1) := ?_
simp_rw [norm_of_nonneg (rpow_nonneg (le_of_lt ht.1) _), mul_assoc]
rw [← rpow_add ht.1]
congr 2
abel
| 0 |
import Mathlib.CategoryTheory.Sites.Grothendieck
import Mathlib.CategoryTheory.Sites.Pretopology
import Mathlib.CategoryTheory.Limits.Lattice
import Mathlib.Topology.Sets.Opens
#align_import category_theory.sites.spaces from "leanprover-community/mathlib"@"b6fa3beb29f035598cf0434d919694c5e98091eb"
universe u
namespace Opens
variable (T : Type u) [TopologicalSpace T]
open CategoryTheory TopologicalSpace CategoryTheory.Limits
def grothendieckTopology : GrothendieckTopology (Opens T) where
sieves X S := ∀ x ∈ X, ∃ (U : _) (f : U ⟶ X), S f ∧ x ∈ U
top_mem' X x hx := ⟨_, 𝟙 _, trivial, hx⟩
pullback_stable' X Y S f hf y hy := by
rcases hf y (f.le hy) with ⟨U, g, hg, hU⟩
refine ⟨U ⊓ Y, homOfLE inf_le_right, ?_, hU, hy⟩
apply S.downward_closed hg (homOfLE inf_le_left)
transitive' X S hS R hR x hx := by
rcases hS x hx with ⟨U, f, hf, hU⟩
rcases hR hf _ hU with ⟨V, g, hg, hV⟩
exact ⟨_, g ≫ f, hg, hV⟩
#align opens.grothendieck_topology Opens.grothendieckTopology
def pretopology : Pretopology (Opens T) where
coverings X R := ∀ x ∈ X, ∃ (U : _) (f : U ⟶ X), R f ∧ x ∈ U
has_isos X Y f i x hx := ⟨_, _, Presieve.singleton_self _, (inv f).le hx⟩
pullbacks X Y f S hS x hx := by
rcases hS _ (f.le hx) with ⟨U, g, hg, hU⟩
refine ⟨_, _, Presieve.pullbackArrows.mk _ _ hg, ?_⟩
have : U ⊓ Y ≤ pullback g f :=
leOfHom (pullback.lift (homOfLE inf_le_left) (homOfLE inf_le_right) rfl)
apply this ⟨hU, hx⟩
transitive X S Ti hS hTi x hx := by
rcases hS x hx with ⟨U, f, hf, hU⟩
rcases hTi f hf x hU with ⟨V, g, hg, hV⟩
exact ⟨_, _, ⟨_, g, f, hf, hg, rfl⟩, hV⟩
#align opens.pretopology Opens.pretopology
@[simp]
theorem pretopology_ofGrothendieck :
Pretopology.ofGrothendieck _ (Opens.grothendieckTopology T) = Opens.pretopology T := by
apply le_antisymm
· intro X R hR x hx
rcases hR x hx with ⟨U, f, ⟨V, g₁, g₂, hg₂, _⟩, hU⟩
exact ⟨V, g₂, hg₂, g₁.le hU⟩
· intro X R hR x hx
rcases hR x hx with ⟨U, f, hf, hU⟩
exact ⟨U, f, Sieve.le_generate R U hf, hU⟩
#align opens.pretopology_of_grothendieck Opens.pretopology_ofGrothendieck
@[simp]
| Mathlib/CategoryTheory/Sites/Spaces.lean | 92 | 95 | theorem pretopology_toGrothendieck :
Pretopology.toGrothendieck _ (Opens.pretopology T) = Opens.grothendieckTopology T := by |
rw [← pretopology_ofGrothendieck]
apply (Pretopology.gi (Opens T)).l_u_eq
| 0 |
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 IsSwap
variable [DecidableEq α]
def IsSwap (f : Perm α) : Prop :=
∃ x y, x ≠ y ∧ f = swap x y
#align equiv.perm.is_swap Equiv.Perm.IsSwap
@[simp]
theorem ofSubtype_swap_eq {p : α → Prop} [DecidablePred p] (x y : Subtype p) :
ofSubtype (Equiv.swap x y) = Equiv.swap ↑x ↑y :=
Equiv.ext fun z => by
by_cases hz : p z
· rw [swap_apply_def, ofSubtype_apply_of_mem _ hz]
split_ifs with hzx hzy
· simp_rw [hzx, Subtype.coe_eta, swap_apply_left]
· simp_rw [hzy, Subtype.coe_eta, swap_apply_right]
· rw [swap_apply_of_ne_of_ne] <;>
simp [Subtype.ext_iff, *]
· rw [ofSubtype_apply_of_not_mem _ hz, swap_apply_of_ne_of_ne]
· intro h
apply hz
rw [h]
exact Subtype.prop x
intro h
apply hz
rw [h]
exact Subtype.prop y
#align equiv.perm.of_subtype_swap_eq Equiv.Perm.ofSubtype_swap_eq
theorem IsSwap.of_subtype_isSwap {p : α → Prop} [DecidablePred p] {f : Perm (Subtype p)}
(h : f.IsSwap) : (ofSubtype f).IsSwap :=
let ⟨⟨x, hx⟩, ⟨y, hy⟩, hxy⟩ := h
⟨x, y, by
simp only [Ne, Subtype.ext_iff] at hxy
exact hxy.1, by
rw [hxy.2, ofSubtype_swap_eq]⟩
#align equiv.perm.is_swap.of_subtype_is_swap Equiv.Perm.IsSwap.of_subtype_isSwap
| Mathlib/GroupTheory/Perm/Support.lean | 248 | 253 | theorem ne_and_ne_of_swap_mul_apply_ne_self {f : Perm α} {x y : α} (hy : (swap x (f x) * f) y ≠ y) :
f y ≠ y ∧ y ≠ x := by |
simp only [swap_apply_def, mul_apply, f.injective.eq_iff] at *
by_cases h : f y = x
· constructor <;> intro <;> simp_all only [if_true, eq_self_iff_true, not_true, Ne]
· split_ifs at hy with h h <;> try { simp [*] at * }
| 0 |
import Mathlib.Algebra.Associated
import Mathlib.Algebra.Order.Monoid.Unbundled.Pow
import Mathlib.Algebra.Ring.Int
import Mathlib.Data.Nat.Factorial.Basic
import Mathlib.Data.Nat.GCD.Basic
import Mathlib.Order.Bounds.Basic
#align_import data.nat.prime from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1"
open Bool Subtype
open Nat
namespace Nat
variable {n : ℕ}
-- Porting note (#11180): removed @[pp_nodot]
def Prime (p : ℕ) :=
Irreducible p
#align nat.prime Nat.Prime
theorem irreducible_iff_nat_prime (a : ℕ) : Irreducible a ↔ Nat.Prime a :=
Iff.rfl
#align irreducible_iff_nat_prime Nat.irreducible_iff_nat_prime
@[aesop safe destruct] theorem not_prime_zero : ¬Prime 0
| h => h.ne_zero rfl
#align nat.not_prime_zero Nat.not_prime_zero
@[aesop safe destruct] theorem not_prime_one : ¬Prime 1
| h => h.ne_one rfl
#align nat.not_prime_one Nat.not_prime_one
theorem Prime.ne_zero {n : ℕ} (h : Prime n) : n ≠ 0 :=
Irreducible.ne_zero h
#align nat.prime.ne_zero Nat.Prime.ne_zero
theorem Prime.pos {p : ℕ} (pp : Prime p) : 0 < p :=
Nat.pos_of_ne_zero pp.ne_zero
#align nat.prime.pos Nat.Prime.pos
theorem Prime.two_le : ∀ {p : ℕ}, Prime p → 2 ≤ p
| 0, h => (not_prime_zero h).elim
| 1, h => (not_prime_one h).elim
| _ + 2, _ => le_add_self
#align nat.prime.two_le Nat.Prime.two_le
theorem Prime.one_lt {p : ℕ} : Prime p → 1 < p :=
Prime.two_le
#align nat.prime.one_lt Nat.Prime.one_lt
lemma Prime.one_le {p : ℕ} (hp : p.Prime) : 1 ≤ p := hp.one_lt.le
instance Prime.one_lt' (p : ℕ) [hp : Fact p.Prime] : Fact (1 < p) :=
⟨hp.1.one_lt⟩
#align nat.prime.one_lt' Nat.Prime.one_lt'
theorem Prime.ne_one {p : ℕ} (hp : p.Prime) : p ≠ 1 :=
hp.one_lt.ne'
#align nat.prime.ne_one Nat.Prime.ne_one
theorem Prime.eq_one_or_self_of_dvd {p : ℕ} (pp : p.Prime) (m : ℕ) (hm : m ∣ p) :
m = 1 ∨ m = p := by
obtain ⟨n, hn⟩ := hm
have := pp.isUnit_or_isUnit hn
rw [Nat.isUnit_iff, Nat.isUnit_iff] at this
apply Or.imp_right _ this
rintro rfl
rw [hn, mul_one]
#align nat.prime.eq_one_or_self_of_dvd Nat.Prime.eq_one_or_self_of_dvd
theorem prime_def_lt'' {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, m ∣ p → m = 1 ∨ m = p := by
refine ⟨fun h => ⟨h.two_le, h.eq_one_or_self_of_dvd⟩, fun h => ?_⟩
-- Porting note: needed to make ℕ explicit
have h1 := (@one_lt_two ℕ ..).trans_le h.1
refine ⟨mt Nat.isUnit_iff.mp h1.ne', fun a b hab => ?_⟩
simp only [Nat.isUnit_iff]
apply Or.imp_right _ (h.2 a _)
· rintro rfl
rw [← mul_right_inj' (pos_of_gt h1).ne', ← hab, mul_one]
· rw [hab]
exact dvd_mul_right _ _
#align nat.prime_def_lt'' Nat.prime_def_lt''
theorem prime_def_lt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m < p, m ∣ p → m = 1 :=
prime_def_lt''.trans <|
and_congr_right fun p2 =>
forall_congr' fun _ =>
⟨fun h l d => (h d).resolve_right (ne_of_lt l), fun h d =>
(le_of_dvd (le_of_succ_le p2) d).lt_or_eq_dec.imp_left fun l => h l d⟩
#align nat.prime_def_lt Nat.prime_def_lt
theorem prime_def_lt' {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m < p → ¬m ∣ p :=
prime_def_lt.trans <|
and_congr_right fun p2 =>
forall_congr' fun m =>
⟨fun h m2 l d => not_lt_of_ge m2 ((h l d).symm ▸ by decide), fun h l d => by
rcases m with (_ | _ | m)
· rw [eq_zero_of_zero_dvd d] at p2
revert p2
decide
· rfl
· exact (h le_add_self l).elim d⟩
#align nat.prime_def_lt' Nat.prime_def_lt'
theorem prime_def_le_sqrt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m ≤ sqrt p → ¬m ∣ p :=
prime_def_lt'.trans <|
and_congr_right fun p2 =>
⟨fun a m m2 l => a m m2 <| lt_of_le_of_lt l <| sqrt_lt_self p2, fun a =>
have : ∀ {m k : ℕ}, m ≤ k → 1 < m → p ≠ m * k := fun {m k} mk m1 e =>
a m m1 (le_sqrt.2 (e.symm ▸ Nat.mul_le_mul_left m mk)) ⟨k, e⟩
fun m m2 l ⟨k, e⟩ => by
rcases le_total m k with mk | km
· exact this mk m2 e
· rw [mul_comm] at e
refine this km (lt_of_mul_lt_mul_right ?_ (zero_le m)) e
rwa [one_mul, ← e]⟩
#align nat.prime_def_le_sqrt Nat.prime_def_le_sqrt
| Mathlib/Data/Nat/Prime.lean | 147 | 153 | theorem prime_of_coprime (n : ℕ) (h1 : 1 < n) (h : ∀ m < n, m ≠ 0 → n.Coprime m) : Prime n := by |
refine prime_def_lt.mpr ⟨h1, fun m mlt mdvd => ?_⟩
have hm : m ≠ 0 := by
rintro rfl
rw [zero_dvd_iff] at mdvd
exact mlt.ne' mdvd
exact (h m mlt hm).symm.eq_one_of_dvd mdvd
| 0 |
import Mathlib.Topology.Separation
open Topology Filter Set TopologicalSpace
section Basic
variable {α : Type*} [TopologicalSpace α] {C : Set α}
theorem AccPt.nhds_inter {x : α} {U : Set α} (h_acc : AccPt x (𝓟 C)) (hU : U ∈ 𝓝 x) :
AccPt x (𝓟 (U ∩ C)) := by
have : 𝓝[≠] x ≤ 𝓟 U := by
rw [le_principal_iff]
exact mem_nhdsWithin_of_mem_nhds hU
rw [AccPt, ← inf_principal, ← inf_assoc, inf_of_le_left this]
exact h_acc
#align acc_pt.nhds_inter AccPt.nhds_inter
def Preperfect (C : Set α) : Prop :=
∀ x ∈ C, AccPt x (𝓟 C)
#align preperfect Preperfect
@[mk_iff perfect_def]
structure Perfect (C : Set α) : Prop where
closed : IsClosed C
acc : Preperfect C
#align perfect Perfect
theorem preperfect_iff_nhds : Preperfect C ↔ ∀ x ∈ C, ∀ U ∈ 𝓝 x, ∃ y ∈ U ∩ C, y ≠ x := by
simp only [Preperfect, accPt_iff_nhds]
#align preperfect_iff_nhds preperfect_iff_nhds
section Preperfect
theorem Preperfect.open_inter {U : Set α} (hC : Preperfect C) (hU : IsOpen U) :
Preperfect (U ∩ C) := by
rintro x ⟨xU, xC⟩
apply (hC _ xC).nhds_inter
exact hU.mem_nhds xU
#align preperfect.open_inter Preperfect.open_inter
theorem Preperfect.perfect_closure (hC : Preperfect C) : Perfect (closure C) := by
constructor; · exact isClosed_closure
intro x hx
by_cases h : x ∈ C <;> apply AccPt.mono _ (principal_mono.mpr subset_closure)
· exact hC _ h
have : {x}ᶜ ∩ C = C := by simp [h]
rw [AccPt, nhdsWithin, inf_assoc, inf_principal, this]
rw [closure_eq_cluster_pts] at hx
exact hx
#align preperfect.perfect_closure Preperfect.perfect_closure
| Mathlib/Topology/Perfect.lean | 132 | 144 | theorem preperfect_iff_perfect_closure [T1Space α] : Preperfect C ↔ Perfect (closure C) := by |
constructor <;> intro h
· exact h.perfect_closure
intro x xC
have H : AccPt x (𝓟 (closure C)) := h.acc _ (subset_closure xC)
rw [accPt_iff_frequently] at *
have : ∀ y, y ≠ x ∧ y ∈ closure C → ∃ᶠ z in 𝓝 y, z ≠ x ∧ z ∈ C := by
rintro y ⟨hyx, yC⟩
simp only [← mem_compl_singleton_iff, and_comm, ← frequently_nhdsWithin_iff,
hyx.nhdsWithin_compl_singleton, ← mem_closure_iff_frequently]
exact yC
rw [← frequently_frequently_nhds]
exact H.mono this
| 0 |
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.NormedSpace.FiniteDimension
import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic
#align_import analysis.calculus.fderiv_measurable from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
set_option linter.uppercaseLean3 false -- A B D
noncomputable section
open Set Metric Asymptotics Filter ContinuousLinearMap MeasureTheory TopologicalSpace
open scoped Topology
section fderiv
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f : E → F} (K : Set (E →L[𝕜] F))
namespace FDerivMeasurableAux
def A (f : E → F) (L : E →L[𝕜] F) (r ε : ℝ) : Set E :=
{ x | ∃ r' ∈ Ioc (r / 2) r, ∀ y ∈ ball x r', ∀ z ∈ ball x r', ‖f z - f y - L (z - y)‖ < ε * r }
#align fderiv_measurable_aux.A FDerivMeasurableAux.A
def B (f : E → F) (K : Set (E →L[𝕜] F)) (r s ε : ℝ) : Set E :=
⋃ L ∈ K, A f L r ε ∩ A f L s ε
#align fderiv_measurable_aux.B FDerivMeasurableAux.B
def D (f : E → F) (K : Set (E →L[𝕜] F)) : Set E :=
⋂ e : ℕ, ⋃ n : ℕ, ⋂ (p ≥ n) (q ≥ n), B f K ((1 / 2) ^ p) ((1 / 2) ^ q) ((1 / 2) ^ e)
#align fderiv_measurable_aux.D FDerivMeasurableAux.D
theorem isOpen_A (L : E →L[𝕜] F) (r ε : ℝ) : IsOpen (A f L r ε) := by
rw [Metric.isOpen_iff]
rintro x ⟨r', r'_mem, hr'⟩
obtain ⟨s, s_gt, s_lt⟩ : ∃ s : ℝ, r / 2 < s ∧ s < r' := exists_between r'_mem.1
have : s ∈ Ioc (r / 2) r := ⟨s_gt, le_of_lt (s_lt.trans_le r'_mem.2)⟩
refine ⟨r' - s, by linarith, fun x' hx' => ⟨s, this, ?_⟩⟩
have B : ball x' s ⊆ ball x r' := ball_subset (le_of_lt hx')
intro y hy z hz
exact hr' y (B hy) z (B hz)
#align fderiv_measurable_aux.is_open_A FDerivMeasurableAux.isOpen_A
| Mathlib/Analysis/Calculus/FDeriv/Measurable.lean | 144 | 145 | theorem isOpen_B {K : Set (E →L[𝕜] F)} {r s ε : ℝ} : IsOpen (B f K r s ε) := by |
simp [B, isOpen_biUnion, IsOpen.inter, isOpen_A]
| 0 |
import Mathlib.Algebra.Polynomial.Degree.Definitions
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.Tactic.Abel
#align_import ring_theory.polynomial.pochhammer from "leanprover-community/mathlib"@"53b216bcc1146df1c4a0a86877890ea9f1f01589"
universe u v
open Polynomial
open Polynomial
section Ring
variable (R : Type u) [Ring R]
noncomputable def descPochhammer : ℕ → R[X]
| 0 => 1
| n + 1 => X * (descPochhammer n).comp (X - 1)
@[simp]
theorem descPochhammer_zero : descPochhammer R 0 = 1 :=
rfl
@[simp]
theorem descPochhammer_one : descPochhammer R 1 = X := by simp [descPochhammer]
theorem descPochhammer_succ_left (n : ℕ) :
descPochhammer R (n + 1) = X * (descPochhammer R n).comp (X - 1) := by
rw [descPochhammer]
theorem monic_descPochhammer (n : ℕ) [Nontrivial R] [NoZeroDivisors R] :
Monic <| descPochhammer R n := by
induction' n with n hn
· simp
· have h : leadingCoeff (X - 1 : R[X]) = 1 := leadingCoeff_X_sub_C 1
have : natDegree (X - (1 : R[X])) ≠ 0 := ne_zero_of_eq_one <| natDegree_X_sub_C (1 : R)
rw [descPochhammer_succ_left, Monic.def, leadingCoeff_mul, leadingCoeff_comp this, hn, monic_X,
one_mul, one_mul, h, one_pow]
section
variable {R} {T : Type v} [Ring T]
@[simp]
theorem descPochhammer_map (f : R →+* T) (n : ℕ) :
(descPochhammer R n).map f = descPochhammer T n := by
induction' n with n ih
· simp
· simp [ih, descPochhammer_succ_left, map_comp]
end
@[simp, norm_cast]
theorem descPochhammer_eval_cast (n : ℕ) (k : ℤ) :
(((descPochhammer ℤ n).eval k : ℤ) : R) = ((descPochhammer R n).eval k : R) := by
rw [← descPochhammer_map (algebraMap ℤ R), eval_map, ← eq_intCast (algebraMap ℤ R)]
simp only [algebraMap_int_eq, eq_intCast, eval₂_at_intCast, Nat.cast_id, eq_natCast, Int.cast_id]
theorem descPochhammer_eval_zero {n : ℕ} :
(descPochhammer R n).eval 0 = if n = 0 then 1 else 0 := by
cases n
· simp
· simp [X_mul, Nat.succ_ne_zero, descPochhammer_succ_left]
theorem descPochhammer_zero_eval_zero : (descPochhammer R 0).eval 0 = 1 := by simp
@[simp]
theorem descPochhammer_ne_zero_eval_zero {n : ℕ} (h : n ≠ 0) : (descPochhammer R n).eval 0 = 0 := by
simp [descPochhammer_eval_zero, h]
theorem descPochhammer_succ_right (n : ℕ) :
descPochhammer R (n + 1) = descPochhammer R n * (X - (n : R[X])) := by
suffices h : descPochhammer ℤ (n + 1) = descPochhammer ℤ n * (X - (n : ℤ[X])) by
apply_fun Polynomial.map (algebraMap ℤ R) at h
simpa [descPochhammer_map, Polynomial.map_mul, Polynomial.map_add, map_X,
Polynomial.map_intCast] using h
induction' n with n ih
· simp [descPochhammer]
· conv_lhs =>
rw [descPochhammer_succ_left, ih, mul_comp, ← mul_assoc, ← descPochhammer_succ_left, sub_comp,
X_comp, natCast_comp]
rw [Nat.cast_add, Nat.cast_one, sub_add_eq_sub_sub_swap]
@[simp]
theorem descPochhammer_natDegree (n : ℕ) [NoZeroDivisors R] [Nontrivial R] :
(descPochhammer R n).natDegree = n := by
induction' n with n hn
· simp
· have : natDegree (X - (n : R[X])) = 1 := natDegree_X_sub_C (n : R)
rw [descPochhammer_succ_right,
natDegree_mul _ (ne_zero_of_natDegree_gt <| this.symm ▸ Nat.zero_lt_one), hn, this]
cases n
· simp
· refine ne_zero_of_natDegree_gt <| hn.symm ▸ Nat.add_one_pos _
| Mathlib/RingTheory/Polynomial/Pochhammer.lean | 326 | 329 | theorem descPochhammer_succ_eval {S : Type*} [Ring S] (n : ℕ) (k : S) :
(descPochhammer S (n + 1)).eval k = (descPochhammer S n).eval k * (k - n) := by |
rw [descPochhammer_succ_right, mul_sub, eval_sub, eval_mul_X, ← Nat.cast_comm, ← C_eq_natCast,
eval_C_mul, Nat.cast_comm, ← mul_sub]
| 0 |
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic
import Mathlib.NumberTheory.GaussSum
#align_import number_theory.legendre_symbol.quadratic_char.gauss_sum from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
section SpecialValues
open ZMod MulChar
variable {F : Type*} [Field F] [Fintype F]
theorem quadraticChar_two [DecidableEq F] (hF : ringChar F ≠ 2) :
quadraticChar F 2 = χ₈ (Fintype.card F) :=
IsQuadratic.eq_of_eq_coe (quadraticChar_isQuadratic F) isQuadratic_χ₈ hF
((quadraticChar_eq_pow_of_char_ne_two' hF 2).trans (FiniteField.two_pow_card hF))
#align quadratic_char_two quadraticChar_two
theorem FiniteField.isSquare_two_iff :
IsSquare (2 : F) ↔ Fintype.card F % 8 ≠ 3 ∧ Fintype.card F % 8 ≠ 5 := by
classical
by_cases hF : ringChar F = 2
focus
have h := FiniteField.even_card_of_char_two hF
simp only [FiniteField.isSquare_of_char_two hF, true_iff_iff]
rotate_left
focus
have h := FiniteField.odd_card_of_char_ne_two hF
rw [← quadraticChar_one_iff_isSquare (Ring.two_ne_zero hF), quadraticChar_two hF,
χ₈_nat_eq_if_mod_eight]
simp only [h, Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne, (by decide : (-1 : ℤ) ≠ 1),
imp_false, Classical.not_not]
all_goals
rw [← Nat.mod_mod_of_dvd _ (by decide : 2 ∣ 8)] at h
have h₁ := Nat.mod_lt (Fintype.card F) (by decide : 0 < 8)
revert h₁ h
generalize Fintype.card F % 8 = n
intros; interval_cases n <;> simp_all -- Porting note (#11043): was `decide!`
#align finite_field.is_square_two_iff FiniteField.isSquare_two_iff
theorem quadraticChar_neg_two [DecidableEq F] (hF : ringChar F ≠ 2) :
quadraticChar F (-2) = χ₈' (Fintype.card F) := by
rw [(by norm_num : (-2 : F) = -1 * 2), map_mul, χ₈'_eq_χ₄_mul_χ₈, quadraticChar_neg_one hF,
quadraticChar_two hF, @cast_natCast _ (ZMod 4) _ _ _ (by decide : 4 ∣ 8)]
#align quadratic_char_neg_two quadraticChar_neg_two
theorem FiniteField.isSquare_neg_two_iff :
IsSquare (-2 : F) ↔ Fintype.card F % 8 ≠ 5 ∧ Fintype.card F % 8 ≠ 7 := by
classical
by_cases hF : ringChar F = 2
focus
have h := FiniteField.even_card_of_char_two hF
simp only [FiniteField.isSquare_of_char_two hF, true_iff_iff]
rotate_left
focus
have h := FiniteField.odd_card_of_char_ne_two hF
rw [← quadraticChar_one_iff_isSquare (neg_ne_zero.mpr (Ring.two_ne_zero hF)),
quadraticChar_neg_two hF, χ₈'_nat_eq_if_mod_eight]
simp only [h, Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne, (by decide : (-1 : ℤ) ≠ 1),
imp_false, Classical.not_not]
all_goals
rw [← Nat.mod_mod_of_dvd _ (by decide : 2 ∣ 8)] at h
have h₁ := Nat.mod_lt (Fintype.card F) (by decide : 0 < 8)
revert h₁ h
generalize Fintype.card F % 8 = n
intros; interval_cases n <;> simp_all -- Porting note (#11043): was `decide!`
#align finite_field.is_square_neg_two_iff FiniteField.isSquare_neg_two_iff
theorem quadraticChar_card_card [DecidableEq F] (hF : ringChar F ≠ 2) {F' : Type*} [Field F']
[Fintype F'] [DecidableEq F'] (hF' : ringChar F' ≠ 2) (h : ringChar F' ≠ ringChar F) :
quadraticChar F (Fintype.card F') =
quadraticChar F' (quadraticChar F (-1) * Fintype.card F) := by
let χ := (quadraticChar F).ringHomComp (algebraMap ℤ F')
have hχ₁ : χ.IsNontrivial := by
obtain ⟨a, ha⟩ := quadraticChar_exists_neg_one hF
have hu : IsUnit a := by
contrapose ha
exact ne_of_eq_of_ne (map_nonunit (quadraticChar F) ha) (mt zero_eq_neg.mp one_ne_zero)
use hu.unit
simp only [χ, IsUnit.unit_spec, ringHomComp_apply, eq_intCast, Ne, ha]
rw [Int.cast_neg, Int.cast_one]
exact Ring.neg_one_ne_one_of_char_ne_two hF'
have hχ₂ : χ.IsQuadratic := IsQuadratic.comp (quadraticChar_isQuadratic F) _
have h := Char.card_pow_card hχ₁ hχ₂ h hF'
rw [← quadraticChar_eq_pow_of_char_ne_two' hF'] at h
exact (IsQuadratic.eq_of_eq_coe (quadraticChar_isQuadratic F')
(quadraticChar_isQuadratic F) hF' h).symm
#align quadratic_char_card_card quadraticChar_card_card
| Mathlib/NumberTheory/LegendreSymbol/QuadraticChar/GaussSum.lean | 119 | 125 | theorem quadraticChar_odd_prime [DecidableEq F] (hF : ringChar F ≠ 2) {p : ℕ} [Fact p.Prime]
(hp₁ : p ≠ 2) (hp₂ : ringChar F ≠ p) :
quadraticChar F p = quadraticChar (ZMod p) (χ₄ (Fintype.card F) * Fintype.card F) := by |
rw [← quadraticChar_neg_one hF]
have h := quadraticChar_card_card hF (ne_of_eq_of_ne (ringChar_zmod_n p) hp₁)
(ne_of_eq_of_ne (ringChar_zmod_n p) hp₂.symm)
rwa [card p] at h
| 0 |
import Mathlib.MeasureTheory.Integral.Lebesgue
import Mathlib.Topology.MetricSpace.ThickenedIndicator
open MeasureTheory Topology Metric Filter Set ENNReal NNReal
open scoped Topology ENNReal NNReal BoundedContinuousFunction
section auxiliary
namespace MeasureTheory
variable {Ω : Type*} [TopologicalSpace Ω] [MeasurableSpace Ω] [OpensMeasurableSpace Ω]
theorem tendsto_lintegral_nn_filter_of_le_const {ι : Type*} {L : Filter ι} [L.IsCountablyGenerated]
(μ : Measure Ω) [IsFiniteMeasure μ] {fs : ι → Ω →ᵇ ℝ≥0} {c : ℝ≥0}
(fs_le_const : ∀ᶠ i in L, ∀ᵐ ω : Ω ∂μ, fs i ω ≤ c) {f : Ω → ℝ≥0}
(fs_lim : ∀ᵐ ω : Ω ∂μ, Tendsto (fun i ↦ fs i ω) L (𝓝 (f ω))) :
Tendsto (fun i ↦ ∫⁻ ω, fs i ω ∂μ) L (𝓝 (∫⁻ ω, f ω ∂μ)) := by
refine tendsto_lintegral_filter_of_dominated_convergence (fun _ ↦ c)
(eventually_of_forall fun i ↦ (ENNReal.continuous_coe.comp (fs i).continuous).measurable) ?_
(@lintegral_const_lt_top _ _ μ _ _ (@ENNReal.coe_ne_top c)).ne ?_
· simpa only [Function.comp_apply, ENNReal.coe_le_coe] using fs_le_const
· simpa only [Function.comp_apply, ENNReal.tendsto_coe] using fs_lim
#align measure_theory.finite_measure.tendsto_lintegral_nn_filter_of_le_const MeasureTheory.tendsto_lintegral_nn_filter_of_le_const
theorem measure_of_cont_bdd_of_tendsto_filter_indicator {ι : Type*} {L : Filter ι}
[L.IsCountablyGenerated] [TopologicalSpace Ω] [OpensMeasurableSpace Ω] (μ : Measure Ω)
[IsFiniteMeasure μ] {c : ℝ≥0} {E : Set Ω} (E_mble : MeasurableSet E) (fs : ι → Ω →ᵇ ℝ≥0)
(fs_bdd : ∀ᶠ i in L, ∀ᵐ ω : Ω ∂μ, fs i ω ≤ c)
(fs_lim : ∀ᵐ ω ∂μ, Tendsto (fun i ↦ fs i ω) L (𝓝 (indicator E (fun _ ↦ (1 : ℝ≥0)) ω))) :
Tendsto (fun n ↦ lintegral μ fun ω ↦ fs n ω) L (𝓝 (μ E)) := by
convert tendsto_lintegral_nn_filter_of_le_const μ fs_bdd fs_lim
have aux : ∀ ω, indicator E (fun _ ↦ (1 : ℝ≥0∞)) ω = ↑(indicator E (fun _ ↦ (1 : ℝ≥0)) ω) :=
fun ω ↦ by simp only [ENNReal.coe_indicator, ENNReal.coe_one]
simp_rw [← aux, lintegral_indicator _ E_mble]
simp only [lintegral_one, Measure.restrict_apply, MeasurableSet.univ, univ_inter]
#align measure_theory.measure_of_cont_bdd_of_tendsto_filter_indicator MeasureTheory.measure_of_cont_bdd_of_tendsto_filter_indicator
| Mathlib/MeasureTheory/Measure/HasOuterApproxClosed.lean | 95 | 105 | theorem measure_of_cont_bdd_of_tendsto_indicator [OpensMeasurableSpace Ω]
(μ : Measure Ω) [IsFiniteMeasure μ] {c : ℝ≥0} {E : Set Ω} (E_mble : MeasurableSet E)
(fs : ℕ → Ω →ᵇ ℝ≥0) (fs_bdd : ∀ n ω, fs n ω ≤ c)
(fs_lim : Tendsto (fun n ω ↦ fs n ω) atTop (𝓝 (indicator E fun _ ↦ (1 : ℝ≥0)))) :
Tendsto (fun n ↦ lintegral μ fun ω ↦ fs n ω) atTop (𝓝 (μ E)) := by |
have fs_lim' :
∀ ω, Tendsto (fun n : ℕ ↦ (fs n ω : ℝ≥0)) atTop (𝓝 (indicator E (fun _ ↦ (1 : ℝ≥0)) ω)) := by
rw [tendsto_pi_nhds] at fs_lim
exact fun ω ↦ fs_lim ω
apply measure_of_cont_bdd_of_tendsto_filter_indicator μ E_mble fs
(eventually_of_forall fun n ↦ eventually_of_forall (fs_bdd n)) (eventually_of_forall fs_lim')
| 0 |
import Mathlib.Algebra.Polynomial.Splits
#align_import algebra.cubic_discriminant from "leanprover-community/mathlib"@"930133160e24036d5242039fe4972407cd4f1222"
noncomputable section
@[ext]
structure Cubic (R : Type*) where
(a b c d : R)
#align cubic Cubic
namespace Cubic
open Cubic Polynomial
open Polynomial
variable {R S F K : Type*}
instance [Inhabited R] : Inhabited (Cubic R) :=
⟨⟨default, default, default, default⟩⟩
instance [Zero R] : Zero (Cubic R) :=
⟨⟨0, 0, 0, 0⟩⟩
section Basic
variable {P Q : Cubic R} {a b c d a' b' c' d' : R} [Semiring R]
def toPoly (P : Cubic R) : R[X] :=
C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d
#align cubic.to_poly Cubic.toPoly
theorem C_mul_prod_X_sub_C_eq [CommRing S] {w x y z : S} :
C w * (X - C x) * (X - C y) * (X - C z) =
toPoly ⟨w, w * -(x + y + z), w * (x * y + x * z + y * z), w * -(x * y * z)⟩ := by
simp only [toPoly, C_neg, C_add, C_mul]
ring1
set_option linter.uppercaseLean3 false in
#align cubic.C_mul_prod_X_sub_C_eq Cubic.C_mul_prod_X_sub_C_eq
theorem prod_X_sub_C_eq [CommRing S] {x y z : S} :
(X - C x) * (X - C y) * (X - C z) =
toPoly ⟨1, -(x + y + z), x * y + x * z + y * z, -(x * y * z)⟩ := by
rw [← one_mul <| X - C x, ← C_1, C_mul_prod_X_sub_C_eq, one_mul, one_mul, one_mul]
set_option linter.uppercaseLean3 false in
#align cubic.prod_X_sub_C_eq Cubic.prod_X_sub_C_eq
section Map
variable [Semiring S] {φ : R →+* S}
def map (φ : R →+* S) (P : Cubic R) : Cubic S :=
⟨φ P.a, φ P.b, φ P.c, φ P.d⟩
#align cubic.map Cubic.map
| Mathlib/Algebra/CubicDiscriminant.lean | 458 | 459 | theorem map_toPoly : (map φ P).toPoly = Polynomial.map φ P.toPoly := by |
simp only [map, toPoly, map_C, map_X, Polynomial.map_add, Polynomial.map_mul, Polynomial.map_pow]
| 0 |
import Mathlib.Algebra.Polynomial.Monic
#align_import algebra.polynomial.big_operators from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722"
open Finset
open Multiset
open Polynomial
universe u w
variable {R : Type u} {ι : Type w}
namespace Polynomial
variable (s : Finset ι)
section Semiring
variable {S : Type*} [Semiring S]
set_option backward.isDefEq.lazyProjDelta false in -- See https://github.com/leanprover-community/mathlib4/issues/12535
theorem natDegree_list_sum_le (l : List S[X]) : natDegree l.sum ≤ (l.map natDegree).foldr max 0 :=
List.sum_le_foldr_max natDegree (by simp) natDegree_add_le _
#align polynomial.nat_degree_list_sum_le Polynomial.natDegree_list_sum_le
theorem natDegree_multiset_sum_le (l : Multiset S[X]) :
natDegree l.sum ≤ (l.map natDegree).foldr max max_left_comm 0 :=
Quotient.inductionOn l (by simpa using natDegree_list_sum_le)
#align polynomial.nat_degree_multiset_sum_le Polynomial.natDegree_multiset_sum_le
theorem natDegree_sum_le (f : ι → S[X]) :
natDegree (∑ i ∈ s, f i) ≤ s.fold max 0 (natDegree ∘ f) := by
simpa using natDegree_multiset_sum_le (s.val.map f)
#align polynomial.nat_degree_sum_le Polynomial.natDegree_sum_le
lemma natDegree_sum_le_of_forall_le {n : ℕ} (f : ι → S[X]) (h : ∀ i ∈ s, natDegree (f i) ≤ n) :
natDegree (∑ i ∈ s, f i) ≤ n :=
le_trans (natDegree_sum_le s f) <| (Finset.fold_max_le n).mpr <| by simpa
theorem degree_list_sum_le (l : List S[X]) : degree l.sum ≤ (l.map natDegree).maximum := by
by_cases h : l.sum = 0
· simp [h]
· rw [degree_eq_natDegree h]
suffices (l.map natDegree).maximum = ((l.map natDegree).foldr max 0 : ℕ) by
rw [this]
simpa using natDegree_list_sum_le l
rw [← List.foldr_max_of_ne_nil]
· congr
contrapose! h
rw [List.map_eq_nil] at h
simp [h]
#align polynomial.degree_list_sum_le Polynomial.degree_list_sum_le
theorem natDegree_list_prod_le (l : List S[X]) : natDegree l.prod ≤ (l.map natDegree).sum := by
induction' l with hd tl IH
· simp
· simpa using natDegree_mul_le.trans (add_le_add_left IH _)
#align polynomial.nat_degree_list_prod_le Polynomial.natDegree_list_prod_le
theorem degree_list_prod_le (l : List S[X]) : degree l.prod ≤ (l.map degree).sum := by
induction' l with hd tl IH
· simp
· simpa using (degree_mul_le _ _).trans (add_le_add_left IH _)
#align polynomial.degree_list_prod_le Polynomial.degree_list_prod_le
| Mathlib/Algebra/Polynomial/BigOperators.lean | 92 | 111 | theorem coeff_list_prod_of_natDegree_le (l : List S[X]) (n : ℕ) (hl : ∀ p ∈ l, natDegree p ≤ n) :
coeff (List.prod l) (l.length * n) = (l.map fun p => coeff p n).prod := by |
induction' l with hd tl IH
· simp
· have hl' : ∀ p ∈ tl, natDegree p ≤ n := fun p hp => hl p (List.mem_cons_of_mem _ hp)
simp only [List.prod_cons, List.map, List.length]
rw [add_mul, one_mul, add_comm, ← IH hl', mul_comm tl.length]
have h : natDegree tl.prod ≤ n * tl.length := by
refine (natDegree_list_prod_le _).trans ?_
rw [← tl.length_map natDegree, mul_comm]
refine List.sum_le_card_nsmul _ _ ?_
simpa using hl'
have hdn : natDegree hd ≤ n := hl _ (List.mem_cons_self _ _)
rcases hdn.eq_or_lt with (rfl | hdn')
· rcases h.eq_or_lt with h' | h'
· rw [← h', coeff_mul_degree_add_degree, leadingCoeff, leadingCoeff]
· rw [coeff_eq_zero_of_natDegree_lt, coeff_eq_zero_of_natDegree_lt h', mul_zero]
exact natDegree_mul_le.trans_lt (add_lt_add_left h' _)
· rw [coeff_eq_zero_of_natDegree_lt hdn', coeff_eq_zero_of_natDegree_lt, zero_mul]
exact natDegree_mul_le.trans_lt (add_lt_add_of_lt_of_le hdn' h)
| 0 |
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]
| Mathlib/Combinatorics/Enumerative/Composition.lean | 252 | 252 | theorem boundary_zero : c.boundary 0 = 0 := by | simp [boundary, Fin.ext_iff]
| 0 |
import Mathlib.Analysis.Analytic.Basic
import Mathlib.Combinatorics.Enumerative.Composition
#align_import analysis.analytic.composition from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a"
noncomputable section
variable {𝕜 : Type*} {E F G H : Type*}
open Filter List
open scoped Topology Classical NNReal ENNReal
section Topological
variable [CommRing 𝕜] [AddCommGroup E] [AddCommGroup F] [AddCommGroup G]
variable [Module 𝕜 E] [Module 𝕜 F] [Module 𝕜 G]
variable [TopologicalSpace E] [TopologicalSpace F] [TopologicalSpace G]
namespace FormalMultilinearSeries
variable [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
variable [TopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
variable [TopologicalAddGroup G] [ContinuousConstSMul 𝕜 G]
def applyComposition (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (c : Composition n) :
(Fin n → E) → Fin c.length → F := fun v i => p (c.blocksFun i) (v ∘ c.embedding i)
#align formal_multilinear_series.apply_composition FormalMultilinearSeries.applyComposition
theorem applyComposition_ones (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) :
p.applyComposition (Composition.ones n) = fun v i =>
p 1 fun _ => v (Fin.castLE (Composition.length_le _) i) := by
funext v i
apply p.congr (Composition.ones_blocksFun _ _)
intro j hjn hj1
obtain rfl : j = 0 := by omega
refine congr_arg v ?_
rw [Fin.ext_iff, Fin.coe_castLE, Composition.ones_embedding, Fin.val_mk]
#align formal_multilinear_series.apply_composition_ones FormalMultilinearSeries.applyComposition_ones
theorem applyComposition_single (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : 0 < n)
(v : Fin n → E) : p.applyComposition (Composition.single n hn) v = fun _j => p n v := by
ext j
refine p.congr (by simp) fun i hi1 hi2 => ?_
dsimp
congr 1
convert Composition.single_embedding hn ⟨i, hi2⟩ using 1
cases' j with j_val j_property
have : j_val = 0 := le_bot_iff.1 (Nat.lt_succ_iff.1 j_property)
congr!
simp
#align formal_multilinear_series.apply_composition_single FormalMultilinearSeries.applyComposition_single
@[simp]
| Mathlib/Analysis/Analytic/Composition.lean | 131 | 134 | theorem removeZero_applyComposition (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(c : Composition n) : p.removeZero.applyComposition c = p.applyComposition c := by |
ext v i
simp [applyComposition, zero_lt_one.trans_le (c.one_le_blocksFun i), removeZero_of_pos]
| 0 |
import Mathlib.CategoryTheory.Sites.Sheaf
#align_import category_theory.sites.canonical from "leanprover-community/mathlib"@"9e7c80f638149bfb3504ba8ff48dfdbfc949fb1a"
universe v u
namespace CategoryTheory
open scoped Classical
open CategoryTheory Category Limits Sieve
variable {C : Type u} [Category.{v} C]
namespace Sheaf
variable {P : Cᵒᵖ ⥤ Type v}
variable {X Y : C} {S : Sieve X} {R : Presieve X}
variable (J J₂ : GrothendieckTopology C)
theorem isSheafFor_bind (P : Cᵒᵖ ⥤ Type v) (U : Sieve X) (B : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, U f → Sieve Y)
(hU : Presieve.IsSheafFor P (U : Presieve X))
(hB : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), Presieve.IsSheafFor P (B hf : Presieve Y))
(hB' : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (h : U f) ⦃Z⦄ (g : Z ⟶ Y),
Presieve.IsSeparatedFor P (((B h).pullback g) : Presieve Z)) :
Presieve.IsSheafFor P (Sieve.bind (U : Presieve X) B : Presieve X) := by
intro s hs
let y : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), Presieve.FamilyOfElements P (B hf : Presieve Y) :=
fun Y f hf Z g hg => s _ (Presieve.bind_comp _ _ hg)
have hy : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).Compatible := by
intro Y f H Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ comm
apply hs
apply reassoc_of% comm
let t : Presieve.FamilyOfElements P (U : Presieve X) :=
fun Y f hf => (hB hf).amalgamate (y hf) (hy hf)
have ht : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).IsAmalgamation (t f hf) := fun Y f hf =>
(hB hf).isAmalgamation _
have hT : t.Compatible := by
rw [Presieve.compatible_iff_sieveCompatible]
intro Z W f h hf
apply (hB (U.downward_closed hf h)).isSeparatedFor.ext
intro Y l hl
apply (hB' hf (l ≫ h)).ext
intro M m hm
have : bind U B (m ≫ l ≫ h ≫ f) := by
-- Porting note: had to make explicit the parameter `((m ≫ l ≫ h) ≫ f)` and
-- using `by exact`
have : bind U B ((m ≫ l ≫ h) ≫ f) := by exact Presieve.bind_comp f hf hm
simpa using this
trans s (m ≫ l ≫ h ≫ f) this
· have := ht (U.downward_closed hf h) _ ((B _).downward_closed hl m)
rw [op_comp, FunctorToTypes.map_comp_apply] at this
rw [this]
change s _ _ = s _ _
-- Porting note: the proof was `by simp`
congr 1
simp only [assoc]
· have h : s _ _ = _ := (ht hf _ hm).symm
-- Porting note: this was done by `simp only [assoc] at`
conv_lhs at h => congr; rw [assoc, assoc]
rw [h]
simp only [op_comp, assoc, FunctorToTypes.map_comp_apply]
refine ⟨hU.amalgamate t hT, ?_, ?_⟩
· rintro Z _ ⟨Y, f, g, hg, hf, rfl⟩
rw [op_comp, FunctorToTypes.map_comp_apply, Presieve.IsSheafFor.valid_glue _ _ _ hg]
apply ht hg _ hf
· intro y hy
apply hU.isSeparatedFor.ext
intro Y f hf
apply (hB hf).isSeparatedFor.ext
intro Z g hg
rw [← FunctorToTypes.map_comp_apply, ← op_comp, hy _ (Presieve.bind_comp _ _ hg),
hU.valid_glue _ _ hf, ht hf _ hg]
#align category_theory.sheaf.is_sheaf_for_bind CategoryTheory.Sheaf.isSheafFor_bind
| Mathlib/CategoryTheory/Sites/Canonical.lean | 125 | 150 | theorem isSheafFor_trans (P : Cᵒᵖ ⥤ Type v) (R S : Sieve X)
(hR : Presieve.IsSheafFor P (R : Presieve X))
(hR' : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (_ : S f), Presieve.IsSeparatedFor P (R.pullback f : Presieve Y))
(hS : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (_ : R f), Presieve.IsSheafFor P (S.pullback f : Presieve Y)) :
Presieve.IsSheafFor P (S : Presieve X) := by |
have : (bind R fun Y f _ => S.pullback f : Presieve X) ≤ S := by
rintro Z f ⟨W, f, g, hg, hf : S _, rfl⟩
apply hf
apply Presieve.isSheafFor_subsieve_aux P this
· apply isSheafFor_bind _ _ _ hR hS
intro Y f hf Z g
rw [← pullback_comp]
apply (hS (R.downward_closed hf _)).isSeparatedFor
· intro Y f hf
have : Sieve.pullback f (bind R fun T (k : T ⟶ X) (_ : R k) => pullback k S) =
R.pullback f := by
ext Z g
constructor
· rintro ⟨W, k, l, hl, _, comm⟩
rw [pullback_apply, ← comm]
simp [hl]
· intro a
refine ⟨Z, 𝟙 Z, _, a, ?_⟩
simp [hf]
rw [this]
apply hR' hf
| 0 |
import Mathlib.Computability.Halting
#align_import computability.reduce from "leanprover-community/mathlib"@"d13b3a4a392ea7273dfa4727dbd1892e26cfd518"
universe u v w
open Function
def ManyOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) :=
∃ f, Computable f ∧ ∀ a, p a ↔ q (f a)
#align many_one_reducible ManyOneReducible
@[inherit_doc ManyOneReducible]
infixl:1000 " ≤₀ " => ManyOneReducible
theorem ManyOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop)
(h : Computable f) : (fun a => q (f a)) ≤₀ q :=
⟨f, h, fun _ => Iff.rfl⟩
#align many_one_reducible.mk ManyOneReducible.mk
@[refl]
theorem manyOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₀ p :=
⟨id, Computable.id, by simp⟩
#align many_one_reducible_refl manyOneReducible_refl
@[trans]
theorem ManyOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]
{p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₀ q → q ≤₀ r → p ≤₀ r
| ⟨f, c₁, h₁⟩, ⟨g, c₂, h₂⟩ =>
⟨g ∘ f, c₂.comp c₁,
fun a => ⟨fun h => by erw [← h₂, ← h₁]; assumption, fun h => by rwa [h₁, h₂]⟩⟩
#align many_one_reducible.trans ManyOneReducible.trans
theorem reflexive_manyOneReducible {α} [Primcodable α] : Reflexive (@ManyOneReducible α α _ _) :=
manyOneReducible_refl
#align reflexive_many_one_reducible reflexive_manyOneReducible
theorem transitive_manyOneReducible {α} [Primcodable α] : Transitive (@ManyOneReducible α α _ _) :=
fun _ _ _ => ManyOneReducible.trans
#align transitive_many_one_reducible transitive_manyOneReducible
def OneOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) :=
∃ f, Computable f ∧ Injective f ∧ ∀ a, p a ↔ q (f a)
#align one_one_reducible OneOneReducible
@[inherit_doc OneOneReducible]
infixl:1000 " ≤₁ " => OneOneReducible
theorem OneOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop)
(h : Computable f) (i : Injective f) : (fun a => q (f a)) ≤₁ q :=
⟨f, h, i, fun _ => Iff.rfl⟩
#align one_one_reducible.mk OneOneReducible.mk
@[refl]
theorem oneOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₁ p :=
⟨id, Computable.id, injective_id, by simp⟩
#align one_one_reducible_refl oneOneReducible_refl
@[trans]
theorem OneOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop}
{q : β → Prop} {r : γ → Prop} : p ≤₁ q → q ≤₁ r → p ≤₁ r
| ⟨f, c₁, i₁, h₁⟩, ⟨g, c₂, i₂, h₂⟩ =>
⟨g ∘ f, c₂.comp c₁, i₂.comp i₁, fun a =>
⟨fun h => by erw [← h₂, ← h₁]; assumption, fun h => by rwa [h₁, h₂]⟩⟩
#align one_one_reducible.trans OneOneReducible.trans
theorem OneOneReducible.to_many_one {α β} [Primcodable α] [Primcodable β] {p : α → Prop}
{q : β → Prop} : p ≤₁ q → p ≤₀ q
| ⟨f, c, _, h⟩ => ⟨f, c, h⟩
#align one_one_reducible.to_many_one OneOneReducible.to_many_one
theorem OneOneReducible.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (q : β → Prop)
(h : Computable e) : (q ∘ e) ≤₁ q :=
OneOneReducible.mk _ h e.injective
#align one_one_reducible.of_equiv OneOneReducible.of_equiv
theorem OneOneReducible.of_equiv_symm {α β} [Primcodable α] [Primcodable β] {e : α ≃ β}
(q : β → Prop) (h : Computable e.symm) : q ≤₁ (q ∘ e) := by
convert OneOneReducible.of_equiv _ h; funext; simp
#align one_one_reducible.of_equiv_symm OneOneReducible.of_equiv_symm
theorem reflexive_oneOneReducible {α} [Primcodable α] : Reflexive (@OneOneReducible α α _ _) :=
oneOneReducible_refl
#align reflexive_one_one_reducible reflexive_oneOneReducible
theorem transitive_oneOneReducible {α} [Primcodable α] : Transitive (@OneOneReducible α α _ _) :=
fun _ _ _ => OneOneReducible.trans
#align transitive_one_one_reducible transitive_oneOneReducible
namespace ComputablePred
variable {α : Type*} {β : Type*} {σ : Type*}
variable [Primcodable α] [Primcodable β] [Primcodable σ]
open Computable
| Mathlib/Computability/Reduce.lean | 131 | 136 | theorem computable_of_manyOneReducible {p : α → Prop} {q : β → Prop} (h₁ : p ≤₀ q)
(h₂ : ComputablePred q) : ComputablePred p := by |
rcases h₁ with ⟨f, c, hf⟩
rw [show p = fun a => q (f a) from Set.ext hf]
rcases computable_iff.1 h₂ with ⟨g, hg, rfl⟩
exact ⟨by infer_instance, by simpa using hg.comp c⟩
| 0 |
import Mathlib.CategoryTheory.Limits.Shapes.Biproducts
import Mathlib.GroupTheory.EckmannHilton
import Mathlib.Tactic.CategoryTheory.Reassoc
#align_import category_theory.preadditive.of_biproducts from "leanprover-community/mathlib"@"061ea99a5610cfc72c286aa930d3c1f47f74f3d0"
noncomputable section
universe v u
open CategoryTheory
open CategoryTheory.Limits
namespace CategoryTheory.SemiadditiveOfBinaryBiproducts
variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C] [HasBinaryBiproducts C]
section
variable (X Y : C)
@[simp]
def leftAdd (f g : X ⟶ Y) : X ⟶ Y :=
biprod.lift f g ≫ biprod.desc (𝟙 Y) (𝟙 Y)
#align category_theory.semiadditive_of_binary_biproducts.left_add CategoryTheory.SemiadditiveOfBinaryBiproducts.leftAdd
@[simp]
def rightAdd (f g : X ⟶ Y) : X ⟶ Y :=
biprod.lift (𝟙 X) (𝟙 X) ≫ biprod.desc f g
#align category_theory.semiadditive_of_binary_biproducts.right_add CategoryTheory.SemiadditiveOfBinaryBiproducts.rightAdd
local infixr:65 " +ₗ " => leftAdd X Y
local infixr:65 " +ᵣ " => rightAdd X Y
theorem isUnital_leftAdd : EckmannHilton.IsUnital (· +ₗ ·) 0 := by
have hr : ∀ f : X ⟶ Y, biprod.lift (0 : X ⟶ Y) f = f ≫ biprod.inr := by
intro f
ext
· aesop_cat
· simp [biprod.lift_fst, Category.assoc, biprod.inr_fst, comp_zero]
have hl : ∀ f : X ⟶ Y, biprod.lift f (0 : X ⟶ Y) = f ≫ biprod.inl := by
intro f
ext
· aesop_cat
· simp [biprod.lift_snd, Category.assoc, biprod.inl_snd, comp_zero]
exact {
left_id := fun f => by simp [hr f, leftAdd, Category.assoc, Category.comp_id, biprod.inr_desc],
right_id := fun f => by simp [hl f, leftAdd, Category.assoc, Category.comp_id, biprod.inl_desc]
}
#align category_theory.semiadditive_of_binary_biproducts.is_unital_left_add CategoryTheory.SemiadditiveOfBinaryBiproducts.isUnital_leftAdd
| Mathlib/CategoryTheory/Preadditive/OfBiproducts.lean | 71 | 85 | theorem isUnital_rightAdd : EckmannHilton.IsUnital (· +ᵣ ·) 0 := by |
have h₂ : ∀ f : X ⟶ Y, biprod.desc (0 : X ⟶ Y) f = biprod.snd ≫ f := by
intro f
ext
· aesop_cat
· simp only [biprod.inr_desc, BinaryBicone.inr_snd_assoc]
have h₁ : ∀ f : X ⟶ Y, biprod.desc f (0 : X ⟶ Y) = biprod.fst ≫ f := by
intro f
ext
· aesop_cat
· simp only [biprod.inr_desc, BinaryBicone.inr_fst_assoc, zero_comp]
exact {
left_id := fun f => by simp [h₂ f, rightAdd, biprod.lift_snd_assoc, Category.id_comp],
right_id := fun f => by simp [h₁ f, rightAdd, biprod.lift_fst_assoc, Category.id_comp]
}
| 0 |
import Mathlib.MeasureTheory.Measure.Dirac
set_option autoImplicit true
open Set
open scoped ENNReal Classical
variable [MeasurableSpace α] [MeasurableSpace β] {s : Set α}
noncomputable section
namespace MeasureTheory.Measure
def count : Measure α :=
sum dirac
#align measure_theory.measure.count MeasureTheory.Measure.count
theorem le_count_apply : ∑' _ : s, (1 : ℝ≥0∞) ≤ count s :=
calc
(∑' _ : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i := tsum_subtype s 1
_ ≤ ∑' i, dirac i s := ENNReal.tsum_le_tsum fun _ => le_dirac_apply
_ ≤ count s := le_sum_apply _ _
#align measure_theory.measure.le_count_apply MeasureTheory.Measure.le_count_apply
theorem count_apply (hs : MeasurableSet s) : count s = ∑' i : s, 1 := by
simp only [count, sum_apply, hs, dirac_apply', ← tsum_subtype s (1 : α → ℝ≥0∞), Pi.one_apply]
#align measure_theory.measure.count_apply MeasureTheory.Measure.count_apply
-- @[simp] -- Porting note (#10618): simp can prove this
theorem count_empty : count (∅ : Set α) = 0 := by rw [count_apply MeasurableSet.empty, tsum_empty]
#align measure_theory.measure.count_empty MeasureTheory.Measure.count_empty
@[simp]
theorem count_apply_finset' {s : Finset α} (s_mble : MeasurableSet (s : Set α)) :
count (↑s : Set α) = s.card :=
calc
count (↑s : Set α) = ∑' i : (↑s : Set α), 1 := count_apply s_mble
_ = ∑ i ∈ s, 1 := s.tsum_subtype 1
_ = s.card := by simp
#align measure_theory.measure.count_apply_finset' MeasureTheory.Measure.count_apply_finset'
@[simp]
theorem count_apply_finset [MeasurableSingletonClass α] (s : Finset α) :
count (↑s : Set α) = s.card :=
count_apply_finset' s.measurableSet
#align measure_theory.measure.count_apply_finset MeasureTheory.Measure.count_apply_finset
| Mathlib/MeasureTheory/Measure/Count.lean | 62 | 65 | theorem count_apply_finite' {s : Set α} (s_fin : s.Finite) (s_mble : MeasurableSet s) :
count s = s_fin.toFinset.card := by |
simp [←
@count_apply_finset' _ _ s_fin.toFinset (by simpa only [Finite.coe_toFinset] using s_mble)]
| 0 |
import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine
import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
import Mathlib.Tactic.IntervalCases
#align_import geometry.euclidean.triangle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open scoped Classical
open scoped Real
open scoped RealInnerProductSpace
namespace InnerProductGeometry
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (x y : V) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) := by
rw [show 2 * ‖x‖ * ‖y‖ * Real.cos (angle x y) = 2 * (Real.cos (angle x y) * (‖x‖ * ‖y‖)) by ring,
cos_angle_mul_norm_mul_norm, ← real_inner_self_eq_norm_mul_norm, ←
real_inner_self_eq_norm_mul_norm, ← real_inner_self_eq_norm_mul_norm, real_inner_sub_sub_self,
sub_add_eq_add_sub]
#align inner_product_geometry.norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle InnerProductGeometry.norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle
| Mathlib/Geometry/Euclidean/Triangle.lean | 71 | 75 | theorem angle_sub_eq_angle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) :
angle x (x - y) = angle y (y - x) := by |
refine Real.injOn_cos ⟨angle_nonneg _ _, angle_le_pi _ _⟩ ⟨angle_nonneg _ _, angle_le_pi _ _⟩ ?_
rw [cos_angle, cos_angle, h, ← neg_sub, norm_neg, neg_sub, inner_sub_right, inner_sub_right,
real_inner_self_eq_norm_mul_norm, real_inner_self_eq_norm_mul_norm, h, real_inner_comm x y]
| 0 |
import Mathlib.Geometry.Manifold.MFDeriv.Basic
noncomputable section
open scoped Manifold
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {f : E → E'}
{s : Set E} {x : E}
section MFDerivFderiv
theorem uniqueMDiffWithinAt_iff_uniqueDiffWithinAt :
UniqueMDiffWithinAt 𝓘(𝕜, E) s x ↔ UniqueDiffWithinAt 𝕜 s x := by
simp only [UniqueMDiffWithinAt, mfld_simps]
#align unique_mdiff_within_at_iff_unique_diff_within_at uniqueMDiffWithinAt_iff_uniqueDiffWithinAt
alias ⟨UniqueMDiffWithinAt.uniqueDiffWithinAt, UniqueDiffWithinAt.uniqueMDiffWithinAt⟩ :=
uniqueMDiffWithinAt_iff_uniqueDiffWithinAt
#align unique_mdiff_within_at.unique_diff_within_at UniqueMDiffWithinAt.uniqueDiffWithinAt
#align unique_diff_within_at.unique_mdiff_within_at UniqueDiffWithinAt.uniqueMDiffWithinAt
theorem uniqueMDiffOn_iff_uniqueDiffOn : UniqueMDiffOn 𝓘(𝕜, E) s ↔ UniqueDiffOn 𝕜 s := by
simp [UniqueMDiffOn, UniqueDiffOn, uniqueMDiffWithinAt_iff_uniqueDiffWithinAt]
#align unique_mdiff_on_iff_unique_diff_on uniqueMDiffOn_iff_uniqueDiffOn
alias ⟨UniqueMDiffOn.uniqueDiffOn, UniqueDiffOn.uniqueMDiffOn⟩ := uniqueMDiffOn_iff_uniqueDiffOn
#align unique_mdiff_on.unique_diff_on UniqueMDiffOn.uniqueDiffOn
#align unique_diff_on.unique_mdiff_on UniqueDiffOn.uniqueMDiffOn
-- Porting note (#10618): was `@[simp, mfld_simps]` but `simp` can prove it
theorem writtenInExtChartAt_model_space : writtenInExtChartAt 𝓘(𝕜, E) 𝓘(𝕜, E') x f = f :=
rfl
#align written_in_ext_chart_model_space writtenInExtChartAt_model_space
theorem hasMFDerivWithinAt_iff_hasFDerivWithinAt {f'} :
HasMFDerivWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') f s x f' ↔ HasFDerivWithinAt f f' s x := by
simpa only [HasMFDerivWithinAt, and_iff_right_iff_imp, mfld_simps] using
HasFDerivWithinAt.continuousWithinAt
#align has_mfderiv_within_at_iff_has_fderiv_within_at hasMFDerivWithinAt_iff_hasFDerivWithinAt
alias ⟨HasMFDerivWithinAt.hasFDerivWithinAt, HasFDerivWithinAt.hasMFDerivWithinAt⟩ :=
hasMFDerivWithinAt_iff_hasFDerivWithinAt
#align has_mfderiv_within_at.has_fderiv_within_at HasMFDerivWithinAt.hasFDerivWithinAt
#align has_fderiv_within_at.has_mfderiv_within_at HasFDerivWithinAt.hasMFDerivWithinAt
theorem hasMFDerivAt_iff_hasFDerivAt {f'} :
HasMFDerivAt 𝓘(𝕜, E) 𝓘(𝕜, E') f x f' ↔ HasFDerivAt f f' x := by
rw [← hasMFDerivWithinAt_univ, hasMFDerivWithinAt_iff_hasFDerivWithinAt, hasFDerivWithinAt_univ]
#align has_mfderiv_at_iff_has_fderiv_at hasMFDerivAt_iff_hasFDerivAt
alias ⟨HasMFDerivAt.hasFDerivAt, HasFDerivAt.hasMFDerivAt⟩ := hasMFDerivAt_iff_hasFDerivAt
#align has_mfderiv_at.has_fderiv_at HasMFDerivAt.hasFDerivAt
#align has_fderiv_at.has_mfderiv_at HasFDerivAt.hasMFDerivAt
theorem mdifferentiableWithinAt_iff_differentiableWithinAt :
MDifferentiableWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') f s x ↔ DifferentiableWithinAt 𝕜 f s x := by
simp only [mdifferentiableWithinAt_iff', mfld_simps]
exact ⟨fun H => H.2, fun H => ⟨H.continuousWithinAt, H⟩⟩
#align mdifferentiable_within_at_iff_differentiable_within_at mdifferentiableWithinAt_iff_differentiableWithinAt
alias ⟨MDifferentiableWithinAt.differentiableWithinAt,
DifferentiableWithinAt.mdifferentiableWithinAt⟩ :=
mdifferentiableWithinAt_iff_differentiableWithinAt
#align mdifferentiable_within_at.differentiable_within_at MDifferentiableWithinAt.differentiableWithinAt
#align differentiable_within_at.mdifferentiable_within_at DifferentiableWithinAt.mdifferentiableWithinAt
| Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean | 84 | 87 | theorem mdifferentiableAt_iff_differentiableAt :
MDifferentiableAt 𝓘(𝕜, E) 𝓘(𝕜, E') f x ↔ DifferentiableAt 𝕜 f x := by |
simp only [mdifferentiableAt_iff, differentiableWithinAt_univ, mfld_simps]
exact ⟨fun H => H.2, fun H => ⟨H.continuousAt, H⟩⟩
| 0 |
import Mathlib.LinearAlgebra.Dual
import Mathlib.LinearAlgebra.Matrix.ToLin
#align_import linear_algebra.contraction from "leanprover-community/mathlib"@"657df4339ae6ceada048c8a2980fb10e393143ec"
suppress_compilation
-- Porting note: universe metavariables behave oddly
universe w u v₁ v₂ v₃ v₄
variable {ι : Type w} (R : Type u) (M : Type v₁) (N : Type v₂)
(P : Type v₃) (Q : Type v₄)
-- Porting note: we need high priority for this to fire first; not the case in ML3
attribute [local ext high] TensorProduct.ext
section Contraction
open TensorProduct LinearMap Matrix Module
open TensorProduct
section CommSemiring
variable [CommSemiring R]
variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]
variable [Module R M] [Module R N] [Module R P] [Module R Q]
variable [DecidableEq ι] [Fintype ι] (b : Basis ι R M)
-- Porting note: doesn't like implicit ring in the tensor product
def contractLeft : Module.Dual R M ⊗[R] M →ₗ[R] R :=
(uncurry _ _ _ _).toFun LinearMap.id
#align contract_left contractLeft
-- Porting note: doesn't like implicit ring in the tensor product
def contractRight : M ⊗[R] Module.Dual R M →ₗ[R] R :=
(uncurry _ _ _ _).toFun (LinearMap.flip LinearMap.id)
#align contract_right contractRight
-- Porting note: doesn't like implicit ring in the tensor product
def dualTensorHom : Module.Dual R M ⊗[R] N →ₗ[R] M →ₗ[R] N :=
let M' := Module.Dual R M
(uncurry R M' N (M →ₗ[R] N) : _ → M' ⊗ N →ₗ[R] M →ₗ[R] N) LinearMap.smulRightₗ
#align dual_tensor_hom dualTensorHom
variable {R M N P Q}
@[simp]
theorem contractLeft_apply (f : Module.Dual R M) (m : M) : contractLeft R M (f ⊗ₜ m) = f m :=
rfl
#align contract_left_apply contractLeft_apply
@[simp]
theorem contractRight_apply (f : Module.Dual R M) (m : M) : contractRight R M (m ⊗ₜ f) = f m :=
rfl
#align contract_right_apply contractRight_apply
@[simp]
theorem dualTensorHom_apply (f : Module.Dual R M) (m : M) (n : N) :
dualTensorHom R M N (f ⊗ₜ n) m = f m • n :=
rfl
#align dual_tensor_hom_apply dualTensorHom_apply
@[simp]
theorem transpose_dualTensorHom (f : Module.Dual R M) (m : M) :
Dual.transpose (R := R) (dualTensorHom R M M (f ⊗ₜ m)) =
dualTensorHom R _ _ (Dual.eval R M m ⊗ₜ f) := by
ext f' m'
simp only [Dual.transpose_apply, coe_comp, Function.comp_apply, dualTensorHom_apply,
LinearMap.map_smulₛₗ, RingHom.id_apply, Algebra.id.smul_eq_mul, Dual.eval_apply,
LinearMap.smul_apply]
exact mul_comm _ _
#align transpose_dual_tensor_hom transpose_dualTensorHom
@[simp]
theorem dualTensorHom_prodMap_zero (f : Module.Dual R M) (p : P) :
((dualTensorHom R M P) (f ⊗ₜ[R] p)).prodMap (0 : N →ₗ[R] Q) =
dualTensorHom R (M × N) (P × Q) ((f ∘ₗ fst R M N) ⊗ₜ inl R P Q p) := by
ext <;>
simp only [coe_comp, coe_inl, Function.comp_apply, prodMap_apply, dualTensorHom_apply,
fst_apply, Prod.smul_mk, LinearMap.zero_apply, smul_zero]
#align dual_tensor_hom_prod_map_zero dualTensorHom_prodMap_zero
@[simp]
theorem zero_prodMap_dualTensorHom (g : Module.Dual R N) (q : Q) :
(0 : M →ₗ[R] P).prodMap ((dualTensorHom R N Q) (g ⊗ₜ[R] q)) =
dualTensorHom R (M × N) (P × Q) ((g ∘ₗ snd R M N) ⊗ₜ inr R P Q q) := by
ext <;>
simp only [coe_comp, coe_inr, Function.comp_apply, prodMap_apply, dualTensorHom_apply,
snd_apply, Prod.smul_mk, LinearMap.zero_apply, smul_zero]
#align zero_prod_map_dual_tensor_hom zero_prodMap_dualTensorHom
theorem map_dualTensorHom (f : Module.Dual R M) (p : P) (g : Module.Dual R N) (q : Q) :
TensorProduct.map (dualTensorHom R M P (f ⊗ₜ[R] p)) (dualTensorHom R N Q (g ⊗ₜ[R] q)) =
dualTensorHom R (M ⊗[R] N) (P ⊗[R] Q) (dualDistrib R M N (f ⊗ₜ g) ⊗ₜ[R] p ⊗ₜ[R] q) := by
ext m n
simp only [compr₂_apply, mk_apply, map_tmul, dualTensorHom_apply, dualDistrib_apply, ←
smul_tmul_smul]
#align map_dual_tensor_hom map_dualTensorHom
@[simp]
| Mathlib/LinearAlgebra/Contraction.lean | 122 | 128 | theorem comp_dualTensorHom (f : Module.Dual R M) (n : N) (g : Module.Dual R N) (p : P) :
dualTensorHom R N P (g ⊗ₜ[R] p) ∘ₗ dualTensorHom R M N (f ⊗ₜ[R] n) =
g n • dualTensorHom R M P (f ⊗ₜ p) := by |
ext m
simp only [coe_comp, Function.comp_apply, dualTensorHom_apply, LinearMap.map_smul,
RingHom.id_apply, LinearMap.smul_apply]
rw [smul_comm]
| 0 |
import Mathlib.AlgebraicTopology.SplitSimplicialObject
import Mathlib.AlgebraicTopology.DoldKan.Degeneracies
import Mathlib.AlgebraicTopology.DoldKan.FunctorN
#align_import algebraic_topology.dold_kan.split_simplicial_object from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504"
open CategoryTheory CategoryTheory.Limits CategoryTheory.Category CategoryTheory.Preadditive
CategoryTheory.Idempotents Opposite AlgebraicTopology AlgebraicTopology.DoldKan
Simplicial DoldKan
namespace SimplicialObject
namespace Splitting
variable {C : Type*} [Category C] {X : SimplicialObject C}
(s : Splitting X)
noncomputable def πSummand [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
X.obj Δ ⟶ s.N A.1.unop.len :=
s.desc Δ (fun B => by
by_cases h : B = A
· exact eqToHom (by subst h; rfl)
· exact 0)
#align simplicial_object.splitting.π_summand SimplicialObject.Splitting.πSummand
@[reassoc (attr := simp)]
theorem cofan_inj_πSummand_eq_id [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
(s.cofan Δ).inj A ≫ s.πSummand A = 𝟙 _ := by
simp [πSummand]
#align simplicial_object.splitting.ι_π_summand_eq_id SimplicialObject.Splitting.cofan_inj_πSummand_eq_id
@[reassoc (attr := simp)]
theorem cofan_inj_πSummand_eq_zero [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A B : IndexSet Δ)
(h : B ≠ A) : (s.cofan Δ).inj A ≫ s.πSummand B = 0 := by
dsimp [πSummand]
rw [ι_desc, dif_neg h.symm]
#align simplicial_object.splitting.ι_π_summand_eq_zero SimplicialObject.Splitting.cofan_inj_πSummand_eq_zero
variable [Preadditive C]
theorem decomposition_id (Δ : SimplexCategoryᵒᵖ) :
𝟙 (X.obj Δ) = ∑ A : IndexSet Δ, s.πSummand A ≫ (s.cofan Δ).inj A := by
apply s.hom_ext'
intro A
dsimp
erw [comp_id, comp_sum, Finset.sum_eq_single A, cofan_inj_πSummand_eq_id_assoc]
· intro B _ h₂
rw [s.cofan_inj_πSummand_eq_zero_assoc _ _ h₂, zero_comp]
· simp
#align simplicial_object.splitting.decomposition_id SimplicialObject.Splitting.decomposition_id
@[reassoc (attr := simp)]
theorem σ_comp_πSummand_id_eq_zero {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ s.πSummand (IndexSet.id (op [n + 1])) = 0 := by
apply s.hom_ext'
intro A
dsimp only [SimplicialObject.σ]
rw [comp_zero, s.cofan_inj_epi_naturality_assoc A (SimplexCategory.σ i).op,
cofan_inj_πSummand_eq_zero]
rw [ne_comm]
change ¬(A.epiComp (SimplexCategory.σ i).op).EqId
rw [IndexSet.eqId_iff_len_eq]
have h := SimplexCategory.len_le_of_epi (inferInstance : Epi A.e)
dsimp at h ⊢
omega
#align simplicial_object.splitting.σ_comp_π_summand_id_eq_zero SimplicialObject.Splitting.σ_comp_πSummand_id_eq_zero
| Mathlib/AlgebraicTopology/DoldKan/SplitSimplicialObject.lean | 91 | 95 | theorem cofan_inj_comp_PInfty_eq_zero {X : SimplicialObject C} (s : SimplicialObject.Splitting X)
{n : ℕ} (A : SimplicialObject.Splitting.IndexSet (op [n])) (hA : ¬A.EqId) :
(s.cofan _).inj A ≫ PInfty.f n = 0 := by |
rw [SimplicialObject.Splitting.IndexSet.eqId_iff_mono] at hA
rw [SimplicialObject.Splitting.cofan_inj_eq, assoc, degeneracy_comp_PInfty X n A.e hA, comp_zero]
| 0 |
import Mathlib.Algebra.GCDMonoid.Multiset
import Mathlib.Combinatorics.Enumerative.Partition
import Mathlib.Data.List.Rotate
import Mathlib.GroupTheory.Perm.Cycle.Factors
import Mathlib.GroupTheory.Perm.Closure
import Mathlib.Algebra.GCDMonoid.Nat
import Mathlib.Tactic.NormNum.GCD
#align_import group_theory.perm.cycle.type from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722"
namespace Equiv.Perm
open Equiv List Multiset
variable {α : Type*} [Fintype α]
section CycleType
variable [DecidableEq α]
def cycleType (σ : Perm α) : Multiset ℕ :=
σ.cycleFactorsFinset.1.map (Finset.card ∘ support)
#align equiv.perm.cycle_type Equiv.Perm.cycleType
theorem cycleType_def (σ : Perm α) :
σ.cycleType = σ.cycleFactorsFinset.1.map (Finset.card ∘ support) :=
rfl
#align equiv.perm.cycle_type_def Equiv.Perm.cycleType_def
theorem cycleType_eq' {σ : Perm α} (s : Finset (Perm α)) (h1 : ∀ f : Perm α, f ∈ s → f.IsCycle)
(h2 : (s : Set (Perm α)).Pairwise Disjoint)
(h0 : s.noncommProd id (h2.imp fun _ _ => Disjoint.commute) = σ) :
σ.cycleType = s.1.map (Finset.card ∘ support) := by
rw [cycleType_def]
congr
rw [cycleFactorsFinset_eq_finset]
exact ⟨h1, h2, h0⟩
#align equiv.perm.cycle_type_eq' Equiv.Perm.cycleType_eq'
| Mathlib/GroupTheory/Perm/Cycle/Type.lean | 67 | 75 | theorem cycleType_eq {σ : Perm α} (l : List (Perm α)) (h0 : l.prod = σ)
(h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) :
σ.cycleType = l.map (Finset.card ∘ support) := by |
have hl : l.Nodup := nodup_of_pairwise_disjoint_cycles h1 h2
rw [cycleType_eq' l.toFinset]
· simp [List.dedup_eq_self.mpr hl, (· ∘ ·)]
· simpa using h1
· simpa [hl] using h2
· simp [hl, h0]
| 0 |
import Mathlib.Algebra.GradedMonoid
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Algebra.MvPolynomial.Basic
#align_import ring_theory.mv_polynomial.weighted_homogeneous from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
noncomputable section
open Set Function Finset Finsupp AddMonoidAlgebra
variable {R M : Type*} [CommSemiring R]
namespace MvPolynomial
variable {σ : Type*}
section AddCommMonoid
variable [AddCommMonoid M]
def weightedDegree (w : σ → M) : (σ →₀ ℕ) →+ M :=
(Finsupp.total σ M ℕ w).toAddMonoidHom
#align mv_polynomial.weighted_degree' MvPolynomial.weightedDegree
theorem weightedDegree_apply (w : σ → M) (f : σ →₀ ℕ):
weightedDegree w f = Finsupp.sum f (fun i c => c • w i) := by
rfl
section SemilatticeSup
variable [SemilatticeSup M]
def weightedTotalDegree' (w : σ → M) (p : MvPolynomial σ R) : WithBot M :=
p.support.sup fun s => weightedDegree w s
#align mv_polynomial.weighted_total_degree' MvPolynomial.weightedTotalDegree'
theorem weightedTotalDegree'_eq_bot_iff (w : σ → M) (p : MvPolynomial σ R) :
weightedTotalDegree' w p = ⊥ ↔ p = 0 := by
simp only [weightedTotalDegree', Finset.sup_eq_bot_iff, mem_support_iff, WithBot.coe_ne_bot,
MvPolynomial.eq_zero_iff]
exact forall_congr' fun _ => Classical.not_not
#align mv_polynomial.weighted_total_degree'_eq_bot_iff MvPolynomial.weightedTotalDegree'_eq_bot_iff
theorem weightedTotalDegree'_zero (w : σ → M) :
weightedTotalDegree' w (0 : MvPolynomial σ R) = ⊥ := by
simp only [weightedTotalDegree', support_zero, Finset.sup_empty]
#align mv_polynomial.weighted_total_degree'_zero MvPolynomial.weightedTotalDegree'_zero
section OrderBot
variable [OrderBot M]
def weightedTotalDegree (w : σ → M) (p : MvPolynomial σ R) : M :=
p.support.sup fun s => weightedDegree w s
#align mv_polynomial.weighted_total_degree MvPolynomial.weightedTotalDegree
| Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean | 105 | 116 | theorem weightedTotalDegree_coe (w : σ → M) (p : MvPolynomial σ R) (hp : p ≠ 0) :
weightedTotalDegree' w p = ↑(weightedTotalDegree w p) := by |
rw [Ne, ← weightedTotalDegree'_eq_bot_iff w p, ← Ne, WithBot.ne_bot_iff_exists] at hp
obtain ⟨m, hm⟩ := hp
apply le_antisymm
· simp only [weightedTotalDegree, weightedTotalDegree', Finset.sup_le_iff, WithBot.coe_le_coe]
intro b
exact Finset.le_sup
· simp only [weightedTotalDegree]
have hm' : weightedTotalDegree' w p ≤ m := le_of_eq hm.symm
rw [← hm]
simpa [weightedTotalDegree'] using hm'
| 0 |
import Mathlib.RingTheory.Noetherian
import Mathlib.Algebra.DirectSum.Module
import Mathlib.Algebra.DirectSum.Finsupp
import Mathlib.Algebra.Module.Projective
import Mathlib.Algebra.Module.Injective
import Mathlib.Algebra.Module.CharacterModule
import Mathlib.LinearAlgebra.DirectSum.TensorProduct
import Mathlib.LinearAlgebra.FreeModule.Basic
import Mathlib.Algebra.Module.Projective
#align_import ring_theory.flat from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c"
universe u v w
namespace Module
open Function (Surjective)
open LinearMap Submodule TensorProduct DirectSum
variable (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M]
@[mk_iff] class Flat : Prop where
out : ∀ ⦃I : Ideal R⦄ (_ : I.FG),
Function.Injective (TensorProduct.lift ((lsmul R M).comp I.subtype))
#align module.flat Module.Flat
namespace Flat
instance self (R : Type u) [CommRing R] : Flat R R :=
⟨by
intro I _
rw [← Equiv.injective_comp (TensorProduct.rid R I).symm.toEquiv]
convert Subtype.coe_injective using 1
ext x
simp only [Function.comp_apply, LinearEquiv.coe_toEquiv, rid_symm_apply, comp_apply, mul_one,
lift.tmul, Submodule.subtype_apply, Algebra.id.smul_eq_mul, lsmul_apply]⟩
#align module.flat.self Module.Flat.self
lemma iff_rTensor_injective :
Flat R M ↔ ∀ ⦃I : Ideal R⦄ (_ : I.FG), Function.Injective (rTensor M I.subtype) := by
simp [flat_iff, ← lid_comp_rTensor]
| Mathlib/RingTheory/Flat/Basic.lean | 98 | 106 | theorem iff_rTensor_injective' :
Flat R M ↔ ∀ I : Ideal R, Function.Injective (rTensor M I.subtype) := by |
rewrite [Flat.iff_rTensor_injective]
refine ⟨fun h I => ?_, fun h I _ => h I⟩
rewrite [injective_iff_map_eq_zero]
intro x hx₀
obtain ⟨J, hfg, hle, y, rfl⟩ := Submodule.exists_fg_le_eq_rTensor_inclusion x
rewrite [← rTensor_comp_apply] at hx₀
rw [(injective_iff_map_eq_zero _).mp (h hfg) y hx₀, LinearMap.map_zero]
| 0 |
import Mathlib.Algebra.Polynomial.Degree.Lemmas
open Polynomial
namespace Mathlib.Tactic.ComputeDegree
section recursion_lemmas
variable {R : Type*}
section semiring
variable [Semiring R]
theorem natDegree_C_le (a : R) : natDegree (C a) ≤ 0 := (natDegree_C a).le
theorem natDegree_natCast_le (n : ℕ) : natDegree (n : R[X]) ≤ 0 := (natDegree_natCast _).le
theorem natDegree_zero_le : natDegree (0 : R[X]) ≤ 0 := natDegree_zero.le
theorem natDegree_one_le : natDegree (1 : R[X]) ≤ 0 := natDegree_one.le
@[deprecated (since := "2024-04-17")]
alias natDegree_nat_cast_le := natDegree_natCast_le
theorem coeff_add_of_eq {n : ℕ} {a b : R} {f g : R[X]}
(h_add_left : f.coeff n = a) (h_add_right : g.coeff n = b) :
(f + g).coeff n = a + b := by subst ‹_› ‹_›; apply coeff_add
| Mathlib/Tactic/ComputeDegree.lean | 105 | 115 | theorem coeff_mul_add_of_le_natDegree_of_eq_ite {d df dg : ℕ} {a b : R} {f g : R[X]}
(h_mul_left : natDegree f ≤ df) (h_mul_right : natDegree g ≤ dg)
(h_mul_left : f.coeff df = a) (h_mul_right : g.coeff dg = b) (ddf : df + dg ≤ d) :
(f * g).coeff d = if d = df + dg then a * b else 0 := by |
split_ifs with h
· subst h_mul_left h_mul_right h
exact coeff_mul_of_natDegree_le ‹_› ‹_›
· apply coeff_eq_zero_of_natDegree_lt
apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ddf ?_)
· exact natDegree_mul_le_of_le ‹_› ‹_›
· exact ne_comm.mp h
| 0 |
import Mathlib.Data.List.Cycle
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.Perm.List
#align_import group_theory.perm.cycle.concrete from "leanprover-community/mathlib"@"00638177efd1b2534fc5269363ebf42a7871df9a"
open Equiv Equiv.Perm List
variable {α : Type*}
namespace Equiv.Perm
section Fintype
variable [Fintype α] [DecidableEq α] (p : Equiv.Perm α) (x : α)
def toList : List α :=
(List.range (cycleOf p x).support.card).map fun k => (p ^ k) x
#align equiv.perm.to_list Equiv.Perm.toList
@[simp]
theorem toList_one : toList (1 : Perm α) x = [] := by simp [toList, cycleOf_one]
#align equiv.perm.to_list_one Equiv.Perm.toList_one
@[simp]
theorem toList_eq_nil_iff {p : Perm α} {x} : toList p x = [] ↔ x ∉ p.support := by simp [toList]
#align equiv.perm.to_list_eq_nil_iff Equiv.Perm.toList_eq_nil_iff
@[simp]
theorem length_toList : length (toList p x) = (cycleOf p x).support.card := by simp [toList]
#align equiv.perm.length_to_list Equiv.Perm.length_toList
theorem toList_ne_singleton (y : α) : toList p x ≠ [y] := by
intro H
simpa [card_support_ne_one] using congr_arg length H
#align equiv.perm.to_list_ne_singleton Equiv.Perm.toList_ne_singleton
theorem two_le_length_toList_iff_mem_support {p : Perm α} {x : α} :
2 ≤ length (toList p x) ↔ x ∈ p.support := by simp
#align equiv.perm.two_le_length_to_list_iff_mem_support Equiv.Perm.two_le_length_toList_iff_mem_support
theorem length_toList_pos_of_mem_support (h : x ∈ p.support) : 0 < length (toList p x) :=
zero_lt_two.trans_le (two_le_length_toList_iff_mem_support.mpr h)
#align equiv.perm.length_to_list_pos_of_mem_support Equiv.Perm.length_toList_pos_of_mem_support
theorem get_toList (n : ℕ) (hn : n < length (toList p x)) :
(toList p x).get ⟨n, hn⟩ = (p ^ n) x := by simp [toList]
theorem toList_get_zero (h : x ∈ p.support) :
(toList p x).get ⟨0, (length_toList_pos_of_mem_support _ _ h)⟩ = x := by simp [toList]
set_option linter.deprecated false in
@[deprecated get_toList (since := "2024-05-08")]
theorem nthLe_toList (n : ℕ) (hn : n < length (toList p x)) :
(toList p x).nthLe n hn = (p ^ n) x := by simp [toList]
#align equiv.perm.nth_le_to_list Equiv.Perm.nthLe_toList
set_option linter.deprecated false in
@[deprecated toList_get_zero (since := "2024-05-08")]
theorem toList_nthLe_zero (h : x ∈ p.support) :
(toList p x).nthLe 0 (length_toList_pos_of_mem_support _ _ h) = x := by simp [toList]
#align equiv.perm.to_list_nth_le_zero Equiv.Perm.toList_nthLe_zero
variable {p} {x}
theorem mem_toList_iff {y : α} : y ∈ toList p x ↔ SameCycle p x y ∧ x ∈ p.support := by
simp only [toList, mem_range, mem_map]
constructor
· rintro ⟨n, hx, rfl⟩
refine ⟨⟨n, rfl⟩, ?_⟩
contrapose! hx
rw [← support_cycleOf_eq_nil_iff] at hx
simp [hx]
· rintro ⟨h, hx⟩
simpa using h.exists_pow_eq_of_mem_support hx
#align equiv.perm.mem_to_list_iff Equiv.Perm.mem_toList_iff
set_option linter.deprecated false in
| Mathlib/GroupTheory/Perm/Cycle/Concrete.lean | 278 | 308 | theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by |
by_cases hx : p x = x
· rw [← not_mem_support, ← toList_eq_nil_iff] at hx
simp [hx]
have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
rw [nodup_iff_nthLe_inj]
rintro n m hn hm
rw [length_toList, ← hc.orderOf] at hm hn
rw [← cycleOf_apply_self, ← Ne, ← mem_support] at hx
rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
cycleOf_pow_apply_self p x m]
cases' n with n <;> cases' m with m
· simp
· rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
cycleOf_pow_apply_self] at hx
simp [hx.symm]
· rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
cycleOf_pow_apply_self] at hx
simp [hx]
intro h
have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
rw [← hc.support_pow_eq_iff] at hn' hm'
rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
refine support_congr ?_ ?_
· rw [hm', hn']
· rw [hm']
intro y hy
obtain ⟨k, rfl⟩ := hc.exists_pow_eq (mem_support.mp hx) (mem_support.mp hy)
rw [← mul_apply, (Commute.pow_pow_self _ _ _).eq, mul_apply, h, ← mul_apply, ← mul_apply,
(Commute.pow_pow_self _ _ _).eq]
| 0 |
import Mathlib.Algebra.Algebra.Equiv
import Mathlib.Algebra.Algebra.NonUnitalHom
import Mathlib.Algebra.BigOperators.Finsupp
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Finsupp.Basic
import Mathlib.LinearAlgebra.Finsupp
#align_import algebra.monoid_algebra.basic from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69"
noncomputable section
open Finset
open Finsupp hiding single mapDomain
universe u₁ u₂ u₃ u₄
variable (k : Type u₁) (G : Type u₂) (H : Type*) {R : Type*}
section
variable [Semiring k]
def MonoidAlgebra : Type max u₁ u₂ :=
G →₀ k
#align monoid_algebra MonoidAlgebra
-- Porting note: The compiler couldn't derive this.
instance MonoidAlgebra.inhabited : Inhabited (MonoidAlgebra k G) :=
inferInstanceAs (Inhabited (G →₀ k))
#align monoid_algebra.inhabited MonoidAlgebra.inhabited
-- Porting note: The compiler couldn't derive this.
instance MonoidAlgebra.addCommMonoid : AddCommMonoid (MonoidAlgebra k G) :=
inferInstanceAs (AddCommMonoid (G →₀ k))
#align monoid_algebra.add_comm_monoid MonoidAlgebra.addCommMonoid
instance MonoidAlgebra.instIsCancelAdd [IsCancelAdd k] : IsCancelAdd (MonoidAlgebra k G) :=
inferInstanceAs (IsCancelAdd (G →₀ k))
instance MonoidAlgebra.coeFun : CoeFun (MonoidAlgebra k G) fun _ => G → k :=
Finsupp.instCoeFun
#align monoid_algebra.has_coe_to_fun MonoidAlgebra.coeFun
end
namespace MonoidAlgebra
variable {k G}
section
variable [Semiring k] [NonUnitalNonAssocSemiring R]
-- Porting note: `reducible` cannot be `local`, so we replace some definitions and theorems with
-- new ones which have new types.
abbrev single (a : G) (b : k) : MonoidAlgebra k G := Finsupp.single a b
theorem single_zero (a : G) : (single a 0 : MonoidAlgebra k G) = 0 := Finsupp.single_zero a
theorem single_add (a : G) (b₁ b₂ : k) : single a (b₁ + b₂) = single a b₁ + single a b₂ :=
Finsupp.single_add a b₁ b₂
@[simp]
theorem sum_single_index {N} [AddCommMonoid N] {a : G} {b : k} {h : G → k → N}
(h_zero : h a 0 = 0) :
(single a b).sum h = h a b := Finsupp.sum_single_index h_zero
@[simp]
theorem sum_single (f : MonoidAlgebra k G) : f.sum single = f :=
Finsupp.sum_single f
theorem single_apply {a a' : G} {b : k} [Decidable (a = a')] :
single a b a' = if a = a' then b else 0 :=
Finsupp.single_apply
@[simp]
theorem single_eq_zero {a : G} {b : k} : single a b = 0 ↔ b = 0 := Finsupp.single_eq_zero
abbrev mapDomain {G' : Type*} (f : G → G') (v : MonoidAlgebra k G) : MonoidAlgebra k G' :=
Finsupp.mapDomain f v
theorem mapDomain_sum {k' G' : Type*} [Semiring k'] {f : G → G'} {s : MonoidAlgebra k' G}
{v : G → k' → MonoidAlgebra k G} :
mapDomain f (s.sum v) = s.sum fun a b => mapDomain f (v a b) :=
Finsupp.mapDomain_sum
def liftNC (f : k →+ R) (g : G → R) : MonoidAlgebra k G →+ R :=
liftAddHom fun x : G => (AddMonoidHom.mulRight (g x)).comp f
#align monoid_algebra.lift_nc MonoidAlgebra.liftNC
@[simp]
theorem liftNC_single (f : k →+ R) (g : G → R) (a : G) (b : k) :
liftNC f g (single a b) = f b * g a :=
liftAddHom_apply_single _ _ _
#align monoid_algebra.lift_nc_single MonoidAlgebra.liftNC_single
end
section Mul
variable [Semiring k] [Mul G]
@[irreducible] def mul' (f g : MonoidAlgebra k G) : MonoidAlgebra k G :=
f.sum fun a₁ b₁ => g.sum fun a₂ b₂ => single (a₁ * a₂) (b₁ * b₂)
instance instMul : Mul (MonoidAlgebra k G) := ⟨MonoidAlgebra.mul'⟩
#align monoid_algebra.has_mul MonoidAlgebra.instMul
theorem mul_def {f g : MonoidAlgebra k G} :
f * g = f.sum fun a₁ b₁ => g.sum fun a₂ b₂ => single (a₁ * a₂) (b₁ * b₂) := by
with_unfolding_all rfl
#align monoid_algebra.mul_def MonoidAlgebra.mul_def
instance nonUnitalNonAssocSemiring : NonUnitalNonAssocSemiring (MonoidAlgebra k G) :=
{ Finsupp.instAddCommMonoid with
-- Porting note: `refine` & `exact` are required because `simp` behaves differently.
left_distrib := fun f g h => by
haveI := Classical.decEq G
simp only [mul_def]
refine Eq.trans (congr_arg (sum f) (funext₂ fun a₁ b₁ => sum_add_index ?_ ?_)) ?_ <;>
simp only [mul_add, mul_zero, single_zero, single_add, forall_true_iff, sum_add]
right_distrib := fun f g h => by
haveI := Classical.decEq G
simp only [mul_def]
refine Eq.trans (sum_add_index ?_ ?_) ?_ <;>
simp only [add_mul, zero_mul, single_zero, single_add, forall_true_iff, sum_zero, sum_add]
zero_mul := fun f => by
simp only [mul_def]
exact sum_zero_index
mul_zero := fun f => by
simp only [mul_def]
exact Eq.trans (congr_arg (sum f) (funext₂ fun a₁ b₁ => sum_zero_index)) sum_zero }
#align monoid_algebra.non_unital_non_assoc_semiring MonoidAlgebra.nonUnitalNonAssocSemiring
variable [Semiring R]
| Mathlib/Algebra/MonoidAlgebra/Basic.lean | 202 | 210 | theorem liftNC_mul {g_hom : Type*} [FunLike g_hom G R] [MulHomClass g_hom G R]
(f : k →+* R) (g : g_hom) (a b : MonoidAlgebra k G)
(h_comm : ∀ {x y}, y ∈ a.support → Commute (f (b x)) (g y)) :
liftNC (f : k →+ R) g (a * b) = liftNC (f : k →+ R) g a * liftNC (f : k →+ R) g b := by |
conv_rhs => rw [← sum_single a, ← sum_single b]
-- Porting note: `(liftNC _ g).map_finsupp_sum` → `map_finsupp_sum`
simp_rw [mul_def, map_finsupp_sum, liftNC_single, Finsupp.sum_mul, Finsupp.mul_sum]
refine Finset.sum_congr rfl fun y hy => Finset.sum_congr rfl fun x _hx => ?_
simp [mul_assoc, (h_comm hy).left_comm]
| 0 |
import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv
import Mathlib.LinearAlgebra.Dual
#align_import analysis.calculus.lagrange_multipliers from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Filter Set
open scoped Topology Filter
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {f : E → F} {φ : E → ℝ} {x₀ : E}
{f' : E →L[ℝ] F} {φ' : E →L[ℝ] ℝ}
theorem IsLocalExtrOn.range_ne_top_of_hasStrictFDerivAt
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) : LinearMap.range (f'.prod φ') ≠ ⊤ := by
intro htop
set fφ := fun x => (f x, φ x)
have A : map φ (𝓝[f ⁻¹' {f x₀}] x₀) = 𝓝 (φ x₀) := by
change map (Prod.snd ∘ fφ) (𝓝[fφ ⁻¹' {p | p.1 = f x₀}] x₀) = 𝓝 (φ x₀)
rw [← map_map, nhdsWithin, map_inf_principal_preimage, (hf'.prod hφ').map_nhds_eq_of_surj htop]
exact map_snd_nhdsWithin _
exact hextr.not_nhds_le_map A.ge
#align is_local_extr_on.range_ne_top_of_has_strict_fderiv_at IsLocalExtrOn.range_ne_top_of_hasStrictFDerivAt
theorem IsLocalExtrOn.exists_linear_map_of_hasStrictFDerivAt
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) :
∃ (Λ : Module.Dual ℝ F) (Λ₀ : ℝ), (Λ, Λ₀) ≠ 0 ∧ ∀ x, Λ (f' x) + Λ₀ • φ' x = 0 := by
rcases Submodule.exists_le_ker_of_lt_top _
(lt_top_iff_ne_top.2 <| hextr.range_ne_top_of_hasStrictFDerivAt hf' hφ') with
⟨Λ', h0, hΛ'⟩
set e : ((F →ₗ[ℝ] ℝ) × ℝ) ≃ₗ[ℝ] F × ℝ →ₗ[ℝ] ℝ :=
((LinearEquiv.refl ℝ (F →ₗ[ℝ] ℝ)).prod (LinearMap.ringLmapEquivSelf ℝ ℝ ℝ).symm).trans
(LinearMap.coprodEquiv ℝ)
rcases e.surjective Λ' with ⟨⟨Λ, Λ₀⟩, rfl⟩
refine ⟨Λ, Λ₀, e.map_ne_zero_iff.1 h0, fun x => ?_⟩
convert LinearMap.congr_fun (LinearMap.range_le_ker_iff.1 hΛ') x using 1
-- squeezed `simp [mul_comm]` to speed up elaboration
simp only [e, smul_eq_mul, LinearEquiv.trans_apply, LinearEquiv.prod_apply,
LinearEquiv.refl_apply, LinearMap.ringLmapEquivSelf_symm_apply, LinearMap.coprodEquiv_apply,
ContinuousLinearMap.coe_prod, LinearMap.coprod_comp_prod, LinearMap.add_apply,
LinearMap.coe_comp, ContinuousLinearMap.coe_coe, Function.comp_apply, LinearMap.coe_smulRight,
LinearMap.one_apply, mul_comm]
#align is_local_extr_on.exists_linear_map_of_has_strict_fderiv_at IsLocalExtrOn.exists_linear_map_of_hasStrictFDerivAt
| Mathlib/Analysis/Calculus/LagrangeMultipliers.lean | 84 | 97 | theorem IsLocalExtrOn.exists_multipliers_of_hasStrictFDerivAt_1d {f : E → ℝ} {f' : E →L[ℝ] ℝ}
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) : ∃ a b : ℝ, (a, b) ≠ 0 ∧ a • f' + b • φ' = 0 := by |
obtain ⟨Λ, Λ₀, hΛ, hfΛ⟩ := hextr.exists_linear_map_of_hasStrictFDerivAt hf' hφ'
refine ⟨Λ 1, Λ₀, ?_, ?_⟩
· contrapose! hΛ
simp only [Prod.mk_eq_zero] at hΛ ⊢
refine ⟨LinearMap.ext fun x => ?_, hΛ.2⟩
simpa [hΛ.1] using Λ.map_smul x 1
· ext x
have H₁ : Λ (f' x) = f' x * Λ 1 := by
simpa only [mul_one, Algebra.id.smul_eq_mul] using Λ.map_smul (f' x) 1
have H₂ : f' x * Λ 1 + Λ₀ * φ' x = 0 := by simpa only [Algebra.id.smul_eq_mul, H₁] using hfΛ x
simpa [mul_comm] using H₂
| 0 |
import Mathlib.Analysis.SpecialFunctions.Log.Base
import Mathlib.MeasureTheory.Measure.MeasureSpaceDef
#align_import measure_theory.measure.doubling from "leanprover-community/mathlib"@"5f6e827d81dfbeb6151d7016586ceeb0099b9655"
noncomputable section
open Set Filter Metric MeasureTheory TopologicalSpace ENNReal NNReal Topology
class IsUnifLocDoublingMeasure {α : Type*} [MetricSpace α] [MeasurableSpace α]
(μ : Measure α) : Prop where
exists_measure_closedBall_le_mul'' :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε)
#align is_unif_loc_doubling_measure IsUnifLocDoublingMeasure
namespace IsUnifLocDoublingMeasure
variable {α : Type*} [MetricSpace α] [MeasurableSpace α] (μ : Measure α)
[IsUnifLocDoublingMeasure μ]
-- Porting note: added for missing infer kinds
theorem exists_measure_closedBall_le_mul :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε) :=
exists_measure_closedBall_le_mul''
def doublingConstant : ℝ≥0 :=
Classical.choose <| exists_measure_closedBall_le_mul μ
#align is_unif_loc_doubling_measure.doubling_constant IsUnifLocDoublingMeasure.doublingConstant
theorem exists_measure_closedBall_le_mul' :
∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ doublingConstant μ * μ (closedBall x ε) :=
Classical.choose_spec <| exists_measure_closedBall_le_mul μ
#align is_unif_loc_doubling_measure.exists_measure_closed_ball_le_mul' IsUnifLocDoublingMeasure.exists_measure_closedBall_le_mul'
theorem exists_eventually_forall_measure_closedBall_le_mul (K : ℝ) :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, ∀ t ≤ K, μ (closedBall x (t * ε)) ≤ C * μ (closedBall x ε) := by
let C := doublingConstant μ
have hμ :
∀ n : ℕ, ∀ᶠ ε in 𝓝[>] 0, ∀ x,
μ (closedBall x ((2 : ℝ) ^ n * ε)) ≤ ↑(C ^ n) * μ (closedBall x ε) := by
intro n
induction' n with n ih
· simp
replace ih := eventually_nhdsWithin_pos_mul_left (two_pos : 0 < (2 : ℝ)) ih
refine (ih.and (exists_measure_closedBall_le_mul' μ)).mono fun ε hε x => ?_
calc
μ (closedBall x ((2 : ℝ) ^ (n + 1) * ε)) = μ (closedBall x ((2 : ℝ) ^ n * (2 * ε))) := by
rw [pow_succ, mul_assoc]
_ ≤ ↑(C ^ n) * μ (closedBall x (2 * ε)) := hε.1 x
_ ≤ ↑(C ^ n) * (C * μ (closedBall x ε)) := by gcongr; exact hε.2 x
_ = ↑(C ^ (n + 1)) * μ (closedBall x ε) := by rw [← mul_assoc, pow_succ, ENNReal.coe_mul]
rcases lt_or_le K 1 with (hK | hK)
· refine ⟨1, ?_⟩
simp only [ENNReal.coe_one, one_mul]
refine eventually_mem_nhdsWithin.mono fun ε hε x t ht ↦ ?_
gcongr
nlinarith [mem_Ioi.mp hε]
· use C ^ ⌈Real.logb 2 K⌉₊
filter_upwards [hμ ⌈Real.logb 2 K⌉₊, eventually_mem_nhdsWithin] with ε hε hε₀ x t ht
refine le_trans ?_ (hε x)
gcongr
· exact (mem_Ioi.mp hε₀).le
· refine ht.trans ?_
rw [← Real.rpow_natCast, ← Real.logb_le_iff_le_rpow]
exacts [Nat.le_ceil _, by norm_num, by linarith]
#align is_unif_loc_doubling_measure.exists_eventually_forall_measure_closed_ball_le_mul IsUnifLocDoublingMeasure.exists_eventually_forall_measure_closedBall_le_mul
def scalingConstantOf (K : ℝ) : ℝ≥0 :=
max (Classical.choose <| exists_eventually_forall_measure_closedBall_le_mul μ K) 1
#align is_unif_loc_doubling_measure.scaling_constant_of IsUnifLocDoublingMeasure.scalingConstantOf
@[simp]
theorem one_le_scalingConstantOf (K : ℝ) : 1 ≤ scalingConstantOf μ K :=
le_max_of_le_right <| le_refl 1
#align is_unif_loc_doubling_measure.one_le_scaling_constant_of IsUnifLocDoublingMeasure.one_le_scalingConstantOf
theorem eventually_measure_mul_le_scalingConstantOf_mul (K : ℝ) :
∃ R : ℝ,
0 < R ∧
∀ x t r, t ∈ Ioc 0 K → r ≤ R →
μ (closedBall x (t * r)) ≤ scalingConstantOf μ K * μ (closedBall x r) := by
have h := Classical.choose_spec (exists_eventually_forall_measure_closedBall_le_mul μ K)
rcases mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 h with ⟨R, Rpos, hR⟩
refine ⟨R, Rpos, fun x t r ht hr => ?_⟩
rcases lt_trichotomy r 0 with (rneg | rfl | rpos)
· have : t * r < 0 := mul_neg_of_pos_of_neg ht.1 rneg
simp only [closedBall_eq_empty.2 this, measure_empty, zero_le']
· simp only [mul_zero, closedBall_zero]
refine le_mul_of_one_le_of_le ?_ le_rfl
apply ENNReal.one_le_coe_iff.2 (le_max_right _ _)
· apply (hR ⟨rpos, hr⟩ x t ht.2).trans
gcongr
apply le_max_left
#align is_unif_loc_doubling_measure.eventually_measure_mul_le_scaling_constant_of_mul IsUnifLocDoublingMeasure.eventually_measure_mul_le_scalingConstantOf_mul
| Mathlib/MeasureTheory/Measure/Doubling.lean | 132 | 136 | theorem eventually_measure_le_scaling_constant_mul (K : ℝ) :
∀ᶠ r in 𝓝[>] 0, ∀ x, μ (closedBall x (K * r)) ≤ scalingConstantOf μ K * μ (closedBall x r) := by |
filter_upwards [Classical.choose_spec
(exists_eventually_forall_measure_closedBall_le_mul μ K)] with r hr x
exact (hr x K le_rfl).trans (mul_le_mul_right' (ENNReal.coe_le_coe.2 (le_max_left _ _)) _)
| 0 |
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Tactic.Ring
#align_import data.nat.hyperoperation from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
def hyperoperation : ℕ → ℕ → ℕ → ℕ
| 0, _, k => k + 1
| 1, m, 0 => m
| 2, _, 0 => 0
| _ + 3, _, 0 => 1
| n + 1, m, k + 1 => hyperoperation n m (hyperoperation (n + 1) m k)
#align hyperoperation hyperoperation
-- Basic hyperoperation lemmas
@[simp]
theorem hyperoperation_zero (m : ℕ) : hyperoperation 0 m = Nat.succ :=
funext fun k => by rw [hyperoperation, Nat.succ_eq_add_one]
#align hyperoperation_zero hyperoperation_zero
theorem hyperoperation_ge_three_eq_one (n m : ℕ) : hyperoperation (n + 3) m 0 = 1 := by
rw [hyperoperation]
#align hyperoperation_ge_three_eq_one hyperoperation_ge_three_eq_one
theorem hyperoperation_recursion (n m k : ℕ) :
hyperoperation (n + 1) m (k + 1) = hyperoperation n m (hyperoperation (n + 1) m k) := by
rw [hyperoperation]
#align hyperoperation_recursion hyperoperation_recursion
-- Interesting hyperoperation lemmas
@[simp]
theorem hyperoperation_one : hyperoperation 1 = (· + ·) := by
ext m k
induction' k with bn bih
· rw [Nat.add_zero m, hyperoperation]
· rw [hyperoperation_recursion, bih, hyperoperation_zero]
exact Nat.add_assoc m bn 1
#align hyperoperation_one hyperoperation_one
@[simp]
theorem hyperoperation_two : hyperoperation 2 = (· * ·) := by
ext m k
induction' k with bn bih
· rw [hyperoperation]
exact (Nat.mul_zero m).symm
· rw [hyperoperation_recursion, hyperoperation_one, bih]
-- Porting note: was `ring`
dsimp only
nth_rewrite 1 [← mul_one m]
rw [← mul_add, add_comm]
#align hyperoperation_two hyperoperation_two
@[simp]
theorem hyperoperation_three : hyperoperation 3 = (· ^ ·) := by
ext m k
induction' k with bn bih
· rw [hyperoperation_ge_three_eq_one]
exact (pow_zero m).symm
· rw [hyperoperation_recursion, hyperoperation_two, bih]
exact (pow_succ' m bn).symm
#align hyperoperation_three hyperoperation_three
theorem hyperoperation_ge_two_eq_self (n m : ℕ) : hyperoperation (n + 2) m 1 = m := by
induction' n with nn nih
· rw [hyperoperation_two]
ring
· rw [hyperoperation_recursion, hyperoperation_ge_three_eq_one, nih]
#align hyperoperation_ge_two_eq_self hyperoperation_ge_two_eq_self
theorem hyperoperation_two_two_eq_four (n : ℕ) : hyperoperation (n + 1) 2 2 = 4 := by
induction' n with nn nih
· rw [hyperoperation_one]
· rw [hyperoperation_recursion, hyperoperation_ge_two_eq_self, nih]
#align hyperoperation_two_two_eq_four hyperoperation_two_two_eq_four
theorem hyperoperation_ge_three_one (n : ℕ) : ∀ k : ℕ, hyperoperation (n + 3) 1 k = 1 := by
induction' n with nn nih
· intro k
rw [hyperoperation_three]
dsimp
rw [one_pow]
· intro k
cases k
· rw [hyperoperation_ge_three_eq_one]
· rw [hyperoperation_recursion, nih]
#align hyperoperation_ge_three_one hyperoperation_ge_three_one
| Mathlib/Data/Nat/Hyperoperation.lean | 116 | 126 | theorem hyperoperation_ge_four_zero (n k : ℕ) :
hyperoperation (n + 4) 0 k = if Even k then 1 else 0 := by |
induction' k with kk kih
· rw [hyperoperation_ge_three_eq_one]
simp only [Nat.zero_eq, even_zero, if_true]
· rw [hyperoperation_recursion]
rw [kih]
simp_rw [Nat.even_add_one]
split_ifs
· exact hyperoperation_ge_two_eq_self (n + 1) 0
· exact hyperoperation_ge_three_eq_one n 0
| 0 |
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
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]
#align module.End.has_eigenvalue_iff_mem_spectrum Module.End.hasEigenvalue_iff_mem_spectrum
alias ⟨_, HasEigenvalue.of_mem_spectrum⟩ := hasEigenvalue_iff_mem_spectrum
| Mathlib/LinearAlgebra/Eigenspace/Basic.lean | 154 | 163 | theorem eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
eigenspace f (a / b) = LinearMap.ker (b • f - algebraMap K (End K V) a) :=
calc
eigenspace f (a / b) = eigenspace f (b⁻¹ * a) := by | rw [div_eq_mul_inv, mul_comm]
_ = LinearMap.ker (f - (b⁻¹ * a) • LinearMap.id) := by rw [eigenspace]; rfl
_ = LinearMap.ker (f - b⁻¹ • a • LinearMap.id) := by rw [smul_smul]
_ = LinearMap.ker (f - b⁻¹ • algebraMap K (End K V) a) := rfl
_ = LinearMap.ker (b • (f - b⁻¹ • algebraMap K (End K V) a)) := by
rw [LinearMap.ker_smul _ b hb]
_ = LinearMap.ker (b • f - algebraMap K (End K V) a) := by rw [smul_sub, smul_inv_smul₀ hb]
| 0 |
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.Polynomial.Degree.Lemmas
#align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448"
noncomputable section
open Polynomial
open Polynomial Finset
namespace Polynomial
variable {R : Type*} [Semiring R] {f : R[X]}
def eraseLead (f : R[X]) : R[X] :=
Polynomial.erase f.natDegree f
#align polynomial.erase_lead Polynomial.eraseLead
section EraseLead
theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by
simp only [eraseLead, support_erase]
#align polynomial.erase_lead_support Polynomial.eraseLead_support
theorem eraseLead_coeff (i : ℕ) :
f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by
simp only [eraseLead, coeff_erase]
#align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff
@[simp]
theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by simp [eraseLead_coeff]
#align polynomial.erase_lead_coeff_nat_degree Polynomial.eraseLead_coeff_natDegree
theorem eraseLead_coeff_of_ne (i : ℕ) (hi : i ≠ f.natDegree) : f.eraseLead.coeff i = f.coeff i := by
simp [eraseLead_coeff, hi]
#align polynomial.erase_lead_coeff_of_ne Polynomial.eraseLead_coeff_of_ne
@[simp]
theorem eraseLead_zero : eraseLead (0 : R[X]) = 0 := by simp only [eraseLead, erase_zero]
#align polynomial.erase_lead_zero Polynomial.eraseLead_zero
@[simp]
theorem eraseLead_add_monomial_natDegree_leadingCoeff (f : R[X]) :
f.eraseLead + monomial f.natDegree f.leadingCoeff = f :=
(add_comm _ _).trans (f.monomial_add_erase _)
#align polynomial.erase_lead_add_monomial_nat_degree_leading_coeff Polynomial.eraseLead_add_monomial_natDegree_leadingCoeff
@[simp]
theorem eraseLead_add_C_mul_X_pow (f : R[X]) :
f.eraseLead + C f.leadingCoeff * X ^ f.natDegree = f := by
rw [C_mul_X_pow_eq_monomial, eraseLead_add_monomial_natDegree_leadingCoeff]
set_option linter.uppercaseLean3 false in
#align polynomial.erase_lead_add_C_mul_X_pow Polynomial.eraseLead_add_C_mul_X_pow
@[simp]
theorem self_sub_monomial_natDegree_leadingCoeff {R : Type*} [Ring R] (f : R[X]) :
f - monomial f.natDegree f.leadingCoeff = f.eraseLead :=
(eq_sub_iff_add_eq.mpr (eraseLead_add_monomial_natDegree_leadingCoeff f)).symm
#align polynomial.self_sub_monomial_nat_degree_leading_coeff Polynomial.self_sub_monomial_natDegree_leadingCoeff
@[simp]
theorem self_sub_C_mul_X_pow {R : Type*} [Ring R] (f : R[X]) :
f - C f.leadingCoeff * X ^ f.natDegree = f.eraseLead := by
rw [C_mul_X_pow_eq_monomial, self_sub_monomial_natDegree_leadingCoeff]
set_option linter.uppercaseLean3 false in
#align polynomial.self_sub_C_mul_X_pow Polynomial.self_sub_C_mul_X_pow
theorem eraseLead_ne_zero (f0 : 2 ≤ f.support.card) : eraseLead f ≠ 0 := by
rw [Ne, ← card_support_eq_zero, eraseLead_support]
exact
(zero_lt_one.trans_le <| (tsub_le_tsub_right f0 1).trans Finset.pred_card_le_card_erase).ne.symm
#align polynomial.erase_lead_ne_zero Polynomial.eraseLead_ne_zero
theorem lt_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) :
a < f.natDegree := by
rw [eraseLead_support, mem_erase] at h
exact (le_natDegree_of_mem_supp a h.2).lt_of_ne h.1
#align polynomial.lt_nat_degree_of_mem_erase_lead_support Polynomial.lt_natDegree_of_mem_eraseLead_support
theorem ne_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) :
a ≠ f.natDegree :=
(lt_natDegree_of_mem_eraseLead_support h).ne
#align polynomial.ne_nat_degree_of_mem_erase_lead_support Polynomial.ne_natDegree_of_mem_eraseLead_support
theorem natDegree_not_mem_eraseLead_support : f.natDegree ∉ (eraseLead f).support := fun h =>
ne_natDegree_of_mem_eraseLead_support h rfl
#align polynomial.nat_degree_not_mem_erase_lead_support Polynomial.natDegree_not_mem_eraseLead_support
theorem eraseLead_support_card_lt (h : f ≠ 0) : (eraseLead f).support.card < f.support.card := by
rw [eraseLead_support]
exact card_lt_card (erase_ssubset <| natDegree_mem_support_of_nonzero h)
#align polynomial.erase_lead_support_card_lt Polynomial.eraseLead_support_card_lt
| Mathlib/Algebra/Polynomial/EraseLead.lean | 115 | 124 | theorem card_support_eraseLead_add_one (h : f ≠ 0) :
f.eraseLead.support.card + 1 = f.support.card := by |
set c := f.support.card with hc
cases h₁ : c
case zero =>
by_contra
exact h (card_support_eq_zero.mp h₁)
case succ =>
rw [eraseLead_support, card_erase_of_mem (natDegree_mem_support_of_nonzero h), ← hc, h₁]
rfl
| 0 |
import Mathlib.Algebra.EuclideanDomain.Defs
import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Algebra.Ring.Regular
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.Ring.Basic
#align_import algebra.euclidean_domain.basic from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6"
universe u
namespace EuclideanDomain
variable {R : Type u}
variable [EuclideanDomain R]
local infixl:50 " ≺ " => EuclideanDomain.R
-- See note [lower instance priority]
instance (priority := 100) toMulDivCancelClass : MulDivCancelClass R where
mul_div_cancel a b hb := by
refine (eq_of_sub_eq_zero ?_).symm
by_contra h
have := mul_right_not_lt b h
rw [sub_mul, mul_comm (_ / _), sub_eq_iff_eq_add'.2 (div_add_mod (a * b) b).symm] at this
exact this (mod_lt _ hb)
#align euclidean_domain.mul_div_cancel_left mul_div_cancel_left₀
#align euclidean_domain.mul_div_cancel mul_div_cancel_right₀
@[simp]
theorem mod_eq_zero {a b : R} : a % b = 0 ↔ b ∣ a :=
⟨fun h => by
rw [← div_add_mod a b, h, add_zero]
exact dvd_mul_right _ _, fun ⟨c, e⟩ => by
rw [e, ← add_left_cancel_iff, div_add_mod, add_zero]
haveI := Classical.dec
by_cases b0 : b = 0
· simp only [b0, zero_mul]
· rw [mul_div_cancel_left₀ _ b0]⟩
#align euclidean_domain.mod_eq_zero EuclideanDomain.mod_eq_zero
@[simp]
theorem mod_self (a : R) : a % a = 0 :=
mod_eq_zero.2 dvd_rfl
#align euclidean_domain.mod_self EuclideanDomain.mod_self
| Mathlib/Algebra/EuclideanDomain/Basic.lean | 63 | 64 | theorem dvd_mod_iff {a b c : R} (h : c ∣ b) : c ∣ a % b ↔ c ∣ a := by |
rw [← dvd_add_right (h.mul_right _), div_add_mod]
| 0 |
import Mathlib.CategoryTheory.Limits.Types
import Mathlib.CategoryTheory.IsConnected
import Mathlib.CategoryTheory.Limits.Final
import Mathlib.CategoryTheory.Conj
universe w v u
namespace CategoryTheory.Limits.Types
variable (C : Type u) [Category.{v} C]
def constPUnitFunctor : C ⥤ Type w := (Functor.const C).obj PUnit.{w + 1}
@[simps]
def pUnitCocone : Cocone (constPUnitFunctor.{w} C) where
pt := PUnit
ι := { app := fun X => id }
noncomputable def isColimitPUnitCocone [IsConnected C] : IsColimit (pUnitCocone.{w} C) where
desc s := s.ι.app Classical.ofNonempty
fac s j := by
ext ⟨⟩
apply constant_of_preserves_morphisms (s.ι.app · PUnit.unit)
intros X Y f
exact congrFun (s.ι.naturality f).symm PUnit.unit
uniq s m h := by
ext ⟨⟩
simp [← h Classical.ofNonempty]
instance instHasColimitConstPUnitFunctor [IsConnected C] : HasColimit (constPUnitFunctor.{w} C) :=
⟨_, isColimitPUnitCocone _⟩
instance instSubsingletonColimitPUnit
[IsPreconnected C] [HasColimit (constPUnitFunctor.{w} C)] :
Subsingleton (colimit (constPUnitFunctor.{w} C)) where
allEq a b := by
obtain ⟨c, ⟨⟩, rfl⟩ := jointly_surjective' a
obtain ⟨d, ⟨⟩, rfl⟩ := jointly_surjective' b
apply constant_of_preserves_morphisms (colimit.ι (constPUnitFunctor C) · PUnit.unit)
exact fun c d f => colimit_sound f rfl
noncomputable def colimitConstPUnitIsoPUnit [IsConnected C] :
colimit (constPUnitFunctor.{w} C) ≅ PUnit.{w + 1} :=
IsColimit.coconePointUniqueUpToIso (colimit.isColimit _) (isColimitPUnitCocone.{w} C)
theorem zigzag_of_eqvGen_quot_rel (F : C ⥤ Type w) (c d : Σ j, F.obj j)
(h : EqvGen (Quot.Rel F) c d) : Zigzag c.1 d.1 := by
induction h with
| rel _ _ h => exact Zigzag.of_hom <| Exists.choose h
| refl _ => exact Zigzag.refl _
| symm _ _ _ ih => exact zigzag_symmetric ih
| trans _ _ _ _ _ ih₁ ih₂ => exact ih₁.trans ih₂
theorem isConnected_iff_colimit_constPUnitFunctor_iso_pUnit
[HasColimit (constPUnitFunctor.{w} C)] :
IsConnected C ↔ Nonempty (colimit (constPUnitFunctor.{w} C) ≅ PUnit) := by
refine ⟨fun _ => ⟨colimitConstPUnitIsoPUnit.{w} C⟩, fun ⟨h⟩ => ?_⟩
have : Nonempty C := nonempty_of_nonempty_colimit <| Nonempty.map h.inv inferInstance
refine zigzag_isConnected <| fun c d => ?_
refine zigzag_of_eqvGen_quot_rel _ (constPUnitFunctor C) ⟨c, PUnit.unit⟩ ⟨d, PUnit.unit⟩ ?_
exact colimit_eq <| h.toEquiv.injective rfl
| Mathlib/CategoryTheory/Limits/IsConnected.lean | 106 | 112 | theorem isConnected_iff_isColimit_pUnitCocone :
IsConnected C ↔ Nonempty (IsColimit (pUnitCocone.{w} C)) := by |
refine ⟨fun inst => ⟨isColimitPUnitCocone C⟩, fun ⟨h⟩ => ?_⟩
let colimitCocone : ColimitCocone (constPUnitFunctor C) := ⟨pUnitCocone.{w} C, h⟩
have : HasColimit (constPUnitFunctor.{w} C) := ⟨⟨colimitCocone⟩⟩
simp only [isConnected_iff_colimit_constPUnitFunctor_iso_pUnit.{w} C]
exact ⟨colimit.isoColimitCocone colimitCocone⟩
| 0 |
import Mathlib.Algebra.Regular.Basic
import Mathlib.LinearAlgebra.Matrix.MvPolynomial
import Mathlib.LinearAlgebra.Matrix.Polynomial
import Mathlib.RingTheory.Polynomial.Basic
#align_import linear_algebra.matrix.adjugate from "leanprover-community/mathlib"@"a99f85220eaf38f14f94e04699943e185a5e1d1a"
namespace Matrix
universe u v w
variable {m : Type u} {n : Type v} {α : Type w}
variable [DecidableEq n] [Fintype n] [DecidableEq m] [Fintype m] [CommRing α]
open Matrix Polynomial Equiv Equiv.Perm Finset
section Cramer
variable (A : Matrix n n α) (b : n → α)
def cramerMap (i : n) : α :=
(A.updateColumn i b).det
#align matrix.cramer_map Matrix.cramerMap
theorem cramerMap_is_linear (i : n) : IsLinearMap α fun b => cramerMap A b i :=
{ map_add := det_updateColumn_add _ _
map_smul := det_updateColumn_smul _ _ }
#align matrix.cramer_map_is_linear Matrix.cramerMap_is_linear
theorem cramer_is_linear : IsLinearMap α (cramerMap A) := by
constructor <;> intros <;> ext i
· apply (cramerMap_is_linear A i).1
· apply (cramerMap_is_linear A i).2
#align matrix.cramer_is_linear Matrix.cramer_is_linear
def cramer (A : Matrix n n α) : (n → α) →ₗ[α] (n → α) :=
IsLinearMap.mk' (cramerMap A) (cramer_is_linear A)
#align matrix.cramer Matrix.cramer
theorem cramer_apply (i : n) : cramer A b i = (A.updateColumn i b).det :=
rfl
#align matrix.cramer_apply Matrix.cramer_apply
theorem cramer_transpose_apply (i : n) : cramer Aᵀ b i = (A.updateRow i b).det := by
rw [cramer_apply, updateColumn_transpose, det_transpose]
#align matrix.cramer_transpose_apply Matrix.cramer_transpose_apply
theorem cramer_transpose_row_self (i : n) : Aᵀ.cramer (A i) = Pi.single i A.det := by
ext j
rw [cramer_apply, Pi.single_apply]
split_ifs with h
· -- i = j: this entry should be `A.det`
subst h
simp only [updateColumn_transpose, det_transpose, updateRow_eq_self]
· -- i ≠ j: this entry should be 0
rw [updateColumn_transpose, det_transpose]
apply det_zero_of_row_eq h
rw [updateRow_self, updateRow_ne (Ne.symm h)]
#align matrix.cramer_transpose_row_self Matrix.cramer_transpose_row_self
theorem cramer_row_self (i : n) (h : ∀ j, b j = A j i) : A.cramer b = Pi.single i A.det := by
rw [← transpose_transpose A, det_transpose]
convert cramer_transpose_row_self Aᵀ i
exact funext h
#align matrix.cramer_row_self Matrix.cramer_row_self
@[simp]
theorem cramer_one : cramer (1 : Matrix n n α) = 1 := by
-- Porting note: was `ext i j`
refine LinearMap.pi_ext' (fun (i : n) => LinearMap.ext_ring (funext (fun (j : n) => ?_)))
convert congr_fun (cramer_row_self (1 : Matrix n n α) (Pi.single i 1) i _) j
· simp
· intro j
rw [Matrix.one_eq_pi_single, Pi.single_comm]
#align matrix.cramer_one Matrix.cramer_one
theorem cramer_smul (r : α) (A : Matrix n n α) :
cramer (r • A) = r ^ (Fintype.card n - 1) • cramer A :=
LinearMap.ext fun _ => funext fun _ => det_updateColumn_smul' _ _ _ _
#align matrix.cramer_smul Matrix.cramer_smul
@[simp]
theorem cramer_subsingleton_apply [Subsingleton n] (A : Matrix n n α) (b : n → α) (i : n) :
cramer A b i = b i := by rw [cramer_apply, det_eq_elem_of_subsingleton _ i, updateColumn_self]
#align matrix.cramer_subsingleton_apply Matrix.cramer_subsingleton_apply
| Mathlib/LinearAlgebra/Matrix/Adjugate.lean | 145 | 150 | theorem cramer_zero [Nontrivial n] : cramer (0 : Matrix n n α) = 0 := by |
ext i j
obtain ⟨j', hj'⟩ : ∃ j', j' ≠ j := exists_ne j
apply det_eq_zero_of_column_eq_zero j'
intro j''
simp [updateColumn_ne hj']
| 0 |
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
theorem gauge_neg (symmetric : ∀ x ∈ s, -x ∈ s) (x : E) : gauge s (-x) = gauge s x := by
have : ∀ x, -x ∈ s ↔ x ∈ s := fun x => ⟨fun h => by simpa using symmetric _ h, symmetric x⟩
simp_rw [gauge_def', smul_neg, this]
#align gauge_neg gauge_neg
| Mathlib/Analysis/Convex/Gauge.lean | 134 | 135 | theorem gauge_neg_set_neg (x : E) : gauge (-s) (-x) = gauge s x := by |
simp_rw [gauge_def', smul_neg, neg_mem_neg]
| 0 |
import Mathlib.Data.Nat.Lattice
import Mathlib.Logic.Denumerable
import Mathlib.Logic.Function.Iterate
import Mathlib.Order.Hom.Basic
import Mathlib.Data.Set.Subsingleton
#align_import order.order_iso_nat from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90"
variable {α : Type*}
namespace RelEmbedding
variable {r : α → α → Prop} [IsStrictOrder α r]
def natLT (f : ℕ → α) (H : ∀ n : ℕ, r (f n) (f (n + 1))) : ((· < ·) : ℕ → ℕ → Prop) ↪r r :=
ofMonotone f <| Nat.rel_of_forall_rel_succ_of_lt r H
#align rel_embedding.nat_lt RelEmbedding.natLT
@[simp]
theorem coe_natLT {f : ℕ → α} {H : ∀ n : ℕ, r (f n) (f (n + 1))} : ⇑(natLT f H) = f :=
rfl
#align rel_embedding.coe_nat_lt RelEmbedding.coe_natLT
def natGT (f : ℕ → α) (H : ∀ n : ℕ, r (f (n + 1)) (f n)) : ((· > ·) : ℕ → ℕ → Prop) ↪r r :=
haveI := IsStrictOrder.swap r
RelEmbedding.swap (natLT f H)
#align rel_embedding.nat_gt RelEmbedding.natGT
@[simp]
theorem coe_natGT {f : ℕ → α} {H : ∀ n : ℕ, r (f (n + 1)) (f n)} : ⇑(natGT f H) = f :=
rfl
#align rel_embedding.coe_nat_gt RelEmbedding.coe_natGT
theorem exists_not_acc_lt_of_not_acc {a : α} {r} (h : ¬Acc r a) : ∃ b, ¬Acc r b ∧ r b a := by
contrapose! h
refine ⟨_, fun b hr => ?_⟩
by_contra hb
exact h b hb hr
#align rel_embedding.exists_not_acc_lt_of_not_acc RelEmbedding.exists_not_acc_lt_of_not_acc
| Mathlib/Order/OrderIsoNat.lean | 66 | 81 | theorem acc_iff_no_decreasing_seq {x} :
Acc r x ↔ IsEmpty { f : ((· > ·) : ℕ → ℕ → Prop) ↪r r // x ∈ Set.range f } := by |
constructor
· refine fun h => h.recOn fun x _ IH => ?_
constructor
rintro ⟨f, k, hf⟩
exact IsEmpty.elim' (IH (f (k + 1)) (hf ▸ f.map_rel_iff.2 (lt_add_one k))) ⟨f, _, rfl⟩
· have : ∀ x : { a // ¬Acc r a }, ∃ y : { a // ¬Acc r a }, r y.1 x.1 := by
rintro ⟨x, hx⟩
cases exists_not_acc_lt_of_not_acc hx with
| intro w h => exact ⟨⟨w, h.1⟩, h.2⟩
choose f h using this
refine fun E =>
by_contradiction fun hx => E.elim' ⟨natGT (fun n => (f^[n] ⟨x, hx⟩).1) fun n => ?_, 0, rfl⟩
simp only [Function.iterate_succ']
apply h
| 0 |
import Mathlib.Algebra.Module.PID
import Mathlib.Data.ZMod.Quotient
#align_import group_theory.finite_abelian from "leanprover-community/mathlib"@"879155bff5af618b9062cbb2915347dafd749ad6"
open scoped DirectSum
private def directSumNeZeroMulHom {ι : Type} [DecidableEq ι] (p : ι → ℕ) (n : ι → ℕ) :
(⨁ i : {i // n i ≠ 0}, ZMod (p i ^ n i)) →+ ⨁ i, ZMod (p i ^ n i) :=
DirectSum.toAddMonoid fun i ↦ DirectSum.of (fun i ↦ ZMod (p i ^ n i)) i
private def directSumNeZeroMulEquiv (ι : Type) [DecidableEq ι] (p : ι → ℕ) (n : ι → ℕ) :
(⨁ i : {i // n i ≠ 0}, ZMod (p i ^ n i)) ≃+ ⨁ i, ZMod (p i ^ n i) where
toFun := directSumNeZeroMulHom p n
invFun := DirectSum.toAddMonoid fun i ↦
if h : n i = 0 then 0 else DirectSum.of (fun j : {i // n i ≠ 0} ↦ ZMod (p j ^ n j)) ⟨i, h⟩
left_inv x := by
induction' x using DirectSum.induction_on with i x x y hx hy
· simp
· rw [directSumNeZeroMulHom, DirectSum.toAddMonoid_of, DirectSum.toAddMonoid_of,
dif_neg i.prop]
· rw [map_add, map_add, hx, hy]
right_inv x := by
induction' x using DirectSum.induction_on with i x x y hx hy
· rw [map_zero, map_zero]
· rw [DirectSum.toAddMonoid_of]
split_ifs with h
· simp [(ZMod.subsingleton_iff.2 $ by rw [h, pow_zero]).elim x 0]
· simp_rw [directSumNeZeroMulHom, DirectSum.toAddMonoid_of]
· rw [map_add, map_add, hx, hy]
map_add' := map_add (directSumNeZeroMulHom p n)
universe u
namespace Module
variable (M : Type u)
| Mathlib/GroupTheory/FiniteAbelian.lean | 91 | 100 | theorem finite_of_fg_torsion [AddCommGroup M] [Module ℤ M] [Module.Finite ℤ M]
(hM : Module.IsTorsion ℤ M) : _root_.Finite M := by |
rcases Module.equiv_directSum_of_isTorsion hM with ⟨ι, _, p, h, e, ⟨l⟩⟩
haveI : ∀ i : ι, NeZero (p i ^ e i).natAbs := fun i =>
⟨Int.natAbs_ne_zero.mpr <| pow_ne_zero (e i) (h i).ne_zero⟩
haveI : ∀ i : ι, _root_.Finite <| ℤ ⧸ Submodule.span ℤ {p i ^ e i} := fun i =>
Finite.of_equiv _ (p i ^ e i).quotientSpanEquivZMod.symm.toEquiv
haveI : _root_.Finite (⨁ i, ℤ ⧸ (Submodule.span ℤ {p i ^ e i} : Submodule ℤ ℤ)) :=
Finite.of_equiv _ DFinsupp.equivFunOnFintype.symm
exact Finite.of_equiv _ l.symm.toEquiv
| 0 |
import Mathlib.RingTheory.OrzechProperty
import Mathlib.RingTheory.Ideal.Quotient
import Mathlib.RingTheory.PrincipalIdealDomain
#align_import linear_algebra.invariant_basis_number from "leanprover-community/mathlib"@"5fd3186f1ec30a75d5f65732e3ce5e623382556f"
noncomputable section
open Function
universe u v w
section
variable (R : Type u) [Semiring R]
@[mk_iff]
class StrongRankCondition : Prop where
le_of_fin_injective : ∀ {n m : ℕ} (f : (Fin n → R) →ₗ[R] Fin m → R), Injective f → n ≤ m
#align strong_rank_condition StrongRankCondition
theorem le_of_fin_injective [StrongRankCondition R] {n m : ℕ} (f : (Fin n → R) →ₗ[R] Fin m → R) :
Injective f → n ≤ m :=
StrongRankCondition.le_of_fin_injective f
#align le_of_fin_injective le_of_fin_injective
theorem strongRankCondition_iff_succ :
StrongRankCondition R ↔
∀ (n : ℕ) (f : (Fin (n + 1) → R) →ₗ[R] Fin n → R), ¬Function.Injective f := by
refine ⟨fun h n => fun f hf => ?_, fun h => ⟨@fun n m f hf => ?_⟩⟩
· letI : StrongRankCondition R := h
exact Nat.not_succ_le_self n (le_of_fin_injective R f hf)
· by_contra H
exact
h m (f.comp (Function.ExtendByZero.linearMap R (Fin.castLE (not_le.1 H))))
(hf.comp (Function.extend_injective (Fin.strictMono_castLE _).injective _))
#align strong_rank_condition_iff_succ strongRankCondition_iff_succ
instance (priority := 100) strongRankCondition_of_orzechProperty
[Nontrivial R] [OrzechProperty R] : StrongRankCondition R := by
refine (strongRankCondition_iff_succ R).2 fun n i hi ↦ ?_
let f : (Fin (n + 1) → R) →ₗ[R] Fin n → R := {
toFun := fun x ↦ x ∘ Fin.castSucc
map_add' := fun _ _ ↦ rfl
map_smul' := fun _ _ ↦ rfl
}
have h : (0 : Fin (n + 1) → R) = update (0 : Fin (n + 1) → R) (Fin.last n) 1 := by
apply OrzechProperty.injective_of_surjective_of_injective i f hi
(Fin.castSucc_injective _).surjective_comp_right
ext m
simp [f, update_apply, (Fin.castSucc_lt_last m).ne]
simpa using congr_fun h (Fin.last n)
theorem card_le_of_injective [StrongRankCondition R] {α β : Type*} [Fintype α] [Fintype β]
(f : (α → R) →ₗ[R] β → R) (i : Injective f) : Fintype.card α ≤ Fintype.card β := by
let P := LinearEquiv.funCongrLeft R R (Fintype.equivFin α)
let Q := LinearEquiv.funCongrLeft R R (Fintype.equivFin β)
exact
le_of_fin_injective R ((Q.symm.toLinearMap.comp f).comp P.toLinearMap)
(((LinearEquiv.symm Q).injective.comp i).comp (LinearEquiv.injective P))
#align card_le_of_injective card_le_of_injective
theorem card_le_of_injective' [StrongRankCondition R] {α β : Type*} [Fintype α] [Fintype β]
(f : (α →₀ R) →ₗ[R] β →₀ R) (i : Injective f) : Fintype.card α ≤ Fintype.card β := by
let P := Finsupp.linearEquivFunOnFinite R R β
let Q := (Finsupp.linearEquivFunOnFinite R R α).symm
exact
card_le_of_injective R ((P.toLinearMap.comp f).comp Q.toLinearMap)
((P.injective.comp i).comp Q.injective)
#align card_le_of_injective' card_le_of_injective'
class RankCondition : Prop where
le_of_fin_surjective : ∀ {n m : ℕ} (f : (Fin n → R) →ₗ[R] Fin m → R), Surjective f → m ≤ n
#align rank_condition RankCondition
theorem le_of_fin_surjective [RankCondition R] {n m : ℕ} (f : (Fin n → R) →ₗ[R] Fin m → R) :
Surjective f → m ≤ n :=
RankCondition.le_of_fin_surjective f
#align le_of_fin_surjective le_of_fin_surjective
| Mathlib/LinearAlgebra/InvariantBasisNumber.lean | 188 | 194 | theorem card_le_of_surjective [RankCondition R] {α β : Type*} [Fintype α] [Fintype β]
(f : (α → R) →ₗ[R] β → R) (i : Surjective f) : Fintype.card β ≤ Fintype.card α := by |
let P := LinearEquiv.funCongrLeft R R (Fintype.equivFin α)
let Q := LinearEquiv.funCongrLeft R R (Fintype.equivFin β)
exact
le_of_fin_surjective R ((Q.symm.toLinearMap.comp f).comp P.toLinearMap)
(((LinearEquiv.symm Q).surjective.comp i).comp (LinearEquiv.surjective P))
| 0 |
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
theorem toMultiset_sum_single (s : Finset ι) (n : ℕ) :
Finsupp.toMultiset (∑ i ∈ s, single i n) = n • s.val := by
simp_rw [toMultiset_sum, Finsupp.toMultiset_single, sum_nsmul, sum_multiset_singleton]
#align finsupp.to_multiset_sum_single Finsupp.toMultiset_sum_single
@[simp]
theorem card_toMultiset (f : α →₀ ℕ) : Multiset.card (toMultiset f) = f.sum fun _ => id := by
simp [toMultiset_apply, map_finsupp_sum, Function.id_def]
#align finsupp.card_to_multiset Finsupp.card_toMultiset
theorem toMultiset_map (f : α →₀ ℕ) (g : α → β) :
f.toMultiset.map g = toMultiset (f.mapDomain g) := by
refine f.induction ?_ ?_
· rw [toMultiset_zero, Multiset.map_zero, mapDomain_zero, toMultiset_zero]
· intro a n f _ _ ih
rw [toMultiset_add, Multiset.map_add, ih, mapDomain_add, mapDomain_single,
toMultiset_single, toMultiset_add, toMultiset_single, ← Multiset.coe_mapAddMonoidHom,
(Multiset.mapAddMonoidHom g).map_nsmul]
rfl
#align finsupp.to_multiset_map Finsupp.toMultiset_map
@[to_additive (attr := simp)]
theorem prod_toMultiset [CommMonoid α] (f : α →₀ ℕ) :
f.toMultiset.prod = f.prod fun a n => a ^ n := by
refine f.induction ?_ ?_
· rw [toMultiset_zero, Multiset.prod_zero, Finsupp.prod_zero_index]
· intro a n f _ _ ih
rw [toMultiset_add, Multiset.prod_add, ih, toMultiset_single, Multiset.prod_nsmul,
Finsupp.prod_add_index' pow_zero pow_add, Finsupp.prod_single_index, Multiset.prod_singleton]
exact pow_zero a
#align finsupp.prod_to_multiset Finsupp.prod_toMultiset
@[simp]
| Mathlib/Data/Finsupp/Multiset.lean | 94 | 101 | theorem toFinset_toMultiset [DecidableEq α] (f : α →₀ ℕ) : f.toMultiset.toFinset = f.support := by |
refine f.induction ?_ ?_
· rw [toMultiset_zero, Multiset.toFinset_zero, support_zero]
· intro a n f ha hn ih
rw [toMultiset_add, Multiset.toFinset_add, ih, toMultiset_single, support_add_eq,
support_single_ne_zero _ hn, Multiset.toFinset_nsmul _ _ hn, Multiset.toFinset_singleton]
refine Disjoint.mono_left support_single_subset ?_
rwa [Finset.disjoint_singleton_left]
| 0 |
import Mathlib.Data.Fin.Fin2
import Mathlib.Data.PFun
import Mathlib.Data.Vector3
import Mathlib.NumberTheory.PellMatiyasevic
#align_import number_theory.dioph from "leanprover-community/mathlib"@"a66d07e27d5b5b8ac1147cacfe353478e5c14002"
open Fin2 Function Nat Sum
local infixr:67 " ::ₒ " => Option.elim'
local infixr:65 " ⊗ " => Sum.elim
universe u
section Polynomials
variable {α β γ : Type*}
inductive IsPoly : ((α → ℕ) → ℤ) → Prop
| proj : ∀ i, IsPoly fun x : α → ℕ => x i
| const : ∀ n : ℤ, IsPoly fun _ : α → ℕ => n
| sub : ∀ {f g : (α → ℕ) → ℤ}, IsPoly f → IsPoly g → IsPoly fun x => f x - g x
| mul : ∀ {f g : (α → ℕ) → ℤ}, IsPoly f → IsPoly g → IsPoly fun x => f x * g x
#align is_poly IsPoly
| Mathlib/NumberTheory/Dioph.lean | 85 | 86 | theorem IsPoly.neg {f : (α → ℕ) → ℤ} : IsPoly f → IsPoly (-f) := by |
rw [← zero_sub]; exact (IsPoly.const 0).sub
| 0 |
import Mathlib.CategoryTheory.Sites.InducedTopology
import Mathlib.CategoryTheory.Sites.LocallyBijective
import Mathlib.CategoryTheory.Sites.PreservesLocallyBijective
import Mathlib.CategoryTheory.Sites.Whiskering
universe u
namespace CategoryTheory
open Functor Limits GrothendieckTopology
variable {C : Type*} [Category C] (J : GrothendieckTopology C)
variable {D : Type*} [Category D] (K : GrothendieckTopology D) (e : C ≌ D) (G : D ⥤ C)
variable (A : Type*) [Category A]
namespace Equivalence
| Mathlib/CategoryTheory/Sites/Equivalence.lean | 51 | 65 | theorem locallyCoverDense : LocallyCoverDense J e.inverse := by |
intro X T
convert T.prop
ext Z f
constructor
· rintro ⟨_, _, g', hg, rfl⟩
exact T.val.downward_closed hg g'
· intro hf
refine ⟨e.functor.obj Z, (Adjunction.homEquiv e.toAdjunction _ _).symm f, e.unit.app Z, ?_, ?_⟩
· simp only [Adjunction.homEquiv_counit, Functor.id_obj, Equivalence.toAdjunction_counit,
Sieve.functorPullback_apply, Presieve.functorPullback_mem, Functor.map_comp,
Equivalence.inv_fun_map, Functor.comp_obj, Category.assoc, Equivalence.unit_inverse_comp,
Category.comp_id]
exact T.val.downward_closed hf _
· simp
| 0 |
import Mathlib.Data.Set.Finite
import Mathlib.Order.Partition.Finpartition
#align_import data.setoid.partition from "leanprover-community/mathlib"@"b363547b3113d350d053abdf2884e9850a56b205"
namespace Setoid
variable {α : Type*}
theorem eq_of_mem_eqv_class {c : Set (Set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b) {x b b'}
(hc : b ∈ c) (hb : x ∈ b) (hc' : b' ∈ c) (hb' : x ∈ b') : b = b' :=
(H x).unique ⟨hc, hb⟩ ⟨hc', hb'⟩
#align setoid.eq_of_mem_eqv_class Setoid.eq_of_mem_eqv_class
def mkClasses (c : Set (Set α)) (H : ∀ a, ∃! b ∈ c, a ∈ b) : Setoid α where
r x y := ∀ s ∈ c, x ∈ s → y ∈ s
iseqv.refl := fun _ _ _ hx => hx
iseqv.symm := fun {x _y} h s hs hy => by
obtain ⟨t, ⟨ht, hx⟩, _⟩ := H x
rwa [eq_of_mem_eqv_class H hs hy ht (h t ht hx)]
iseqv.trans := fun {_x y z} h1 h2 s hs hx => h2 s hs (h1 s hs hx)
#align setoid.mk_classes Setoid.mkClasses
def classes (r : Setoid α) : Set (Set α) :=
{ s | ∃ y, s = { x | r.Rel x y } }
#align setoid.classes Setoid.classes
theorem mem_classes (r : Setoid α) (y) : { x | r.Rel x y } ∈ r.classes :=
⟨y, rfl⟩
#align setoid.mem_classes Setoid.mem_classes
theorem classes_ker_subset_fiber_set {β : Type*} (f : α → β) :
(Setoid.ker f).classes ⊆ Set.range fun y => { x | f x = y } := by
rintro s ⟨x, rfl⟩
rw [Set.mem_range]
exact ⟨f x, rfl⟩
#align setoid.classes_ker_subset_fiber_set Setoid.classes_ker_subset_fiber_set
theorem finite_classes_ker {α β : Type*} [Finite β] (f : α → β) : (Setoid.ker f).classes.Finite :=
(Set.finite_range _).subset <| classes_ker_subset_fiber_set f
#align setoid.finite_classes_ker Setoid.finite_classes_ker
theorem card_classes_ker_le {α β : Type*} [Fintype β] (f : α → β)
[Fintype (Setoid.ker f).classes] : Fintype.card (Setoid.ker f).classes ≤ Fintype.card β := by
classical exact
le_trans (Set.card_le_card (classes_ker_subset_fiber_set f)) (Fintype.card_range_le _)
#align setoid.card_classes_ker_le Setoid.card_classes_ker_le
theorem eq_iff_classes_eq {r₁ r₂ : Setoid α} :
r₁ = r₂ ↔ ∀ x, { y | r₁.Rel x y } = { y | r₂.Rel x y } :=
⟨fun h _x => h ▸ rfl, fun h => ext' fun x => Set.ext_iff.1 <| h x⟩
#align setoid.eq_iff_classes_eq Setoid.eq_iff_classes_eq
theorem rel_iff_exists_classes (r : Setoid α) {x y} : r.Rel x y ↔ ∃ c ∈ r.classes, x ∈ c ∧ y ∈ c :=
⟨fun h => ⟨_, r.mem_classes y, h, r.refl' y⟩, fun ⟨c, ⟨z, hz⟩, hx, hy⟩ => by
subst c
exact r.trans' hx (r.symm' hy)⟩
#align setoid.rel_iff_exists_classes Setoid.rel_iff_exists_classes
theorem classes_inj {r₁ r₂ : Setoid α} : r₁ = r₂ ↔ r₁.classes = r₂.classes :=
⟨fun h => h ▸ rfl, fun h => ext' fun a b => by simp only [rel_iff_exists_classes, exists_prop, h]⟩
#align setoid.classes_inj Setoid.classes_inj
theorem empty_not_mem_classes {r : Setoid α} : ∅ ∉ r.classes := fun ⟨y, hy⟩ =>
Set.not_mem_empty y <| hy.symm ▸ r.refl' y
#align setoid.empty_not_mem_classes Setoid.empty_not_mem_classes
theorem classes_eqv_classes {r : Setoid α} (a) : ∃! b ∈ r.classes, a ∈ b :=
ExistsUnique.intro { x | r.Rel x a } ⟨r.mem_classes a, r.refl' _⟩ <| by
rintro y ⟨⟨_, rfl⟩, ha⟩
ext x
exact ⟨fun hx => r.trans' hx (r.symm' ha), fun hx => r.trans' hx ha⟩
#align setoid.classes_eqv_classes Setoid.classes_eqv_classes
theorem eq_of_mem_classes {r : Setoid α} {x b} (hc : b ∈ r.classes) (hb : x ∈ b) {b'}
(hc' : b' ∈ r.classes) (hb' : x ∈ b') : b = b' :=
eq_of_mem_eqv_class classes_eqv_classes hc hb hc' hb'
#align setoid.eq_of_mem_classes Setoid.eq_of_mem_classes
| Mathlib/Data/Setoid/Partition.lean | 122 | 130 | theorem eq_eqv_class_of_mem {c : Set (Set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b) {s y}
(hs : s ∈ c) (hy : y ∈ s) : s = { x | (mkClasses c H).Rel x y } := by |
ext x
constructor
· intro hx _s' hs' hx'
rwa [eq_of_mem_eqv_class H hs' hx' hs hx]
· intro hx
obtain ⟨b', ⟨hc, hb'⟩, _⟩ := H x
rwa [eq_of_mem_eqv_class H hs hy hc (hx b' hc hb')]
| 0 |
import Mathlib.Analysis.Complex.UpperHalfPlane.Basic
import Mathlib.Analysis.Convex.Contractible
import Mathlib.Analysis.Convex.Normed
import Mathlib.Analysis.Convex.Complex
import Mathlib.Analysis.Complex.ReImTopology
import Mathlib.Topology.Homotopy.Contractible
import Mathlib.Topology.PartialHomeomorph
#align_import analysis.complex.upper_half_plane.topology from "leanprover-community/mathlib"@"57f9349f2fe19d2de7207e99b0341808d977cdcf"
noncomputable section
open Set Filter Function TopologicalSpace Complex
open scoped Filter Topology UpperHalfPlane
namespace UpperHalfPlane
instance : TopologicalSpace ℍ :=
instTopologicalSpaceSubtype
theorem openEmbedding_coe : OpenEmbedding ((↑) : ℍ → ℂ) :=
IsOpen.openEmbedding_subtype_val <| isOpen_lt continuous_const Complex.continuous_im
#align upper_half_plane.open_embedding_coe UpperHalfPlane.openEmbedding_coe
theorem embedding_coe : Embedding ((↑) : ℍ → ℂ) :=
embedding_subtype_val
#align upper_half_plane.embedding_coe UpperHalfPlane.embedding_coe
theorem continuous_coe : Continuous ((↑) : ℍ → ℂ) :=
embedding_coe.continuous
#align upper_half_plane.continuous_coe UpperHalfPlane.continuous_coe
theorem continuous_re : Continuous re :=
Complex.continuous_re.comp continuous_coe
#align upper_half_plane.continuous_re UpperHalfPlane.continuous_re
theorem continuous_im : Continuous im :=
Complex.continuous_im.comp continuous_coe
#align upper_half_plane.continuous_im UpperHalfPlane.continuous_im
instance : SecondCountableTopology ℍ :=
TopologicalSpace.Subtype.secondCountableTopology _
instance : T3Space ℍ := Subtype.t3Space
instance : T4Space ℍ := inferInstance
instance : ContractibleSpace ℍ :=
(convex_halfspace_im_gt 0).contractibleSpace ⟨I, one_pos.trans_eq I_im.symm⟩
instance : LocPathConnectedSpace ℍ :=
locPathConnected_of_isOpen <| isOpen_lt continuous_const Complex.continuous_im
instance : NoncompactSpace ℍ := by
refine ⟨fun h => ?_⟩
have : IsCompact (Complex.im ⁻¹' Ioi 0) := isCompact_iff_isCompact_univ.2 h
replace := this.isClosed.closure_eq
rw [closure_preimage_im, closure_Ioi, Set.ext_iff] at this
exact absurd ((this 0).1 (@left_mem_Ici ℝ _ 0)) (@lt_irrefl ℝ _ 0)
instance : LocallyCompactSpace ℍ :=
openEmbedding_coe.locallyCompactSpace
section strips
def verticalStrip (A B : ℝ) := {z : ℍ | |z.re| ≤ A ∧ B ≤ z.im}
theorem mem_verticalStrip_iff (A B : ℝ) (z : ℍ) : z ∈ verticalStrip A B ↔ |z.re| ≤ A ∧ B ≤ z.im :=
Iff.rfl
@[gcongr]
lemma verticalStrip_mono {A B A' B' : ℝ} (hA : A ≤ A') (hB : B' ≤ B) :
verticalStrip A B ⊆ verticalStrip A' B' := by
rintro z ⟨hzre, hzim⟩
exact ⟨hzre.trans hA, hB.trans hzim⟩
@[gcongr]
lemma verticalStrip_mono_left {A A'} (h : A ≤ A') (B) : verticalStrip A B ⊆ verticalStrip A' B :=
verticalStrip_mono h le_rfl
@[gcongr]
lemma verticalStrip_anti_right (A) {B B'} (h : B' ≤ B) : verticalStrip A B ⊆ verticalStrip A B' :=
verticalStrip_mono le_rfl h
lemma subset_verticalStrip_of_isCompact {K : Set ℍ} (hK : IsCompact K) :
∃ A B : ℝ, 0 < B ∧ K ⊆ verticalStrip A B := by
rcases K.eq_empty_or_nonempty with rfl | hne
· exact ⟨1, 1, Real.zero_lt_one, empty_subset _⟩
obtain ⟨u, _, hu⟩ := hK.exists_isMaxOn hne (_root_.continuous_abs.comp continuous_re).continuousOn
obtain ⟨v, _, hv⟩ := hK.exists_isMinOn hne continuous_im.continuousOn
exact ⟨|re u|, im v, v.im_pos, fun k hk ↦ ⟨isMaxOn_iff.mp hu _ hk, isMinOn_iff.mp hv _ hk⟩⟩
| Mathlib/Analysis/Complex/UpperHalfPlane/Topology.lean | 109 | 124 | theorem ModularGroup_T_zpow_mem_verticalStrip (z : ℍ) {N : ℕ} (hn : 0 < N) :
∃ n : ℤ, ModularGroup.T ^ (N * n) • z ∈ verticalStrip N z.im := by |
let n := Int.floor (z.re/N)
use -n
rw [modular_T_zpow_smul z (N * -n)]
refine ⟨?_, (by simp only [mul_neg, Int.cast_neg, Int.cast_mul, Int.cast_natCast, vadd_im,
le_refl])⟩
have h : (N * (-n : ℝ) +ᵥ z).re = -N * Int.floor (z.re / N) + z.re := by
simp only [Int.cast_natCast, mul_neg, vadd_re, neg_mul]
norm_cast at *
rw [h, add_comm]
simp only [neg_mul, Int.cast_neg, Int.cast_mul, Int.cast_natCast, ge_iff_le]
have hnn : (0 : ℝ) < (N : ℝ) := by norm_cast at *
have h2 : z.re + -(N * n) = z.re - n * N := by ring
rw [h2, abs_eq_self.2 (Int.sub_floor_div_mul_nonneg (z.re : ℝ) hnn)]
apply (Int.sub_floor_div_mul_lt (z.re : ℝ) hnn).le
| 0 |
import Mathlib.Analysis.Convex.Body
import Mathlib.Analysis.Convex.Measure
import Mathlib.MeasureTheory.Group.FundamentalDomain
#align_import measure_theory.group.geometry_of_numbers from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
namespace MeasureTheory
open ENNReal FiniteDimensional MeasureTheory MeasureTheory.Measure Set Filter
open scoped Pointwise NNReal
variable {E L : Type*} [MeasurableSpace E] {μ : Measure E} {F s : Set E}
| Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean | 50 | 58 | theorem exists_pair_mem_lattice_not_disjoint_vadd [AddCommGroup L] [Countable L] [AddAction L E]
[MeasurableSpace L] [MeasurableVAdd L E] [VAddInvariantMeasure L E μ]
(fund : IsAddFundamentalDomain L F μ) (hS : NullMeasurableSet s μ) (h : μ F < μ s) :
∃ x y : L, x ≠ y ∧ ¬Disjoint (x +ᵥ s) (y +ᵥ s) := by |
contrapose! h
exact ((fund.measure_eq_tsum _).trans (measure_iUnion₀
(Pairwise.mono h fun i j hij => (hij.mono inf_le_left inf_le_left).aedisjoint)
fun _ => (hS.vadd _).inter fund.nullMeasurableSet).symm).trans_le
(measure_mono <| Set.iUnion_subset fun _ => Set.inter_subset_right)
| 0 |
import Mathlib.Algebra.Polynomial.Basic
import Mathlib.FieldTheory.IsAlgClosed.Basic
#align_import linear_algebra.matrix.charpoly.eigs from "leanprover-community/mathlib"@"48dc6abe71248bd6f4bffc9703dc87bdd4e37d0b"
variable {n : Type*} [Fintype n] [DecidableEq n]
variable {R : Type*} [Field R]
variable {A : Matrix n n R}
open Matrix Polynomial
open scoped Matrix
namespace Matrix
theorem det_eq_prod_roots_charpoly_of_splits (hAps : A.charpoly.Splits (RingHom.id R)) :
A.det = (Matrix.charpoly A).roots.prod := by
rw [det_eq_sign_charpoly_coeff, ← charpoly_natDegree_eq_dim A,
Polynomial.prod_roots_eq_coeff_zero_of_monic_of_split A.charpoly_monic hAps, ← mul_assoc,
← pow_two, pow_right_comm, neg_one_sq, one_pow, one_mul]
#align matrix.det_eq_prod_roots_charpoly_of_splits Matrix.det_eq_prod_roots_charpoly_of_splits
| Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean | 67 | 75 | theorem trace_eq_sum_roots_charpoly_of_splits (hAps : A.charpoly.Splits (RingHom.id R)) :
A.trace = (Matrix.charpoly A).roots.sum := by |
cases' isEmpty_or_nonempty n with h
· rw [Matrix.trace, Fintype.sum_empty, Matrix.charpoly,
det_eq_one_of_card_eq_zero (Fintype.card_eq_zero_iff.2 h), Polynomial.roots_one,
Multiset.empty_eq_zero, Multiset.sum_zero]
· rw [trace_eq_neg_charpoly_coeff, neg_eq_iff_eq_neg,
← Polynomial.sum_roots_eq_nextCoeff_of_monic_of_split A.charpoly_monic hAps, nextCoeff,
charpoly_natDegree_eq_dim, if_neg (Fintype.card_ne_zero : Fintype.card n ≠ 0)]
| 0 |
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]
theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m) s := by
ext; simp [Nat.add_assoc]
#align stream.drop_drop Stream'.drop_drop
@[simp] theorem get_tail {s : Stream' α} : s.tail.get n = s.get (n + 1) := rfl
@[simp] theorem tail_drop' {s : Stream' α} : tail (drop i s) = s.drop (i+1) := by
ext; simp [Nat.add_comm, Nat.add_assoc, Nat.add_left_comm]
@[simp] theorem drop_tail' {s : Stream' α} : drop i (tail s) = s.drop (i+1) := rfl
theorem tail_drop (n : Nat) (s : Stream' α) : tail (drop n s) = drop n (tail s) := by simp
#align stream.tail_drop Stream'.tail_drop
theorem get_succ (n : Nat) (s : Stream' α) : get s (succ n) = get (tail s) n :=
rfl
#align stream.nth_succ Stream'.get_succ
@[simp]
theorem get_succ_cons (n : Nat) (s : Stream' α) (x : α) : get (x::s) n.succ = get s n :=
rfl
#align stream.nth_succ_cons Stream'.get_succ_cons
@[simp] theorem drop_zero {s : Stream' α} : s.drop 0 = s := rfl
theorem drop_succ (n : Nat) (s : Stream' α) : drop (succ n) s = drop n (tail s) :=
rfl
#align stream.drop_succ Stream'.drop_succ
theorem head_drop (a : Stream' α) (n : ℕ) : (a.drop n).head = a.get n := by simp
#align stream.head_drop Stream'.head_drop
theorem cons_injective2 : Function.Injective2 (cons : α → Stream' α → Stream' α) := fun x y s t h =>
⟨by rw [← get_zero_cons x s, h, get_zero_cons],
Stream'.ext fun n => by rw [← get_succ_cons n _ x, h, get_succ_cons]⟩
#align stream.cons_injective2 Stream'.cons_injective2
theorem cons_injective_left (s : Stream' α) : Function.Injective fun x => cons x s :=
cons_injective2.left _
#align stream.cons_injective_left Stream'.cons_injective_left
theorem cons_injective_right (x : α) : Function.Injective (cons x) :=
cons_injective2.right _
#align stream.cons_injective_right Stream'.cons_injective_right
theorem all_def (p : α → Prop) (s : Stream' α) : All p s = ∀ n, p (get s n) :=
rfl
#align stream.all_def Stream'.all_def
theorem any_def (p : α → Prop) (s : Stream' α) : Any p s = ∃ n, p (get s n) :=
rfl
#align stream.any_def Stream'.any_def
@[simp]
theorem mem_cons (a : α) (s : Stream' α) : a ∈ a::s :=
Exists.intro 0 rfl
#align stream.mem_cons Stream'.mem_cons
theorem mem_cons_of_mem {a : α} {s : Stream' α} (b : α) : a ∈ s → a ∈ b::s := fun ⟨n, h⟩ =>
Exists.intro (succ n) (by rw [get_succ, tail_cons, h])
#align stream.mem_cons_of_mem Stream'.mem_cons_of_mem
theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a = b ∨ a ∈ s :=
fun ⟨n, h⟩ => by
cases' n with n'
· left
exact h
· right
rw [get_succ, tail_cons] at h
exact ⟨n', h⟩
#align stream.eq_or_mem_of_mem_cons Stream'.eq_or_mem_of_mem_cons
theorem mem_of_get_eq {n : Nat} {s : Stream' α} {a : α} : a = get s n → a ∈ s := fun h =>
Exists.intro n h
#align stream.mem_of_nth_eq Stream'.mem_of_get_eq
section Map
variable (f : α → β)
theorem drop_map (n : Nat) (s : Stream' α) : drop n (map f s) = map f (drop n s) :=
Stream'.ext fun _ => rfl
#align stream.drop_map Stream'.drop_map
@[simp]
theorem get_map (n : Nat) (s : Stream' α) : get (map f s) n = f (get s n) :=
rfl
#align stream.nth_map Stream'.get_map
theorem tail_map (s : Stream' α) : tail (map f s) = map f (tail s) := rfl
#align stream.tail_map Stream'.tail_map
@[simp]
theorem head_map (s : Stream' α) : head (map f s) = f (head s) :=
rfl
#align stream.head_map Stream'.head_map
| Mathlib/Data/Stream/Init.lean | 162 | 163 | theorem map_eq (s : Stream' α) : map f s = f (head s)::map f (tail s) := by |
rw [← Stream'.eta (map f s), tail_map, head_map]
| 0 |
import Mathlib.Combinatorics.SimpleGraph.Coloring
#align_import combinatorics.simple_graph.partition from "leanprover-community/mathlib"@"2303b3e299f1c75b07bceaaac130ce23044d1386"
universe u v
namespace SimpleGraph
variable {V : Type u} (G : SimpleGraph V)
structure Partition where
parts : Set (Set V)
isPartition : Setoid.IsPartition parts
independent : ∀ s ∈ parts, IsAntichain G.Adj s
#align simple_graph.partition SimpleGraph.Partition
def Partition.PartsCardLe {G : SimpleGraph V} (P : G.Partition) (n : ℕ) : Prop :=
∃ h : P.parts.Finite, h.toFinset.card ≤ n
#align simple_graph.partition.parts_card_le SimpleGraph.Partition.PartsCardLe
def Partitionable (n : ℕ) : Prop := ∃ P : G.Partition, P.PartsCardLe n
#align simple_graph.partitionable SimpleGraph.Partitionable
namespace Partition
variable {G} (P : G.Partition)
def partOfVertex (v : V) : Set V := Classical.choose (P.isPartition.2 v)
#align simple_graph.partition.part_of_vertex SimpleGraph.Partition.partOfVertex
theorem partOfVertex_mem (v : V) : P.partOfVertex v ∈ P.parts := by
obtain ⟨h, -⟩ := (P.isPartition.2 v).choose_spec.1
exact h
#align simple_graph.partition.part_of_vertex_mem SimpleGraph.Partition.partOfVertex_mem
theorem mem_partOfVertex (v : V) : v ∈ P.partOfVertex v := by
obtain ⟨⟨_, h⟩, _⟩ := (P.isPartition.2 v).choose_spec
exact h
#align simple_graph.partition.mem_part_of_vertex SimpleGraph.Partition.mem_partOfVertex
| Mathlib/Combinatorics/SimpleGraph/Partition.lean | 98 | 102 | theorem partOfVertex_ne_of_adj {v w : V} (h : G.Adj v w) : P.partOfVertex v ≠ P.partOfVertex w := by |
intro hn
have hw := P.mem_partOfVertex w
rw [← hn] at hw
exact P.independent _ (P.partOfVertex_mem v) (P.mem_partOfVertex v) hw (G.ne_of_adj h) h
| 0 |
import Mathlib.LinearAlgebra.AffineSpace.Basis
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
#align_import linear_algebra.affine_space.matrix from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
open Affine Matrix
open Set
universe u₁ u₂ u₃ u₄
variable {ι : Type u₁} {k : Type u₂} {V : Type u₃} {P : Type u₄}
variable [AddCommGroup V] [AffineSpace V P]
namespace AffineBasis
section Ring
variable [Ring k] [Module k V] (b : AffineBasis ι k P)
noncomputable def toMatrix {ι' : Type*} (q : ι' → P) : Matrix ι' ι k :=
fun i j => b.coord j (q i)
#align affine_basis.to_matrix AffineBasis.toMatrix
@[simp]
theorem toMatrix_apply {ι' : Type*} (q : ι' → P) (i : ι') (j : ι) :
b.toMatrix q i j = b.coord j (q i) := rfl
#align affine_basis.to_matrix_apply AffineBasis.toMatrix_apply
@[simp]
theorem toMatrix_self [DecidableEq ι] : b.toMatrix b = (1 : Matrix ι ι k) := by
ext i j
rw [toMatrix_apply, coord_apply, Matrix.one_eq_pi_single, Pi.single_apply]
#align affine_basis.to_matrix_self AffineBasis.toMatrix_self
variable {ι' : Type*}
theorem toMatrix_row_sum_one [Fintype ι] (q : ι' → P) (i : ι') : ∑ j, b.toMatrix q i j = 1 := by
simp
#align affine_basis.to_matrix_row_sum_one AffineBasis.toMatrix_row_sum_one
theorem affineIndependent_of_toMatrix_right_inv [Fintype ι] [Finite ι'] [DecidableEq ι']
(p : ι' → P) {A : Matrix ι ι' k} (hA : b.toMatrix p * A = 1) : AffineIndependent k p := by
cases nonempty_fintype ι'
rw [affineIndependent_iff_eq_of_fintype_affineCombination_eq]
intro w₁ w₂ hw₁ hw₂ hweq
have hweq' : w₁ ᵥ* b.toMatrix p = w₂ ᵥ* b.toMatrix p := by
ext j
change (∑ i, w₁ i • b.coord j (p i)) = ∑ i, w₂ i • b.coord j (p i)
-- Porting note: Added `u` because `∘` was causing trouble
have u : (fun i => b.coord j (p i)) = b.coord j ∘ p := by simp only [(· ∘ ·)]
rw [← Finset.univ.affineCombination_eq_linear_combination _ _ hw₁,
← Finset.univ.affineCombination_eq_linear_combination _ _ hw₂, u,
← Finset.univ.map_affineCombination p w₁ hw₁, ← Finset.univ.map_affineCombination p w₂ hw₂,
hweq]
replace hweq' := congr_arg (fun w => w ᵥ* A) hweq'
simpa only [Matrix.vecMul_vecMul, hA, Matrix.vecMul_one] using hweq'
#align affine_basis.affine_independent_of_to_matrix_right_inv AffineBasis.affineIndependent_of_toMatrix_right_inv
theorem affineSpan_eq_top_of_toMatrix_left_inv [Finite ι] [Fintype ι'] [DecidableEq ι]
[Nontrivial k] (p : ι' → P) {A : Matrix ι ι' k} (hA : A * b.toMatrix p = 1) :
affineSpan k (range p) = ⊤ := by
cases nonempty_fintype ι
suffices ∀ i, b i ∈ affineSpan k (range p) by
rw [eq_top_iff, ← b.tot, affineSpan_le]
rintro q ⟨i, rfl⟩
exact this i
intro i
have hAi : ∑ j, A i j = 1 := by
calc
∑ j, A i j = ∑ j, A i j * ∑ l, b.toMatrix p j l := by simp
_ = ∑ j, ∑ l, A i j * b.toMatrix p j l := by simp_rw [Finset.mul_sum]
_ = ∑ l, ∑ j, A i j * b.toMatrix p j l := by rw [Finset.sum_comm]
_ = ∑ l, (A * b.toMatrix p) i l := rfl
_ = 1 := by simp [hA, Matrix.one_apply, Finset.filter_eq]
have hbi : b i = Finset.univ.affineCombination k p (A i) := by
apply b.ext_elem
intro j
rw [b.coord_apply, Finset.univ.map_affineCombination _ _ hAi,
Finset.univ.affineCombination_eq_linear_combination _ _ hAi]
change _ = (A * b.toMatrix p) i j
simp_rw [hA, Matrix.one_apply, @eq_comm _ i j]
rw [hbi]
exact affineCombination_mem_affineSpan hAi p
#align affine_basis.affine_span_eq_top_of_to_matrix_left_inv AffineBasis.affineSpan_eq_top_of_toMatrix_left_inv
variable [Fintype ι] (b₂ : AffineBasis ι k P)
@[simp]
theorem toMatrix_vecMul_coords (x : P) : b₂.coords x ᵥ* b.toMatrix b₂ = b.coords x := by
ext j
change _ = b.coord j x
conv_rhs => rw [← b₂.affineCombination_coord_eq_self x]
rw [Finset.map_affineCombination _ _ _ (b₂.sum_coord_apply_eq_one x)]
simp [Matrix.vecMul, Matrix.dotProduct, toMatrix_apply, coords]
#align affine_basis.to_matrix_vec_mul_coords AffineBasis.toMatrix_vecMul_coords
variable [DecidableEq ι]
theorem toMatrix_mul_toMatrix : b.toMatrix b₂ * b₂.toMatrix b = 1 := by
ext l m
change (b.coords (b₂ l) ᵥ* b₂.toMatrix b) m = _
rw [toMatrix_vecMul_coords, coords_apply, ← toMatrix_apply, toMatrix_self]
#align affine_basis.to_matrix_mul_to_matrix AffineBasis.toMatrix_mul_toMatrix
theorem isUnit_toMatrix : IsUnit (b.toMatrix b₂) :=
⟨{ val := b.toMatrix b₂
inv := b₂.toMatrix b
val_inv := b.toMatrix_mul_toMatrix b₂
inv_val := b₂.toMatrix_mul_toMatrix b }, rfl⟩
#align affine_basis.is_unit_to_matrix AffineBasis.isUnit_toMatrix
| Mathlib/LinearAlgebra/AffineSpace/Matrix.lean | 137 | 146 | theorem isUnit_toMatrix_iff [Nontrivial k] (p : ι → P) :
IsUnit (b.toMatrix p) ↔ AffineIndependent k p ∧ affineSpan k (range p) = ⊤ := by |
constructor
· rintro ⟨⟨B, A, hA, hA'⟩, rfl : B = b.toMatrix p⟩
exact ⟨b.affineIndependent_of_toMatrix_right_inv p hA,
b.affineSpan_eq_top_of_toMatrix_left_inv p hA'⟩
· rintro ⟨h_tot, h_ind⟩
let b' : AffineBasis ι k P := ⟨p, h_tot, h_ind⟩
change IsUnit (b.toMatrix b')
exact b.isUnit_toMatrix b'
| 0 |
import Mathlib.Data.Fintype.Basic
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Tactic.Zify
import Mathlib.Data.Nat.Totient
#align_import number_theory.lucas_primality from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
| Mathlib/NumberTheory/LucasPrimality.lean | 42 | 63 | theorem lucas_primality (p : ℕ) (a : ZMod p) (ha : a ^ (p - 1) = 1)
(hd : ∀ q : ℕ, q.Prime → q ∣ p - 1 → a ^ ((p - 1) / q) ≠ 1) : p.Prime := by |
have h0 : p ≠ 0 := by
rintro ⟨⟩
exact hd 2 Nat.prime_two (dvd_zero _) (pow_zero _)
have h1 : p ≠ 1 := by
rintro ⟨⟩
exact hd 2 Nat.prime_two (dvd_zero _) (pow_zero _)
have hp1 : 1 < p := lt_of_le_of_ne h0.bot_lt h1.symm
have order_of_a : orderOf a = p - 1 := by
apply orderOf_eq_of_pow_and_pow_div_prime _ ha hd
exact tsub_pos_of_lt hp1
haveI : NeZero p := ⟨h0⟩
rw [Nat.prime_iff_card_units]
-- Prove cardinality of `Units` of `ZMod p` is both `≤ p-1` and `≥ p-1`
refine le_antisymm (Nat.card_units_zmod_lt_sub_one hp1) ?_
have hp' : p - 2 + 1 = p - 1 := tsub_add_eq_add_tsub hp1
let a' : (ZMod p)ˣ := Units.mkOfMulEqOne a (a ^ (p - 2)) (by rw [← pow_succ', hp', ha])
calc
p - 1 = orderOf a := order_of_a.symm
_ = orderOf a' := (orderOf_injective (Units.coeHom (ZMod p)) Units.ext a')
_ ≤ Fintype.card (ZMod p)ˣ := orderOf_le_card_univ
| 0 |
namespace Nat
@[reducible] def Coprime (m n : Nat) : Prop := gcd m n = 1
instance (m n : Nat) : Decidable (Coprime m n) := inferInstanceAs (Decidable (_ = 1))
theorem coprime_iff_gcd_eq_one : Coprime m n ↔ gcd m n = 1 := .rfl
theorem Coprime.gcd_eq_one : Coprime m n → gcd m n = 1 := id
theorem Coprime.symm : Coprime n m → Coprime m n := (gcd_comm m n).trans
theorem coprime_comm : Coprime n m ↔ Coprime m n := ⟨Coprime.symm, Coprime.symm⟩
theorem Coprime.dvd_of_dvd_mul_right (H1 : Coprime k n) (H2 : k ∣ m * n) : k ∣ m := by
let t := dvd_gcd (Nat.dvd_mul_left k m) H2
rwa [gcd_mul_left, H1.gcd_eq_one, Nat.mul_one] at t
theorem Coprime.dvd_of_dvd_mul_left (H1 : Coprime k m) (H2 : k ∣ m * n) : k ∣ n :=
H1.dvd_of_dvd_mul_right (by rwa [Nat.mul_comm])
theorem Coprime.gcd_mul_left_cancel (m : Nat) (H : Coprime k n) : gcd (k * m) n = gcd m n :=
have H1 : Coprime (gcd (k * m) n) k := by
rw [Coprime, Nat.gcd_assoc, H.symm.gcd_eq_one, gcd_one_right]
Nat.dvd_antisymm
(dvd_gcd (H1.dvd_of_dvd_mul_left (gcd_dvd_left _ _)) (gcd_dvd_right _ _))
(gcd_dvd_gcd_mul_left _ _ _)
theorem Coprime.gcd_mul_right_cancel (m : Nat) (H : Coprime k n) : gcd (m * k) n = gcd m n := by
rw [Nat.mul_comm m k, H.gcd_mul_left_cancel m]
theorem Coprime.gcd_mul_left_cancel_right (n : Nat)
(H : Coprime k m) : gcd m (k * n) = gcd m n := by
rw [gcd_comm m n, gcd_comm m (k * n), H.gcd_mul_left_cancel n]
theorem Coprime.gcd_mul_right_cancel_right (n : Nat)
(H : Coprime k m) : gcd m (n * k) = gcd m n := by
rw [Nat.mul_comm n k, H.gcd_mul_left_cancel_right n]
theorem coprime_div_gcd_div_gcd
(H : 0 < gcd m n) : Coprime (m / gcd m n) (n / gcd m n) := by
rw [coprime_iff_gcd_eq_one, gcd_div (gcd_dvd_left m n) (gcd_dvd_right m n), Nat.div_self H]
theorem not_coprime_of_dvd_of_dvd (dgt1 : 1 < d) (Hm : d ∣ m) (Hn : d ∣ n) : ¬ Coprime m n :=
fun co => Nat.not_le_of_gt dgt1 <| Nat.le_of_dvd Nat.zero_lt_one <| by
rw [← co.gcd_eq_one]; exact dvd_gcd Hm Hn
theorem exists_coprime (m n : Nat) :
∃ m' n', Coprime m' n' ∧ m = m' * gcd m n ∧ n = n' * gcd m n := by
cases eq_zero_or_pos (gcd m n) with
| inl h0 =>
rw [gcd_eq_zero_iff] at h0
refine ⟨1, 1, gcd_one_left 1, ?_⟩
simp [h0]
| inr hpos =>
exact ⟨_, _, coprime_div_gcd_div_gcd hpos,
(Nat.div_mul_cancel (gcd_dvd_left m n)).symm,
(Nat.div_mul_cancel (gcd_dvd_right m n)).symm⟩
theorem exists_coprime' (H : 0 < gcd m n) :
∃ g m' n', 0 < g ∧ Coprime m' n' ∧ m = m' * g ∧ n = n' * g :=
let ⟨m', n', h⟩ := exists_coprime m n; ⟨_, m', n', H, h⟩
theorem Coprime.mul (H1 : Coprime m k) (H2 : Coprime n k) : Coprime (m * n) k :=
(H1.gcd_mul_left_cancel n).trans H2
theorem Coprime.mul_right (H1 : Coprime k m) (H2 : Coprime k n) : Coprime k (m * n) :=
(H1.symm.mul H2.symm).symm
| .lake/packages/batteries/Batteries/Data/Nat/Gcd.lean | 87 | 91 | theorem Coprime.coprime_dvd_left (H1 : m ∣ k) (H2 : Coprime k n) : Coprime m n := by |
apply eq_one_of_dvd_one
rw [Coprime] at H2
have := Nat.gcd_dvd_gcd_of_dvd_left n H1
rwa [← H2]
| 0 |
import Mathlib.MeasureTheory.Function.SimpleFunc
import Mathlib.MeasureTheory.Constructions.BorelSpace.Metrizable
#align_import measure_theory.function.simple_func_dense from "leanprover-community/mathlib"@"7317149f12f55affbc900fc873d0d422485122b9"
open Set Function Filter TopologicalSpace ENNReal EMetric Finset
open scoped Classical
open Topology ENNReal MeasureTheory
variable {α β ι E F 𝕜 : Type*}
noncomputable section
namespace MeasureTheory
local infixr:25 " →ₛ " => SimpleFunc
namespace SimpleFunc
variable [MeasurableSpace α] [PseudoEMetricSpace α] [OpensMeasurableSpace α]
noncomputable def nearestPtInd (e : ℕ → α) : ℕ → α →ₛ ℕ
| 0 => const α 0
| N + 1 =>
piecewise (⋂ k ≤ N, { x | edist (e (N + 1)) x < edist (e k) x })
(MeasurableSet.iInter fun _ =>
MeasurableSet.iInter fun _ =>
measurableSet_lt measurable_edist_right measurable_edist_right)
(const α <| N + 1) (nearestPtInd e N)
#align measure_theory.simple_func.nearest_pt_ind MeasureTheory.SimpleFunc.nearestPtInd
noncomputable def nearestPt (e : ℕ → α) (N : ℕ) : α →ₛ α :=
(nearestPtInd e N).map e
#align measure_theory.simple_func.nearest_pt MeasureTheory.SimpleFunc.nearestPt
@[simp]
theorem nearestPtInd_zero (e : ℕ → α) : nearestPtInd e 0 = const α 0 :=
rfl
#align measure_theory.simple_func.nearest_pt_ind_zero MeasureTheory.SimpleFunc.nearestPtInd_zero
@[simp]
theorem nearestPt_zero (e : ℕ → α) : nearestPt e 0 = const α (e 0) :=
rfl
#align measure_theory.simple_func.nearest_pt_zero MeasureTheory.SimpleFunc.nearestPt_zero
| Mathlib/MeasureTheory/Function/SimpleFuncDense.lean | 87 | 92 | theorem nearestPtInd_succ (e : ℕ → α) (N : ℕ) (x : α) :
nearestPtInd e (N + 1) x =
if ∀ k ≤ N, edist (e (N + 1)) x < edist (e k) x then N + 1 else nearestPtInd e N x := by |
simp only [nearestPtInd, coe_piecewise, Set.piecewise]
congr
simp
| 0 |
import Mathlib.Data.Finset.Lattice
import Mathlib.Data.Set.Sigma
#align_import data.finset.sigma from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
open Function Multiset
variable {ι : Type*}
namespace Finset
section Sigma
variable {α : ι → Type*} {β : Type*} (s s₁ s₂ : Finset ι) (t t₁ t₂ : ∀ i, Finset (α i))
protected def sigma : Finset (Σi, α i) :=
⟨_, s.nodup.sigma fun i => (t i).nodup⟩
#align finset.sigma Finset.sigma
variable {s s₁ s₂ t t₁ t₂}
@[simp]
theorem mem_sigma {a : Σi, α i} : a ∈ s.sigma t ↔ a.1 ∈ s ∧ a.2 ∈ t a.1 :=
Multiset.mem_sigma
#align finset.mem_sigma Finset.mem_sigma
@[simp, norm_cast]
theorem coe_sigma (s : Finset ι) (t : ∀ i, Finset (α i)) :
(s.sigma t : Set (Σ i, α i)) = (s : Set ι).sigma fun i ↦ (t i : Set (α i)) :=
Set.ext fun _ => mem_sigma
#align finset.coe_sigma Finset.coe_sigma
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
theorem sigma_nonempty : (s.sigma t).Nonempty ↔ ∃ i ∈ s, (t i).Nonempty := by simp [Finset.Nonempty]
#align finset.sigma_nonempty Finset.sigma_nonempty
@[simp]
theorem sigma_eq_empty : s.sigma t = ∅ ↔ ∀ i ∈ s, t i = ∅ := by
simp only [← not_nonempty_iff_eq_empty, sigma_nonempty, not_exists, not_and]
#align finset.sigma_eq_empty Finset.sigma_eq_empty
@[mono]
theorem sigma_mono (hs : s₁ ⊆ s₂) (ht : ∀ i, t₁ i ⊆ t₂ i) : s₁.sigma t₁ ⊆ s₂.sigma t₂ :=
fun ⟨i, _⟩ h =>
let ⟨hi, ha⟩ := mem_sigma.1 h
mem_sigma.2 ⟨hs hi, ht i ha⟩
#align finset.sigma_mono Finset.sigma_mono
| Mathlib/Data/Finset/Sigma.lean | 75 | 81 | theorem pairwiseDisjoint_map_sigmaMk :
(s : Set ι).PairwiseDisjoint fun i => (t i).map (Embedding.sigmaMk i) := by |
intro i _ j _ hij
rw [Function.onFun, disjoint_left]
simp_rw [mem_map, Function.Embedding.sigmaMk_apply]
rintro _ ⟨y, _, rfl⟩ ⟨z, _, hz'⟩
exact hij (congr_arg Sigma.fst hz'.symm)
| 0 |
import Mathlib.Tactic.CategoryTheory.Elementwise
import Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer
import Mathlib.CategoryTheory.Limits.Constructions.EpiMono
import Mathlib.CategoryTheory.Limits.Preserves.Limits
import Mathlib.CategoryTheory.Limits.Shapes.Types
#align_import category_theory.glue_data from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7"
noncomputable section
open CategoryTheory.Limits
namespace CategoryTheory
universe v u₁ u₂
variable (C : Type u₁) [Category.{v} C] {C' : Type u₂} [Category.{v} C']
-- Porting note(#5171): linter not ported yet
-- @[nolint has_nonempty_instance]
structure GlueData where
J : Type v
U : J → C
V : J × J → C
f : ∀ i j, V (i, j) ⟶ U i
f_mono : ∀ i j, Mono (f i j) := by infer_instance
f_hasPullback : ∀ i j k, HasPullback (f i j) (f i k) := by infer_instance
f_id : ∀ i, IsIso (f i i) := by infer_instance
t : ∀ i j, V (i, j) ⟶ V (j, i)
t_id : ∀ i, t i i = 𝟙 _
t' : ∀ i j k, pullback (f i j) (f i k) ⟶ pullback (f j k) (f j i)
t_fac : ∀ i j k, t' i j k ≫ pullback.snd = pullback.fst ≫ t i j
cocycle : ∀ i j k, t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _
#align category_theory.glue_data CategoryTheory.GlueData
attribute [simp] GlueData.t_id
attribute [instance] GlueData.f_id GlueData.f_mono GlueData.f_hasPullback
attribute [reassoc] GlueData.t_fac GlueData.cocycle
namespace GlueData
variable {C}
variable (D : GlueData C)
@[simp]
| Mathlib/CategoryTheory/GlueData.lean | 77 | 85 | theorem t'_iij (i j : D.J) : D.t' i i j = (pullbackSymmetry _ _).hom := by |
have eq₁ := D.t_fac i i j
have eq₂ := (IsIso.eq_comp_inv (D.f i i)).mpr (@pullback.condition _ _ _ _ _ _ (D.f i j) _)
rw [D.t_id, Category.comp_id, eq₂] at eq₁
have eq₃ := (IsIso.eq_comp_inv (D.f i i)).mp eq₁
rw [Category.assoc, ← pullback.condition, ← Category.assoc] at eq₃
exact
Mono.right_cancellation _ _
((Mono.right_cancellation _ _ eq₃).trans (pullbackSymmetry_hom_comp_fst _ _).symm)
| 0 |
import Mathlib.LinearAlgebra.CliffordAlgebra.Contraction
variable {R M : Type*}
variable [CommRing R] [AddCommGroup M] [Module R M] {Q : QuadraticForm R M}
namespace CliffordAlgebra
variable (Q)
def invertibleιOfInvertible (m : M) [Invertible (Q m)] : Invertible (ι Q m) where
invOf := ι Q (⅟ (Q m) • m)
invOf_mul_self := by
rw [map_smul, smul_mul_assoc, ι_sq_scalar, Algebra.smul_def, ← map_mul, invOf_mul_self, map_one]
mul_invOf_self := by
rw [map_smul, mul_smul_comm, ι_sq_scalar, Algebra.smul_def, ← map_mul, invOf_mul_self, map_one]
#align clifford_algebra.invertible_ι_of_invertible CliffordAlgebra.invertibleιOfInvertible
theorem invOf_ι (m : M) [Invertible (Q m)] [Invertible (ι Q m)] :
⅟ (ι Q m) = ι Q (⅟ (Q m) • m) := by
letI := invertibleιOfInvertible Q m
convert (rfl : ⅟ (ι Q m) = _)
#align clifford_algebra.inv_of_ι CliffordAlgebra.invOf_ι
theorem isUnit_ι_of_isUnit {m : M} (h : IsUnit (Q m)) : IsUnit (ι Q m) := by
cases h.nonempty_invertible
letI := invertibleιOfInvertible Q m
exact isUnit_of_invertible (ι Q m)
#align clifford_algebra.is_unit_ι_of_is_unit CliffordAlgebra.isUnit_ι_of_isUnit
| Mathlib/LinearAlgebra/CliffordAlgebra/Inversion.lean | 44 | 47 | theorem ι_mul_ι_mul_invOf_ι (a b : M) [Invertible (ι Q a)] [Invertible (Q a)] :
ι Q a * ι Q b * ⅟ (ι Q a) = ι Q ((⅟ (Q a) * QuadraticForm.polar Q a b) • a - b) := by |
rw [invOf_ι, map_smul, mul_smul_comm, ι_mul_ι_mul_ι, ← map_smul, smul_sub, smul_smul, smul_smul,
invOf_mul_self, one_smul]
| 0 |
import Mathlib.Topology.Defs.Sequences
import Mathlib.Topology.UniformSpace.Cauchy
#align_import topology.sequences from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Set Function Filter TopologicalSpace Bornology
open scoped Topology Uniformity
variable {X Y : Type*}
section TopologicalSpace
variable [TopologicalSpace X] [TopologicalSpace Y]
theorem subset_seqClosure {s : Set X} : s ⊆ seqClosure s := fun p hp =>
⟨const ℕ p, fun _ => hp, tendsto_const_nhds⟩
#align subset_seq_closure subset_seqClosure
theorem seqClosure_subset_closure {s : Set X} : seqClosure s ⊆ closure s := fun _p ⟨_x, xM, xp⟩ =>
mem_closure_of_tendsto xp (univ_mem' xM)
#align seq_closure_subset_closure seqClosure_subset_closure
theorem IsSeqClosed.seqClosure_eq {s : Set X} (hs : IsSeqClosed s) : seqClosure s = s :=
Subset.antisymm (fun _p ⟨_x, hx, hp⟩ => hs hx hp) subset_seqClosure
#align is_seq_closed.seq_closure_eq IsSeqClosed.seqClosure_eq
theorem isSeqClosed_of_seqClosure_eq {s : Set X} (hs : seqClosure s = s) : IsSeqClosed s :=
fun x _p hxs hxp => hs ▸ ⟨x, hxs, hxp⟩
#align is_seq_closed_of_seq_closure_eq isSeqClosed_of_seqClosure_eq
theorem isSeqClosed_iff {s : Set X} : IsSeqClosed s ↔ seqClosure s = s :=
⟨IsSeqClosed.seqClosure_eq, isSeqClosed_of_seqClosure_eq⟩
#align is_seq_closed_iff isSeqClosed_iff
protected theorem IsClosed.isSeqClosed {s : Set X} (hc : IsClosed s) : IsSeqClosed s :=
fun _u _x hu hx => hc.mem_of_tendsto hx (eventually_of_forall hu)
#align is_closed.is_seq_closed IsClosed.isSeqClosed
theorem seqClosure_eq_closure [FrechetUrysohnSpace X] (s : Set X) : seqClosure s = closure s :=
seqClosure_subset_closure.antisymm <| FrechetUrysohnSpace.closure_subset_seqClosure s
#align seq_closure_eq_closure seqClosure_eq_closure
theorem mem_closure_iff_seq_limit [FrechetUrysohnSpace X] {s : Set X} {a : X} :
a ∈ closure s ↔ ∃ x : ℕ → X, (∀ n : ℕ, x n ∈ s) ∧ Tendsto x atTop (𝓝 a) := by
rw [← seqClosure_eq_closure]
rfl
#align mem_closure_iff_seq_limit mem_closure_iff_seq_limit
theorem tendsto_nhds_iff_seq_tendsto [FrechetUrysohnSpace X] {f : X → Y} {a : X} {b : Y} :
Tendsto f (𝓝 a) (𝓝 b) ↔ ∀ u : ℕ → X, Tendsto u atTop (𝓝 a) → Tendsto (f ∘ u) atTop (𝓝 b) := by
refine
⟨fun hf u hu => hf.comp hu, fun h =>
((nhds_basis_closeds _).tendsto_iff (nhds_basis_closeds _)).2 ?_⟩
rintro s ⟨hbs, hsc⟩
refine ⟨closure (f ⁻¹' s), ⟨mt ?_ hbs, isClosed_closure⟩, fun x => mt fun hx => subset_closure hx⟩
rw [← seqClosure_eq_closure]
rintro ⟨u, hus, hu⟩
exact hsc.mem_of_tendsto (h u hu) (eventually_of_forall hus)
#align tendsto_nhds_iff_seq_tendsto tendsto_nhds_iff_seq_tendsto
| Mathlib/Topology/Sequences.lean | 139 | 151 | theorem FrechetUrysohnSpace.of_seq_tendsto_imp_tendsto
(h : ∀ (f : X → Prop) (a : X),
(∀ u : ℕ → X, Tendsto u atTop (𝓝 a) → Tendsto (f ∘ u) atTop (𝓝 (f a))) → ContinuousAt f a) :
FrechetUrysohnSpace X := by |
refine ⟨fun s x hcx => ?_⟩
by_cases hx : x ∈ s;
· exact subset_seqClosure hx
· obtain ⟨u, hux, hus⟩ : ∃ u : ℕ → X, Tendsto u atTop (𝓝 x) ∧ ∃ᶠ x in atTop, u x ∈ s := by
simpa only [ContinuousAt, hx, tendsto_nhds_true, (· ∘ ·), ← not_frequently, exists_prop,
← mem_closure_iff_frequently, hcx, imp_false, not_forall, not_not, not_false_eq_true,
not_true_eq_false] using h (· ∉ s) x
rcases extraction_of_frequently_atTop hus with ⟨φ, φ_mono, hφ⟩
exact ⟨u ∘ φ, hφ, hux.comp φ_mono.tendsto_atTop⟩
| 0 |
import Mathlib.Data.Sigma.Basic
import Mathlib.Algebra.Order.Ring.Nat
#align_import set_theory.lists from "leanprover-community/mathlib"@"497d1e06409995dd8ec95301fa8d8f3480187f4c"
variable {α : Type*}
inductive Lists'.{u} (α : Type u) : Bool → Type u
| atom : α → Lists' α false
| nil : Lists' α true
| cons' {b} : Lists' α b → Lists' α true → Lists' α true
deriving DecidableEq
#align lists' Lists'
compile_inductive% Lists'
def Lists (α : Type*) :=
Σb, Lists' α b
#align lists Lists
namespace Lists'
instance [Inhabited α] : ∀ b, Inhabited (Lists' α b)
| true => ⟨nil⟩
| false => ⟨atom default⟩
def cons : Lists α → Lists' α true → Lists' α true
| ⟨_, a⟩, l => cons' a l
#align lists'.cons Lists'.cons
@[simp]
def toList : ∀ {b}, Lists' α b → List (Lists α)
| _, atom _ => []
| _, nil => []
| _, cons' a l => ⟨_, a⟩ :: l.toList
#align lists'.to_list Lists'.toList
-- Porting note (#10618): removed @[simp]
-- simp can prove this: by simp only [@Lists'.toList, @Sigma.eta]
theorem toList_cons (a : Lists α) (l) : toList (cons a l) = a :: l.toList := by simp
#align lists'.to_list_cons Lists'.toList_cons
@[simp]
def ofList : List (Lists α) → Lists' α true
| [] => nil
| a :: l => cons a (ofList l)
#align lists'.of_list Lists'.ofList
@[simp]
theorem to_ofList (l : List (Lists α)) : toList (ofList l) = l := by induction l <;> simp [*]
#align lists'.to_of_list Lists'.to_ofList
@[simp]
| Mathlib/SetTheory/Lists.lean | 103 | 120 | theorem of_toList : ∀ l : Lists' α true, ofList (toList l) = l :=
suffices
∀ (b) (h : true = b) (l : Lists' α b),
let l' : Lists' α true := by | rw [h]; exact l
ofList (toList l') = l'
from this _ rfl
fun b h l => by
induction l with
| atom => cases h
-- Porting note: case nil was not covered.
| nil => simp
| cons' b a _ IH =>
intro l'
-- Porting note: Previous code was:
-- change l' with cons' a l
--
-- This can be removed.
simpa [cons, l'] using IH rfl
| 0 |
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup
import Mathlib.LinearAlgebra.Matrix.Nondegenerate
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.LinearAlgebra.Matrix.ToLin
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Integer
#align_import linear_algebra.matrix.to_linear_equiv from "leanprover-community/mathlib"@"e42cfdb03b7902f8787a1eb552cb8f77766b45b9"
variable {n : Type*} [Fintype n]
namespace Matrix
section LinearEquiv
open LinearMap
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]
section Nondegenerate
open Matrix
theorem exists_mulVec_eq_zero_iff_aux {K : Type*} [DecidableEq n] [Field K] {M : Matrix n n K} :
(∃ v ≠ 0, M *ᵥ v = 0) ↔ M.det = 0 := by
constructor
· rintro ⟨v, hv, mul_eq⟩
contrapose! hv
exact eq_zero_of_mulVec_eq_zero hv mul_eq
· contrapose!
intro h
have : Function.Injective (Matrix.toLin' M) := by
simpa only [← LinearMap.ker_eq_bot, ker_toLin'_eq_bot_iff, not_imp_not] using h
have :
M *
LinearMap.toMatrix'
((LinearEquiv.ofInjectiveEndo (Matrix.toLin' M) this).symm : (n → K) →ₗ[K] n → K) =
1 := by
refine Matrix.toLin'.injective (LinearMap.ext fun v => ?_)
rw [Matrix.toLin'_mul, Matrix.toLin'_one, Matrix.toLin'_toMatrix', LinearMap.comp_apply]
exact (LinearEquiv.ofInjectiveEndo (Matrix.toLin' M) this).apply_symm_apply v
exact Matrix.det_ne_zero_of_right_inverse this
#align matrix.exists_mul_vec_eq_zero_iff_aux Matrix.exists_mulVec_eq_zero_iff_aux
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A]
[Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} :
(∃ v ≠ 0, M *ᵥ v = 0) ↔ M.det = 0 := by
have : (∃ v ≠ 0, (algebraMap A K).mapMatrix M *ᵥ v = 0) ↔ _ :=
exists_mulVec_eq_zero_iff_aux
rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this
refine Iff.trans ?_ this; constructor <;> rintro ⟨v, hv, mul_eq⟩
· refine ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => ?_) hv, ?_⟩
· exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i)
· ext i
refine (RingHom.map_mulVec _ _ _ i).symm.trans ?_
rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply]
· letI := Classical.decEq K
obtain ⟨⟨b, hb⟩, ba_eq⟩ :=
IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v)
choose f hf using ba_eq
refine
⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩),
mt (fun h => funext fun i => ?_) hv, ?_⟩
· have := congr_arg (algebraMap A K) (congr_fun h i)
rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero,
IsFractionRing.to_map_eq_zero_iff] at this
exact this.resolve_left (nonZeroDivisors.ne_zero hb)
· ext i
refine IsFractionRing.injective A K ?_
calc
algebraMap A K ((M *ᵥ (fun i : n => f (v i) _)) i) =
((algebraMap A K).mapMatrix M *ᵥ algebraMap _ K b • v) i := ?_
_ = 0 := ?_
_ = algebraMap A K 0 := (RingHom.map_zero _).symm
· simp_rw [RingHom.map_mulVec, mulVec, dotProduct, Function.comp_apply, hf,
RingHom.mapMatrix_apply, Pi.smul_apply, smul_eq_mul, Algebra.smul_def]
· rw [mulVec_smul, mul_eq, Pi.smul_apply, Pi.zero_apply, smul_zero]
#align matrix.exists_mul_vec_eq_zero_iff' Matrix.exists_mulVec_eq_zero_iff'
theorem exists_mulVec_eq_zero_iff {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
{M : Matrix n n A} : (∃ v ≠ 0, M *ᵥ v = 0) ↔ M.det = 0 :=
exists_mulVec_eq_zero_iff' (FractionRing A)
#align matrix.exists_mul_vec_eq_zero_iff Matrix.exists_mulVec_eq_zero_iff
theorem exists_vecMul_eq_zero_iff {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
{M : Matrix n n A} : (∃ v ≠ 0, v ᵥ* M = 0) ↔ M.det = 0 := by
simpa only [← M.det_transpose, ← mulVec_transpose] using exists_mulVec_eq_zero_iff
#align matrix.exists_vec_mul_eq_zero_iff Matrix.exists_vecMul_eq_zero_iff
| Mathlib/LinearAlgebra/Matrix/ToLinearEquiv.lean | 180 | 190 | theorem nondegenerate_iff_det_ne_zero {A : Type*} [DecidableEq n] [CommRing A] [IsDomain A]
{M : Matrix n n A} : Nondegenerate M ↔ M.det ≠ 0 := by |
rw [ne_eq, ← exists_vecMul_eq_zero_iff]
push_neg
constructor
· intro hM v hv hMv
obtain ⟨w, hwMv⟩ := hM.exists_not_ortho_of_ne_zero hv
simp [dotProduct_mulVec, hMv, zero_dotProduct, ne_eq, not_true] at hwMv
· intro h v hv
refine not_imp_not.mp (h v) (funext fun i => ?_)
simpa only [dotProduct_mulVec, dotProduct_single, mul_one] using hv (Pi.single i 1)
| 0 |
import Mathlib.RingTheory.Ideal.IsPrimary
import Mathlib.RingTheory.Localization.AtPrime
import Mathlib.Order.Minimal
#align_import ring_theory.ideal.minimal_prime from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
section
variable {R S : Type*} [CommSemiring R] [CommSemiring S] (I J : Ideal R)
protected def Ideal.minimalPrimes : Set (Ideal R) :=
minimals (· ≤ ·) { p | p.IsPrime ∧ I ≤ p }
#align ideal.minimal_primes Ideal.minimalPrimes
variable (R) in
def minimalPrimes : Set (Ideal R) :=
Ideal.minimalPrimes ⊥
#align minimal_primes minimalPrimes
lemma minimalPrimes_eq_minimals : minimalPrimes R = minimals (· ≤ ·) (setOf Ideal.IsPrime) :=
congr_arg (minimals (· ≤ ·)) (by simp)
variable {I J}
theorem Ideal.exists_minimalPrimes_le [J.IsPrime] (e : I ≤ J) : ∃ p ∈ I.minimalPrimes, p ≤ J := by
suffices
∃ m ∈ { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ OrderDual.ofDual p },
OrderDual.toDual J ≤ m ∧ ∀ z ∈ { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ p }, m ≤ z → z = m by
obtain ⟨p, h₁, h₂, h₃⟩ := this
simp_rw [← @eq_comm _ p] at h₃
exact ⟨p, ⟨h₁, fun a b c => le_of_eq (h₃ a b c)⟩, h₂⟩
apply zorn_nonempty_partialOrder₀
swap
· refine ⟨show J.IsPrime by infer_instance, e⟩
rintro (c : Set (Ideal R)) hc hc' J' hJ'
refine
⟨OrderDual.toDual (sInf c),
⟨Ideal.sInf_isPrime_of_isChain ⟨J', hJ'⟩ hc'.symm fun x hx => (hc hx).1, ?_⟩, ?_⟩
· rw [OrderDual.ofDual_toDual, le_sInf_iff]
exact fun _ hx => (hc hx).2
· rintro z hz
rw [OrderDual.le_toDual]
exact sInf_le hz
#align ideal.exists_minimal_primes_le Ideal.exists_minimalPrimes_le
@[simp]
theorem Ideal.radical_minimalPrimes : I.radical.minimalPrimes = I.minimalPrimes := by
rw [Ideal.minimalPrimes, Ideal.minimalPrimes]
ext p
refine ⟨?_, ?_⟩ <;> rintro ⟨⟨a, ha⟩, b⟩
· refine ⟨⟨a, a.radical_le_iff.1 ha⟩, ?_⟩
simp only [Set.mem_setOf_eq, and_imp] at *
exact fun _ h2 h3 h4 => b h2 (h2.radical_le_iff.2 h3) h4
· refine ⟨⟨a, a.radical_le_iff.2 ha⟩, ?_⟩
simp only [Set.mem_setOf_eq, and_imp] at *
exact fun _ h2 h3 h4 => b h2 (h2.radical_le_iff.1 h3) h4
#align ideal.radical_minimal_primes Ideal.radical_minimalPrimes
@[simp]
theorem Ideal.sInf_minimalPrimes : sInf I.minimalPrimes = I.radical := by
rw [I.radical_eq_sInf]
apply le_antisymm
· intro x hx
rw [Ideal.mem_sInf] at hx ⊢
rintro J ⟨e, hJ⟩
obtain ⟨p, hp, hp'⟩ := Ideal.exists_minimalPrimes_le e
exact hp' (hx hp)
· apply sInf_le_sInf _
intro I hI
exact hI.1.symm
#align ideal.Inf_minimal_primes Ideal.sInf_minimalPrimes
| Mathlib/RingTheory/Ideal/MinimalPrime.lean | 104 | 125 | theorem Ideal.exists_comap_eq_of_mem_minimalPrimes_of_injective {f : R →+* S}
(hf : Function.Injective f) (p) (H : p ∈ minimalPrimes R) :
∃ p' : Ideal S, p'.IsPrime ∧ p'.comap f = p := by |
have := H.1.1
have : Nontrivial (Localization (Submonoid.map f p.primeCompl)) := by
refine ⟨⟨1, 0, ?_⟩⟩
convert (IsLocalization.map_injective_of_injective p.primeCompl (Localization.AtPrime p)
(Localization <| p.primeCompl.map f) hf).ne one_ne_zero
· rw [map_one]
· rw [map_zero]
obtain ⟨M, hM⟩ := Ideal.exists_maximal (Localization (Submonoid.map f p.primeCompl))
refine ⟨M.comap (algebraMap S <| Localization (Submonoid.map f p.primeCompl)), inferInstance, ?_⟩
rw [Ideal.comap_comap, ← @IsLocalization.map_comp _ _ _ _ _ _ _ _ Localization.isLocalization
_ _ _ _ p.primeCompl.le_comap_map _ Localization.isLocalization,
← Ideal.comap_comap]
suffices _ ≤ p by exact this.antisymm (H.2 ⟨inferInstance, bot_le⟩ this)
intro x hx
by_contra h
apply hM.ne_top
apply M.eq_top_of_isUnit_mem hx
apply IsUnit.map
apply IsLocalization.map_units _ (show p.primeCompl from ⟨x, h⟩)
| 0 |
import Mathlib.MeasureTheory.Decomposition.SignedLebesgue
import Mathlib.MeasureTheory.Measure.WithDensityVectorMeasure
#align_import measure_theory.decomposition.radon_nikodym from "leanprover-community/mathlib"@"fc75855907eaa8ff39791039710f567f37d4556f"
noncomputable section
open scoped Classical MeasureTheory NNReal ENNReal
variable {α β : Type*} {m : MeasurableSpace α}
namespace MeasureTheory
namespace Measure
| Mathlib/MeasureTheory/Decomposition/RadonNikodym.lean | 56 | 66 | theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
ν.withDensity (rnDeriv μ ν) = μ := by |
suffices μ.singularPart ν = 0 by
conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
suffices μ.singularPart ν Set.univ = 0 by simpa using this
have h_sing := mutuallySingular_singularPart μ ν
rw [← measure_add_measure_compl h_sing.measurableSet_nullSet]
simp only [MutuallySingular.measure_nullSet, zero_add]
refine le_antisymm ?_ (zero_le _)
refine (singularPart_le μ ν ?_ ).trans_eq ?_
exact h h_sing.measure_compl_nullSet
| 0 |
import Mathlib.AlgebraicTopology.DoldKan.PInfty
#align_import algebraic_topology.dold_kan.decomposition from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504"
open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive
Opposite Simplicial
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X X' : SimplicialObject C}
| Mathlib/AlgebraicTopology/DoldKan/Decomposition.lean | 52 | 81 | theorem decomposition_Q (n q : ℕ) :
((Q q).f (n + 1) : X _[n + 1] ⟶ X _[n + 1]) =
∑ i ∈ Finset.filter (fun i : Fin (n + 1) => (i : ℕ) < q) Finset.univ,
(P i).f (n + 1) ≫ X.δ i.rev.succ ≫ X.σ (Fin.rev i) := by |
induction' q with q hq
· simp only [Nat.zero_eq, Q_zero, HomologicalComplex.zero_f_apply, Nat.not_lt_zero,
Finset.filter_False, Finset.sum_empty]
· by_cases hqn : q + 1 ≤ n + 1
swap
· rw [Q_is_eventually_constant (show n + 1 ≤ q by omega), hq]
congr 1
ext ⟨x, hx⟩
simp only [Nat.succ_eq_add_one, Finset.mem_filter, Finset.mem_univ, true_and]
omega
· cases' Nat.le.dest (Nat.succ_le_succ_iff.mp hqn) with a ha
rw [Q_succ, HomologicalComplex.sub_f_apply, HomologicalComplex.comp_f, hq]
symm
conv_rhs => rw [sub_eq_add_neg, add_comm]
let q' : Fin (n + 1) := ⟨q, Nat.succ_le_iff.mp hqn⟩
rw [← @Finset.add_sum_erase _ _ _ _ _ _ q' (by simp)]
congr
· have hnaq' : n = a + q := by omega
simp only [Fin.val_mk, (HigherFacesVanish.of_P q n).comp_Hσ_eq hnaq',
q'.rev_eq hnaq', neg_neg]
rfl
· ext ⟨i, hi⟩
simp only [q', Nat.succ_eq_add_one, Nat.lt_succ_iff_lt_or_eq, Finset.mem_univ,
forall_true_left, Finset.mem_filter, lt_self_iff_false, or_true, and_self, not_true,
Finset.mem_erase, ne_eq, Fin.mk.injEq, true_and]
aesop
| 0 |
import Mathlib.Topology.Sets.Opens
#align_import topology.local_at_target from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open TopologicalSpace Set Filter
open Topology Filter
variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {f : α → β}
variable {s : Set β} {ι : Type*} {U : ι → Opens β} (hU : iSup U = ⊤)
theorem Set.restrictPreimage_inducing (s : Set β) (h : Inducing f) :
Inducing (s.restrictPreimage f) := by
simp_rw [← inducing_subtype_val.of_comp_iff, inducing_iff_nhds, restrictPreimage,
MapsTo.coe_restrict, restrict_eq, ← @Filter.comap_comap _ _ _ _ _ f, Function.comp_apply] at h ⊢
intro a
rw [← h, ← inducing_subtype_val.nhds_eq_comap]
#align set.restrict_preimage_inducing Set.restrictPreimage_inducing
alias Inducing.restrictPreimage := Set.restrictPreimage_inducing
#align inducing.restrict_preimage Inducing.restrictPreimage
theorem Set.restrictPreimage_embedding (s : Set β) (h : Embedding f) :
Embedding (s.restrictPreimage f) :=
⟨h.1.restrictPreimage s, h.2.restrictPreimage s⟩
#align set.restrict_preimage_embedding Set.restrictPreimage_embedding
alias Embedding.restrictPreimage := Set.restrictPreimage_embedding
#align embedding.restrict_preimage Embedding.restrictPreimage
theorem Set.restrictPreimage_openEmbedding (s : Set β) (h : OpenEmbedding f) :
OpenEmbedding (s.restrictPreimage f) :=
⟨h.1.restrictPreimage s,
(s.range_restrictPreimage f).symm ▸ continuous_subtype_val.isOpen_preimage _ h.isOpen_range⟩
#align set.restrict_preimage_open_embedding Set.restrictPreimage_openEmbedding
alias OpenEmbedding.restrictPreimage := Set.restrictPreimage_openEmbedding
#align open_embedding.restrict_preimage OpenEmbedding.restrictPreimage
theorem Set.restrictPreimage_closedEmbedding (s : Set β) (h : ClosedEmbedding f) :
ClosedEmbedding (s.restrictPreimage f) :=
⟨h.1.restrictPreimage s,
(s.range_restrictPreimage f).symm ▸ inducing_subtype_val.isClosed_preimage _ h.isClosed_range⟩
#align set.restrict_preimage_closed_embedding Set.restrictPreimage_closedEmbedding
alias ClosedEmbedding.restrictPreimage := Set.restrictPreimage_closedEmbedding
#align closed_embedding.restrict_preimage ClosedEmbedding.restrictPreimage
theorem IsClosedMap.restrictPreimage (H : IsClosedMap f) (s : Set β) :
IsClosedMap (s.restrictPreimage f) := by
intro t
suffices ∀ u, IsClosed u → Subtype.val ⁻¹' u = t →
∃ v, IsClosed v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by
simpa [isClosed_induced_iff]
exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩
@[deprecated (since := "2024-04-02")]
theorem Set.restrictPreimage_isClosedMap (s : Set β) (H : IsClosedMap f) :
IsClosedMap (s.restrictPreimage f) := H.restrictPreimage s
theorem IsOpenMap.restrictPreimage (H : IsOpenMap f) (s : Set β) :
IsOpenMap (s.restrictPreimage f) := by
intro t
suffices ∀ u, IsOpen u → Subtype.val ⁻¹' u = t →
∃ v, IsOpen v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by
simpa [isOpen_induced_iff]
exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩
@[deprecated (since := "2024-04-02")]
theorem Set.restrictPreimage_isOpenMap (s : Set β) (H : IsOpenMap f) :
IsOpenMap (s.restrictPreimage f) := H.restrictPreimage s
theorem isOpen_iff_inter_of_iSup_eq_top (s : Set β) : IsOpen s ↔ ∀ i, IsOpen (s ∩ U i) := by
constructor
· exact fun H i => H.inter (U i).2
· intro H
have : ⋃ i, (U i : Set β) = Set.univ := by
convert congr_arg (SetLike.coe) hU
simp
rw [← s.inter_univ, ← this, Set.inter_iUnion]
exact isOpen_iUnion H
#align is_open_iff_inter_of_supr_eq_top isOpen_iff_inter_of_iSup_eq_top
| Mathlib/Topology/LocalAtTarget.lean | 101 | 108 | theorem isOpen_iff_coe_preimage_of_iSup_eq_top (s : Set β) :
IsOpen s ↔ ∀ i, IsOpen ((↑) ⁻¹' s : Set (U i)) := by |
-- Porting note: rewrote to avoid ´simp´ issues
rw [isOpen_iff_inter_of_iSup_eq_top hU s]
refine forall_congr' fun i => ?_
rw [(U _).2.openEmbedding_subtype_val.open_iff_image_open]
erw [Set.image_preimage_eq_inter_range]
rw [Subtype.range_coe, Opens.carrier_eq_coe]
| 0 |
import Mathlib.AlgebraicGeometry.Restrict
import Mathlib.CategoryTheory.Adjunction.Limits
import Mathlib.CategoryTheory.Adjunction.Reflective
#align_import algebraic_geometry.Gamma_Spec_adjunction from "leanprover-community/mathlib"@"d39590fc8728fbf6743249802486f8c91ffe07bc"
-- Explicit universe annotations were used in this file to improve perfomance #12737
set_option linter.uppercaseLean3 false
noncomputable section
universe u
open PrimeSpectrum
namespace AlgebraicGeometry
open Opposite
open CategoryTheory
open StructureSheaf
open Spec (structureSheaf)
open TopologicalSpace
open AlgebraicGeometry.LocallyRingedSpace
open TopCat.Presheaf
open TopCat.Presheaf.SheafCondition
namespace LocallyRingedSpace
variable (X : LocallyRingedSpace.{u})
def ΓToStalk (x : X) : Γ.obj (op X) ⟶ X.presheaf.stalk x :=
X.presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens X))
#align algebraic_geometry.LocallyRingedSpace.Γ_to_stalk AlgebraicGeometry.LocallyRingedSpace.ΓToStalk
def toΓSpecFun : X → PrimeSpectrum (Γ.obj (op X)) := fun x =>
comap (X.ΓToStalk x) (LocalRing.closedPoint (X.presheaf.stalk x))
#align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_fun AlgebraicGeometry.LocallyRingedSpace.toΓSpecFun
theorem not_mem_prime_iff_unit_in_stalk (r : Γ.obj (op X)) (x : X) :
r ∉ (X.toΓSpecFun x).asIdeal ↔ IsUnit (X.ΓToStalk x r) := by
erw [LocalRing.mem_maximalIdeal, Classical.not_not]
#align algebraic_geometry.LocallyRingedSpace.not_mem_prime_iff_unit_in_stalk AlgebraicGeometry.LocallyRingedSpace.not_mem_prime_iff_unit_in_stalk
theorem toΓSpec_preim_basicOpen_eq (r : Γ.obj (op X)) :
X.toΓSpecFun ⁻¹' (basicOpen r).1 = (X.toRingedSpace.basicOpen r).1 := by
ext
erw [X.toRingedSpace.mem_top_basicOpen]; apply not_mem_prime_iff_unit_in_stalk
#align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_preim_basic_open_eq AlgebraicGeometry.LocallyRingedSpace.toΓSpec_preim_basicOpen_eq
theorem toΓSpec_continuous : Continuous X.toΓSpecFun := by
rw [isTopologicalBasis_basic_opens.continuous_iff]
rintro _ ⟨r, rfl⟩
erw [X.toΓSpec_preim_basicOpen_eq r]
exact (X.toRingedSpace.basicOpen r).2
#align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_continuous AlgebraicGeometry.LocallyRingedSpace.toΓSpec_continuous
@[simps]
def toΓSpecBase : X.toTopCat ⟶ Spec.topObj (Γ.obj (op X)) where
toFun := X.toΓSpecFun
continuous_toFun := X.toΓSpec_continuous
#align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_base AlgebraicGeometry.LocallyRingedSpace.toΓSpecBase
-- These lemmas have always been bad (#7657), but lean4#2644 made `simp` start noticing
attribute [nolint simpNF] AlgebraicGeometry.LocallyRingedSpace.toΓSpecBase_apply
variable (r : Γ.obj (op X))
abbrev toΓSpecMapBasicOpen : Opens X :=
(Opens.map X.toΓSpecBase).obj (basicOpen r)
#align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_map_basic_open AlgebraicGeometry.LocallyRingedSpace.toΓSpecMapBasicOpen
theorem toΓSpecMapBasicOpen_eq : X.toΓSpecMapBasicOpen r = X.toRingedSpace.basicOpen r :=
Opens.ext (X.toΓSpec_preim_basicOpen_eq r)
#align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_map_basic_open_eq AlgebraicGeometry.LocallyRingedSpace.toΓSpecMapBasicOpen_eq
abbrev toToΓSpecMapBasicOpen :
X.presheaf.obj (op ⊤) ⟶ X.presheaf.obj (op <| X.toΓSpecMapBasicOpen r) :=
X.presheaf.map (X.toΓSpecMapBasicOpen r).leTop.op
#align algebraic_geometry.LocallyRingedSpace.to_to_Γ_Spec_map_basic_open AlgebraicGeometry.LocallyRingedSpace.toToΓSpecMapBasicOpen
theorem isUnit_res_toΓSpecMapBasicOpen : IsUnit (X.toToΓSpecMapBasicOpen r r) := by
convert
(X.presheaf.map <| (eqToHom <| X.toΓSpecMapBasicOpen_eq r).op).isUnit_map
(X.toRingedSpace.isUnit_res_basicOpen r)
-- Porting note: `rw [comp_apply]` to `erw [comp_apply]`
erw [← comp_apply, ← Functor.map_comp]
congr
#align algebraic_geometry.LocallyRingedSpace.is_unit_res_to_Γ_Spec_map_basic_open AlgebraicGeometry.LocallyRingedSpace.isUnit_res_toΓSpecMapBasicOpen
def toΓSpecCApp :
(structureSheaf <| Γ.obj <| op X).val.obj (op <| basicOpen r) ⟶
X.presheaf.obj (op <| X.toΓSpecMapBasicOpen r) :=
IsLocalization.Away.lift r (isUnit_res_toΓSpecMapBasicOpen _ r)
#align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_c_app AlgebraicGeometry.LocallyRingedSpace.toΓSpecCApp
| Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean | 146 | 160 | theorem toΓSpecCApp_iff
(f :
(structureSheaf <| Γ.obj <| op X).val.obj (op <| basicOpen r) ⟶
X.presheaf.obj (op <| X.toΓSpecMapBasicOpen r)) :
toOpen _ (basicOpen r) ≫ f = X.toToΓSpecMapBasicOpen r ↔ f = X.toΓSpecCApp r := by |
-- Porting Note: Type class problem got stuck in `IsLocalization.Away.AwayMap.lift_comp`
-- created instance manually. This replaces the `pick_goal` tactics
have loc_inst := IsLocalization.to_basicOpen (Γ.obj (op X)) r
rw [← @IsLocalization.Away.AwayMap.lift_comp _ _ _ _ _ _ _ r loc_inst _
(X.isUnit_res_toΓSpecMapBasicOpen r)]
--pick_goal 5; exact is_localization.to_basic_open _ r
constructor
· intro h
exact IsLocalization.ringHom_ext (Submonoid.powers r) h
apply congr_arg
| 0 |
import Mathlib.Data.Set.Lattice
import Mathlib.Data.Set.Pairwise.Basic
#align_import data.set.pairwise.lattice from "leanprover-community/mathlib"@"c4c2ed622f43768eff32608d4a0f8a6cec1c047d"
open Function Set Order
variable {α β γ ι ι' : Type*} {κ : Sort*} {r p q : α → α → Prop}
section Pairwise
variable {f g : ι → α} {s t u : Set α} {a b : α}
namespace Set
section CompleteLattice
variable [CompleteLattice α] {s : Set ι} {t : Set ι'}
| Mathlib/Data/Set/Pairwise/Lattice.lean | 72 | 84 | theorem PairwiseDisjoint.biUnion {s : Set ι'} {g : ι' → Set ι} {f : ι → α}
(hs : s.PairwiseDisjoint fun i' : ι' => ⨆ i ∈ g i', f i)
(hg : ∀ i ∈ s, (g i).PairwiseDisjoint f) : (⋃ i ∈ s, g i).PairwiseDisjoint f := by |
rintro a ha b hb hab
simp_rw [Set.mem_iUnion] at ha hb
obtain ⟨c, hc, ha⟩ := ha
obtain ⟨d, hd, hb⟩ := hb
obtain hcd | hcd := eq_or_ne (g c) (g d)
· exact hg d hd (hcd.subst ha) hb hab
-- Porting note: the elaborator couldn't figure out `f` here.
· exact (hs hc hd <| ne_of_apply_ne _ hcd).mono
(le_iSup₂ (f := fun i (_ : i ∈ g c) => f i) a ha)
(le_iSup₂ (f := fun i (_ : i ∈ g d) => f i) b hb)
| 0 |
import Mathlib.Algebra.ContinuedFractions.Computation.Basic
import Mathlib.Algebra.ContinuedFractions.Translations
#align_import algebra.continued_fractions.computation.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace GeneralizedContinuedFraction
open GeneralizedContinuedFraction (of)
-- Fix a discrete linear ordered floor field and a value `v`.
variable {K : Type*} [LinearOrderedField K] [FloorRing K] {v : K}
namespace IntFractPair
theorem stream_zero (v : K) : IntFractPair.stream v 0 = some (IntFractPair.of v) :=
rfl
#align generalized_continued_fraction.int_fract_pair.stream_zero GeneralizedContinuedFraction.IntFractPair.stream_zero
variable {n : ℕ}
theorem stream_eq_none_of_fr_eq_zero {ifp_n : IntFractPair K}
(stream_nth_eq : IntFractPair.stream v n = some ifp_n) (nth_fr_eq_zero : ifp_n.fr = 0) :
IntFractPair.stream v (n + 1) = none := by
cases' ifp_n with _ fr
change fr = 0 at nth_fr_eq_zero
simp [IntFractPair.stream, stream_nth_eq, nth_fr_eq_zero]
#align generalized_continued_fraction.int_fract_pair.stream_eq_none_of_fr_eq_zero GeneralizedContinuedFraction.IntFractPair.stream_eq_none_of_fr_eq_zero
| Mathlib/Algebra/ContinuedFractions/Computation/Translations.lean | 77 | 81 | theorem succ_nth_stream_eq_none_iff :
IntFractPair.stream v (n + 1) = none ↔
IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 := by |
rw [IntFractPair.stream]
cases IntFractPair.stream v n <;> simp [imp_false]
| 0 |
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]
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' ℕ)]
set_option linter.uppercaseLean3 false in
#align mv_polynomial.vars_X MvPolynomial.vars_X
theorem mem_vars (i : σ) : i ∈ p.vars ↔ ∃ d ∈ p.support, i ∈ d.support := by
classical simp only [vars_def, Multiset.mem_toFinset, mem_degrees, mem_support_iff, exists_prop]
#align mv_polynomial.mem_vars MvPolynomial.mem_vars
theorem mem_support_not_mem_vars_zero {f : MvPolynomial σ R} {x : σ →₀ ℕ} (H : x ∈ f.support)
{v : σ} (h : v ∉ vars f) : x v = 0 := by
contrapose! h
exact (mem_vars v).mpr ⟨x, H, Finsupp.mem_support_iff.mpr h⟩
#align mv_polynomial.mem_support_not_mem_vars_zero MvPolynomial.mem_support_not_mem_vars_zero
theorem vars_add_subset [DecidableEq σ] (p q : MvPolynomial σ R) :
(p + q).vars ⊆ p.vars ∪ q.vars := by
intro x hx
simp only [vars_def, Finset.mem_union, Multiset.mem_toFinset] at hx ⊢
simpa using Multiset.mem_of_le (degrees_add _ _) hx
#align mv_polynomial.vars_add_subset MvPolynomial.vars_add_subset
theorem vars_add_of_disjoint [DecidableEq σ] (h : Disjoint p.vars q.vars) :
(p + q).vars = p.vars ∪ q.vars := by
refine (vars_add_subset p q).antisymm fun x hx => ?_
simp only [vars_def, Multiset.disjoint_toFinset] at h hx ⊢
rwa [degrees_add_of_disjoint h, Multiset.toFinset_union]
#align mv_polynomial.vars_add_of_disjoint MvPolynomial.vars_add_of_disjoint
section Mul
theorem vars_mul [DecidableEq σ] (φ ψ : MvPolynomial σ R) : (φ * ψ).vars ⊆ φ.vars ∪ ψ.vars := by
simp_rw [vars_def, ← Multiset.toFinset_add, Multiset.toFinset_subset]
exact Multiset.subset_of_le (degrees_mul φ ψ)
#align mv_polynomial.vars_mul MvPolynomial.vars_mul
@[simp]
theorem vars_one : (1 : MvPolynomial σ R).vars = ∅ :=
vars_C
#align mv_polynomial.vars_one MvPolynomial.vars_one
theorem vars_pow (φ : MvPolynomial σ R) (n : ℕ) : (φ ^ n).vars ⊆ φ.vars := by
classical
induction' n with n ih
· simp
· rw [pow_succ']
apply Finset.Subset.trans (vars_mul _ _)
exact Finset.union_subset (Finset.Subset.refl _) ih
#align mv_polynomial.vars_pow MvPolynomial.vars_pow
theorem vars_prod {ι : Type*} [DecidableEq σ] {s : Finset ι} (f : ι → MvPolynomial σ R) :
(∏ i ∈ s, f i).vars ⊆ s.biUnion fun i => (f i).vars := by
classical
induction s using Finset.induction_on with
| empty => simp
| insert hs hsub =>
simp only [hs, Finset.biUnion_insert, Finset.prod_insert, not_false_iff]
apply Finset.Subset.trans (vars_mul _ _)
exact Finset.union_subset_union (Finset.Subset.refl _) hsub
#align mv_polynomial.vars_prod MvPolynomial.vars_prod
section EvalVars
variable [CommSemiring S]
| Mathlib/Algebra/MvPolynomial/Variables.lean | 248 | 274 | theorem eval₂Hom_eq_constantCoeff_of_vars (f : R →+* S) {g : σ → S} {p : MvPolynomial σ R}
(hp : ∀ i ∈ p.vars, g i = 0) : eval₂Hom f g p = f (constantCoeff p) := by |
conv_lhs => rw [p.as_sum]
simp only [map_sum, eval₂Hom_monomial]
by_cases h0 : constantCoeff p = 0
on_goal 1 =>
rw [h0, f.map_zero, Finset.sum_eq_zero]
intro d hd
on_goal 2 =>
rw [Finset.sum_eq_single (0 : σ →₀ ℕ)]
· rw [Finsupp.prod_zero_index, mul_one]
rfl
on_goal 1 => intro d hd hd0
on_goal 3 =>
rw [constantCoeff_eq, coeff, ← Ne, ← Finsupp.mem_support_iff] at h0
intro
contradiction
repeat'
obtain ⟨i, hi⟩ : Finset.Nonempty (Finsupp.support d) := by
rw [constantCoeff_eq, coeff, ← Finsupp.not_mem_support_iff] at h0
rw [Finset.nonempty_iff_ne_empty, Ne, Finsupp.support_eq_empty]
rintro rfl
contradiction
rw [Finsupp.prod, Finset.prod_eq_zero hi, mul_zero]
rw [hp, zero_pow (Finsupp.mem_support_iff.1 hi)]
rw [mem_vars]
exact ⟨d, hd, hi⟩
| 0 |
import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL1
#align_import measure_theory.function.conditional_expectation.basic from "leanprover-community/mathlib"@"d8bbb04e2d2a44596798a9207ceefc0fb236e41e"
open TopologicalSpace MeasureTheory.Lp Filter
open scoped ENNReal Topology MeasureTheory
namespace MeasureTheory
variable {α F F' 𝕜 : Type*} {p : ℝ≥0∞} [RCLike 𝕜]
-- 𝕜 for ℝ or ℂ
-- F for a Lp submodule
[NormedAddCommGroup F]
[NormedSpace 𝕜 F]
-- F' for integrals on a Lp submodule
[NormedAddCommGroup F']
[NormedSpace 𝕜 F'] [NormedSpace ℝ F'] [CompleteSpace F']
open scoped Classical
variable {m m0 : MeasurableSpace α} {μ : Measure α} {f g : α → F'} {s : Set α}
noncomputable irreducible_def condexp (m : MeasurableSpace α) {m0 : MeasurableSpace α}
(μ : Measure α) (f : α → F') : α → F' :=
if hm : m ≤ m0 then
if h : SigmaFinite (μ.trim hm) ∧ Integrable f μ then
if StronglyMeasurable[m] f then f
else (@aestronglyMeasurable'_condexpL1 _ _ _ _ _ m m0 μ hm h.1 _).mk
(@condexpL1 _ _ _ _ _ _ _ hm μ h.1 f)
else 0
else 0
#align measure_theory.condexp MeasureTheory.condexp
-- We define notation `μ[f|m]` for the conditional expectation of `f` with respect to `m`.
scoped notation μ "[" f "|" m "]" => MeasureTheory.condexp m μ f
theorem condexp_of_not_le (hm_not : ¬m ≤ m0) : μ[f|m] = 0 := by rw [condexp, dif_neg hm_not]
#align measure_theory.condexp_of_not_le MeasureTheory.condexp_of_not_le
theorem condexp_of_not_sigmaFinite (hm : m ≤ m0) (hμm_not : ¬SigmaFinite (μ.trim hm)) :
μ[f|m] = 0 := by rw [condexp, dif_pos hm, dif_neg]; push_neg; exact fun h => absurd h hμm_not
#align measure_theory.condexp_of_not_sigma_finite MeasureTheory.condexp_of_not_sigmaFinite
| Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean | 113 | 123 | theorem condexp_of_sigmaFinite (hm : m ≤ m0) [hμm : SigmaFinite (μ.trim hm)] :
μ[f|m] =
if Integrable f μ then
if StronglyMeasurable[m] f then f
else aestronglyMeasurable'_condexpL1.mk (condexpL1 hm μ f)
else 0 := by |
rw [condexp, dif_pos hm]
simp only [hμm, Ne, true_and_iff]
by_cases hf : Integrable f μ
· rw [dif_pos hf, if_pos hf]
· rw [dif_neg hf, if_neg hf]
| 0 |
import Mathlib.Analysis.Convex.Cone.Basic
import Mathlib.Analysis.InnerProductSpace.Projection
#align_import analysis.convex.cone.dual from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4"
open Set LinearMap
open scoped Classical
open Pointwise
variable {𝕜 E F G : Type*}
section Dual
variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℝ H] (s t : Set H)
open RealInnerProductSpace
def Set.innerDualCone (s : Set H) : ConvexCone ℝ H where
carrier := { y | ∀ x ∈ s, 0 ≤ ⟪x, y⟫ }
smul_mem' c hc y hy x hx := by
rw [real_inner_smul_right]
exact mul_nonneg hc.le (hy x hx)
add_mem' u hu v hv x hx := by
rw [inner_add_right]
exact add_nonneg (hu x hx) (hv x hx)
#align set.inner_dual_cone Set.innerDualCone
@[simp]
theorem mem_innerDualCone (y : H) (s : Set H) : y ∈ s.innerDualCone ↔ ∀ x ∈ s, 0 ≤ ⟪x, y⟫ :=
Iff.rfl
#align mem_inner_dual_cone mem_innerDualCone
@[simp]
theorem innerDualCone_empty : (∅ : Set H).innerDualCone = ⊤ :=
eq_top_iff.mpr fun _ _ _ => False.elim
#align inner_dual_cone_empty innerDualCone_empty
@[simp]
theorem innerDualCone_zero : (0 : Set H).innerDualCone = ⊤ :=
eq_top_iff.mpr fun _ _ y (hy : y = 0) => hy.symm ▸ (inner_zero_left _).ge
#align inner_dual_cone_zero innerDualCone_zero
@[simp]
theorem innerDualCone_univ : (univ : Set H).innerDualCone = 0 := by
suffices ∀ x : H, x ∈ (univ : Set H).innerDualCone → x = 0 by
apply SetLike.coe_injective
exact eq_singleton_iff_unique_mem.mpr ⟨fun x _ => (inner_zero_right _).ge, this⟩
exact fun x hx => by simpa [← real_inner_self_nonpos] using hx (-x) (mem_univ _)
#align inner_dual_cone_univ innerDualCone_univ
theorem innerDualCone_le_innerDualCone (h : t ⊆ s) : s.innerDualCone ≤ t.innerDualCone :=
fun _ hy x hx => hy x (h hx)
#align inner_dual_cone_le_inner_dual_cone innerDualCone_le_innerDualCone
theorem pointed_innerDualCone : s.innerDualCone.Pointed := fun x _ => by rw [inner_zero_right]
#align pointed_inner_dual_cone pointed_innerDualCone
theorem innerDualCone_singleton (x : H) :
({x} : Set H).innerDualCone = (ConvexCone.positive ℝ ℝ).comap (innerₛₗ ℝ x) :=
ConvexCone.ext fun _ => forall_eq
#align inner_dual_cone_singleton innerDualCone_singleton
theorem innerDualCone_union (s t : Set H) :
(s ∪ t).innerDualCone = s.innerDualCone ⊓ t.innerDualCone :=
le_antisymm (le_inf (fun _ hx _ hy => hx _ <| Or.inl hy) fun _ hx _ hy => hx _ <| Or.inr hy)
fun _ hx _ => Or.rec (hx.1 _) (hx.2 _)
#align inner_dual_cone_union innerDualCone_union
theorem innerDualCone_insert (x : H) (s : Set H) :
(insert x s).innerDualCone = Set.innerDualCone {x} ⊓ s.innerDualCone := by
rw [insert_eq, innerDualCone_union]
#align inner_dual_cone_insert innerDualCone_insert
theorem innerDualCone_iUnion {ι : Sort*} (f : ι → Set H) :
(⋃ i, f i).innerDualCone = ⨅ i, (f i).innerDualCone := by
refine le_antisymm (le_iInf fun i x hx y hy => hx _ <| mem_iUnion_of_mem _ hy) ?_
intro x hx y hy
rw [ConvexCone.mem_iInf] at hx
obtain ⟨j, hj⟩ := mem_iUnion.mp hy
exact hx _ _ hj
#align inner_dual_cone_Union innerDualCone_iUnion
theorem innerDualCone_sUnion (S : Set (Set H)) :
(⋃₀ S).innerDualCone = sInf (Set.innerDualCone '' S) := by
simp_rw [sInf_image, sUnion_eq_biUnion, innerDualCone_iUnion]
#align inner_dual_cone_sUnion innerDualCone_sUnion
theorem innerDualCone_eq_iInter_innerDualCone_singleton :
(s.innerDualCone : Set H) = ⋂ i : s, (({↑i} : Set H).innerDualCone : Set H) := by
rw [← ConvexCone.coe_iInf, ← innerDualCone_iUnion, iUnion_of_singleton_coe]
#align inner_dual_cone_eq_Inter_inner_dual_cone_singleton innerDualCone_eq_iInter_innerDualCone_singleton
| Mathlib/Analysis/Convex/Cone/InnerDual.lean | 130 | 140 | theorem isClosed_innerDualCone : IsClosed (s.innerDualCone : Set H) := by |
-- reduce the problem to showing that dual cone of a singleton `{x}` is closed
rw [innerDualCone_eq_iInter_innerDualCone_singleton]
apply isClosed_iInter
intro x
-- the dual cone of a singleton `{x}` is the preimage of `[0, ∞)` under `inner x`
have h : ({↑x} : Set H).innerDualCone = (inner x : H → ℝ) ⁻¹' Set.Ici 0 := by
rw [innerDualCone_singleton, ConvexCone.coe_comap, ConvexCone.coe_positive, innerₛₗ_apply_coe]
-- the preimage is closed as `inner x` is continuous and `[0, ∞)` is closed
rw [h]
exact isClosed_Ici.preimage (continuous_const.inner continuous_id')
| 0 |
import Mathlib.CategoryTheory.Category.Grpd
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Homotopy.Path
import Mathlib.Data.Set.Subsingleton
#align_import algebraic_topology.fundamental_groupoid.basic from "leanprover-community/mathlib"@"3d7987cda72abc473c7cdbbb075170e9ac620042"
open CategoryTheory
universe u v
variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y]
variable {x₀ x₁ : X}
noncomputable section
open unitInterval
namespace Path
namespace Homotopy
section
def reflTransSymmAux (x : I × I) : ℝ :=
if (x.2 : ℝ) ≤ 1 / 2 then x.1 * 2 * x.2 else x.1 * (2 - 2 * x.2)
#align path.homotopy.refl_trans_symm_aux Path.Homotopy.reflTransSymmAux
@[continuity]
theorem continuous_reflTransSymmAux : Continuous reflTransSymmAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_
· continuity
· continuity
· continuity
· continuity
intro x hx
norm_num [hx, mul_assoc]
#align path.homotopy.continuous_refl_trans_symm_aux Path.Homotopy.continuous_reflTransSymmAux
theorem reflTransSymmAux_mem_I (x : I × I) : reflTransSymmAux x ∈ I := by
dsimp only [reflTransSymmAux]
split_ifs
· constructor
· apply mul_nonneg
· apply mul_nonneg
· unit_interval
· norm_num
· unit_interval
· rw [mul_assoc]
apply mul_le_one
· unit_interval
· apply mul_nonneg
· norm_num
· unit_interval
· linarith
· constructor
· apply mul_nonneg
· unit_interval
linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· apply mul_le_one
· unit_interval
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
set_option linter.uppercaseLean3 false in
#align path.homotopy.refl_trans_symm_aux_mem_I Path.Homotopy.reflTransSymmAux_mem_I
def reflTransSymm (p : Path x₀ x₁) : Homotopy (Path.refl x₀) (p.trans p.symm) where
toFun x := p ⟨reflTransSymmAux x, reflTransSymmAux_mem_I x⟩
continuous_toFun := by continuity
map_zero_left := by simp [reflTransSymmAux]
map_one_left x := by
dsimp only [reflTransSymmAux, Path.coe_toContinuousMap, Path.trans]
change _ = ite _ _ _
split_ifs with h
· rw [Path.extend, Set.IccExtend_of_mem]
· norm_num
· rw [unitInterval.mul_pos_mem_iff zero_lt_two]
exact ⟨unitInterval.nonneg x, h⟩
· rw [Path.symm, Path.extend, Set.IccExtend_of_mem]
· simp only [Set.Icc.coe_one, one_mul, coe_mk_mk, Function.comp_apply]
congr 1
ext
norm_num [sub_sub_eq_add_sub]
· rw [unitInterval.two_mul_sub_one_mem_iff]
exact ⟨(not_le.1 h).le, unitInterval.le_one x⟩
prop' t x hx := by
simp only [Set.mem_singleton_iff, Set.mem_insert_iff] at hx
simp only [ContinuousMap.coe_mk, coe_toContinuousMap, Path.refl_apply]
cases hx with
| inl hx
| inr hx =>
set_option tactic.skipAssignedInstances false in
rw [hx]
norm_num [reflTransSymmAux]
#align path.homotopy.refl_trans_symm Path.Homotopy.reflTransSymm
def reflSymmTrans (p : Path x₀ x₁) : Homotopy (Path.refl x₁) (p.symm.trans p) :=
(reflTransSymm p.symm).cast rfl <| congr_arg _ (Path.symm_symm _)
#align path.homotopy.refl_symm_trans Path.Homotopy.reflSymmTrans
end
section Assoc
def transAssocReparamAux (t : I) : ℝ :=
if (t : ℝ) ≤ 1 / 4 then 2 * t else if (t : ℝ) ≤ 1 / 2 then t + 1 / 4 else 1 / 2 * (t + 1)
#align path.homotopy.trans_assoc_reparam_aux Path.Homotopy.transAssocReparamAux
@[continuity]
theorem continuous_transAssocReparamAux : Continuous transAssocReparamAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_)
(continuous_if_le ?_ ?_
(Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_).continuousOn
?_ <;>
[continuity; continuity; continuity; continuity; continuity; continuity; continuity; skip;
skip] <;>
· intro x hx
set_option tactic.skipAssignedInstances false in norm_num [hx]
#align path.homotopy.continuous_trans_assoc_reparam_aux Path.Homotopy.continuous_transAssocReparamAux
theorem transAssocReparamAux_mem_I (t : I) : transAssocReparamAux t ∈ I := by
unfold transAssocReparamAux
split_ifs <;> constructor <;> linarith [unitInterval.le_one t, unitInterval.nonneg t]
set_option linter.uppercaseLean3 false in
#align path.homotopy.trans_assoc_reparam_aux_mem_I Path.Homotopy.transAssocReparamAux_mem_I
theorem transAssocReparamAux_zero : transAssocReparamAux 0 = 0 := by
set_option tactic.skipAssignedInstances false in norm_num [transAssocReparamAux]
#align path.homotopy.trans_assoc_reparam_aux_zero Path.Homotopy.transAssocReparamAux_zero
theorem transAssocReparamAux_one : transAssocReparamAux 1 = 1 := by
set_option tactic.skipAssignedInstances false in norm_num [transAssocReparamAux]
#align path.homotopy.trans_assoc_reparam_aux_one Path.Homotopy.transAssocReparamAux_one
| Mathlib/AlgebraicTopology/FundamentalGroupoid/Basic.lean | 214 | 253 | theorem trans_assoc_reparam {x₀ x₁ x₂ x₃ : X} (p : Path x₀ x₁) (q : Path x₁ x₂) (r : Path x₂ x₃) :
(p.trans q).trans r =
(p.trans (q.trans r)).reparam
(fun t => ⟨transAssocReparamAux t, transAssocReparamAux_mem_I t⟩) (by continuity)
(Subtype.ext transAssocReparamAux_zero) (Subtype.ext transAssocReparamAux_one) := by |
ext x
simp only [transAssocReparamAux, Path.trans_apply, mul_inv_cancel_left₀, not_le,
Function.comp_apply, Ne, not_false_iff, bit0_eq_zero, one_ne_zero, mul_ite, Subtype.coe_mk,
Path.coe_reparam]
-- TODO: why does split_ifs not reduce the ifs??????
split_ifs with h₁ h₂ h₃ h₄ h₅
· rfl
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· have h : 2 * (2 * (x : ℝ)) - 1 = 2 * (2 * (↑x + 1 / 4) - 1) := by linarith
simp [h₂, h₁, h, dif_neg (show ¬False from id), dif_pos True.intro, if_false, if_true]
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· congr
ring
| 0 |
import Mathlib.FieldTheory.RatFunc.AsPolynomial
import Mathlib.RingTheory.EuclideanDomain
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Polynomial.Content
noncomputable section
universe u
variable {K : Type u}
namespace RatFunc
section IntDegree
open Polynomial
variable [Field K]
def intDegree (x : RatFunc K) : ℤ :=
natDegree x.num - natDegree x.denom
#align ratfunc.int_degree RatFunc.intDegree
@[simp]
theorem intDegree_zero : intDegree (0 : RatFunc K) = 0 := by
rw [intDegree, num_zero, natDegree_zero, denom_zero, natDegree_one, sub_self]
#align ratfunc.int_degree_zero RatFunc.intDegree_zero
@[simp]
theorem intDegree_one : intDegree (1 : RatFunc K) = 0 := by
rw [intDegree, num_one, denom_one, sub_self]
#align ratfunc.int_degree_one RatFunc.intDegree_one
@[simp]
theorem intDegree_C (k : K) : intDegree (C k) = 0 := by
rw [intDegree, num_C, natDegree_C, denom_C, natDegree_one, sub_self]
set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_C RatFunc.intDegree_C
@[simp]
theorem intDegree_X : intDegree (X : RatFunc K) = 1 := by
rw [intDegree, num_X, Polynomial.natDegree_X, denom_X, Polynomial.natDegree_one,
Int.ofNat_one, Int.ofNat_zero, sub_zero]
set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_X RatFunc.intDegree_X
@[simp]
theorem intDegree_polynomial {p : K[X]} :
intDegree (algebraMap K[X] (RatFunc K) p) = natDegree p := by
rw [intDegree, RatFunc.num_algebraMap, RatFunc.denom_algebraMap, Polynomial.natDegree_one,
Int.ofNat_zero, sub_zero]
#align ratfunc.int_degree_polynomial RatFunc.intDegree_polynomial
theorem intDegree_mul {x y : RatFunc K} (hx : x ≠ 0) (hy : y ≠ 0) :
intDegree (x * y) = intDegree x + intDegree y := by
simp only [intDegree, add_sub, sub_add, sub_sub_eq_add_sub, sub_sub, sub_eq_sub_iff_add_eq_add]
norm_cast
rw [← Polynomial.natDegree_mul x.denom_ne_zero y.denom_ne_zero, ←
Polynomial.natDegree_mul (RatFunc.num_ne_zero (mul_ne_zero hx hy))
(mul_ne_zero x.denom_ne_zero y.denom_ne_zero),
← Polynomial.natDegree_mul (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy), ←
Polynomial.natDegree_mul (mul_ne_zero (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy))
(x * y).denom_ne_zero,
RatFunc.num_denom_mul]
#align ratfunc.int_degree_mul RatFunc.intDegree_mul
@[simp]
| Mathlib/FieldTheory/RatFunc/Degree.lean | 85 | 91 | theorem intDegree_neg (x : RatFunc K) : intDegree (-x) = intDegree x := by |
by_cases hx : x = 0
· rw [hx, neg_zero]
· rw [intDegree, intDegree, ← natDegree_neg x.num]
exact
natDegree_sub_eq_of_prod_eq (num_ne_zero (neg_ne_zero.mpr hx)) (denom_ne_zero (-x))
(neg_ne_zero.mpr (num_ne_zero hx)) (denom_ne_zero x) (num_denom_neg x)
| 0 |
import Mathlib.Algebra.Order.Field.Canonical.Defs
#align_import algebra.order.field.canonical.basic from "leanprover-community/mathlib"@"ee0c179cd3c8a45aa5bffbf1b41d8dbede452865"
variable {α : Type*}
section CanonicallyLinearOrderedSemifield
variable [CanonicallyLinearOrderedSemifield α] [Sub α] [OrderedSub α]
| Mathlib/Algebra/Order/Field/Canonical/Basic.lean | 22 | 22 | theorem tsub_div (a b c : α) : (a - b) / c = a / c - b / c := by | simp_rw [div_eq_mul_inv, tsub_mul]
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.