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.
Updating one coordinate by +1 increases the total sum by exactly one.
Updating one coordinate of a ℕ-valued function by -1 at a positive-valued coordinate
decreases the total sum by exactly one.
Filtered sum after updating a ℕ-valued function by -1 at a positive-valued coordinate
inside the filter.
Updating a ℕ-valued function at an index outside the filter leaves the filtered sum
unchanged.
Instances For
Instances For
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.
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:
If the first steps agree after projection, and continuations agree on matching inputs,
then the full bind computations agree. Generalizes bind_congr to different source types.