Lemmas to be Ported to Mathlib #
This file gives a centralized location to add lemmas that belong better in general mathlib than in the project itself.
@[simp]
theorem
tprod_ite_eq'
{α : Type u_1}
{β : Type u_2}
[CommMonoid α]
[TopologicalSpace α]
(b : β)
[DecidablePred fun (x : β) => b = x]
(a : α)
(L : SummationFilter β := SummationFilter.unconditional β)
[L.LeAtTop]
:
@[simp]
theorem
tsum_ite_eq'
{α : Type u_1}
{β : Type u_2}
[AddCommMonoid α]
[TopologicalSpace α]
(b : β)
[DecidablePred fun (x : β) => b = x]
(a : α)
(L : SummationFilter β := SummationFilter.unconditional β)
[L.LeAtTop]
:
@[simp]
theorem
tprod_ite_eq_apply
{α : Type u_1}
{β : Type u_2}
[CommMonoid α]
[TopologicalSpace α]
(b : β)
[DecidablePred fun (x : β) => x = b]
(f : β → α)
(L : SummationFilter β := SummationFilter.unconditional β)
[L.LeAtTop]
:
@[simp]
theorem
tsum_ite_eq_apply
{α : Type u_1}
{β : Type u_2}
[AddCommMonoid α]
[TopologicalSpace α]
(b : β)
[DecidablePred fun (x : β) => x = b]
(f : β → α)
(L : SummationFilter β := SummationFilter.unconditional β)
[L.LeAtTop]
:
@[simp]
theorem
tprod_ite_eq_apply'
{α : Type u_1}
{β : Type u_2}
[CommMonoid α]
[TopologicalSpace α]
(b : β)
[DecidablePred fun (x : β) => b = x]
(f : β → α)
(L : SummationFilter β := SummationFilter.unconditional β)
[L.LeAtTop]
:
@[simp]
theorem
tsum_ite_eq_apply'
{α : Type u_1}
{β : Type u_2}
[AddCommMonoid α]
[TopologicalSpace α]
(b : β)
[DecidablePred fun (x : β) => b = x]
(f : β → α)
(L : SummationFilter β := SummationFilter.unconditional β)
[L.LeAtTop]
:
theorem
mul_abs_of_nonneg
{G : Type u_1}
[CommRing G]
[LinearOrder G]
[IsStrictOrderedRing G]
{a b : G}
(h : 0 ≤ a)
:
theorem
abs_mul_of_nonneg
{G : Type u_1}
[CommRing G]
[LinearOrder G]
[IsStrictOrderedRing G]
{a b : G}
(h : 0 ≤ b)
:
theorem
mul_abs_of_nonpos
{G : Type u_1}
[CommRing G]
[LinearOrder G]
[IsStrictOrderedRing G]
{a b : G}
(h : a < 0)
:
theorem
abs_mul_of_nonpos
{G : Type u_1}
[CommRing G]
[LinearOrder G]
[IsStrictOrderedRing G]
{a b : G}
(h : b < 0)
:
@[simp]
theorem
Finset.sum_boole'
{ι : Type u_1}
{β : Type u_2}
[AddCommMonoid β]
(r : β)
(p : ι → Prop)
[DecidablePred p]
(s : Finset ι)
:
@[simp]
Equations
- instFintypeBitVec_toMathlib n = Fintype.ofBijective (fun (x : Fin (2 ^ n)) => { toFin := x }) ⋯
def
Vector.induction
{α : Type u_2}
{motive : {n : ℕ} → Vector α n → Sort u_1}
(v_empty : motive #v[])
(v_insert : {n : ℕ} → (hd : α) → (tl : Vector α n) → motive tl → motive (tl.insertIdx 0 hd ⋯))
{m : ℕ}
(v : Vector α m)
:
motive v
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Vector.cases₂
{α : Type u_2}
{β : Type u_3}
{motive : {n : ℕ} → Vector α n → Vector β n → Sort u_1}
(v_empty : motive #v[] #v[])
(v_insert :
{n : ℕ} →
(hd : α) →
(tl : Vector α n) → (hd' : β) → (tl' : Vector β n) → motive (tl.insertIdx 0 hd ⋯) (tl'.insertIdx 0 hd' ⋯))
{m : ℕ}
(v : Vector α m)
(v' : Vector β m)
:
motive v v'
Equations
Instances For
def
Vector.induction₂
{α : Type u_2}
{β : Type u_3}
{motive : {n : ℕ} → Vector α n → Vector β n → Sort u_1}
(v_empty : motive #v[] #v[])
(v_insert :
{n : ℕ} →
(hd : α) →
(tl : Vector α n) →
(hd' : β) → (tl' : Vector β n) → motive tl tl' → motive (tl.insertIdx 0 hd ⋯) (tl'.insertIdx 0 hd' ⋯))
{m : ℕ}
(v : Vector α m)
(v' : Vector β m)
:
motive v v'
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Vector.instZero_toMathlib = { zero := Vector.ofFn 0 }
theorem
tsum_option
{α : Type u_1}
{β : Type u_2}
[AddCommMonoid α]
[TopologicalSpace α]
[ContinuousAdd α]
[T2Space α]
(f : Option β → α)
(hf : Summable (Function.update f none 0))
:
theorem
PMF.uniformOfFintype_map_of_bijective
{α : Type u_1}
{β : Type u_2}
[Fintype α]
[Fintype β]
[Nonempty α]
[Nonempty β]
(f : α → β)
(hf : Function.Bijective f)
:
@[simp]
theorem
List.foldlM_range
{m : Type u → Type v}
[Monad m]
[LawfulMonad m]
{s : Type u}
(n : ℕ)
(f : s → Fin n → m s)
(init : s)
:
theorem
list_mapM_loop_eq
{m : Type u → Type v}
[Monad m]
[LawfulMonad m]
{α : Type w}
{β : Type u}
(xs : List α)
(f : α → m β)
(ys : List β)
:
forIn / foldlM bridge for imperative-style loops #
Lean's for/let mut syntax desugars to List.forIn with MProd state and
ForInStep.yield continuations, while functional-style code uses List.foldlM
with Prod state. The lemmas below bridge these two representations.
For a single mutable variable (no MProd wrapper), use Mathlib's
List.forIn_yield_eq_foldlM directly.
theorem
List.forIn_mprod_yield_eq_foldlM
{m : Type u → Type v}
[Monad m]
[LawfulMonad m]
{α : Type w}
{β γ : Type u}
(l : List α)
(b₀ : β)
(c₀ : γ)
(f : α → MProd β γ → m (ForInStep (MProd β γ)))
(g : β × γ → α → m (β × γ))
(hfg :
∀ (a : α) (b : β) (c : γ),
f a ⟨b, c⟩ = do
let r ← g (b, c) a
pure (ForInStep.yield ⟨r.1, r.2⟩))
:
A for/let mut loop with two mutable variables (desugared to forIn over
MProd state with ForInStep.yield in every branch) is equivalent to foldlM
with Prod state. This bridges two impedance mismatches at once: