@@ -46,27 +46,39 @@ Product 0 _ = ⊤
46
46
Product 1 (a , _) = a
47
47
Product (suc n) (a , as) = a × Product n as
48
48
49
- -- Pointwise lifting of a relation on products
49
+ -- An n-ary product where every element of the product lives at the same universe level.
50
50
51
- Allₙ : (∀ {a} {A : Set a} → Rel A a) →
52
- ∀ n {ls} {as : Sets n ls} (l r : Product n as) → Sets n ls
53
- Allₙ R 0 l r = _
54
- Allₙ R 1 a b = R a b , _
55
- Allₙ R (suc n@(suc _)) (a , l) (b , r) = R a b , Allₙ R n l r
51
+ HomoProduct′ : ∀ n {a} → (Fin n → Set a) → Set (lconst n a)
52
+ HomoProduct′ n f = Product n (stabulate n (const _) f)
53
+
54
+ -- An n-ary product where every element of the product lives in the same type.
55
+
56
+ HomoProduct : ∀ n {a} → Set a → Set (lconst n a)
57
+ HomoProduct n A = HomoProduct′ n (const A)
58
+
59
+ -- Pointwise lifting of a relation over n-ary products
60
+
61
+ Pointwiseₙ : (∀ {a} {A : Set a} → Rel A a) →
62
+ ∀ n {ls} {as : Sets n ls} (l r : Product n as) → Sets n ls
63
+ Pointwiseₙ R 0 l r = _
64
+ Pointwiseₙ R 1 a b = R a b , _
65
+ Pointwiseₙ R (suc n@(suc _)) (a , l) (b , r) = R a b , Pointwiseₙ R n l r
66
+
67
+ -- Pointwise lifting of propositional equality over n-ary products
56
68
57
69
Equalₙ : ∀ n {ls} {as : Sets n ls} (l r : Product n as) → Sets n ls
58
- Equalₙ = Allₙ _≡_
70
+ Equalₙ = Pointwiseₙ _≡_
59
71
60
72
------------------------------------------------------------------------
61
73
-- Generic Programs
74
+ ------------------------------------------------------------------------
62
75
63
76
-- Once we have these type definitions, we can write generic programs
64
77
-- over them. They will typically be split into two or three definitions:
65
78
66
79
-- 1. action on the vector of n levels (if any)
67
80
-- 2. action on the corresponding vector of n Sets
68
81
-- 3. actual program, typed thank to the function defined in step 2.
69
- ------------------------------------------------------------------------
70
82
71
83
-- see Relation.Binary.PropositionalEquality for congₙ and substₙ, two
72
84
-- equality-related generic programs.
@@ -168,7 +180,6 @@ projₙ : ∀ n {ls} {as : Sets n ls} k → Product n as → Projₙ as k
168
180
projₙ 1 zero v = v
169
181
projₙ (suc n@(suc _)) zero (v , _) = v
170
182
projₙ (suc n@(suc _)) (suc k) (_ , vs) = projₙ n k vs
171
- projₙ 1 (suc ()) v
172
183
173
184
------------------------------------------------------------------------
174
185
-- zip
@@ -188,41 +199,35 @@ zipWith (suc n@(suc _)) f (v , vs) (w , ws) =
188
199
Levelₙ⁻ : ∀ {n} → Levels n → Fin n → Levels (pred n)
189
200
Levelₙ⁻ (_ , ls) zero = ls
190
201
Levelₙ⁻ {suc (suc _)} (l , ls) (suc k) = l , Levelₙ⁻ ls k
191
- Levelₙ⁻ {1 } _ (suc ())
192
202
193
203
Removeₙ : ∀ {n ls} → Sets n ls → ∀ k → Sets (pred n) (Levelₙ⁻ ls k)
194
204
Removeₙ (_ , as) zero = as
195
205
Removeₙ {suc (suc _)} (a , as) (suc k) = a , Removeₙ as k
196
- Removeₙ {1 } _ (suc ())
197
206
198
207
removeₙ : ∀ n {ls} {as : Sets n ls} k →
199
208
Product n as → Product (pred n) (Removeₙ as k)
200
209
removeₙ (suc zero) zero _ = _
201
210
removeₙ (suc (suc _)) zero (_ , vs) = vs
202
211
removeₙ (suc (suc zero)) (suc k) (v , _) = v
203
212
removeₙ (suc (suc (suc _))) (suc k) (v , vs) = v , removeₙ _ k vs
204
- removeₙ (suc zero) (suc ()) _
205
213
206
214
------------------------------------------------------------------------
207
215
-- insertion of a k-th component
208
216
209
217
Levelₙ⁺ : ∀ {n} → Levels n → Fin (suc n) → Level → Levels (suc n)
210
218
Levelₙ⁺ ls zero l⁺ = l⁺ , ls
211
219
Levelₙ⁺ {suc _} (l , ls) (suc k) l⁺ = l , Levelₙ⁺ ls k l⁺
212
- Levelₙ⁺ {0 } _ (suc ())
213
220
214
221
Insertₙ : ∀ {n ls l⁺} → Sets n ls → ∀ k (a⁺ : Set l⁺) → Sets (suc n) (Levelₙ⁺ ls k l⁺)
215
222
Insertₙ as zero a⁺ = a⁺ , as
216
223
Insertₙ {suc _} (a , as) (suc k) a⁺ = a , Insertₙ as k a⁺
217
- Insertₙ {zero} _ (suc ()) _
218
224
219
225
insertₙ : ∀ n {ls l⁺} {as : Sets n ls} {a⁺ : Set l⁺} k (v⁺ : a⁺) →
220
226
Product n as → Product (suc n) (Insertₙ as k a⁺)
221
227
insertₙ 0 zero v⁺ vs = v⁺
222
228
insertₙ (suc n) zero v⁺ vs = v⁺ , vs
223
229
insertₙ 1 (suc k) v⁺ vs = vs , insertₙ 0 k v⁺ _
224
230
insertₙ (suc n@(suc _)) (suc k) v⁺ (v , vs) = v , insertₙ n k v⁺ vs
225
- insertₙ 0 (suc ()) _ _
226
231
227
232
------------------------------------------------------------------------
228
233
-- update of a k-th component
@@ -240,8 +245,20 @@ updateₙ : ∀ n {ls lᵘ} {as : Sets n ls} k {aᵘ : _ → Set lᵘ} (f : ∀
240
245
updateₙ 1 zero f v = f v
241
246
updateₙ (suc (suc _)) zero f (v , vs) = f v , vs
242
247
updateₙ (suc n@(suc _)) (suc k) f (v , vs) = v , updateₙ n k f vs
243
- updateₙ 1 (suc ()) _ _
244
248
245
249
updateₙ′ : ∀ n {ls lᵘ} {as : Sets n ls} k {aᵘ : Set lᵘ} (f : Projₙ as k → aᵘ) →
246
250
Product n as → Product n (Updateₙ as k aᵘ)
247
251
updateₙ′ n k = updateₙ n k
252
+
253
+ ------------------------------------------------------------------------
254
+ -- DEPRECATED NAMES
255
+ ------------------------------------------------------------------------
256
+ -- Please use the new names as continuing support for the old names is
257
+ -- not guaranteed.
258
+
259
+ -- Version 2.3
260
+
261
+ Allₙ = Pointwiseₙ
262
+ {-# WARNING_ON_USAGE Allₙ
263
+ "Warning: Allₙ was deprecated in v2.3. Please use Pointwiseₙ instead."
264
+ #-}
0 commit comments