-
Notifications
You must be signed in to change notification settings - Fork 2
/
Open.agda
74 lines (62 loc) · 2.21 KB
/
Open.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{-# OPTIONS --rewriting #-}
-- Open/extensional modality.
module Calf.Phase.Open where
open import Calf.Prelude
open import Calf.CBPV
open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl)
open import Calf.Phase.Core
◯ : □ → □
◯ 𝕁 = (u : ext) → 𝕁
postulate
open⁺ : (ext → tp⁺) → tp⁺
open⁺/decode : ∀ {A} → val (open⁺ A) ≡ ((u : ext) → val (A u))
{-# REWRITE open⁺/decode #-}
open⁻ : (ext → tp⁻) → tp⁻
open⁻/decode : ∀ {A} → val (U (open⁻ A)) ≡ ((u : ext) → cmp (A u))
{-# REWRITE open⁻/decode #-}
infix 10 ◯⁺_ ◯⁻_
◯⁺_ : tp⁺ → tp⁺
◯⁺ A = open⁺ λ _ → A
◯⁻_ : tp⁻ → tp⁻
◯⁻ A = open⁻ λ _ → A
module _ where
open import Algebra.Cost
◯-CostMonoid : CostMonoid → CostMonoid
◯-CostMonoid cm =
record
{ ℂ = ◯ ℂ
; _+_ = λ c₁ c₂ u → c₁ u + c₂ u
; zero = λ u → zero
; _≤_ = λ c₁ c₂ → (u : ext) → c₁ u ≤ c₂ u
; isCostMonoid =
record
{ isMonoid =
record
{ isSemigroup =
record
{ isMagma =
record
{ isEquivalence = Eq.isEquivalence
; ∙-cong = Eq.cong₂ _
}
; assoc = λ c₁ c₂ c₃ → funext/Ω λ u → +-assoc (c₁ u) (c₂ u) (c₃ u)
}
; identity =
(λ c → funext/Ω λ u → +-identityˡ (c u)) ,
(λ c → funext/Ω λ u → +-identityʳ (c u))
}
; isPreorder =
record
{ isEquivalence = Eq.isEquivalence
; reflexive = λ h u → ≤-reflexive (Eq.cong (λ x → x u) h)
; trans = λ h₁ h₂ u → ≤-trans (h₁ u) (h₂ u)
}
; isMonotone =
record
{ ∙-mono-≤ = λ h₁ h₂ u → +-mono-≤ (h₁ u) (h₂ u)
}
}
}
where
open CostMonoid cm
open import Data.Product