Documentation

CslibFrontier.Foundations.Logic.Function.FoldlUpdate

Updates of a function along a list #

Updating a function f at the points g i to the values v i, for the indices i of a list in order, gives f outside the points g i of the list and v i at them, if g is injective. If the list contains every index, the result is Function.extend g v f.

Main results #

theorem Function.foldl_update_apply {ι : Type u_1} {α : Type u_2} {β : Type u_3} [DecidableEq β] {g : ι → β} (hg : Injective g) (v : ι → α) (s : List ι) (f : β → α) (y : β) :
List.foldl (fun (f : β → α) (i : ι) => update f (g i) (v i)) f s y = if ∃ i ∈ s, g i = y then extend g v f y else f y

After the updates at the points g i of the indices i of s, a point of s has the value that extend gives it, and every other point keeps its value.

theorem Function.foldl_update_eq_extend {ι : Type u_1} {α : Type u_2} {β : Type u_3} [DecidableEq β] {g : ι → β} (hg : Injective g) (v : ι → α) {s : List ι} (hs : ∀ (i : ι), i ∈ s) (f : β → α) :
List.foldl (fun (f : β → α) (i : ι) => update f (g i) (v i)) f s = extend g v f

Updates at the points g i of all indices i, in any order, give Function.extend g v f.