example

On the Natural Numbers , define if divides without remainder, written . Then but . This is a Partial Order but not a Total Order: and .

Sources: 7 Sketches Example 1.45, Exercises 1.46, 1.90; CTfS Exercises 4.5.1.4, 4.5.1.16, 4.5.1.29, 4.5.3.11, Example 3.4.2.6

The Hasse Diagram of under divisibility (7S Exercise 1.46):

8964103257189641032571

Viewed as a category, the Product of and is and their Coproduct is ; is the Initial Object and the Terminal Object (CTfS Exercises 4.5.1.16, 4.5.1.29, 4.5.3.11). The opposite order is “is a multiple of”: and . In the product we have and but not (CTfS Exercise 4.5.1.4).

The Meet of two numbers is their greatest common divisor and the Join is their least common multiple (7S Exercise 1.90): , . The bottom element is ; adding (divisible by everything) gives a top element, making a complete lattice.

Docs: Vignette: preorders

divides(n, m) = m % n == 0
gcd(4, 6), lcm(4, 6)     # (2, 12) — meet and join
-- Mathlib: `Nat.instLattice`? No — but ℕ with divisibility is the `Associates`/`Nat` lattice:
example : 2 ∣ 4 := ⟨2, rfl⟩
#check Nat.gcd_dvd_left     -- gcd is a lower bound
#check Nat.dvd_lcm_left     -- lcm is an upper bound
#check Nat.dvd_gcd          -- gcd is the greatest lower bound
newtype Div = Div Int
instance Preorder Div where
  leq (Div n) (Div m) = m `mod` n == 0
meetDiv, joinDiv :: Int -> Int -> Int
meetDiv = gcd
joinDiv = lcm