Core's order hierarchy from Mathlib's #
Core's weakest-precondition stack states assertions over Lean.Order.CompleteLattice, a
lattice class whose order is a bare relation ⊑ and whose suprema are indexed by predicates,
while Mathlib's program-logic carriers (Prop, ℝ≥0∞, function lattices) come with Mathlib's
CompleteLattice. The pinned Mathlib has no bridge between the two hierarchies; this file
supplies it. The instances are low priority so that core's own instances on Prop and on
function types win where both apply; they agree with these definitionally on the order relation,
and Lean.Order.CompleteLattice carries no further data, so the two routes to a lattice
structure on the same type are propositionally interchangeable.
The file also reverses core's order on Mathlib's OrderDual: ⊑ on αᵒᵈ is ⊑ on α read
backwards, and the supremum of a predicate is its infimum in α. On a Mathlib lattice this agrees,
at instance transparency, with the bridge of Mathlib's own dual order.
On a bridged carrier, core's lattice operations are Mathlib's. The transfer lemmas of the namespace
LeanOrder (LeanOrder.top_eq_top, LeanOrder.meet_eq_inf, …) rewrite each into Mathlib's
spelling, and simp uses them.
Mathlib's ≤ as core's ⊑.
Equations
- Lean.Order.instPartialOrderOfMathlib = { rel := fun (x1 x2 : α) => x1 ≤ x2, rel_refl := ⋯, rel_trans := ⋯, rel_antisymm := ⋯ }
The relation underlying the bridged order is Mathlib's ≤.
Mathlib's complete lattice as core's, with sSup of the set a predicate carves out
supplying every predicate-indexed supremum.
Equations
- Lean.Order.instCompleteLatticeOfMathlib = { toPartialOrder := Lean.Order.instPartialOrderOfMathlib, has_sup := ⋯ }
Core's predicate-indexed supremum is Mathlib's sSup of the carved-out set.
Core's order read backwards on the order dual.
Equations
- Lean.Order.instPartialOrderOrderDual = { rel := fun (x y : αᵒᵈ) => Lean.Order.PartialOrder.rel y x, rel_refl := ⋯, rel_trans := ⋯, rel_antisymm := ⋯ }
The order dual of a complete lattice: the supremum of a predicate is its infimum below.
Equations
- Lean.Order.instCompleteLatticeOrderDual = { toPartialOrder := Lean.Order.instPartialOrderOrderDual, has_sup := ⋯ }
The dual order is the original order with its arguments swapped.
Lattice operations across the bridge #
Std.Internal.Order defines core's top, meet, join, iInf, iSup, himp, and ⌜·⌝ from
predicate-indexed suprema, and bot as the supremum of the empty chain. On a carrier whose
Lean.Order.CompleteLattice is the bridge above, they are Mathlib's ⊤, ⊓, ⊔, ⨅, ⨆, ⇨,
if p then ⊤ else ⊥, and ⊥.
The transfer lemmas live in the namespace LeanOrder, outside Lean.Order. A declaration in
Lean.Order, or in a namespace below it, is elaborated with Lean.Order open. That activates
core's scoped ⊤, ⊓, ⊔, ⨅, ⨆, and ⇨ notation beside Mathlib's, and it resolves le_top
and le_inf to core's lemmas. Outside Lean.Order, the statements use Mathlib's notation and name
core's operations in full.
On a Mathlib complete lattice, core's top element is Mathlib's ⊤.
On a Mathlib complete lattice, core's bottom element, the supremum of the empty chain under
the chain-complete order of the lattice, is Mathlib's ⊥.
On a Mathlib complete lattice, core's binary meet is Mathlib's ⊓.
On a Mathlib complete lattice, core's binary join is Mathlib's ⊔.
On a Mathlib complete lattice, core's infimum of an indexed family is Mathlib's ⨅.
On a Mathlib complete lattice, core's supremum of an indexed family is Mathlib's ⨆.
On a Mathlib complete lattice, core's embedding ⌜p⌝ of a proposition is ⊤ when p holds
and ⊥ otherwise. It is not a simp lemma, since its right-hand side needs p decidable.
On a Mathlib frame, a complete lattice whose meets distribute over suprema, core's Heyting
implication is Mathlib's ⇨.