Skip to content

Commit ec8ace1

Browse files
gallaisMatthewDaggitt
authored andcommitted
[ fix #718 ] Fix unsolved metas in propositional uniqueness (#719)
1 parent 4765f88 commit ec8ace1

File tree

4 files changed

+79
-41
lines changed

4 files changed

+79
-41
lines changed

src/Data/List/Relation/Binary/Sublist/Heterogeneous/Core.agda

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
-- Data.List.Relation.Binary.Sublist.Heterogeneous.
66
------------------------------------------------------------------------
77

8+
-- This module should be removable if and when Agda issue
9+
-- https://github.com/agda/agda/issues/3210 is fixed
10+
811
{-# OPTIONS --without-K --safe #-}
912

1013
open import Relation.Binary using (REL)

src/Data/List/Relation/Unary/AllPairs.agda

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
{-# OPTIONS --without-K --safe #-}
88

9-
module Data.List.Relation.Unary.AllPairs where
9+
open import Relation.Binary using (Rel)
10+
11+
module Data.List.Relation.Unary.AllPairs
12+
{a ℓ} {A : Set a} {R : Rel A ℓ} where
1013

1114
open import Data.List using (List; []; _∷_)
1215
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
@@ -23,65 +26,54 @@ import Relation.Nullary.Decidable as Dec
2326
------------------------------------------------------------------------
2427
-- Definition
2528

26-
-- AllPairs R xs means that every pair of elements (x , y) in xs is a
27-
-- member of relation R (as long as x comes before y in the list).
28-
29-
infixr 5 _∷_
30-
31-
data AllPairs {a ℓ} {A : Set a} (R : Rel A ℓ) : List A Set (a ⊔ ℓ) where
32-
[] : AllPairs R []
33-
_∷_ : {x xs} All (R x) xs AllPairs R xs AllPairs R (x ∷ xs)
29+
open import Data.List.Relation.Unary.AllPairs.Core public
3430

3531
------------------------------------------------------------------------
3632
-- Operations
3733

38-
module _ {a ℓ} {A : Set a} {R : Rel A ℓ} where
34+
head : {x xs} AllPairs R (x ∷ xs) All (R x) xs
35+
head (px ∷ pxs) = px
3936

40-
head : {x xs} AllPairs R (x ∷ xs) All (R x) xs
41-
head (px ∷ pxs) = px
37+
tail : {x xs} AllPairs R (x ∷ xs) AllPairs R xs
38+
tail (px ∷ pxs) = pxs
4239

43-
tail : {x xs} AllPairs R (x ∷ xs) AllPairs R xs
44-
tail (px ∷ pxs) = pxs
45-
46-
module _ {a p q} {A : Set a} {R : Rel A p} {S : Rel A q} where
40+
module _ {q} {S : Rel A q} where
4741

4842
map : R ⇒ S AllPairs R ⊆ AllPairs S
4943
map ~₁⇒~₂ [] = []
5044
map ~₁⇒~₂ (x~xs ∷ pxs) = All.map ~₁⇒~₂ x~xs ∷ (map ~₁⇒~₂ pxs)
5145

52-
module _ {a p q r} {A : Set a} {P : Rel A p} {Q : Rel A q} {R : Rel A r} where
46+
module _ {s t} {S : Rel A s} {T : Rel A t} where
5347

54-
zipWith : P ∩ᵇ QR AllPairs P ∩ᵘ AllPairs Q ⊆ AllPairs R
48+
zipWith : R ∩ᵇ ST AllPairs R ∩ᵘ AllPairs S ⊆ AllPairs T
5549
zipWith f ([] , []) = []
5650
zipWith f (px ∷ pxs , qx ∷ qxs) = All.zipWith f (px , qx) ∷ zipWith f (pxs , qxs)
5751

58-
unzipWith : RP ∩ᵇ Q AllPairs R ⊆ AllPairs P ∩ᵘ AllPairs Q
52+
unzipWith : TR ∩ᵇ S AllPairs T ⊆ AllPairs R ∩ᵘ AllPairs S
5953
unzipWith f [] = [] , []
6054
unzipWith f (rx ∷ rxs) = Prod.zip _∷_ _∷_ (All.unzipWith f rx) (unzipWith f rxs)
6155

62-
module _ {a p q} {A : Set a} {P : Rel A p} {Q : Rel A q} where
56+
module _ {s} {S : Rel A s} where
6357

64-
zip : AllPairs P ∩ᵘ AllPairs Q ⊆ AllPairs (P ∩ᵇ Q)
58+
zip : AllPairs R ∩ᵘ AllPairs S ⊆ AllPairs (R ∩ᵇ S)
6559
zip = zipWith id
6660

67-
unzip : AllPairs (P ∩ᵇ Q) ⊆ AllPairs P ∩ᵘ AllPairs Q
61+
unzip : AllPairs (R ∩ᵇ S) ⊆ AllPairs R ∩ᵘ AllPairs S
6862
unzip = unzipWith id
6963

7064
------------------------------------------------------------------------
7165
-- Properties of predicates preserved by AllPairs
7266

73-
module _ {a ℓ} {A : Set a} {R : Rel A ℓ} where
74-
75-
allPairs? : B.Decidable R U.Decidable (AllPairs R)
76-
allPairs? R? [] = yes []
77-
allPairs? R? (x ∷ xs) with All.all (R? x) xs
78-
... | yes px = Dec.map′ (px ∷_) tail (allPairs? R? xs)
79-
... | no ¬px = no (¬px ∘ head)
67+
allPairs? : B.Decidable R U.Decidable (AllPairs R)
68+
allPairs? R? [] = yes []
69+
allPairs? R? (x ∷ xs) with All.all (R? x) xs
70+
... | yes px = Dec.map′ (px ∷_) tail (allPairs? R? xs)
71+
... | no ¬px = no (¬px ∘ head)
8072

81-
irrelevant : B.Irrelevant R U.Irrelevant (AllPairs R)
82-
irrelevant irr [] [] = refl
83-
irrelevant irr (px₁ ∷ pxs₁) (px₂ ∷ pxs₂) =
84-
cong₂ _∷_ (All.irrelevant irr px₁ px₂) (irrelevant irr pxs₁ pxs₂)
73+
irrelevant : B.Irrelevant R U.Irrelevant (AllPairs R)
74+
irrelevant irr [] [] = refl
75+
irrelevant irr (px₁ ∷ pxs₁) (px₂ ∷ pxs₂) =
76+
cong₂ _∷_ (All.irrelevant irr px₁ px₂) (irrelevant irr pxs₁ pxs₂)
8577

86-
satisfiable : U.Satisfiable (AllPairs R)
87-
satisfiable = [] , []
78+
satisfiable : U.Satisfiable (AllPairs R)
79+
satisfiable = [] , []
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Lists where every pair of elements are related (symmetrically)
5+
------------------------------------------------------------------------
6+
7+
-- Core modules are not meant to be used directly outside of the
8+
-- standard library.
9+
10+
-- This module should be removable if and when Agda issue
11+
-- https://github.com/agda/agda/issues/3210 is fixed
12+
13+
{-# OPTIONS --without-K --safe #-}
14+
15+
open import Relation.Binary using (Rel)
16+
17+
module Data.List.Relation.Unary.AllPairs.Core
18+
{a ℓ} {A : Set a} (R : Rel A ℓ) where
19+
20+
open import Level
21+
open import Data.List.Base
22+
open import Data.List.Relation.Unary.All
23+
24+
------------------------------------------------------------------------
25+
-- Definition
26+
27+
-- AllPairs R xs means that every pair of elements (x , y) in xs is a
28+
-- member of relation R (as long as x comes before y in the list).
29+
30+
infixr 5 _∷_
31+
32+
data AllPairs : List A Set (a ⊔ ℓ) where
33+
[] : AllPairs []
34+
_∷_ : {x xs} All (R x) xs AllPairs xs AllPairs (x ∷ xs)

src/Data/List/Relation/Unary/Unique/Setoid.agda

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,31 @@
66

77
{-# OPTIONS --without-K --safe #-}
88

9-
open import Relation.Binary using (Setoid)
9+
open import Relation.Binary using (Rel; Setoid)
1010

1111
module Data.List.Relation.Unary.Unique.Setoid {a ℓ} (S : Setoid a ℓ) where
1212

13+
open Setoid S renaming (Carrier to A)
14+
1315
open import Data.List
14-
open import Data.List.Relation.Unary.AllPairs as AllPairsM
16+
import Data.List.Relation.Unary.AllPairs as AllPairsM
1517
open import Level using (_⊔_)
1618
open import Relation.Unary using (Pred)
1719
open import Relation.Nullary using (¬_)
1820

19-
open Setoid S renaming (Carrier to A)
2021

2122
------------------------------------------------------------------------
2223
-- Definition
2324

24-
Unique : Pred (List A) (a ⊔ ℓ)
25-
Unique xs = AllPairs (λ x y ¬ (x ≈ y)) xs
25+
private
26+
27+
Distinct : Rel A ℓ
28+
Distinct x y = ¬ (x ≈ y)
29+
30+
open import Data.List.Relation.Unary.AllPairs.Core Distinct
31+
renaming (AllPairs to Unique)
32+
public
2633

27-
open AllPairsM public using (_∷_; []; head; tail)
34+
open import Data.List.Relation.Unary.AllPairs {R = Distinct}
35+
using (head; tail)
36+
public

0 commit comments

Comments
 (0)