6
6
7
7
{-# OPTIONS --cubical-compatible --safe #-}
8
8
9
+ module Data.List.Relation.Unary.Enumerates.Setoid.Properties where
10
+
9
11
open import Data.List.Base
10
12
open import Data.List.Membership.Setoid.Properties as Membership
11
13
open import Data.List.Relation.Unary.Any using (index)
@@ -14,32 +16,32 @@ open import Data.List.Relation.Unary.Enumerates.Setoid
14
16
open import Data.Sum.Base using (inj₁; inj₂)
15
17
open import Data.Sum.Relation.Binary.Pointwise
16
18
using (_⊎ₛ_; inj₁; inj₂)
17
- open import Data.Product.Base using (_,_; proj₁; proj₂ )
19
+ open import Data.Product.Base using (_,_)
18
20
open import Data.Product.Relation.Binary.Pointwise.NonDependent
19
21
using (_×ₛ_)
20
22
open import Function.Base using (_∘_)
21
23
open import Function.Bundles using (Surjection)
22
24
open import Function.Definitions using (Surjective)
23
- open import Function.Consequences using (strictlySurjective ⇒surjective)
25
+ open import Function.Consequences using (inverseˡ ⇒surjective)
24
26
open import Level
25
27
open import Relation.Binary.Bundles using (Setoid; DecSetoid)
26
28
open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_)
27
29
open import Relation.Binary.Properties.Setoid using (respʳ-flip)
28
30
29
- module Data.List.Relation.Unary.Enumerates.Setoid.Properties where
30
-
31
-
32
31
private
33
32
variable
34
33
a b ℓ₁ ℓ₂ : Level
34
+ A : Set a
35
+ xs ys : List A
36
+
35
37
36
38
------------------------------------------------------------------------
37
39
-- map
38
40
39
41
module _ (S : Setoid a ℓ₁) (T : Setoid b ℓ₂) (surj : Surjection S T) where
40
42
open Surjection surj
41
43
42
- map⁺ : ∀ {xs} → IsEnumeration S xs → IsEnumeration T (map to xs)
44
+ map⁺ : IsEnumeration S xs → IsEnumeration T (map to xs)
43
45
map⁺ _∈xs y with (x , fx≈y) ← strictlySurjective y =
44
46
∈-resp-≈ T fx≈y (∈-map⁺ S T cong (x ∈xs))
45
47
@@ -48,15 +50,15 @@ module _ (S : Setoid a ℓ₁) (T : Setoid b ℓ₂) (surj : Surjection S T) whe
48
50
49
51
module _ (S : Setoid a ℓ₁) where
50
52
51
- ++⁺ˡ : ∀ {xs} ys → IsEnumeration S xs → IsEnumeration S (xs ++ ys)
53
+ ++⁺ˡ : ∀ ys → IsEnumeration S xs → IsEnumeration S (xs ++ ys)
52
54
++⁺ˡ _ _∈xs v = Membership.∈-++⁺ˡ S (v ∈xs)
53
55
54
- ++⁺ʳ : ∀ xs {ys} → IsEnumeration S ys → IsEnumeration S (xs ++ ys)
56
+ ++⁺ʳ : ∀ xs → IsEnumeration S ys → IsEnumeration S (xs ++ ys)
55
57
++⁺ʳ _ _∈ys v = Membership.∈-++⁺ʳ S _ (v ∈ys)
56
58
57
59
module _ (S : Setoid a ℓ₁) (T : Setoid b ℓ₂) where
58
60
59
- ++⁺ : ∀ {xs ys} → IsEnumeration S xs → IsEnumeration T ys →
61
+ ++⁺ : IsEnumeration S xs → IsEnumeration T ys →
60
62
IsEnumeration (S ⊎ₛ T) (map inj₁ xs ++ map inj₂ ys)
61
63
++⁺ _∈xs _ (inj₁ x) = ∈-++⁺ˡ (S ⊎ₛ T) (∈-map⁺ S (S ⊎ₛ T) inj₁ (x ∈xs))
62
64
++⁺ _ _∈ys (inj₂ y) = ∈-++⁺ʳ (S ⊎ₛ T) _ (∈-map⁺ T (S ⊎ₛ T) inj₂ (y ∈ys))
@@ -66,7 +68,7 @@ module _ (S : Setoid a ℓ₁) (T : Setoid b ℓ₂) where
66
68
67
69
module _ (S : Setoid a ℓ₁) (T : Setoid b ℓ₂) where
68
70
69
- cartesianProduct⁺ : ∀ {xs ys} → IsEnumeration S xs → IsEnumeration T ys →
71
+ cartesianProduct⁺ : IsEnumeration S xs → IsEnumeration T ys →
70
72
IsEnumeration (S ×ₛ T) (cartesianProduct xs ys)
71
73
cartesianProduct⁺ _∈xs _∈ys (x , y) = ∈-cartesianProduct⁺ S T (x ∈xs) (y ∈ys)
72
74
@@ -76,17 +78,15 @@ module _ (S : Setoid a ℓ₁) (T : Setoid b ℓ₂) where
76
78
module _ (S? : DecSetoid a ℓ₁) where
77
79
open DecSetoid S? renaming (setoid to S)
78
80
79
- deduplicate⁺ : ∀ {xs} → IsEnumeration S xs →
80
- IsEnumeration S (deduplicate _≟_ xs)
81
+ deduplicate⁺ : IsEnumeration S xs → IsEnumeration S (deduplicate _≟_ xs)
81
82
deduplicate⁺ = ∈-deduplicate⁺ S _≟_ (respʳ-flip S) ∘_
82
83
83
84
------------------------------------------------------------------------
84
85
-- lookup
85
86
86
87
module _ (S : Setoid a ℓ₁) where
87
- open Setoid S
88
+ open Setoid S using (_≈_; sym)
88
89
89
- lookup-surjective : ∀ {xs} → IsEnumeration S xs →
90
- Surjective _≡_ _≈_ (lookup xs)
91
- lookup-surjective _∈xs = strictlySurjective⇒surjective
92
- trans (λ { ≡.refl → refl}) (λ y → index (y ∈xs) , sym (lookup-index (y ∈xs)))
90
+ lookup-surjective : IsEnumeration S xs → Surjective _≡_ _≈_ (lookup xs)
91
+ lookup-surjective _∈xs = inverseˡ⇒surjective _≈_
92
+ λ where ≡.refl → sym (lookup-index (_ ∈xs))
0 commit comments