-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsum.agda
45 lines (35 loc) · 1.23 KB
/
sum.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{-# OPTIONS --without-K #-}
module sum where
open import level using (Level; _⊔_)
open import function.core
infixr 4 _,_
infixr 2 _×_
infixr 1 _⊎_
record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ public
_×_ : {l k : Level} (A : Set l) (B : Set k) → Set (l ⊔ k)
A × B = Σ A λ _ → B
uncurry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : (x : A) → (B x) → Set c}
→ ((x : A) → (y : B x) → C x y) → ((xy : Σ A B) → C (proj₁ xy) (proj₂ xy))
uncurry f (a , b) = f a b
uncurry' : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k}
→ (X → Y → Z)
→ (X × Y) → Z
uncurry' f (x , y) = f x y
data _⊎_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
inj₁ : (x : A) → A ⊎ B
inj₂ : (y : B) → A ⊎ B
[_,⊎_] : ∀ {i i' j}{A : Set i}{A' : Set i'}{B : Set j}
→ (A → B) → (A' → B)
→ A ⊎ A' → B
[ f ,⊎ f' ] (inj₁ a) = f a
[ f ,⊎ f' ] (inj₂ a') = f' a'
map-⊎ : ∀ {i i' j j'}{A : Set i}{A' : Set i'}
→ {B : Set j}{B' : Set j'}
→ (A → B) → (A' → B')
→ A ⊎ A' → B ⊎ B'
map-⊎ g g' = [ inj₁ ∘' g ,⊎ inj₂ ∘' g' ]