Skip to content

Commit ada10d9

Browse files
committed
Lists: extra subset lemmas about _∷_
1 parent 21602e3 commit ada10d9

File tree

5 files changed

+84
-9
lines changed

5 files changed

+84
-9
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Additions to existing modules
138138
y ∈₂ map f (filter P? xs)
139139
∈-concatMap⁺ : Any ((y ∈_) ∘ f) xs → y ∈ concatMap f xs
140140
∈-concatMap⁻ : y ∈ concatMap f xs → Any ((y ∈_) ∘ f) xs
141+
∉[] : x ∉ []
141142
```
142143

143144
* In `Data.List.Membership.Propositional.Properties`:
@@ -152,6 +153,7 @@ Additions to existing modules
152153
map∷-decomp∈ : (x ∷ xs) ∈ map (y ∷_) xss → x ≡ y × xs ∈ xss
153154
map∷-decomp : xs ∈ map (y ∷_) xss → ∃[ ys ] ys ∈ xss × y ∷ ys ≡ xs
154155
∈-map∷⁻ : xs ∈ map (x ∷_) xss → x ∈ xs
156+
∉[] : x ∉ []
155157
```
156158

157159
* In `Data.List.Membership.Propositional.Properties.WithK`:
@@ -216,6 +218,20 @@ Additions to existing modules
216218
∈-dedup : x ∈ xs ⇔ x ∈ deduplicate _≟_ xs
217219
```
218220

221+
* In `Data.List.Relation.Binary.Permutation.Setoid.Properties`:
222+
```agda
223+
⊈[] : x ∷ xs ⊈ []
224+
⊆∷∧∉⇒⊆ : xs ⊆ y ∷ ys → y ∉ xs → xs ⊆ ys
225+
∈∷∧⊆⇒∈ : x ∈ y ∷ xs → xs ⊆ ys → x ∈ y ∷ ys
226+
```
227+
228+
* In `Data.List.Relation.Binary.Permutation.Propositional.Properties`:
229+
```agda
230+
⊈[] : x ∷ xs ⊈ []
231+
⊆∷∧∉⇒⊆ : xs ⊆ y ∷ ys → y ∉ xs → xs ⊆ ys
232+
∈∷∧⊆⇒∈ : x ∈ y ∷ xs → xs ⊆ ys → x ∈ y ∷ ys
233+
```
234+
219235
* In `Data.List.Relation.Binary.Permutation.Propositional.Properties.WithK`:
220236
```agda
221237
dedup-++-↭ : Disjoint xs ys →

src/Data/List/Membership/Propositional/Properties/Core.agda

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module Data.List.Membership.Propositional.Properties.Core where
1414

15-
open import Data.List.Base using (List)
15+
open import Data.List.Base using (List; [])
1616
open import Data.List.Membership.Propositional
1717
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
1818
open import Data.Product.Base as Product using (_,_; ∃; _×_)
@@ -30,6 +30,12 @@ private
3030
x : A
3131
xs : List A
3232

33+
------------------------------------------------------------------------
34+
-- Basics
35+
36+
∉[] : x ∉ []
37+
∉[] ()
38+
3339
------------------------------------------------------------------------
3440
-- find satisfies a simple equality when the predicate is a
3541
-- propositional equality.

src/Data/List/Membership/Setoid/Properties.agda

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
------------------------------------------------------------------------
1+
-----------------------------------------------------------------------
22
-- The Agda standard library
33
--
44
-- Properties related to setoid list membership
@@ -42,6 +42,16 @@ private
4242
variable
4343
c c₁ c₂ c₃ p ℓ ℓ₁ ℓ₂ ℓ₃ : Level
4444

45+
------------------------------------------------------------------------
46+
-- Basics
47+
48+
module _ (S : Setoid c ℓ) where
49+
50+
open Membership S
51+
52+
∉[] : {x} x ∉ []
53+
∉[] ()
54+
4555
------------------------------------------------------------------------
4656
-- Equality properties
4757

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ module Data.List.Relation.Binary.Subset.Propositional.Properties
1111

1212
open import Data.Bool.Base using (Bool; true; false; T)
1313
open import Data.List.Base
14-
using (List; map; _∷_; _++_; concat; concatMap; applyUpTo; any; filter)
14+
using (List; []; map; _∷_; _++_; concat; concatMap; applyUpTo; any; filter)
1515
open import Data.List.Relation.Unary.Any using (Any; here; there)
1616
open import Data.List.Relation.Unary.All using (All)
1717
import Data.List.Relation.Unary.Any.Properties as Any hiding (filter⁺)
1818
open import Data.List.Effectful using (monad)
1919
open import Data.List.Relation.Unary.Any using (Any)
20-
open import Data.List.Membership.Propositional using (_∈_; mapWith∈)
20+
open import Data.List.Membership.Propositional using (_∈_; _∉_; mapWith∈)
2121
open import Data.List.Membership.Propositional.Properties
2222
using (map-∈↔; concat-∈↔; >>=-∈↔; ⊛-∈↔; ⊗-∈↔)
2323
import Data.List.Relation.Binary.Subset.Setoid.Properties as Subset
2424
open import Data.List.Relation.Binary.Subset.Propositional
25-
using (_⊆_; _⊇_)
25+
using (_⊆_; _⊇_; _⊈_)
2626
open import Data.List.Relation.Binary.Permutation.Propositional
2727
using (_↭_; ↭-sym; ↭-isEquivalence)
2828
import Data.List.Relation.Binary.Permutation.Propositional.Properties as Permutation
@@ -52,8 +52,16 @@ private
5252
a b p q : Level
5353
A : Set a
5454
B : Set b
55+
x y : A
5556
ws xs ys zs : List A
5657

58+
------------------------------------------------------------------------
59+
-- Basics
60+
------------------------------------------------------------------------
61+
62+
⊈[] : x ∷ xs ⊈ []
63+
⊈[] = Subset.⊈[] (setoid _)
64+
5765
------------------------------------------------------------------------
5866
-- Relational properties with _≋_ (pointwise equality)
5967
------------------------------------------------------------------------
@@ -150,6 +158,12 @@ xs⊆x∷xs = Subset.xs⊆x∷xs (setoid _)
150158
∈-∷⁺ʳ : {x} x ∈ ys xs ⊆ ys x ∷ xs ⊆ ys
151159
∈-∷⁺ʳ = Subset.∈-∷⁺ʳ (setoid _)
152160

161+
⊆∷∧∉⇒⊆ : xs ⊆ y ∷ ys y ∉ xs xs ⊆ ys
162+
⊆∷∧∉⇒⊆ = Subset.⊆∷∧∉⇒⊆ (setoid _)
163+
164+
∈∷∧⊆⇒∈ : x ∈ y ∷ xs xs ⊆ ys x ∈ y ∷ ys
165+
∈∷∧⊆⇒∈ = Subset.∈∷∧⊆⇒∈ (setoid _)
166+
153167
------------------------------------------------------------------------
154168
-- _++_
155169

src/Data/List/Relation/Binary/Subset/Setoid/Properties.agda

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
module Data.List.Relation.Binary.Subset.Setoid.Properties where
1010

1111
open import Data.Bool.Base using (Bool; true; false)
12+
open import Data.Empty using (⊥-elim)
1213
open import Data.List.Base hiding (_∷ʳ_; find)
1314
import Data.List.Properties as List
1415
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
@@ -22,7 +23,7 @@ import Data.List.Relation.Binary.Equality.Setoid as Equality
2223
import Data.List.Relation.Binary.Permutation.Setoid as Permutation
2324
import Data.List.Relation.Binary.Permutation.Setoid.Properties as Permutationₚ
2425
open import Data.Product.Base using (_,_)
25-
open import Function.Base using (_∘_; _∘₂_; _$_)
26+
open import Function.Base using (_∘_; _∘₂_; _$_; case_of_)
2627
open import Level using (Level)
2728
open import Relation.Nullary using (¬_; does; yes; no)
2829
open import Relation.Nullary.Negation using (contradiction)
@@ -41,6 +42,18 @@ private
4142
variable
4243
a b p q r ℓ : Level
4344

45+
------------------------------------------------------------------------
46+
-- Basics
47+
------------------------------------------------------------------------
48+
49+
module _ (S : Setoid a ℓ) where
50+
51+
open Setoid S using (refl)
52+
open Subset S
53+
54+
⊈[] : {x xs} x ∷ xs ⊈ []
55+
⊈[] p = Membershipₚ.∉[] S $ p (here refl)
56+
4457
------------------------------------------------------------------------
4558
-- Relational properties with _≋_ (pointwise equality)
4659
------------------------------------------------------------------------
@@ -161,27 +174,43 @@ module _ (S : Setoid a ℓ) where
161174

162175
------------------------------------------------------------------------
163176
-- Properties of list functions
177+
------------------------------------------------------------------------
178+
164179
------------------------------------------------------------------------
165180
-- ∷
166181

167182
module _ (S : Setoid a ℓ) where
168183

169-
open Setoid S
184+
open Setoid S renaming (Carrier to A)
170185
open Subset S
171186
open Membership S
172187
open Membershipₚ
173188

174189
xs⊆x∷xs : xs x xs ⊆ x ∷ xs
175190
xs⊆x∷xs xs x = there
176191

177-
∷⁺ʳ : {xs ys} x xs ⊆ ys x ∷ xs ⊆ x ∷ ys
192+
private variable
193+
x y : A
194+
xs ys : List A
195+
196+
∷⁺ʳ : x xs ⊆ ys x ∷ xs ⊆ x ∷ ys
178197
∷⁺ʳ x xs⊆ys (here p) = here p
179198
∷⁺ʳ x xs⊆ys (there p) = there (xs⊆ys p)
180199

181-
∈-∷⁺ʳ : {xs ys x} x ∈ ys xs ⊆ ys x ∷ xs ⊆ ys
200+
∈-∷⁺ʳ : x ∈ ys xs ⊆ ys x ∷ xs ⊆ ys
182201
∈-∷⁺ʳ x∈ys _ (here v≈x) = ∈-resp-≈ S (sym v≈x) x∈ys
183202
∈-∷⁺ʳ _ xs⊆ys (there x∈xs) = xs⊆ys x∈xs
184203

204+
⊆∷∧∉⇒⊆ : xs ⊆ y ∷ ys y ∉ xs xs ⊆ ys
205+
⊆∷∧∉⇒⊆ xs⊆ y∉ x∈ = case xs⊆ x∈ of λ where
206+
(here x≈) ⊥-elim $ y∉ (∈-resp-≈ S x≈ x∈)
207+
(there p) p
208+
209+
∈∷∧⊆⇒∈ : x ∈ y ∷ xs xs ⊆ ys x ∈ y ∷ ys
210+
∈∷∧⊆⇒∈ = λ where
211+
(here x≡y) _ here x≡y
212+
(there x∈) xs⊆ there $ xs⊆ x∈
213+
185214
------------------------------------------------------------------------
186215
-- ++
187216

0 commit comments

Comments
 (0)