forked from cedille/ial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct-thms.agda
More file actions
66 lines (52 loc) · 2.31 KB
/
product-thms.agda
File metadata and controls
66 lines (52 loc) · 2.31 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module product-thms where
open import eq
open import level
open import product
open import unit
open import functions
-- this is called the inspect idiom, in the Agda stdlib
keep : ∀{ℓ}{A : Set ℓ} → (x : A) → Σ A (λ y → x ≡ y)
keep x = ( x , refl )
,inj : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}{a a' : A}{b b' : B} →
a , b ≡ a' , b' → a ≡ a' ∧ b ≡ b'
,inj refl = refl , refl
eta-× : ∀{ℓ₁ ℓ₂ ℓ₃}{A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃}{h : A × B → C}
→ (extensionality {ℓ₁ ⊔ ℓ₂}{ℓ₃})
→ (λ c → h (fst c , snd c)) ≡ h
eta-× {A = A}{B}{C}{h} ext = ext eta-×-aux
where
eta-×-aux : ∀{a : Σ A (λ x → B)} → h (fst a , snd a) ≡ h a
eta-×-aux {(a , b)} = refl
eq-× : ∀{ℓ₁ ℓ₂}{A : Set ℓ₁}{B : Set ℓ₂}{a a' : A}{b b' : B}
→ a ≡ a'
→ b ≡ b'
→ (a , b) ≡ (a' , b')
eq-× refl refl = refl
-- This module proves typical isomorphisms about ∧.
module ∧-Isos where
postulate ext-set : ∀{l1 l2 : level} → extensionality {l1} {l2}
∧-unit-l : ∀{ℓ}{A : Set ℓ} → A → A ∧ ⊤
∧-unit-l x = x , triv
∧-unit-r : ∀{ℓ}{A : Set ℓ} → A → ⊤ ∧ A
∧-unit-r x = twist-× (∧-unit-l x)
∧-unit-l-iso : ∀{ℓ}{A : Set ℓ} → Iso A (A ∧ ⊤)
∧-unit-l-iso {_}{A} = isIso ∧-unit-l fst refl (ext-set aux)
where
aux : {a : A ∧ ⊤} → (fst a , triv) ≡ a
aux {x , triv} = refl
∧-unit-r-iso : ∀{ℓ}{A : Set ℓ} → Iso A (⊤ ∧ A)
∧-unit-r-iso {_}{A} = isIso ∧-unit-r snd refl (ext-set aux)
where
aux : {a : ⊤ ∧ A} → (triv , snd a) ≡ a
aux {triv , x} = refl
∧-assoc₁ : ∀{ℓ}{A B C : Set ℓ} → (A ∧ (B ∧ C)) → ((A ∧ B) ∧ C)
∧-assoc₁ (a , b , c) = ((a , b) , c)
∧-assoc₂ : ∀{ℓ}{A B C : Set ℓ} → ((A ∧ B) ∧ C) → (A ∧ (B ∧ C))
∧-assoc₂ ((a , b) , c) = (a , b , c)
∧-assoc-iso : ∀{ℓ}{A B C : Set ℓ} → Iso (A ∧ (B ∧ C)) ((A ∧ B) ∧ C)
∧-assoc-iso {_}{A}{B}{C} = isIso ∧-assoc₁ ∧-assoc₂ (ext-set aux₁) (ext-set aux₂)
where
aux₁ : {a : A ∧ (B ∧ C)} → ∧-assoc₂ (∧-assoc₁ a) ≡ a
aux₁ {a , (b , c)} = refl
aux₂ : {a : (A ∧ B) ∧ C} → ∧-assoc₁ (∧-assoc₂ a) ≡ a
aux₂ {(a , b) , c} = refl