Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 77ca1ed

Browse files
committed
feat(order/category/Lattice): The category of lattices (#11968)
Define `Lattice`, the category of lattices with lattice homs.
1 parent 5bcffd9 commit 77ca1ed

File tree

4 files changed

+111
-11
lines changed

4 files changed

+111
-11
lines changed

src/category_theory/concrete_category/bundled_hom.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ intros; apply 𝒞.hom_ext;
6363
6464
This instance generates the type-class problem `bundled_hom ?m` (which is why this is marked as
6565
`[nolint]`). Currently that is not a problem, as there are almost no instances of `bundled_hom`. -/
66-
@[nolint dangerous_instance] instance : concrete_category.{u} (bundled c) :=
66+
@[nolint dangerous_instance] instance concrete_category : concrete_category.{u} (bundled c) :=
6767
{ forget := { obj := λ X, X,
6868
map := λ X Y f, 𝒞.to_fun X.str Y.str f,
6969
map_id' := λ X, 𝒞.id_to_fun X.str,

src/order/category/Lattice.lean

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/-
2+
Copyright (c) 2022 Yaël Dillies. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yaël Dillies
5+
-/
6+
import order.category.PartialOrder
7+
import order.hom.lattice
8+
9+
/-!
10+
# The category of lattices
11+
12+
This defines `Lattice`, the category of lattices.
13+
14+
Note that `Lattice` doesn't correspond to the literature definition of `Lat` as we don't require
15+
bottom or top elements. Instead, `Lat` corresponds to `BoundedLattice` (not yet in mathlib).
16+
17+
## TODO
18+
19+
The free functor from `Lattice` to `BoundedLattice` is `X → with_top (with_bot X)`.
20+
-/
21+
22+
universes u
23+
24+
open category_theory
25+
26+
/-- The category of lattices. -/
27+
def Lattice := bundled lattice
28+
29+
namespace Lattice
30+
31+
instance : has_coe_to_sort Lattice Type* := bundled.has_coe_to_sort
32+
instance (X : Lattice) : lattice X := X.str
33+
34+
/-- Construct a bundled `Lattice` from a `lattice`. -/
35+
def of (α : Type*) [lattice α] : Lattice := bundled.of α
36+
37+
instance : inhabited Lattice := ⟨of bool⟩
38+
39+
instance : bundled_hom @lattice_hom :=
40+
{ to_fun := λ _ _ _ _, coe_fn,
41+
id := @lattice_hom.id,
42+
comp := @lattice_hom.comp,
43+
hom_ext := λ X Y _ _, by exactI fun_like.coe_injective }
44+
45+
instance : large_category.{u} Lattice := bundled_hom.category lattice_hom
46+
instance : concrete_category Lattice := bundled_hom.concrete_category lattice_hom
47+
48+
instance has_forget_to_PartialOrder : has_forget₂ Lattice PartialOrder :=
49+
{ forget₂ := { obj := λ X, ⟨X⟩, map := λ X Y f, f },
50+
forget_comp := rfl }
51+
52+
/-- Constructs an isomorphism of lattices from an order isomorphism between them. -/
53+
@[simps] def iso.mk {α β : Lattice.{u}} (e : α ≃o β) : α ≅ β :=
54+
{ hom := e,
55+
inv := e.symm,
56+
hom_inv_id' := by { ext, exact e.symm_apply_apply _ },
57+
inv_hom_id' := by { ext, exact e.apply_symm_apply _ } }
58+
59+
/-- `order_dual` as a functor. -/
60+
@[simps] def dual : Lattice ⥤ Lattice :=
61+
{ obj := λ X, of (order_dual X), map := λ X Y, lattice_hom.dual }
62+
63+
/-- The equivalence between `Lattice` and itself induced by `order_dual` both ways. -/
64+
@[simps functor inverse] def dual_equiv : Lattice ≌ Lattice :=
65+
equivalence.mk dual dual
66+
(nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)
67+
(nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)
68+
69+
end Lattice
70+
71+
lemma Lattice_dual_comp_forget_to_PartialOrder :
72+
Lattice.dual ⋙ forget₂ Lattice PartialOrder =
73+
forget₂ Lattice PartialOrder ⋙ PartialOrder.to_dual := rfl

src/order/category/LinearOrder.lean

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johan Commelin
55
-/
66

7-
import order.category.PartialOrder
7+
import order.category.Lattice
88

99
/-!
1010
# Category of linear orders
@@ -34,8 +34,9 @@ instance : inhabited LinearOrder := ⟨of punit⟩
3434

3535
instance (α : LinearOrder) : linear_order α := α.str
3636

37-
instance has_forget_to_PartialOrder : has_forget₂ LinearOrder PartialOrder :=
38-
bundled_hom.forget₂ _ _
37+
instance has_forget_to_Lattice : has_forget₂ LinearOrder Lattice :=
38+
{ forget₂ := { obj := λ X, Lattice.of X,
39+
map := λ X Y f, (order_hom_class.to_lattice_hom X Y f : lattice_hom X Y) } }
3940

4041
/-- Constructs an equivalence between linear orders from an order isomorphism between them. -/
4142
@[simps] def iso.mk {α β : LinearOrder.{u}} (e : α ≃o β) : α ≅ β :=
@@ -45,17 +46,17 @@ bundled_hom.forget₂ _ _
4546
inv_hom_id' := by { ext, exact e.apply_symm_apply x } }
4647

4748
/-- `order_dual` as a functor. -/
48-
@[simps] def to_dual : LinearOrder ⥤ LinearOrder :=
49+
@[simps] def dual : LinearOrder ⥤ LinearOrder :=
4950
{ obj := λ X, of (order_dual X), map := λ X Y, order_hom.dual }
5051

51-
/-- The equivalence between `PartialOrder` and itself induced by `order_dual` both ways. -/
52+
/-- The equivalence between `LinearOrder` and itself induced by `order_dual` both ways. -/
5253
@[simps functor inverse] def dual_equiv : LinearOrder ≌ LinearOrder :=
53-
equivalence.mk to_dual to_dual
54+
equivalence.mk dual dual
5455
(nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)
5556
(nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)
5657

5758
end LinearOrder
5859

59-
lemma LinearOrder_dual_equiv_comp_forget_to_PartialOrder :
60-
LinearOrder.dual_equiv.functor ⋙ forget₂ LinearOrder PartialOrder
61-
= forget₂ LinearOrder PartialOrder ⋙ PartialOrder.dual_equiv.functor := rfl
60+
lemma LinearOrder_dual_comp_forget_to_Lattice :
61+
LinearOrder.dual ⋙ forget₂ LinearOrder Lattice = forget₂ LinearOrder Lattice ⋙ Lattice.dual :=
62+
rfl

src/order/hom/lattice.lean

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ be satisfied by itself and all stricter types.
3232
Do we need more intersections between `bot_hom`, `top_hom` and lattice homomorphisms?
3333
-/
3434

35-
open function
35+
open function order_dual
3636

3737
variables {F α β γ δ : Type*}
3838

@@ -114,6 +114,20 @@ instance bounded_lattice_hom_class.to_bounded_order_hom_class [lattice α] [latt
114114
bounded_order_hom_class F α β :=
115115
{ .. ‹bounded_lattice_hom_class F α β› }
116116

117+
@[priority 100] -- See note [lower instance priority]
118+
instance order_iso.sup_hom_class [semilattice_sup α] [semilattice_sup β] :
119+
sup_hom_class (α ≃o β) α β :=
120+
{ map_sup := λ f, f.map_sup, ..rel_iso.rel_hom_class }
121+
122+
@[priority 100] -- See note [lower instance priority]
123+
instance order_iso.inf_hom_class [semilattice_inf α] [semilattice_inf β] :
124+
inf_hom_class (α ≃o β) α β :=
125+
{ map_inf := λ f, f.map_inf, ..rel_iso.rel_hom_class }
126+
127+
@[priority 100] -- See note [lower instance priority]
128+
instance order_iso.lattice_hom_class [lattice α] [lattice β] : lattice_hom_class (α ≃o β) α β :=
129+
{ ..order_iso.sup_hom_class, ..order_iso.inf_hom_class }
130+
117131
instance [has_sup α] [has_sup β] [sup_hom_class F α β] : has_coe_t F (sup_hom α β) :=
118132
⟨λ f, ⟨f, map_sup f⟩⟩
119133

@@ -366,6 +380,18 @@ lemma cancel_left {g : lattice_hom β γ} {f₁ f₂ : lattice_hom α β} (hg :
366380
⟨λ h, lattice_hom.ext $ λ a, hg $
367381
by rw [←lattice_hom.comp_apply, h, lattice_hom.comp_apply], congr_arg _⟩
368382

383+
/-- Reinterpret a lattice homomorphism as a lattice homomorphism between the dual lattices. -/
384+
@[simps] protected def dual :
385+
lattice_hom α β ≃ lattice_hom (order_dual α) (order_dual β) :=
386+
{ to_fun := λ f, { to_fun := to_dual ∘ f ∘ of_dual,
387+
map_sup' := λ _ _, congr_arg to_dual (map_inf f _ _),
388+
map_inf' := λ _ _, congr_arg to_dual (map_sup f _ _) },
389+
inv_fun := λ f, { to_fun := of_dual ∘ f ∘ to_dual,
390+
map_sup' := λ _ _, congr_arg of_dual (map_inf f _ _),
391+
map_inf' := λ _ _, congr_arg of_dual (map_sup f _ _) },
392+
left_inv := λ f, ext $ λ a, rfl,
393+
right_inv := λ f, ext $ λ a, rfl }
394+
369395
end lattice_hom
370396

371397
namespace order_hom_class

0 commit comments

Comments
 (0)