The reason I studied the thinning theorem again is because I need a slightly generalised variation. The following seems to be what I need. The general idea and the term “pruning” emerged from discussion with Sharon Curtis. The term “lax preorder” is invented by myself. I am not good at naming, and welcome suggestions for better names.
The notation below are mostly taken from the book Algebra of Programming. Not many people, even among functional programmers, are familiar with these notations involving relational intersection, division, etc. One starts to appreciate their benefits once he/she gets used to using their calculation rules. Most of the time when I was doing the proof, I was merely manipulating the symbols. I could not have managed the complexity if I had to fall back to the semantics and think about what they “mean” all the time.
A relation Q :: PA ← A between a set of A and an element is called a lax preorder if it is
- reflexive in the sense that ∋ ⊆ Q, and
- transitive in the sense that (Q/∋) . Q ⊆ Q.
A relation S :: A ← FA is monotonic on lax preorder Q if S . FQ˘ ⊆ Q˘. Λ(S . F∈).
Given a lax preorder, we define:
The definition induces the universal property:
Any preorder R induces a lax preorder ∋ . R. If a relation S is monotonic on R˘, it is monotonic on lax preorder ∋ . R. Furthermore, prune (∋ . R) = thin R. Therefore, pruning is a generalisation of thinning. We need the notion of lax preorders because, for some problems, the generating relation S is monotonic on a lax preorder, but not a preorder.
Theorem: if S is monotonic on lax preorder Q, we have:
Proof. Since Λ(fold S) = fold (Λ(S . F∈)), by fold fusion, the theorem holds if
By the universal property of prune, the above is equivalent to:
The first inclusion is proved by:
And the second by:
The proof above uses transitivity of Q but not reflectivity. I need reflectivity to construct base cases, for example, to come up wit this specialised Pruning Theorem for lists:
if S . (id × Q˘) ⊆ Q˘. Λ(S . (id × ∈)).