Skip to content

Commit 8c8bf56

Browse files
committed
feat(CategoryTheory): FinCategory instance on Pairwise (leanprover-community#33537)
1 parent 50b8949 commit 8c8bf56

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Mathlib/CategoryTheory/Category/Pairwise.lean

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ module
77

88
public import Mathlib.CategoryTheory.Category.Preorder
99
public import Mathlib.CategoryTheory.Limits.IsLimit
10+
public import Mathlib.CategoryTheory.FinCategory.Basic
1011
public import Mathlib.Order.CompleteLattice.Basic
12+
public import Mathlib.Tactic.DeriveFintype
1113

1214
/-!
1315
# The category of "pairwise intersections".
@@ -43,6 +45,7 @@ We use this as the objects of a category to describe the sheaf condition.
4345
inductive Pairwise (ι : Type v)
4446
| single : ι → Pairwise ι
4547
| pair : ι → ι → Pairwise ι
48+
deriving Fintype, DecidableEq
4649

4750
variable {ι : Type v}
4851

@@ -59,6 +62,10 @@ inductive Hom : Pairwise ι → Pairwise ι → Type v
5962
| id_pair : ∀ i j, Hom (pair i j) (pair i j)
6063
| left : ∀ i j, Hom (pair i j) (single i)
6164
| right : ∀ i j, Hom (pair i j) (single j)
65+
deriving DecidableEq
66+
67+
-- False positive?
68+
attribute [nolint unusedArguments] instDecidableEqHom.decEq
6269

6370
open Hom
6471

@@ -95,6 +102,20 @@ instance : Category (Pairwise ι) where
95102

96103
end
97104

105+
instance {i j : Pairwise ι} [DecidableEq ι] : DecidableEq (i ⟶ j) :=
106+
inferInstanceAs (DecidableEq (Pairwise.Hom i j))
107+
108+
instance [Fintype ι] [DecidableEq ι] : FinCategory (Pairwise ι) where
109+
fintypeHom
110+
| .single i, .single j => ⟨if h : i = j then {eqToHom (h ▸ rfl)} else ∅, by rintro ⟨⟩; cat_disch⟩
111+
| .single i, .pair j k => ⟨∅, by rintro ⟨⟩⟩
112+
| .pair i j, .single k =>
113+
⟨(if h : i = k then {Hom.left i j ≫ eqToHom (h ▸ rfl)} else ∅) ∪
114+
(if h : j = k then {Hom.right i j ≫ eqToHom (h ▸ rfl)} else ∅),
115+
by rintro ⟨⟩ <;> cat_disch⟩
116+
| .pair i j, .pair k l =>
117+
if h : i = k ∧ j = l then {eqToHom (h.1 ▸ h.2 ▸ rfl)} else ∅, by rintro ⟨⟩; cat_disch⟩
118+
98119
variable {α : Type u} (U : ι → α)
99120

100121
section

0 commit comments

Comments
 (0)