Skip to content

Commit 64250e8

Browse files
authored
Merge branch 'agda:master' into refactor-fresh
2 parents ab384a4 + dbdebad commit 64250e8

File tree

5 files changed

+196
-86
lines changed

5 files changed

+196
-86
lines changed

CHANGELOG.md

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Bug-fixes
1313

1414
* Fix a typo in `Algebra.Morphism.Construct.DirectProduct`.
1515

16+
* Fix a typo in `Data.Rational.Properties`: `nonPos*nonPos⇒nonPos` erroneously named,
17+
corrected to `nonPos*nonPos⇒nonNeg`.
18+
1619
* Fix a typo in `Function.Construct.Constant`.
1720

1821
Non-backwards compatible changes
@@ -21,6 +24,14 @@ Non-backwards compatible changes
2124
Minor improvements
2225
------------------
2326

27+
* The types of `Data.Vec.Base.{truncate|padRight}` have been weakened so
28+
that the argument of type `m ≤ n` is marked as irrelevant. This should be
29+
backwards compatible, but does change the intensional behaviour of these
30+
functions to be more eager, because no longer blocking on pattern matching
31+
on that argument. Corresponding changes have been made to the types of their
32+
properties (and their proofs). In particular, `truncate-irrelevant` is now
33+
deprecated, because definitionally trivial.
34+
2435
* The type of `Relation.Nullary.Negation.Core.contradiction-irr` has been further
2536
weakened so that the negated hypothesis `¬ A` is marked as irrelevant. This is
2637
safe to do, in view of `Relation.Nullary.Recomputable.Properties.¬-recompute`.
@@ -68,6 +79,16 @@ Deprecated names
6879
¬∀⟶∃¬- ↦ ¬∀⇒∃¬
6980
```
7081

82+
* In `Data.Rational.Properties`:
83+
```agda
84+
nonPos*nonPos⇒nonPos ↦ nonPos*nonPos⇒nonNeg
85+
```
86+
87+
* In `Data.Vec.Properties`:
88+
```agda
89+
truncate-irrelevant ↦ Relation.Binary.PropositionalEquality.Core.refl
90+
```
91+
7192
* In `Relation.Nullary.Decidable.Core`:
7293
```agda
7394
⊤-dec ↦ ⊤?
@@ -100,6 +121,8 @@ New modules
100121

101122
* `Algebra.Properties.Semiring`.
102123

124+
* `Data.List.Fresh.Membership.DecSetoid`.
125+
103126
* `Data.List.Relation.Binary.Permutation.Algorithmic{.Properties}` for the Choudhury and Fiore definition of permutation, and its equivalence with `Declarative` below.
104127

105128
* `Data.List.Relation.Binary.Permutation.Declarative{.Properties}` for the least congruence on `List` making `_++_` commutative, and its equivalence with the `Setoid` definition.
@@ -236,46 +259,55 @@ Additions to existing modules
236259
* In `Data.Vec.Properties`:
237260
```agda
238261
map-removeAt : ∀ (f : A → B) (xs : Vec A (suc n)) (i : Fin (suc n)) →
239-
map f (removeAt xs i) ≡ removeAt (map f xs) i
262+
map f (removeAt xs i) ≡ removeAt (map f xs) i
240263
241264
updateAt-take : (xs : Vec A (m + n)) (i : Fin m) (f : A → A) →
242265
updateAt (take m xs) i f ≡ take m (updateAt xs (inject≤ i (m≤m+n m n)) f)
243266
244-
truncate-zipWith : (f : A → B → C) (m≤n : m ≤ n) (xs : Vec A n) (ys : Vec B n) →
245-
truncate m≤n (zipWith f xs ys) ≡ zipWith f (truncate m≤n xs) (truncate m≤n ys)
267+
truncate-zipWith : (f : A → B → C) .(m≤n : m ≤ n) (xs : Vec A n) (ys : Vec B n) →
268+
truncate m≤n (zipWith f xs ys) ≡ zipWith f (truncate m≤n xs) (truncate m≤n ys)
246269
247-
truncate-zipWith-truncate : (f : A → B → C) (m≤n : m ≤ n) (n≤o : n ≤ o) (xs : Vec A o) (ys : Vec B n) →
270+
truncate-zipWith-truncate : (f : A → B → C) .(m≤n : m ≤ n) .(n≤o : n ≤ o)
271+
(xs : Vec A o) (ys : Vec B n) →
248272
truncate m≤n (zipWith f (truncate n≤o xs) ys) ≡
249273
zipWith f (truncate (≤-trans m≤n n≤o) xs) (truncate m≤n ys)
250274
251-
truncate-updateAt : (m≤n : m ≤ n) (xs : Vec A n) (i : Fin m) (f : A → A) →
275+
truncate-updateAt : .(m≤n : m ≤ n) (xs : Vec A n) (i : Fin m) (f : A → A) →
252276
updateAt (truncate m≤n xs) i f ≡
253277
truncate m≤n (updateAt xs (inject≤ i m≤n) f)
254278
255279
updateAt-truncate : (xs : Vec A (m + n)) (i : Fin m) (f : A → A) →
256280
updateAt (truncate (m≤m+n m n) xs) i f ≡
257281
truncate (m≤m+n m n) (updateAt xs (inject≤ i (m≤m+n m n)) f)
258282
259-
map-truncate : (f : A → B) (m≤n : m ≤ n) (xs : Vec A n) →
260-
map f (truncate m≤n xs) ≡ truncate m≤n (map f xs)
283+
map-truncate : (f : A → B) .(m≤n : m ≤ n) (xs : Vec A n) →
284+
map f (truncate m≤n xs) ≡ truncate m≤n (map f xs)
261285
262-
padRight-lookup : (m≤n : m ≤ n) (a : A) (xs : Vec A m) (i : Fin m) → lookup (padRight m≤n a xs) (inject≤ i m≤n) ≡ lookup xs i
286+
padRight-lookup : .(m≤n : m ≤ n) (a : A) (xs : Vec A m) (i : Fin m) →
287+
lookup (padRight m≤n a xs) (inject≤ i m≤n) ≡ lookup xs i
263288
264-
padRight-map : (f : A → B) (m≤n : m ≤ n) (a : A) (xs : Vec A m) → map f (padRight m≤n a xs) ≡ padRight m≤n (f a) (map f xs)
289+
padRight-map : (f : A → B) .(m≤n : m ≤ n) (a : A) (xs : Vec A m) →
290+
map f (padRight m≤n a xs) ≡ padRight m≤n (f a) (map f xs)
265291
266-
padRight-zipWith : (f : A → B → C) (m≤n : m ≤ n) (a : A) (b : B) (xs : Vec A m) (ys : Vec B m) →
267-
zipWith f (padRight m≤n a xs) (padRight m≤n b ys) ≡ padRight m≤n (f a b) (zipWith f xs ys)
292+
padRight-zipWith : (f : A → B → C) .(m≤n : m ≤ n) (a : A) (b : B)
293+
(xs : Vec A m) (ys : Vec B m) →
294+
zipWith f (padRight m≤n a xs) (padRight m≤n b ys) ≡
295+
padRight m≤n (f a b) (zipWith f xs ys)
268296
269-
padRight-zipWith₁ : (f : A → B → C) (o≤m : o ≤ m) (m≤n : m ≤ n) (a : A) (b : B) (xs : Vec A m) (ys : Vec B o) →
270-
zipWith f (padRight m≤n a xs) (padRight (≤-trans o≤m m≤n) b ys) ≡
271-
padRight m≤n (f a b) (zipWith f xs (padRight o≤m b ys))
297+
padRight-zipWith₁ : (f : A → B → C) .(o≤m : o ≤ m) .(m≤n : m ≤ n) (a : A) (b : B)
298+
(xs : Vec A m) (ys : Vec B o) →
299+
zipWith f (padRight m≤n a xs) (padRight (≤-trans o≤m m≤n) b ys) ≡
300+
padRight m≤n (f a b) (zipWith f xs (padRight o≤m b ys))
272301
273-
padRight-take : (m≤n : m ≤ n) (a : A) (xs : Vec A m) .(n≡m+o : n ≡ m + o) → take m (cast n≡m+o (padRight m≤n a xs)) ≡ xs
302+
padRight-take : .(m≤n : m ≤ n) (a : A) (xs : Vec A m) .(n≡m+o : n ≡ m + o) →
303+
take m (cast n≡m+o (padRight m≤n a xs)) ≡ xs
274304
275-
padRight-drop : (m≤n : m ≤ n) (a : A) (xs : Vec A m) .(n≡m+o : n ≡ m + o) → drop m (cast n≡m+o (padRight m≤n a xs)) ≡ replicate o a
305+
padRight-drop : .(m≤n : m ≤ n) (a : A) (xs : Vec A m) .(n≡m+o : n ≡ m + o) →
306+
drop m (cast n≡m+o (padRight m≤n a xs)) ≡ replicate o a
276307
277-
padRight-updateAt : (m≤n : m ≤ n) (x : A) (xs : Vec A m) (f : A → A) (i : Fin m) →
278-
updateAt (padRight m≤n x xs) (inject≤ i m≤n) f ≡ padRight m≤n x (updateAt xs i f)
308+
padRight-updateAt : .(m≤n : m ≤ n) (x : A) (xs : Vec A m) (f : A → A) (i : Fin m) →
309+
updateAt (padRight m≤n x xs) (inject≤ i m≤n) f ≡
310+
padRight m≤n x (updateAt xs i f)
279311
```
280312

281313
* In `Relation.Binary.Construct.Add.Extrema.NonStrict`:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Decidable setoid membership over fresh lists
5+
------------------------------------------------------------------------
6+
7+
{-# OPTIONS --cubical-compatible --safe #-}
8+
9+
open import Relation.Binary.Bundles using (DecSetoid)
10+
11+
module Data.List.Fresh.Membership.DecSetoid {a ℓ} (DS : DecSetoid a ℓ) where
12+
13+
open import Level using (Level)
14+
open import Data.List.Fresh.Relation.Unary.Any using (any?)
15+
import Data.List.Fresh.Membership.Setoid as MembershipSetoid
16+
open import Relation.Binary.Core using (Rel)
17+
open import Relation.Binary.Definitions using (Decidable)
18+
open import Relation.Nullary.Decidable using (¬?)
19+
20+
open DecSetoid DS using (setoid; _≟_) renaming (Carrier to A)
21+
22+
private
23+
variable
24+
r : Level
25+
R : Rel A r
26+
27+
28+
------------------------------------------------------------------------
29+
-- Re-export contents of Setoid membership
30+
open MembershipSetoid setoid public
31+
32+
------------------------------------------------------------------------
33+
-- Other operations
34+
infix 4 _∈?_ _∉?_
35+
36+
_∈?_ : Decidable (_∈_ {R = R})
37+
x ∈? xs = any? (x ≟_) xs
38+
39+
_∉?_ : Decidable (_∉_ {R = R})
40+
x ∉? xs = ¬? (x ∈? xs)

src/Data/Rational/Properties.agda

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,8 +1389,8 @@ nonNeg*nonPos⇒nonPos p q = nonPositive $ begin
13891389
0ℚ ∎
13901390
where open ≤-Reasoning
13911391

1392-
nonPos*nonPos⇒nonPos : p .{{_ : NonPositive p}} q .{{_ : NonPositive q}} NonNegative (p * q)
1393-
nonPos*nonPos⇒nonPos p q = nonNegative $ begin
1392+
nonPos*nonPos⇒nonNeg : p .{{_ : NonPositive p}} q .{{_ : NonPositive q}} NonNegative (p * q)
1393+
nonPos*nonPos⇒nonNeg p q = nonNegative $ begin
13941394
0ℚ ≡⟨ *-zeroʳ p ⟨
13951395
p * 0ℚ ≤⟨ *-monoˡ-≤-nonPos p (nonPositive⁻¹ q) ⟩
13961396
p * q ∎
@@ -1870,3 +1870,11 @@ Please use neg<pos instead."
18701870
open Data.Rational.Base public
18711871
using (+-rawMagma; +-0-rawGroup; *-rawMagma; +-*-rawNearSemiring; +-*-rawSemiring; +-*-rawRing)
18721872
renaming (+-0-rawMonoid to +-rawMonoid; *-1-rawMonoid to *-rawMonoid)
1873+
1874+
-- Version 2.4
1875+
1876+
nonPos*nonPos⇒nonPos = nonPos*nonPos⇒nonNeg
1877+
{-# WARNING_ON_USAGE nonPos*nonPos⇒nonPos
1878+
"Warning: nonPos*nonPos⇒nonPos was deprecated in v2.4.
1879+
Please use nonPos*nonPos⇒nonNeg instead."
1880+
#-}

src/Data/Vec/Base.agda

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,14 @@ uncons (x ∷ xs) = x , xs
289289
-- Operations involving ≤
290290

291291
-- Take the first 'm' elements of a vector.
292-
truncate : {m n} m ≤ n Vec A n Vec A m
293-
truncate {m = zero} _ _ = []
294-
truncate (s≤s le) (x ∷ xs) = x ∷ (truncate le xs)
292+
truncate : .(m ≤ n) Vec A n Vec A m
293+
truncate {m = zero} _ _ = []
294+
truncate {m = suc _} le (x ∷ xs) = x ∷ (truncate (s≤s⁻¹ le) xs)
295295

296296
-- Pad out a vector with extra elements.
297-
padRight : {m n} m ≤ n A Vec A m Vec A n
298-
padRight z≤n a xs = replicate _ a
299-
padRight (s≤s le) a (x ∷ xs) = x ∷ padRight le a xs
297+
padRight : .(m ≤ n) A Vec A m Vec A n
298+
padRight {n = n} _ a [] = replicate n a
299+
padRight {n = suc _} le a (x ∷ xs) = x ∷ padRight (s≤s⁻¹ le) a xs
300300

301301
------------------------------------------------------------------------
302302
-- Operations for converting between lists

0 commit comments

Comments
 (0)