Physlib

Physlib.Mathematics.ForMathlib.List

List lemmas

1 declaration

theorem

takeWhile P(l.eraseIdx i)=(takeWhile P l).eraseIdx i\text{takeWhile } P (l.\text{eraseIdx } i) = (\text{takeWhile } P \ l).\text{eraseIdx } i for prefix-closed PP

Let II be a type and PP be a decidable predicate on II. Let ll be a list of elements of type II. Suppose that for any indices i,ji, j such that 0≤i<j<length(l)0 \le i < j < \text{length}(l), if the element at index jj satisfies PP, then the element at index ii must also satisfy PP (i.e., the property PP is "prefix-closed" on ll). Then, for any index kk, removing the kk-th element from ll and then taking the longest prefix of elements satisfying PP is equivalent to taking the longest prefix of ll satisfying PP and then removing its kk-th element.