Documentation

CslibFrontier.Foundations.Data.List.FoldrForall

Predicates that distribute over a fold #

A predicate p that holds of the initial value and satisfies p (op x y) ↔ p x ∧ p y holds of l.foldr op init exactly when it holds of every element of l. Typical instances are the truth, rank bound and free-variable bound of a finite conjunction of formulas, built as a fold of a binary conjunction from a true formula.

Main results #

theorem List.apply_foldr_iff_forall {α : Type u_1} {op : α → α → α} {init : α} {p : α → Prop} (hop : ∀ (x y : α), p (op x y) ↔ p x ∧ p y) (hinit : p init) (l : List α) :
p (foldr op init l) ↔ ∀ x ∈ l, p x

A predicate p that holds of init and distributes over op, in the sense that p (op x y) ↔ p x ∧ p y, holds of l.foldr op init exactly when it holds of every element of l.

theorem List.apply_foldr_map_univ_toList_iff {α : Type u_1} {op : α → α → α} {init : α} {p : α → Prop} {β : Type u_2} [Fintype β] (hop : ∀ (x y : α), p (op x y) ↔ p x ∧ p y) (hinit : p init) (f : β → α) :
p (foldr op init (map f Finset.univ.toList)) ↔ ∀ (b : β), p (f b)

A predicate p that holds of init and distributes over op holds of the fold of op over the values of f on an enumeration of a finite type exactly when it holds of every value.