Skip to content

Commit 88c2d5d

Browse files
authored
Sites and sheaves (#369)
Stuff from C2.1 in the elephant
1 parent 8f1aa7c commit 88c2d5d

33 files changed

+2836
-86
lines changed

src/1Lab/Membership.agda

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ module 1Lab.Membership where
1616
-- propositions, either. In practice, both of these conditions are
1717
-- satisfied.
1818

19-
record Membership {ℓ ℓe} (A : Type ℓe) (ℙA : Type ℓ) ℓm : Type (ℓ ⊔ lsuc (ℓe ⊔ ℓm)) where
19+
record Membership {ℓ ℓe} (A : Type ℓe) (ℙA : Type ℓ) ℓm : Type (ℓ ⊔ ℓe ⊔ lsuc ℓm) where
2020
field _∈_ : A ℙA Type ℓm
2121
infix 30 _∈_
2222

2323
open Membership ⦃ ... ⦄ using (_∈_) public
24+
{-# DISPLAY Membership._∈_ i a b = a ∈ b #-}
2425

2526
-- The prototypical instance is given by functions into a universe:
2627

@@ -38,17 +39,37 @@ _∉_ : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {ℙA : Type ℓ'} ⦃ m : Membershi
3839
A ℙA Type ℓ''
3940
x ∉ y = ¬ (x ∈ y)
4041

41-
-- Inclusion relative to the _∈_ projection.
42-
43-
_⊆_ : {ℓ ℓ' ℓ''} {A : Type ℓ} {ℙA : Type ℓ'} ⦃ m : Membership A ℙA ℓ'' ⦄
44-
ℙA ℙA Type (ℓ ⊔ ℓ'')
45-
_⊆_ {A = A} S T = (a : A) a ∈ S a ∈ T
42+
infix 30 _∉_
4643

4744
-- Total space of a predicate.
48-
4945
∫ₚ
5046
: {ℓ ℓ' ℓ''} {X : Type ℓ} {ℙX : Type ℓ'} ⦃ m : Membership X ℙX ℓ'' ⦄
5147
ℙX Type _
5248
∫ₚ {X = X} P = Σ[ x ∈ X ] (x ∈ P)
5349

54-
infix 30 _∉_ _⊆_
50+
-- Notation typeclass for _⊆_. We could always define
51+
--
52+
-- S ⊆ T = ∀ x → x ∈ S → x ∈ T
53+
--
54+
-- but this doesn't work too well for collections where the element type
55+
-- is more polymorphic than the collection type, e.g. sieves, where we
56+
-- would instead like
57+
--
58+
-- S ⊆ T = ∀ {i} (x : F i) → x ∈ S → x ∈ T
59+
--
60+
-- Instead we can define _⊆_ as its own class, then write a default
61+
-- instance in terms of _∈_.
62+
63+
record Inclusion {ℓ} (ℙA : Type ℓ) ℓi : Type (ℓ ⊔ lsuc (ℓi)) where
64+
field _⊆_ : ℙA ℙA Type ℓi
65+
infix 30 _⊆_
66+
67+
open Inclusion ⦃ ... ⦄ using (_⊆_) public
68+
{-# DISPLAY Inclusion._⊆_ i a b = a ⊆ b #-}
69+
70+
instance
71+
Inclusion-default
72+
: {ℓ ℓ' ℓ''} {A : Type ℓ} {ℙA : Type ℓ'} ⦃ m : Membership A ℙA ℓ'' ⦄
73+
Inclusion ℙA (ℓ ⊔ ℓ'')
74+
Inclusion-default {A = A} = record { _⊆_ = λ S T (a : A) a ∈ S a ∈ T }
75+
{-# INCOHERENT Inclusion-default #-}

src/1Lab/Path.lagda.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,21 +1100,6 @@ J-refl {x = x} P prefl i = transport-filler (λ i → P _ (λ j → x)) prefl (~
11001100
```agda
11011101
inspect : ∀ {a} {A : Type a} (x : A) → Singleton x
11021102
inspect x = x , refl
1103-
1104-
record Recall
1105-
{a b} {A : Type a} {B : A → Type b}
1106-
(f : (x : A) → B x) (x : A) (y : B x)
1107-
: Type (a ⊔ b)
1108-
where
1109-
constructor ⟪_⟫
1110-
field
1111-
eq : f x ≡ y
1112-
1113-
recall
1114-
: ∀ {a b} {A : Type a} {B : A → Type b}
1115-
→ (f : (x : A) → B x) (x : A)
1116-
→ Recall f x (f x)
1117-
recall f x = ⟪ refl ⟫
11181103
```
11191104
-->
11201105

src/1Lab/Prelude.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ open import 1Lab.Path.Groupoid public
1313
open import 1Lab.Path.IdentitySystem public
1414
open import 1Lab.Path.IdentitySystem.Interface public
1515

16+
open import Meta.Brackets public
1617
open import Meta.Append public
1718
open import Meta.Idiom public
1819
open import Meta.Bind public

src/Algebra/Ring/Solver.agda

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,16 @@ module Impl {ℓ} {R : Type ℓ} (cring : CRing-on R) where
175175
sem [+] = R._+_
176176
sem [*] = R._*_
177177

178-
⟦_⟧ : {n} Polynomial n Vec R n R
179-
⟦ op o p₁ p₂ ⟧ ρ = sem o (⟦ p₁ ⟧ ρ) (⟦ p₂ ⟧ ρ)
180-
⟦ con c ⟧ ρ = embed-coe (lift c)
181-
⟦ var x ⟧ ρ = lookup ρ x
182-
:- p ⟧ ρ = R.- ⟦ p ⟧ ρ
178+
eval : {n} Polynomial n Vec R n R
179+
180+
instance
181+
⟦⟧-Polynomial : {n} ⟦⟧-notation (Polynomial n)
182+
⟦⟧-Polynomial = brackets _ eval
183+
184+
eval (op o p₁ p₂) ρ = sem o (⟦ p₁ ⟧ ρ) (⟦ p₂ ⟧ ρ)
185+
eval (con c) ρ = embed-coe (lift c)
186+
eval (var x) ρ = lookup ρ x
187+
eval (:- p) ρ = R.- ⟦ p ⟧ ρ
183188

184189
---
185190

src/Cat/Base.lagda.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,5 +592,12 @@ instance
592592
sa .idsᵉ .to-path (x i)
593593
Extensional-natural-transformation {D = D} ⦃ sa ⦄ .idsᵉ .to-path-over h =
594594
is-prop→pathp (λ i → Π-is-hlevel 1 λ _ → Pathᵉ-is-hlevel 1 sa (hlevel 2)) _ _
595+
596+
_⟪_⟫_
597+
: ∀ {o ℓ o' ℓ'} {C : Precategory o ℓ} {D : Precategory o' ℓ'}
598+
→ (F : Functor C D) {U V : ⌞ C ⌟}
599+
→ C .Precategory.Hom U V
600+
→ D .Precategory.Hom (F # U) (F # V)
601+
_⟪_⟫_ F f = Functor.F₁ F f
595602
```
596603
-->

src/Cat/CartesianClosed/Instances/PSh.agda

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,30 +176,32 @@ module _ {κ} {C : Precategory κ κ} where
176176
module C = Cat.Reasoning C
177177
module PSh = Cat.Reasoning (PSh κ C)
178178

179+
open Binary-products (PSh κ C) (PSh-products {C = C})
180+
181+
PSh[_,_] : PSh.Ob PSh.Ob PSh.Ob
182+
PSh[ A , B ] = F module psh-exp where
183+
module A = Functor A
184+
module B = Functor B
185+
186+
F : PSh.Ob
187+
F .F₀ c = el ((よ₀ C c ⊗₀ A) => B) Nat-is-set
188+
F .F₁ f nt .η i (g , x) = nt .η i (f C.∘ g , x)
189+
F .F₁ f nt .is-natural x y g = funext λ o
190+
ap (nt .η y) (Σ-pathp (C.assoc _ _ _) refl) ∙ happly (nt .is-natural _ _ _) _
191+
F .F-id = ext λ f i g x
192+
ap (f .η i) (Σ-pathp (C.idl _) refl)
193+
F .F-∘ f g = ext λ h i j x
194+
ap (h .η i) (Σ-pathp (sym (C.assoc _ _ _)) refl)
195+
196+
{-# DISPLAY psh-exp.F A B = PSh[ A , B ] #-}
197+
179198
PSh-closed : Cartesian-closed (PSh κ C) (PSh-products {C = C}) (PSh-terminal {C = C})
180199
PSh-closed = cc where
181200
cat = PSh κ C
182201

183-
open Binary-products cat (PSh-products {C = C}) public
184-
185202
module _ (A : PSh.Ob) where
186-
module A = Functor A
187-
188-
hom₀ : PSh.Ob PSh.Ob
189-
hom₀ B = F where
190-
module B = Functor B
191-
F : PSh.Ob
192-
F .F₀ c = el ((よ₀ C c ⊗₀ A) => B) Nat-is-set
193-
F .F₁ f nt .η i (g , x) = nt .η i (f C.∘ g , x)
194-
F .F₁ f nt .is-natural x y g = funext λ o
195-
ap (nt .η y) (Σ-pathp (C.assoc _ _ _) refl) ∙ happly (nt .is-natural _ _ _) _
196-
F .F-id = ext λ f i g x
197-
ap (f .η i) (Σ-pathp (C.idl _) refl)
198-
F .F-∘ f g = ext λ h i j x
199-
ap (h .η i) (Σ-pathp (sym (C.assoc _ _ _)) refl)
200-
201203
func : Functor (PSh κ C) (PSh κ C)
202-
func .F₀ = hom₀
204+
func .F₀ = PSh[ A ,_]
203205
func .F₁ f .η i g .η j (h , x) = f .η _ (g .η _ (h , x))
204206
func .F₁ f .η i g .is-natural x y h = funext λ x
205207
ap (f .η _) (happly (g .is-natural _ _ _) _) ∙ happly (f .is-natural _ _ _) _

src/Cat/Diagram/Colimit/Base.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ is-cocontinuous oshape hshape {C = C} F =
646646
→ preserves-colimit F Diagram
647647
```
648648

649-
# Cocompleteness
649+
# Cocompleteness {defines="cocomplete-category"}
650650

651651
A category is **cocomplete** if it admits colimits for diagrams of arbitrary shape.
652652
However, in the presence of excluded middle, if a category admits

src/Cat/Diagram/Colimit/Cocone.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ open _=>_
2222
```
2323
-->
2424

25-
# Colimits via cocones
25+
# Colimits via cocones {defines="cocone"}
2626

2727
As noted in the main page on [[colimits]], most introductory texts opt
2828
to define colimits via categorical gadgets called **cocones**. A

src/Cat/Diagram/Monad/Limits.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ open Algebra-on
3131
```
3232
-->
3333

34-
# Limits in categories of algebras
34+
# Limits in categories of algebras {defines="limits-in-categories-of-algebras"}
3535

3636
Suppose that $\cC$ be a category, $M$ be a [monad] on $\cC$, and
3737
$F$ be a $\cJ$-shaped diagram of [$M$-algebras][malg] (that is, a

0 commit comments

Comments
 (0)