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 #
List.apply_foldr_iff_forall: a predicate distributing overopholds of a fold exactly when it holds of every folded element.List.apply_foldr_map_univ_toList_iff: the same for a fold over an enumeration of a finite type.
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 α) :
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 : β → α) :
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.