Comparison categories #
A comparison category is a Finset Ordering — which of lt/eq/gt a pair of elements of a
linear order may stand in. The atomic categories are the singletons (mathlib Ordering itself);
unions like ≤/≥ are larger sets. holds s a b says the comparison of a and b falls in s.
This is framework-agnostic order theory (the point analogue of AllenRelation for intervals): it is
generic over any [LinearOrder α] and bakes in no notion of time. Tense, evidential, and
modal-base-time semantics each supply the order (Time) and name the categories they use
(Tense.past = before, etc.).
Finset Ordering is the eight-element Boolean algebra 𝒫 {lt, eq, gt} — the Aristotelian diagram of
the trichotomy, with the three singletons as atoms and ≤/≥/≠ as their joins. For each pair
a, b, the map s ↦ holds s a b is its Stone-dual point-evaluation at compare a b: a
BoundedLatticeHom into Prop (holdsHom, holds_sup/holds_inf/holds_compl/holds_top/
holds_bot). Together with converse (↦ SetRel.inv) and comp (↦ SetRel.comp) below, this
exhibits holds as a homomorphism from the finite point algebra into the relation algebra
SetRel α α, and makes the named categories' holds_* reductions corollaries of one morphism.
A pair a, b stands in comparison category s iff compare a b is one of s's orderings.
Equations
- Core.Order.holds s a b = (compare a b ∈ s)
Instances For
Equations
holds as a Boolean-algebra homomorphism #
For each pair a, b, s ↦ holds s a b preserves the Boolean structure of Finset Ordering: it is
point-evaluation of the membership relation at compare a b. These are the ∪/∩/ᶜ/⊤/⊥ half
of the relation-algebra homomorphism (the converse/comp half is below).
holds, bundled. For every [LinearOrder α], the map s ↦ fun a b => holds s a b is a
BoundedLatticeHom from the eight-element Boolean algebra Finset Ordering (= 𝒫 {lt, eq, gt})
into the relation algebra α → α → Prop — the Stone-dual evaluation of the comparison-category
algebra. With converse (holds_converse) and comp (holds_comp) it is the point algebra's
image in the concrete relation algebra.
Equations
- Core.Order.holdsHom = { toFun := fun (s : Finset Ordering) (a b : α) => Core.Order.holds s a b, map_sup' := ⋯, map_inf' := ⋯, map_top' := ⋯, map_bot' := ⋯ }
Instances For
Named comparison categories #
The three atoms are the singletons before/overlapping/after; every other category is a Boolean
combination of them, so the composite holds_* reductions below are corollaries of holds_sup, not
separate compare-inspections.
no constraint (= ⊤, see unrestricted_eq_top); kept as the explicit literal so the
decide-checked relation-algebra laws below reduce without unfolding Finset.univ.
Equations
- Core.Order.unrestricted = {Ordering.lt, Ordering.eq, Ordering.gt}
Instances For
Reductions to the underlying order (so consumers' <-shaped proofs go through) #
holds_before/holds_after/holds_overlapping discharge the three atoms; each composite category
then reduces through the homomorphism (holds_sup) plus those atoms, rather than by re-inspecting
compare.
unrestricted is the top of the comparison-category Boolean algebra.
Relation-algebra structure: converse and composition #
Beyond Finset's Boolean-lattice structure (⊆, ∩, ∪), Finset Ordering
carries a converse (swap lt/gt) and a composition with unit
overlapping — the point algebra (the point analogue of AllenRelation's
interval relations). comp r s over-approximates which category a stands in to
c given holds r a b and holds s b c: the transitivity / path-consistency
operation. Generic over any [LinearOrder α], so one algebra structures time,
degree, or any other linear domain alike.
Swapping the arguments of compare swaps the ordering.
Converse of a comparison category: swap lt and gt.
Equations
- Core.Order.converse s = Finset.image Ordering.swap s
Instances For
Base composition table for the point algebra: which categories a may stand
in to c given compare a b and compare b c.
Equations
- Core.Order.compBase Ordering.lt Ordering.lt = Core.Order.before
- Core.Order.compBase Ordering.lt Ordering.eq = Core.Order.before
- Core.Order.compBase Ordering.eq x✝ = {x✝}
- Core.Order.compBase Ordering.gt Ordering.eq = Core.Order.after
- Core.Order.compBase Ordering.gt Ordering.gt = Core.Order.after
- Core.Order.compBase x✝¹ x✝ = Core.Order.unrestricted
Instances For
Composition of comparison categories (transitivity / path-consistency):
the relations a may stand in to c given r between a, b and s
between b, c.
Equations
- Core.Order.comp r s = r.biUnion fun (o₁ : Ordering) => s.biUnion fun (o₂ : Ordering) => Core.Order.compBase o₁ o₂
Instances For
Base soundness: the actual comparison of a and c lies in the composed
category determined by compare a b and compare b c.
Composition is sound: it over-approximates the transitive relation. If
a stands in r to b and b in s to c, then a stands in comp r s
to c.
A comparison category is convex unless it is the non-convex {lt, gt}
("≠", skipping eq) — the one relation that takes the point algebra out of
its path-consistency-complete fragment.
Equations
- Core.Order.IsConvex s = (Ordering.lt ∈ s → Ordering.gt ∈ s → Ordering.eq ∈ s)
Instances For
Equations
- Core.Order.instDecidableIsConvex s = id inferInstance
Relation-algebra laws #
The point algebra is a genuine relation algebra: comp is associative with unit
overlapping, converse is an involution that anti-distributes over comp,
comp is additive and monotone, and the convex fragment is closed under comp,
∩, and converse. All are finite checks over the 8-element carrier (decide,
kernel-verified). mathlib has the concrete relation category (SetRel α β with
comp/inv, and CategoryTheory.RelCat) but no abstract relation-algebra class;
this is the finite, decidable point algebra, bridged to the concrete one by
holds: holds s is the relation {(a, b) | compare a b ∈ s} (a SetRel α α),
with converse mirroring SetRel.inv (holds_converse) and comp sound w.r.t.
SetRel.comp (holds_comp) — exact only when the order realizes every
intermediate point.