Skip to content

Commit 10f1ba6

Browse files
Merge pull request #52 from jonsterling/stdlib-2.0
Update to `agda-stdlib` v2.0
2 parents 8825566 + 005f3d0 commit 10f1ba6

17 files changed

+68
-74
lines changed

.github/workflows/agda.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
agda-ref: ["v2.6.3"]
23-
stdlib-ref: ["fc473ec905ab1a11a16718a7e8b628f1ab7eb435"]
23+
stdlib-ref: ["v2.0"]
2424
ghc-ver: ["8.10.2"]
2525
cabal-ver: ["3.4.0.0"]
2626
steps:

INSTALL.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Installation
22

33
1. Install Agda v2.6.3 ([instructions](https://agda.readthedocs.io/en/v2.6.3/getting-started/installation.html)).
4-
2. Install `agda-stdlib` v2.0 ([instructions](https://github.com/agda/agda-stdlib/blob/fc473ec/notes/installation-guide.md)).
5-
We have tested on commit [fc473ec](https://github.com/agda/agda-stdlib/tree/fc473ec905ab1a11a16718a7e8b628f1ab7eb435).
4+
2. Install `agda-stdlib` v2.0 ([instructions](https://github.com/agda/agda-stdlib/blob/v2.0/doc/installation-guide.md)).
65

76
This is all that is required to play with **calf**.
87

calf.agda-lib

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name: calf
2-
depend: standard-library
2+
depend: standard-library-2.0
33
include: src
44
flags: --prop --guardedness

src/Algebra/Cost/Bundles.agda

+15-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Algebra.Cost.Bundles where
44

55
open import Algebra.Core
66
open import Algebra.Cost.Structures
7-
open import Relation.Binary using (Rel; _Preserves_⟶_; _Preserves₂_⟶_⟶_)
7+
open import Relation.Binary using (Rel; Preorder; _Preserves_⟶_; _Preserves₂_⟶_⟶_)
88
open import Relation.Binary.PropositionalEquality using (_≡_; resp₂)
99
open import Level using (0ℓ)
1010

@@ -21,16 +21,14 @@ record CostMonoid : Set₁ where
2121

2222
open IsCostMonoid isCostMonoid public
2323

24+
≤-preorder : Preorder 0ℓ 0ℓ 0ℓ
25+
Preorder.Carrier ≤-preorder =
26+
Preorder._≈_ ≤-preorder = _≡_
27+
Preorder._≲_ ≤-preorder = _≤_
28+
Preorder.isPreorder ≤-preorder = isPreorder
29+
2430
module ≤-Reasoning where
25-
open import Relation.Binary.Reasoning.Base.Triple
26-
isPreorder
27-
≤-trans
28-
(resp₂ _≤_)
29-
(λ h h)
30-
≤-trans
31-
≤-trans
32-
public
33-
hiding (step-≈; step-≈˘; step-<)
31+
open import Relation.Binary.Reasoning.Preorder ≤-preorder public
3432

3533

3634
record ParCostMonoid : Set₁ where
@@ -60,13 +58,11 @@ record ParCostMonoid : Set₁ where
6058
}
6159
}
6260

61+
≤-preorder : Preorder 0ℓ 0ℓ 0ℓ
62+
Preorder.Carrier ≤-preorder =
63+
Preorder._≈_ ≤-preorder = _≡_
64+
Preorder._≲_ ≤-preorder = _≤_
65+
Preorder.isPreorder ≤-preorder = isPreorder
66+
6367
module ≤-Reasoning where
64-
open import Relation.Binary.Reasoning.Base.Triple
65-
isPreorder
66-
≤-trans
67-
(resp₂ _≤_)
68-
(λ h h)
69-
≤-trans
70-
≤-trans
71-
public
72-
hiding (step-≈; step-≈˘; step-<)
68+
open import Relation.Binary.Reasoning.Preorder ≤-preorder public

src/Calf/Data/IsBounded.agda

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ bound/bind/const {e = e} {f} c d he hf =
4040
let open ≤⁻-Reasoning cost in
4141
begin
4242
bind cost e (λ v bind cost (f v) (λ _ ret triv))
43-
⟨ bind-monoʳ-≤⁻ e hf ⟩
43+
⟨ bind-monoʳ-≤⁻ e hf ⟩
4444
bind cost e (λ _ step⋆ d)
4545
≡⟨⟩
4646
bind cost (bind cost e λ _ ret triv) (λ _ step⋆ d)
47-
⟨ bind-monoˡ-≤⁻ (λ _ step⋆ d) he ⟩
47+
⟨ bind-monoˡ-≤⁻ (λ _ step⋆ d) he ⟩
4848
bind cost (step⋆ c) (λ _ step⋆ d)
4949
≡⟨⟩
5050
step⋆ (c + d)
@@ -66,6 +66,6 @@ module Legacy where
6666
bind cost (step (F A) c' (ret a)) (λ _ ret triv)
6767
≡⟨⟩
6868
step⋆ c'
69-
⟨ step-monoˡ-≤⁻ (ret triv) c'≤c ⟩
69+
⟨ step-monoˡ-≤⁻ (ret triv) c'≤c ⟩
7070
step⋆ c
7171

src/Calf/Data/IsBoundedG.agda

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ boundg/relax {b = b} {b'} h {e = e} ib-b =
3838
let open ≤⁻-Reasoning cost in
3939
begin
4040
bind cost e (λ _ ret triv)
41-
⟨ ib-b ⟩
41+
⟨ ib-b ⟩
4242
b
43-
⟨ h ⟩
43+
⟨ h ⟩
4444
b'
4545
4646

@@ -53,7 +53,7 @@ boundg/step c {b} e h =
5353
bind cost (step (F _) c e) (λ _ ret triv)
5454
≡⟨⟩
5555
step cost c (bind cost e (λ _ ret triv))
56-
⟨ step-monoʳ-≤⁻ c h ⟩
56+
⟨ step-monoʳ-≤⁻ c h ⟩
5757
step cost c b
5858
5959

@@ -67,6 +67,6 @@ boundg/bind {e = e} {f} b hf =
6767
bind cost (bind (F _) e f) (λ _ ret triv)
6868
≡⟨⟩
6969
bind cost e (λ a bind cost (f a) λ _ ret triv)
70-
⟨ bind-monoʳ-≤⁻ e hf ⟩
70+
⟨ bind-monoʳ-≤⁻ e hf ⟩
7171
bind cost e b
7272

src/Calf/Directed.agda

+9-10
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,15 @@ bind-irr-monoˡ-≤⁻ e₁≤e₁' =
118118
bind-irr-mono-≤⁻ e₁≤e₁' ≤⁻-refl
119119

120120

121+
open import Level using (0ℓ)
122+
open import Relation.Binary using (Preorder)
121123
open import Relation.Binary.Structures
122124

125+
≤⁻-preorder : tp⁻ Preorder 0ℓ 0ℓ 0ℓ
126+
Preorder.Carrier (≤⁻-preorder X) = cmp X
127+
Preorder._≈_ (≤⁻-preorder X) = _≡_
128+
Preorder._≲_ (≤⁻-preorder X) = _≤⁻_ {X}
129+
Preorder.isPreorder (≤⁻-preorder X) = ≤⁻-isPreorder {X}
130+
123131
module ≤⁻-Reasoning (X : tp⁻) where
124-
open import Relation.Binary.Reasoning.Base.Triple
125-
(≤⁻-isPreorder {X})
126-
≤⁻-trans
127-
(resp₂ _≤⁻_)
128-
(λ h h)
129-
≤⁻-trans
130-
≤⁻-trans
131-
public
132-
hiding (begin-strict_; step-<; step-≈; step-≈˘)
133-
renaming (step-≤ to step-≤⁻)
132+
open import Relation.Binary.Reasoning.Preorder (≤⁻-preorder X) public

src/Calf/Parallel.agda

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ boundg/par {A₁} {A₂} {e₁} {e₂} {b₁} {b₂} ib₁ ib₂ =
5858
let open ≤⁻-Reasoning cost in
5959
begin
6060
bind cost (e₁ ∥ e₂) (λ _ ret triv)
61-
{! !}
61+
{! !}
6262
bind cost ((bind cost e₁ λ _ ret triv) ∥ (bind cost e₂ λ _ ret triv)) (λ _ ret triv)
63-
⟨ ≤⁻-mono (λ e bind cost (e ∥ (bind cost e₂ λ _ ret triv)) (λ _ ret triv)) ib₁ ⟩
63+
⟨ ≤⁻-mono (λ e bind cost (e ∥ (bind cost e₂ λ _ ret triv)) (λ _ ret triv)) ib₁ ⟩
6464
bind cost (b₁ ∥ (bind cost e₂ λ _ ret triv)) (λ _ ret triv)
65-
⟨ ≤⁻-mono (λ e bind cost (b₁ ∥ e) (λ _ ret triv)) ib₂ ⟩
65+
⟨ ≤⁻-mono (λ e bind cost (b₁ ∥ e) (λ _ ret triv)) ib₂ ⟩
6666
bind cost (b₁ ∥ b₂) (λ _ ret triv)
6767
6868

src/Calf/Step.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ step-mono-≤⁻ {X} {c} {c'} {e} {e'} c≤c' e≤e' =
8080
let open ≤⁻-Reasoning X in
8181
begin
8282
step X c e
83-
⟨ step-monoˡ-≤⁻ e c≤c' ⟩
83+
⟨ step-monoˡ-≤⁻ e c≤c' ⟩
8484
step X c' e
85-
⟨ step-monoʳ-≤⁻ c' e≤e' ⟩
85+
⟨ step-monoʳ-≤⁻ c' e≤e' ⟩
8686
step X c' e'
8787

src/Data/Nat/PredExp2.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private
5050
... | zero | ()
5151

5252
pred[2^]-mono : pred[2^_] Preserves _≤_ ⟶ _≤_
53-
pred[2^]-mono m≤n = pred-mono (2^-mono m≤n)
53+
pred[2^]-mono m≤n = pred-mono-≤ (2^-mono m≤n)
5454
where
5555
2^-mono : (2 ^_) Preserves _≤_ ⟶ _≤_
5656
2^-mono {y = y} z≤n = lemma/1≤2^n y

src/Examples/Decalf/HigherOrderFunction.agda

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module Twice where
4242
bind cost e λ _
4343
ret triv
4444
)
45-
⟨ ≤⁻-mono₂ (λ e₁ e₂ bind (F _) e₁ λ _ bind (F _) e₂ λ _ ret triv) e≤step⋆1 e≤step⋆1 ⟩
45+
⟨ ≤⁻-mono₂ (λ e₁ e₂ bind (F _) e₁ λ _ bind (F _) e₂ λ _ ret triv) e≤step⋆1 e≤step⋆1 ⟩
4646
( bind cost (step⋆ 1) λ _
4747
bind cost (step⋆ 1) λ _
4848
ret triv
@@ -79,7 +79,7 @@ module Map where
7979
bind cost (map f xs) λ _
8080
ret triv
8181
)
82-
82+
8383
≤⁻-mono₂ (λ e₁ e₂ bind cost e₁ λ _ bind cost e₂ λ _ ret triv)
8484
(f-bound x)
8585
(map/is-bounded f f-bound xs)
@@ -114,11 +114,11 @@ module Map where
114114
bind cost (map f xs) λ _
115115
ret triv
116116
)
117-
⟨ ≤⁻-mono (λ e bind cost (f x) λ _ e) (map/is-bounded' f f-bound xs) ⟩
117+
⟨ ≤⁻-mono (λ e bind cost (f x) λ _ e) (map/is-bounded' f f-bound xs) ⟩
118118
( bind cost (f x) λ _
119119
binomial (length xs * n)
120120
)
121-
⟨ ≤⁻-mono (λ e bind cost e λ _ binomial (length xs * n)) (f-bound x) ⟩
121+
⟨ ≤⁻-mono (λ e bind cost e λ _ binomial (length xs * n)) (f-bound x) ⟩
122122
( bind cost (binomial n) λ _
123123
binomial (length xs * n)
124124
)

src/Examples/Decalf/Nondeterminism.agda

+12-12
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module QuickSort (M : Comparable) where
7070
let open ≤⁻-Reasoning cost in
7171
begin
7272
branch (F unit) (bind (F unit) (choose (x' ∷ xs)) λ _ ret triv) (ret triv)
73-
⟨ ≤⁻-mono (λ e branch (F unit) (bind (F unit) e λ _ ret triv) (ret triv)) (choose/is-bounded x' xs) ⟩
73+
⟨ ≤⁻-mono (λ e branch (F unit) (bind (F unit) e λ _ ret triv) (ret triv)) (choose/is-bounded x' xs) ⟩
7474
branch (F unit) (ret triv) (ret triv)
7575
≡⟨ branch/idem ⟩
7676
ret triv
@@ -128,7 +128,7 @@ module QuickSort (M : Comparable) where
128128
bind (F unit) (x ≤? pivot) λ _
129129
ret triv
130130
)
131-
131+
132132
( ≤⁻-mono
133133
{Π (Σ⁺ (list A) λ l₁ Σ⁺ (list A) λ l₂ meta⁺ (All (_≤ pivot) l₁) ×⁺ meta⁺ (All (pivot ≤_) l₂) ×⁺ meta⁺ (l₁ ++ l₂ ↭ xs)) λ _ F unit}
134134
(bind (F unit) (partition pivot xs)) $
@@ -143,7 +143,7 @@ module QuickSort (M : Comparable) where
143143
( bind (F unit) (bind (F unit) (partition pivot xs) λ _ ret triv) λ _
144144
step⋆ 1
145145
)
146-
⟨ ≤⁻-mono (λ e bind (F unit) (bind (F unit) e λ _ ret triv) λ _ step (F unit) 1 (ret triv)) (partition/is-bounded pivot xs) ⟩
146+
⟨ ≤⁻-mono (λ e bind (F unit) (bind (F unit) e λ _ ret triv) λ _ step (F unit) 1 (ret triv)) (partition/is-bounded pivot xs) ⟩
147147
( bind (F unit) (step (F unit) (length xs) (ret triv)) λ _
148148
step⋆ 1
149149
)
@@ -191,7 +191,7 @@ module QuickSort (M : Comparable) where
191191
bind (F _) (sort l₂) λ _
192192
ret triv
193193
)
194-
194+
195195
( ≤⁻-mono
196196
{Π (Σ⁺ A λ pivot Σ⁺ (list A) λ l' meta⁺ (x ∷ xs ↭ pivot ∷ l')) λ _ F unit}
197197
{F unit}
@@ -220,7 +220,7 @@ module QuickSort (M : Comparable) where
220220
bind (F _) (sort l₁) λ _
221221
step⋆ (length l₂ ²)
222222
)
223-
223+
224224
( ≤⁻-mono
225225
{Π (Σ⁺ A λ pivot Σ⁺ (list A) λ l' meta⁺ (x ∷ xs ↭ pivot ∷ l')) λ _ F unit}
226226
{F unit}
@@ -245,7 +245,7 @@ module QuickSort (M : Comparable) where
245245
bind (F _) (partition pivot l) λ (l₁ , l₂ , h₁ , h₂ , l₁++l₂↭l)
246246
step⋆ (length l₁ ² + length l₂ ²)
247247
)
248-
248+
249249
( ≤⁻-mono
250250
{Π (Σ⁺ A λ pivot Σ⁺ (list A) λ l' meta⁺ (x ∷ xs ↭ pivot ∷ l')) λ _ F unit}
251251
{F unit}
@@ -270,7 +270,7 @@ module QuickSort (M : Comparable) where
270270
bind (F _) (partition pivot l) λ _
271271
step⋆ (length l ²)
272272
)
273-
273+
274274
( ≤⁻-mono
275275
{Π (Σ⁺ A λ pivot Σ⁺ (list A) λ l' meta⁺ (x ∷ xs ↭ pivot ∷ l')) λ _ F unit}
276276
{F unit}
@@ -295,9 +295,9 @@ module QuickSort (M : Comparable) where
295295
( bind (F _) (choose (x ∷ xs)) λ _
296296
step⋆ (length xs + length xs ²)
297297
)
298-
⟨ bind-irr-monoˡ-≤⁻ (choose/is-bounded x xs) ⟩
298+
⟨ bind-irr-monoˡ-≤⁻ (choose/is-bounded x xs) ⟩
299299
step⋆ (length xs + length xs ²)
300-
⟨ step⋆-mono-≤⁻ (Nat.+-mono-≤ (Nat.n≤1+n (length xs)) (Nat.*-monoʳ-≤ (length xs) (Nat.n≤1+n (length xs)))) ⟩
300+
⟨ step⋆-mono-≤⁻ (Nat.+-mono-≤ (Nat.n≤1+n (length xs)) (Nat.*-monoʳ-≤ (length xs) (Nat.n≤1+n (length xs)))) ⟩
301301
step⋆ (length (x ∷ xs) + length xs * length (x ∷ xs))
302302
≡⟨⟩
303303
step⋆ (length (x ∷ xs) ²)
@@ -330,7 +330,7 @@ module Lookup {A : tp⁺} where
330330
let open ≤⁻-Reasoning (F _) in
331331
begin
332332
step (F _) 1 (lookup xs i)
333-
⟨ ≤⁻-mono (step (F _) 1) (lemma xs i p) ⟩
333+
⟨ ≤⁻-mono (step (F _) 1) (lemma xs i p) ⟩
334334
step (F _) 1 (fail (F _))
335335
≡⟨ fail/step 1
336336
fail (F _)
@@ -353,7 +353,7 @@ module Pervasive where
353353
branch (F bool)
354354
(step (F bool) 3 (ret true))
355355
(step (F bool) 12 (ret false))
356-
356+
357357
≤⁻-mono
358358
(λ e branch (F bool) e (step (F bool) 12 (ret false)))
359359
(step-monoˡ-≤⁻ {F bool} (ret true) (Nat.s≤s (Nat.s≤s (Nat.s≤s Nat.z≤n))))
@@ -370,7 +370,7 @@ module Pervasive where
370370
let open ≤⁻-Reasoning (F unit) in
371371
begin
372372
bind (F unit) e (λ _ ret triv)
373-
⟨ ≤⁻-mono (λ e bind (F _) e (λ _ ret triv)) e/is-bounded ⟩
373+
⟨ ≤⁻-mono (λ e bind (F _) e (λ _ ret triv)) e/is-bounded ⟩
374374
bind (F unit) (step (F bool) 12 (branch (F bool) (ret true) (ret false))) (λ _ ret triv)
375375
≡⟨⟩
376376
step (F unit) 12 (branch (F unit) (ret triv) (ret triv))

src/Examples/Decalf/ProbabilisticChoice.agda

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module _ where
6464
let open ≤⁻-Reasoning cost in
6565
begin
6666
flip cost ½ (step⋆ 0) (step⋆ 1)
67-
⟨ ≤⁻-mono {cost} (λ e flip cost ½ e (step⋆ 1)) (≤⁺-mono step⋆ (≤⇒≤⁺ (z≤n {1}))) ⟩
67+
⟨ ≤⁻-mono {cost} (λ e flip cost ½ e (step⋆ 1)) (≤⁺-mono step⋆ (≤⇒≤⁺ (z≤n {1}))) ⟩
6868
flip cost ½ (step⋆ 1) (step⋆ 1)
6969
≡⟨ flip/same cost (step⋆ 1) {½} ⟩
7070
step⋆ 1
@@ -123,13 +123,13 @@ module _ where
123123
( bind cost bernoulli λ _
124124
binomial n
125125
)
126-
⟨ ≤⁻-mono (λ e bind cost e λ _ binomial n) bernoulli/upper ⟩
126+
⟨ ≤⁻-mono (λ e bind cost e λ _ binomial n) bernoulli/upper ⟩
127127
( bind cost (step⋆ 1) λ _
128128
binomial n
129129
)
130130
≡⟨⟩
131131
step cost 1 (binomial n)
132-
⟨ ≤⁻-mono (step cost 1) (binomial/upper n) ⟩
132+
⟨ ≤⁻-mono (step cost 1) (binomial/upper n) ⟩
133133
step⋆ (suc n)
134134
135135

@@ -161,7 +161,7 @@ sublist/is-bounded {A} (x ∷ xs) =
161161
( bind cost (sublist {A} xs) λ _
162162
bernoulli
163163
)
164-
⟨ ≤⁻-mono (λ e bind cost e λ _ bernoulli) (sublist/is-bounded {A} xs) ⟩
164+
⟨ ≤⁻-mono (λ e bind cost e λ _ bernoulli) (sublist/is-bounded {A} xs) ⟩
165165
( bind cost (binomial (length xs)) λ _
166166
bernoulli
167167
)

src/Examples/Exp2.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module Slow where
4343
begin
4444
(bind (F nat) (exp₂ n ∥ exp₂ n) λ (r₁ , r₂)
4545
step (F nat) (1 , 1) (ret (r₁ + r₂)))
46-
46+
4747
≤⁻-mono₂ (λ e₁ e₂ bind (F nat) (e₁ ∥ e₂) λ (r₁ , r₂) step (F nat) (1 , 1) (ret (r₁ + r₂)))
4848
(exp₂/is-bounded n)
4949
(exp₂/is-bounded n)
@@ -90,7 +90,7 @@ module Fast where
9090
begin
9191
(bind (F nat) (exp₂ n) λ r
9292
step (F nat) (1 , 1) (ret (r + r)))
93-
⟨ ≤⁻-mono (λ e bind (F nat) e λ r step (F nat) (1 , 1) (ret (r + r))) (exp₂/is-bounded n) ⟩
93+
⟨ ≤⁻-mono (λ e bind (F nat) e λ r step (F nat) (1 , 1) (ret (r + r))) (exp₂/is-bounded n) ⟩
9494
(bind (F nat) (step (F nat) (n , n) (ret (2 ^ n))) λ r
9595
step (F nat) (1 , 1) (ret (r + r)))
9696
≡⟨⟩

src/Examples/Id.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module Hard where
5252
≤⁻-mono (step (F nat) 1) $
5353
begin
5454
bind (F nat) (id n) (λ n' ret (suc n'))
55-
⟨ ≤⁻-mono (λ e bind (F nat) e (ret ∘ suc)) (id/is-bounded n) ⟩
55+
⟨ ≤⁻-mono (λ e bind (F nat) e (ret ∘ suc)) (id/is-bounded n) ⟩
5656
bind (F nat) (step (F nat) n (ret n)) (λ n' ret (suc n'))
5757
≡⟨⟩
5858
step (F nat) n (ret (suc n))

0 commit comments

Comments
 (0)