Given a Preorder , an upper set in is a Subset such that if and then : “if is an element then so is anything bigger”. Write for the set of upper sets, ordered by inclusion iff .
Sources: 7 Sketches Example 1.54, 1.64, Exercises 1.55, 1.57, 1.65, 1.66, 1.79, Proposition 1.78.
Example. For the Booleans, is ; is not an upper set since .
- On a Discrete Preorder every subset is an upper set, so (7S Exercise 1.55).
- The inclusion is a Monotone Map (Example 1.64).
- Upper Sets Classified by Maps to Bool (Proposition 1.78): upper sets of correspond to monotone maps via .
- Pullback: a monotone induces , , which in terms of classifying maps is precomposition (7S Exercise 1.79).
- Principal upper sets and Yoneda: is an upper set, is monotone, and iff — the Yoneda Lemma for Preorders (7S Exercise 1.66): to know an element is to know its web of relationships.
Upper sets are the preorder version of presheaves / co-presheaves valued in .
Docs: Vignette: preorders
# upper sets of a finite preorder given by a leq predicate on elements xs
is_upper(leq, xs, U) = all((p ∈ U && leq(p, q)) <= (q ∈ U) for p in xs, q in xs)
upper_sets(leq, xs) = [Set(U) for U in Iterators.map(collect, powerset(xs)) if is_upper(leq, xs, Set(U))]
principal_up(leq, xs, p) = Set(q for q in xs if leq(p, q)) # ↑p
# (powerset from Combinatorics.jl)-- Mathlib: `UpperSet α` and `IsUpperSet`
#check @IsUpperSet -- ∀ ⦃a b⦄, a ≤ b → a ∈ s → b ∈ s
#check (UpperSet ℕ) -- bundled, a complete lattice
#check @UpperSet.Ici -- the principal upper set ↑p = Set.Ici p-- an upper set as a predicate closed upwards (law unenforced)
type UpperSet a = a -> Bool
principalUp :: Preorder a => a -> UpperSet a
principalUp p q = leq p q -- ↑p
pullback :: (a -> b) -> UpperSet b -> UpperSet a
pullback f u = u . f -- f^* U = f⁻¹(U)