Skip to content

Commit bfb0c88

Browse files
gallaisMatthewDaggitt
authored andcommitted
[ fix #683 ] re-export specialised versions of the constructors (#684)
1 parent b276b59 commit bfb0c88

File tree

15 files changed

+627
-321
lines changed

15 files changed

+627
-321
lines changed

CHANGELOG.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,16 @@ New modules
7373
Data.List.Relation.Binary.Suffix.Heterogeneous.Properties
7474
Data.List.Relation.Binary.Prefix.Heterogeneous
7575
Data.List.Relation.Binary.Prefix.Heterogeneous.Properties
76-
Data.List.Relation.Binary.Sublist.Homogeneous.Properties
77-
Data.List.Relation.Binary.Sublist.Homogeneous.Solver
7876
Data.List.Relation.Binary.Sublist.Heterogeneous
7977
Data.List.Relation.Binary.Sublist.Heterogeneous.Properties
78+
Data.List.Relation.Binary.Sublist.Heterogeneous.Solver
8079
Data.List.Relation.Binary.Sublist.Setoid
8180
Data.List.Relation.Binary.Sublist.Setoid.Properties
8281
Data.List.Relation.Binary.Sublist.DecSetoid
83-
Data.List.Relation.Binary.Sublist.DecSetoid.Properties
8482
Data.List.Relation.Binary.Sublist.DecSetoid.Solver
8583
Data.List.Relation.Binary.Sublist.Propositional
8684
Data.List.Relation.Binary.Sublist.Propositional.Properties
8785
Data.List.Relation.Binary.Sublist.DecPropositional
88-
Data.List.Relation.Binary.Sublist.DecPropositional.Properties
8986
Data.List.Relation.Binary.Sublist.DecPropositional.Solver
9087
Data.List.Relation.Ternary.Interleaving.Setoid
9188
Data.List.Relation.Ternary.Interleaving.Setoid.Properties
Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
11
------------------------------------------------------------------------
22
-- The Agda standard library
33
--
4-
-- An inductive definition of the sublist relation for types which have a
5-
-- decidable equality. This is commonly known as Order Preserving Embeddings (OPE).
4+
-- An inductive definition of the sublist relation for types which have
5+
-- a decidable equality. This is commonly known as Order Preserving
6+
-- Embeddings (OPE).
67
------------------------------------------------------------------------
78

89
{-# OPTIONS --without-K --safe #-}
910

10-
open import Relation.Binary using (Decidable)
11+
open import Relation.Binary
1112
open import Agda.Builtin.Equality using (_≡_)
1213

1314
module Data.List.Relation.Binary.Sublist.DecPropositional
14-
{a} {A : Set a} (_≟_ : Decidable {A = A} _≡_)
15-
where
15+
{a} {A : Set a} (_≟_ : Decidable {A = A} _≡_)
16+
where
1617

17-
import Relation.Binary.PropositionalEquality as P
18+
open import Data.List.Relation.Binary.Equality.DecPropositional _≟_
19+
using (_≡?_)
20+
import Data.List.Relation.Binary.Sublist.DecSetoid as DecSetoidSublist
21+
import Data.List.Relation.Binary.Sublist.Propositional as PropositionalSublist
22+
open import Relation.Binary.PropositionalEquality
1823

19-
open import Data.List.Relation.Binary.Sublist.DecSetoid (P.decSetoid _≟_)
20-
hiding (lookup) public
21-
open import Data.List.Relation.Binary.Sublist.Propositional {A = A}
22-
using (lookup) public
24+
------------------------------------------------------------------------
25+
-- Re-export core definitions and operations
26+
27+
open PropositionalSublist {A = A} public
28+
open DecSetoidSublist (decSetoid _≟_) using (_⊆?_) public
29+
30+
------------------------------------------------------------------------
31+
-- Additional relational properties
32+
33+
⊆-isDecPartialOrder : IsDecPartialOrder _≡_ _⊆_
34+
⊆-isDecPartialOrder = record
35+
{ isPartialOrder = ⊆-isPartialOrder
36+
; _≟_ = _≡?_
37+
; _≤?_ = _⊆?_
38+
}
39+
40+
⊆-decPoset : DecPoset a a a
41+
⊆-decPoset = record
42+
{ isDecPartialOrder = ⊆-isDecPartialOrder
43+
}

src/Data/List/Relation/Binary/Sublist/DecPropositional/Properties.agda

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
------------------------------------------------------------------------
22
-- The Agda standard library
33
--
4-
-- An inductive definition of the sublist relation with respect to a setoid
5-
-- which is decidable. This is a generalisation of what is commonly known as
6-
-- Order Preserving Embeddings (OPE).
4+
-- An inductive definition of the sublist relation with respect to a
5+
-- setoid which is decidable. This is a generalisation of what is
6+
-- commonly known as Order Preserving Embeddings (OPE).
77
------------------------------------------------------------------------
88

99
{-# OPTIONS --without-K --safe #-}
1010

11-
open import Relation.Binary using (DecSetoid)
11+
open import Relation.Binary
1212

13-
module Data.List.Relation.Binary.Sublist.DecSetoid {c ℓ} (S : DecSetoid c ℓ) where
13+
module Data.List.Relation.Binary.Sublist.DecSetoid
14+
{c ℓ} (S : DecSetoid c ℓ) where
1415

15-
private
16-
module S = DecSetoid S
16+
import Data.List.Relation.Binary.Equality.DecSetoid as DecSetoidEquality
17+
import Data.List.Relation.Binary.Sublist.Setoid as SetoidSublist
18+
import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties
19+
as HeterogeneousProperties
20+
open import Level using (_⊔_)
1721

18-
open import Data.List.Relation.Binary.Sublist.Setoid S.setoid public
22+
open DecSetoid S
23+
open DecSetoidEquality S
24+
25+
------------------------------------------------------------------------
26+
-- Re-export core definitions
27+
28+
open SetoidSublist setoid public
29+
30+
------------------------------------------------------------------------
31+
-- Additional relational properties
32+
33+
_⊆?_ : Decidable _⊆_
34+
_⊆?_ = HeterogeneousProperties.sublist? _≟_
35+
36+
⊆-isDecPartialOrder : IsDecPartialOrder _≋_ _⊆_
37+
⊆-isDecPartialOrder = record
38+
{ isPartialOrder = ⊆-isPartialOrder
39+
; _≟_ = _≋?_
40+
; _≤?_ = _⊆?_
41+
}
42+
43+
⊆-decPoset : DecPoset c (c ⊔ ℓ) (c ⊔ ℓ)
44+
⊆-decPoset = record
45+
{ isDecPartialOrder = ⊆-isDecPartialOrder
46+
}

src/Data/List/Relation/Binary/Sublist/DecSetoid/Properties.agda

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Data/List/Relation/Binary/Sublist/DecSetoid/Solver.agda

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open import Relation.Binary using (DecSetoid)
1010

1111
module Data.List.Relation.Binary.Sublist.DecSetoid.Solver {c ℓ} (S : DecSetoid c ℓ) where
1212

13-
private module S = DecSetoid S
13+
open DecSetoid S
1414

15-
open import Data.List.Relation.Binary.Sublist.Homogeneous.Solver S._≈_ S.refl S._≟_
15+
open import Data.List.Relation.Binary.Sublist.Heterogeneous.Solver _≈_ refl _≟_
1616
using (Item; module Item; TList; module TList; prove) public

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
{-# OPTIONS --without-K --safe #-}
1010

11-
module Data.List.Relation.Binary.Sublist.Heterogeneous where
11+
open import Relation.Binary using (REL)
12+
13+
module Data.List.Relation.Binary.Sublist.Heterogeneous
14+
{a b r} {A : Set a} {B : Set b} {R : REL A B r}
15+
where
1216

1317
open import Level using (_⊔_)
1418
open import Data.List.Base using (List; []; _∷_; [_])
@@ -19,44 +23,39 @@ open import Relation.Binary
1923
open import Relation.Binary.PropositionalEquality as P using (_≡_)
2024

2125
------------------------------------------------------------------------
22-
-- Type and basic combinators
26+
-- Re-export core definitions
2327

24-
module _ {a b r} {A : Set a} {B : Set b} (R : REL A B r) where
28+
open import Data.List.Relation.Binary.Sublist.Heterogeneous.Core public
2529

26-
data Sublist : REL (List A) (List B) (a ⊔ b ⊔ r) where
27-
[] : Sublist [] []
28-
_∷ʳ_ : {xs ys} y Sublist xs ys Sublist xs (y ∷ ys)
29-
_∷_ : {x xs y ys} R x y Sublist xs ys Sublist (x ∷ xs) (y ∷ ys)
30+
------------------------------------------------------------------------
31+
-- Type and basic combinators
3032

31-
module _ {a b r s} {A : Set a} {B : Set b} {R : REL A B r} {S : REL A B s} where
33+
module _ {s} {S : REL A B s} where
3234

3335
map : R ⇒ S Sublist R ⇒ Sublist S
3436
map f [] = []
3537
map f (y ∷ʳ rs) = y ∷ʳ map f rs
3638
map f (r ∷ rs) = f r ∷ map f rs
3739

38-
module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where
39-
40-
minimum : Min (Sublist R) []
41-
minimum [] = []
42-
minimum (x ∷ xs) = x ∷ʳ minimum xs
40+
minimum : Min (Sublist R) []
41+
minimum [] = []
42+
minimum (x ∷ xs) = x ∷ʳ minimum xs
4343

4444
------------------------------------------------------------------------
4545
-- Conversion to and from Any
4646

47-
toAny : {a bs} Sublist R [ a ] bs Any (R a) bs
48-
toAny (y ∷ʳ rs) = there (toAny rs)
49-
toAny (r ∷ rs) = here r
47+
toAny : {a bs} Sublist R [ a ] bs Any (R a) bs
48+
toAny (y ∷ʳ rs) = there (toAny rs)
49+
toAny (r ∷ rs) = here r
5050

51-
fromAny : {a bs} Any (R a) bs Sublist R [ a ] bs
52-
fromAny (here r) = r ∷ minimum _
53-
fromAny (there p) = _ ∷ʳ fromAny p
51+
fromAny : {a bs} Any (R a) bs Sublist R [ a ] bs
52+
fromAny (here r) = r ∷ minimum _
53+
fromAny (there p) = _ ∷ʳ fromAny p
5454

5555
------------------------------------------------------------------------
5656
-- Generalised lookup based on a proof of Any
5757

58-
module _ {a b p q r} {A : Set a} {B : Set b} {R : REL A B r}
59-
{P : Pred A p} {Q : Pred B q} (resp : P ⟶ Q Respects R) where
58+
module _ {p q} {P : Pred A p} {Q : Pred B q} (resp : P ⟶ Q Respects R) where
6059

6160
lookup : {xs ys} Sublist R xs ys Any P xs Any Q ys
6261
lookup [] ()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- This file contains some core definitions which are re-exported by
5+
-- Data.List.Relation.Binary.Sublist.Heterogeneous.
6+
------------------------------------------------------------------------
7+
8+
{-# OPTIONS --without-K --safe #-}
9+
10+
open import Relation.Binary using (REL)
11+
12+
module Data.List.Relation.Binary.Sublist.Heterogeneous.Core
13+
{a b r} {A : Set a} {B : Set b} (R : REL A B r)
14+
where
15+
16+
open import Level using (_⊔_)
17+
open import Data.List.Base using (List; []; _∷_; [_])
18+
19+
data Sublist : REL (List A) (List B) (a ⊔ b ⊔ r) where
20+
[] : Sublist [] []
21+
_∷ʳ_ : {xs ys} y Sublist xs ys Sublist xs (y ∷ ys)
22+
_∷_ : {x xs y ys} R x y Sublist xs ys Sublist (x ∷ xs) (y ∷ ys)

0 commit comments

Comments
 (0)