Skip to content

Commit 5da81d0

Browse files
authored
Merge branch 'master' into refactor-heyting
2 parents 3786f55 + ee36a77 commit 5da81d0

File tree

9 files changed

+85
-27
lines changed

9 files changed

+85
-27
lines changed

CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Highlights
99
Bug-fixes
1010
---------
1111

12+
* In `Algebra.Apartness.Structures`, renamed `sym` from `IsApartnessRelation`
13+
to `#-sym` in order to avoid overloaded projection.
14+
`irrefl` and `cotrans` are similarly renamed for the sake of consistency.
15+
1216
Non-backwards compatible changes
1317
--------------------------------
1418

@@ -44,7 +48,7 @@ Deprecated names
4448
_∤∤_ ↦ _∦_
4549
```
4650

47-
* In `Algebra.Module.Consequences
51+
* In `Algebra.Module.Consequences`
4852
```agda
4953
*ₗ-assoc+comm⇒*ᵣ-assoc ↦ *ₗ-assoc∧comm⇒*ᵣ-assoc
5054
*ₗ-assoc+comm⇒*ₗ-*ᵣ-assoc ↦ *ₗ-assoc∧comm⇒*ₗ-*ᵣ-assoc
@@ -162,6 +166,19 @@ Additions to existing modules
162166
x-0#≈x : RightIdentity 0# _-_
163167
```
164168

169+
* In `Data.List.Properties`:
170+
```agda
171+
map-applyUpTo : ∀ (f : ℕ → A) (g : A → B) n → map g (applyUpTo f n) ≡ applyUpTo (g ∘ f) n
172+
map-applyDownFrom : ∀ (f : ℕ → A) (g : A → B) n → map g (applyDownFrom f n) ≡ applyDownFrom (g ∘ f) n
173+
map-upTo : ∀ (f : ℕ → A) n → map f (upTo n) ≡ applyUpTo f n
174+
map-downFrom : ∀ (f : ℕ → A) n → map f (downFrom n) ≡ applyDownFrom f n
175+
```
176+
177+
* In `Data.List.Relation.Binary.Permutation.PropositionalProperties`:
178+
```agda
179+
filter-↭ : ∀ (P? : Pred.Decidable P) → xs ↭ ys → filter P? xs ↭ filter P? ys
180+
```
181+
165182
* In `Relation.Binary.Properties.DecSetoid`:
166183
```agda
167184
≉-isTightApartnessRelation : IsTightApartnessRelation _≈_ _#_

src/Algebra/Apartness/Structures.agda

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ record IsHeytingCommutativeRing : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
3232

3333
open IsCommutativeRing isCommutativeRing public
3434
open IsTightApartnessRelation isTightApartnessRelation public
35+
open IsApartnessRelation isApartnessRelation public
36+
renaming
37+
( irrefl to #-irrefl
38+
; sym to #-sym
39+
; cotrans to #-cotrans
40+
)
3541

3642
¬#-isEquivalence : IsEquivalence _¬#_
3743
¬#-isEquivalence = AR.¬#-isEquivalence refl isApartnessRelation

src/Algebra/Properties/Magma/Divisibility.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
{-# OPTIONS --cubical-compatible --safe #-}
88

9-
open import Algebra using (Magma)
9+
open import Algebra.Bundles using (Magma)
1010

1111
module Algebra.Properties.Magma.Divisibility {a ℓ} (M : Magma a ℓ) where
1212

src/Algebra/Properties/Monoid/Divisibility.agda

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
{-# OPTIONS --cubical-compatible --safe #-}
88

9-
open import Algebra using (Monoid)
9+
open import Algebra.Bundles using (Monoid)
10+
11+
module Algebra.Properties.Monoid.Divisibility
12+
{a ℓ} (M : Monoid a ℓ) where
13+
1014
open import Data.Product.Base using (_,_)
1115
open import Relation.Binary.Core using (_⇒_)
1216
open import Relation.Binary.Bundles using (Preorder)
1317
open import Relation.Binary.Structures using (IsPreorder; IsEquivalence)
1418
open import Relation.Binary.Definitions using (Reflexive)
1519

16-
module Algebra.Properties.Monoid.Divisibility
17-
{a ℓ} (M : Monoid a ℓ) where
18-
1920
open Monoid M
2021

2122
------------------------------------------------------------------------
@@ -60,9 +61,9 @@ infix 4 ε∣_
6061

6162
∥-isEquivalence : IsEquivalence _∥_
6263
∥-isEquivalence = record
63-
{ refl = λ {x} ∥-refl {x}
64-
; sym = λ {x} {y} ∥-sym {x} {y}
65-
; trans = λ {x} {y} {z} ∥-trans {x} {y} {z}
64+
{ refl = ∥-refl
65+
; sym = ∥-sym
66+
; trans = ∥-trans
6667
}
6768

6869

src/Algebra/Properties/Semigroup/Divisibility.agda

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
{-# OPTIONS --cubical-compatible --safe #-}
88

9-
open import Algebra using (Semigroup)
10-
open import Data.Product.Base using (_,_)
11-
open import Relation.Binary.Definitions using (Transitive)
9+
open import Algebra.Bundles using (Semigroup)
1210

1311
module Algebra.Properties.Semigroup.Divisibility
1412
{a ℓ} (S : Semigroup a ℓ) where
1513

14+
open import Data.Product.Base using (_,_)
15+
open import Relation.Binary.Definitions using (Transitive)
16+
1617
open Semigroup S
1718

1819
------------------------------------------------------------------------

src/Algebra/Properties/Semiring/Divisibility.agda

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
{-# OPTIONS --cubical-compatible --safe #-}
88

9-
open import Algebra using (Semiring)
10-
import Algebra.Properties.Monoid.Divisibility as MonoidDivisibility
11-
open import Data.Product.Base using (_,_)
12-
open import Data.Sum.Base using (_⊎_; inj₁; inj₂)
9+
open import Algebra.Bundles using (Semiring)
1310

1411
module Algebra.Properties.Semiring.Divisibility
1512
{a ℓ} (R : Semiring a ℓ) where
@@ -19,7 +16,7 @@ open Semiring R
1916
------------------------------------------------------------------------
2017
-- Re-exporting divisibility over monoids
2118

22-
open MonoidDivisibility *-monoid public
19+
open import Algebra.Properties.Monoid.Divisibility *-monoid public
2320
renaming (ε∣_ to 1∣_)
2421

2522
------------------------------------------------------------------------
@@ -37,4 +34,4 @@ x∣y∧y≉0⇒x≉0 : ∀ {x y} → x ∣ y → y ≉ 0# → x ≉ 0#
3734
x∣y∧y≉0⇒x≉0 x∣y y≉0 x≈0 = y≉0 (0∣x⇒x≈0 (∣-respˡ x≈0 x∣y))
3835

3936
0∤1 : 0# ≉ 1# 0# ∤ 1#
40-
0∤1 0≉1 (q , q*0≈1) = 0≉1 (trans (sym (zeroʳ q)) q*0≈1)
37+
0∤1 0≉1 0∣1 = 0≉1 (sym (0∣x⇒x≈0 0∣1))
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
------------------------------------------------------------------------
22
-- The Agda standard library
33
--
4-
-- Some theory for CancellativeCommutativeSemiring.
4+
-- Properties of Coprimality and Irreducibility for Semiring.
55
------------------------------------------------------------------------
66

77
{-# OPTIONS --cubical-compatible --safe #-}
88

9-
open import Algebra using (Semiring)
10-
open import Data.Sum.Base using (reduce)
11-
open import Function.Base using (flip)
12-
open import Relation.Binary.Definitions using (Symmetric)
9+
open import Algebra.Bundles using (Semiring)
1310

1411
module Algebra.Properties.Semiring.Primality
1512
{a ℓ} (R : Semiring a ℓ)
1613
where
1714

15+
open import Data.Sum.Base using (reduce)
16+
open import Function.Base using (flip)
17+
open import Relation.Binary.Definitions using (Symmetric)
18+
1819
open Semiring R renaming (Carrier to A)
1920
open import Algebra.Properties.Semiring.Divisibility R
21+
using (_∣_; ∣-trans; 0∤1)
22+
23+
private
24+
variable
25+
x p : A
26+
2027

2128
------------------------------------------------------------------------
2229
-- Re-export primality definitions
@@ -30,12 +37,12 @@ open import Algebra.Definitions.RawSemiring rawSemiring public
3037
Coprime-sym : Symmetric Coprime
3138
Coprime-sym coprime = flip coprime
3239

33-
∣1⇒Coprime : {x} y x ∣ 1# Coprime x y
34-
∣1⇒Coprime {x} y x∣1 z∣x _ = ∣-trans z∣x x∣1
40+
∣1⇒Coprime : y x ∣ 1# Coprime x y
41+
∣1⇒Coprime _ x∣1 z∣x _ = ∣-trans z∣x x∣1
3542

3643
------------------------------------------------------------------------
3744
-- Properties of Irreducible
3845

39-
Irreducible⇒≉0 : 0# ≉ 1# {p} Irreducible p p ≉ 0#
46+
Irreducible⇒≉0 : 0# ≉ 1# Irreducible p p ≉ 0#
4047
Irreducible⇒≉0 0≉1 (mkIrred _ chooseInvertible) p≈0 =
4148
0∤1 0≉1 (reduce (chooseInvertible (trans p≈0 (sym (zeroˡ 0#)))))

src/Data/List/Properties.agda

+14
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,10 @@ applyUpTo-∷ʳ : ∀ (f : ℕ → A) n → applyUpTo f n ∷ʳ f n ≡ applyUpT
842842
applyUpTo-∷ʳ f zero = refl
843843
applyUpTo-∷ʳ f (suc n) = cong (f 0 ∷_) (applyUpTo-∷ʳ (f ∘ suc) n)
844844

845+
map-applyUpTo : (f : A) (g : A B) n map g (applyUpTo f n) ≡ applyUpTo (g ∘ f) n
846+
map-applyUpTo f g zero = refl
847+
map-applyUpTo f g (suc n) = cong (g (f 0) ∷_) (map-applyUpTo (f ∘ suc) g n)
848+
845849
------------------------------------------------------------------------
846850
-- applyDownFrom
847851

@@ -859,6 +863,10 @@ module _ (f : ℕ → A) where
859863
applyDownFrom-∷ʳ zero = refl
860864
applyDownFrom-∷ʳ (suc n) = cong (f (suc n) ∷_) (applyDownFrom-∷ʳ n)
861865

866+
map-applyDownFrom : (g : A B) n map g (applyDownFrom f n) ≡ applyDownFrom (g ∘ f) n
867+
map-applyDownFrom g zero = refl
868+
map-applyDownFrom g (suc n) = cong (g (f n) ∷_) (map-applyDownFrom g n)
869+
862870
------------------------------------------------------------------------
863871
-- upTo
864872

@@ -871,6 +879,9 @@ lookup-upTo = lookup-applyUpTo id
871879
upTo-∷ʳ : n upTo n ∷ʳ n ≡ upTo (suc n)
872880
upTo-∷ʳ = applyUpTo-∷ʳ id
873881

882+
map-upTo : (f : A) n map f (upTo n) ≡ applyUpTo f n
883+
map-upTo = map-applyUpTo id
884+
874885
------------------------------------------------------------------------
875886
-- downFrom
876887

@@ -883,6 +894,9 @@ lookup-downFrom = lookup-applyDownFrom id
883894
downFrom-∷ʳ : n applyDownFrom suc n ∷ʳ 0 ≡ downFrom (suc n)
884895
downFrom-∷ʳ = applyDownFrom-∷ʳ id
885896

897+
map-downFrom : (f : A) n map f (downFrom n) ≡ applyDownFrom f n
898+
map-downFrom = map-applyDownFrom id
899+
886900
------------------------------------------------------------------------
887901
-- tabulate
888902

src/Data/List/Relation/Binary/Permutation/Propositional/Properties.agda

+16-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ open import Data.Product.Base using (_,_; _×_; ∃; ∃₂)
2626
open import Data.Maybe.Base using (Maybe; just; nothing)
2727
open import Function.Base using (_∘_; _⟨_⟩_; _$_)
2828
open import Level using (Level)
29-
open import Relation.Unary using (Pred)
29+
open import Relation.Unary as Pred using (Pred)
3030
open import Relation.Binary.Core using (Rel; _Preserves_⟶_; _Preserves₂_⟶_⟶_)
3131
open import Relation.Binary.Definitions using (_Respects_; Decidable)
3232
open import Relation.Binary.PropositionalEquality.Core as ≡
@@ -372,6 +372,21 @@ module _ {ℓ} {R : Rel A ℓ} (R? : Decidable R) where
372372
x ∷ xs ++ y ∷ ys ∎
373373
where open PermutationReasoning
374374

375+
------------------------------------------------------------------------
376+
-- filter
377+
378+
filter-↭ : {p} {P : Pred A p} (P? : Pred.Decidable P) xs ↭ ys filter P? xs ↭ filter P? ys
379+
filter-↭ P? refl = refl
380+
filter-↭ P? (prep x xs↭ys) with P? x
381+
... | yes _ = prep x (filter-↭ P? xs↭ys)
382+
... | no _ = filter-↭ P? xs↭ys
383+
filter-↭ P? (swap x y xs↭ys) with P? x in eqˣ | P? y in eqʸ
384+
... | yes _ | yes _ rewrite eqˣ rewrite eqʸ = swap x y (filter-↭ P? xs↭ys)
385+
... | yes _ | no _ rewrite eqˣ rewrite eqʸ = prep x (filter-↭ P? xs↭ys)
386+
... | no _ | yes _ rewrite eqˣ rewrite eqʸ = prep y (filter-↭ P? xs↭ys)
387+
... | no _ | no _ rewrite eqˣ rewrite eqʸ = filter-↭ P? xs↭ys
388+
filter-↭ P? (trans xs↭ys ys↭zs) = ↭-trans (filter-↭ P? xs↭ys) (filter-↭ P? ys↭zs)
389+
375390
------------------------------------------------------------------------
376391
-- catMaybes
377392

0 commit comments

Comments
 (0)