|
| 1 | +/- |
| 2 | +Copyright (c) 2025 Violeta Hernández Palacios. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Violeta Hernández Palacios |
| 5 | +-/ |
| 6 | +module |
| 7 | + |
| 8 | +public import Mathlib.Order.Concept |
| 9 | + |
| 10 | +import Mathlib.Order.UpperLower.CompleteLattice |
| 11 | + |
| 12 | +/-! |
| 13 | +# Dedekind-MacNeille completion |
| 14 | +
|
| 15 | +The Dedekind-MacNeille completion of a partial order is the smallest complete lattice into which it |
| 16 | +embeds. |
| 17 | +
|
| 18 | +The theory of concept lattices allows for a simple construction. In fact, `DedekindCut α` is simply |
| 19 | +an abbreviation for `Concept α α (· ≤ ·)`. This means we don't need to reprove that this is a |
| 20 | +complete lattice; instead, the file simply proves that any order embedding into another complete |
| 21 | +lattice factors through it. |
| 22 | +
|
| 23 | +## Todo |
| 24 | +
|
| 25 | +- Build the order isomorphism `DedekindCut ℚ ≃o EReal`. |
| 26 | +
|
| 27 | +## Tags |
| 28 | +
|
| 29 | +Dedekind completion, Dedekind cut |
| 30 | +-/ |
| 31 | + |
| 32 | +@[expose] public section |
| 33 | + |
| 34 | +open Concept Set |
| 35 | + |
| 36 | +variable {α β : Type*} |
| 37 | + |
| 38 | +variable (α) in |
| 39 | +/-- The **Dedekind-MacNeille completion** of a partial order is the smallest complete lattice that |
| 40 | +contains it. We define here the type of Dedekind cuts of `α` as the `Concept` lattice of the `≤` |
| 41 | +relation of `α`. |
| 42 | +
|
| 43 | +For `A : DedekindCut α`, the sets `A.left` and `A.right` are related by |
| 44 | +`upperBounds A.left = A.right` and `lowerBounds A.right = A.left`. |
| 45 | +
|
| 46 | +The theorem `DedekindCut.principalEmbedding_trans_factorEmbedding` proves that if `α` is a partial |
| 47 | +order and `β` is a complete lattice, any embedding `α ↪o β` factors through `DedekindCut α`. -/ |
| 48 | +abbrev DedekindCut [Preorder α] := Concept α α (· ≤ ·) |
| 49 | + |
| 50 | +namespace DedekindCut |
| 51 | + |
| 52 | +section Preorder |
| 53 | +variable [Preorder α] [Preorder β] |
| 54 | + |
| 55 | +/-- The left set of a Dedekind cut. This is an alias for `Concept.extent`. -/ |
| 56 | +abbrev left (A : DedekindCut α) : Set α := A.extent |
| 57 | + |
| 58 | +/-- The right set of a Dedekind cut. This is an alias for `Concept.intent`. -/ |
| 59 | +abbrev right (A : DedekindCut α) : Set α := A.intent |
| 60 | + |
| 61 | +/-- See `DedekindCut.ext'` for a version using the right set instead. -/ |
| 62 | +@[ext] theorem ext {A B : DedekindCut α} (h : A.left = B.left) : A = B := Concept.ext h |
| 63 | + |
| 64 | +/-- See `DedekindCut.ext` for a version using the left set instead. -/ |
| 65 | +theorem ext' {A B : DedekindCut α} (h : A.right = B.right) : A = B := Concept.ext' h |
| 66 | + |
| 67 | +@[simp] |
| 68 | +theorem upperBounds_left (A : DedekindCut α) : upperBounds A.left = A.right := |
| 69 | + A.upperPolar_extent |
| 70 | + |
| 71 | +@[simp] |
| 72 | +theorem lowerBounds_right (A : DedekindCut α) : lowerBounds A.right = A.left := |
| 73 | + A.lowerPolar_intent |
| 74 | + |
| 75 | +theorem image_left_subset_lowerBounds {f : α → β} (hf : Monotone f) |
| 76 | + (A : DedekindCut α) : f '' A.left ⊆ lowerBounds (f '' A.right) := by |
| 77 | + rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ |
| 78 | + exact hf <| rel_extent_intent hx hy |
| 79 | + |
| 80 | +theorem image_right_subset_upperBounds {f : α → β} (hf : Monotone f) |
| 81 | + (A : DedekindCut α) : f '' A.right ⊆ upperBounds (f '' A.left) := by |
| 82 | + rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ |
| 83 | + exact hf <| rel_extent_intent hy hx |
| 84 | + |
| 85 | +/-- Convert an element into its Dedekind cut (`Iic a`, `Ici a`). This map is order-preserving, |
| 86 | +though it is injective only on partial orders. -/ |
| 87 | +def principal (a : α) : DedekindCut α := |
| 88 | + (Concept.ofObject _ a).copy (Iic a) (Ici a) |
| 89 | + (by ext; simpa [mem_lowerPolar_iff] using forall_ge_iff_le.symm) |
| 90 | + (by ext; simp) |
| 91 | + |
| 92 | +@[simp] theorem left_principal (a : α) : (principal a).left = Iic a := rfl |
| 93 | +@[simp] theorem right_principal (a : α) : (principal a).right = Ici a := rfl |
| 94 | + |
| 95 | +@[simp] theorem ofObject_eq_principal (a : α) : ofObject (· ≤ ·) a = principal a := |
| 96 | + (copy_eq ..).symm |
| 97 | +@[simp] theorem ofAttribute_eq_principal (a : α) : ofAttribute (· ≤ ·) a = principal a := by |
| 98 | + ext; simp |
| 99 | + |
| 100 | +@[simp] |
| 101 | +theorem principal_le_principal {a b : α} : principal a ≤ principal b ↔ a ≤ b := by |
| 102 | + simpa using ofObject_le_ofAttribute_iff (r := (· ≤ ·)) (a := a) |
| 103 | + |
| 104 | +@[simp] |
| 105 | +theorem principal_lt_principal {a b : α} : principal a < principal b ↔ a < b := by |
| 106 | + simp [lt_iff_le_not_ge] |
| 107 | + |
| 108 | +/-- We can never have a computable decidable instance, for the same reason we can't on `Set α`. -/ |
| 109 | +noncomputable instance : DecidableLE (DedekindCut α) := |
| 110 | + Classical.decRel _ |
| 111 | + |
| 112 | +end Preorder |
| 113 | + |
| 114 | +section PartialOrder |
| 115 | +variable [PartialOrder α] |
| 116 | + |
| 117 | +@[simp] |
| 118 | +theorem principal_inj {a b : α} : principal a = principal b ↔ a = b := by |
| 119 | + simp [le_antisymm_iff] |
| 120 | + |
| 121 | +/-- `DedekindCut.principal` as an `OrderEmbedding`. -/ |
| 122 | +@[simps! apply] |
| 123 | +def principalEmbedding : α ↪o DedekindCut α where |
| 124 | + toFun := principal |
| 125 | + inj' _ _ := principal_inj.1 |
| 126 | + map_rel_iff' := principal_le_principal |
| 127 | + |
| 128 | +@[simp] theorem coe_principalEmbedding : ⇑(@principalEmbedding α _) = principal := rfl |
| 129 | + |
| 130 | +end PartialOrder |
| 131 | + |
| 132 | +section CompleteLattice |
| 133 | +variable [CompleteLattice α] [PartialOrder β] |
| 134 | + |
| 135 | +@[simp] |
| 136 | +theorem principal_sSup_left (A : DedekindCut α) : principal (sSup A.left) = A := by |
| 137 | + apply ext' |
| 138 | + ext |
| 139 | + rw [right_principal, mem_Ici, sSup_le_iff, ← upperBounds_left, mem_upperBounds] |
| 140 | + |
| 141 | +@[simp] |
| 142 | +theorem principal_sInf_right (A : DedekindCut α) : principal (sInf A.right) = A := by |
| 143 | + ext |
| 144 | + rw [left_principal, mem_Iic, le_sInf_iff, ← lowerBounds_right, mem_lowerBounds] |
| 145 | + |
| 146 | +/-- Any order embedding `β ↪o α` into a complete lattice `α` factors through `DedekindCut β`. |
| 147 | +
|
| 148 | +This map is defined so that `factorEmbedding f A = sSup (f '' A.left)`. Although the construction |
| 149 | +`factorEmbedding f A = sInf (f '' A.right)` would also work, these do **not** in general give equal |
| 150 | +embeddings. -/ |
| 151 | +def factorEmbedding (f : β ↪o α) : DedekindCut β ↪o α := |
| 152 | + .ofMapLEIff (fun A ↦ sSup (f '' A.left)) <| by |
| 153 | + refine fun A B ↦ ⟨fun h x hx ↦ ?_, fun h ↦ sSup_le_sSup (image_mono h)⟩ |
| 154 | + simp_rw [← lowerBounds_right] |
| 155 | + simp_rw [le_sSup_iff, sSup_le_iff, forall_mem_image] at h |
| 156 | + intro y hy |
| 157 | + rw [← f.le_iff_le] |
| 158 | + exact h _ (image_right_subset_upperBounds f.monotone _ (mem_image_of_mem _ hy)) hx |
| 159 | + |
| 160 | +theorem factorEmbedding_apply (f : β ↪o α) (A : DedekindCut β) : |
| 161 | + factorEmbedding f A = sSup (f '' A.left) := |
| 162 | + rfl |
| 163 | + |
| 164 | +@[simp] |
| 165 | +theorem factorEmbedding_principal (f : β ↪o α) (x : β) : factorEmbedding f (principal x) = f x := by |
| 166 | + rw [factorEmbedding_apply] |
| 167 | + apply le_antisymm (by simp) |
| 168 | + rw [le_sSup_iff] |
| 169 | + refine fun y hy ↦ hy ?_ |
| 170 | + simp |
| 171 | + |
| 172 | +/-- The Dedekind-MacNeille completion of a partial order is the smallest complete lattice containing |
| 173 | +it, in the sense that any embedding into any complete lattice factors through it. -/ |
| 174 | +theorem principalEmbedding_trans_factorEmbedding (f : β ↪o α) : |
| 175 | + principalEmbedding.trans (factorEmbedding f) = f := by |
| 176 | + ext; simp |
| 177 | + |
| 178 | +/-- `DedekindCut.principal` as an `OrderIso`. |
| 179 | +
|
| 180 | +This provides the second half of the **fundamental theorem of concept lattices**: every complete |
| 181 | +lattice is isomorphic to a concept lattice (its own Dedekind completion). |
| 182 | +
|
| 183 | +See `Concept.instCompleteLattice` for the first half. -/ |
| 184 | +@[simps! apply] |
| 185 | +def principalIso : α ≃o DedekindCut α where |
| 186 | + invFun := factorEmbedding (OrderIso.refl α) |
| 187 | + left_inv x := factorEmbedding_principal _ x |
| 188 | + right_inv x := by simp [factorEmbedding] |
| 189 | + __ := principalEmbedding |
| 190 | + |
| 191 | +theorem principalIso_symm_apply (A : DedekindCut α) : principalIso.symm A = sSup A.left := |
| 192 | + (factorEmbedding_apply ..).trans <| by simp |
| 193 | + |
| 194 | +end CompleteLattice |
| 195 | + |
| 196 | +section LinearOrder |
| 197 | +variable [LinearOrder α] |
| 198 | + |
| 199 | +instance : @Std.Total (DedekindCut α) (· ≤ ·) where |
| 200 | + total x y := le_total (α := LowerSet α) ⟨_, isLowerSet_extent_le x⟩ ⟨_, isLowerSet_extent_le y⟩ |
| 201 | + |
| 202 | +noncomputable instance : LinearOrder (DedekindCut α) where |
| 203 | + min_def x y := congrFun₂ inf_eq_minDefault x y |
| 204 | + max_def x y := congrFun₂ sup_eq_maxDefault x y |
| 205 | + le_total := total_of _ |
| 206 | + toDecidableLE := inferInstance |
| 207 | + |
| 208 | +noncomputable instance : CompleteLinearOrder (DedekindCut α) where |
| 209 | + __ := inferInstanceAs (LinearOrder _) |
| 210 | + __ := inferInstanceAs (CompleteLattice _) |
| 211 | + __ := LinearOrder.toBiheytingAlgebra _ |
| 212 | + |
| 213 | +end LinearOrder |
| 214 | +end DedekindCut |
0 commit comments