Skip to content

Commit e614c2a

Browse files
committed
Lists: extra lemmas about _∷_/Unique
1 parent c60e884 commit e614c2a

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ Additions to existing modules
179179
concatMap⁻ : Any P (concatMap f xs) → Any (Any P ∘ f) xs
180180
```
181181

182+
* In `Data.List.Relation.Unary.Unique.Setoid.Properties`:
183+
```agda
184+
Unique-dropSnd : Unique S (x ∷ y ∷ xs) → Unique S (x ∷ xs)
185+
Unique∷⇒head∉tail : Unique S (x ∷ xs) → x ∉ xs
186+
```
187+
188+
* In `Data.List.Relation.Unary.Unique.Propositional.Properties`:
189+
```agda
190+
Unique-dropSnd : Unique (x ∷ y ∷ xs) → Unique (x ∷ xs)
191+
Unique∷⇒head∉tail : Unique (x ∷ xs) → x ∉ xs
192+
```
193+
182194
* In `Data.List.Relation.Binary.Equality.Setoid`:
183195
```agda
184196
++⁺ʳ : ∀ xs → ys ≋ zs → xs ++ ys ≋ xs ++ zs

src/Data/List/Relation/Unary/Unique/Propositional/Properties.agda

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88

99
module Data.List.Relation.Unary.Unique.Propositional.Properties where
1010

11-
open import Data.List.Base using (map; _++_; concat; cartesianProductWith;
12-
cartesianProduct; drop; take; applyUpTo; upTo; applyDownFrom; downFrom;
13-
tabulate; allFin; filter)
11+
open import Data.List.Base
12+
using ( List; _∷_; map; _++_; concat; cartesianProductWith
13+
; cartesianProduct; drop; take; applyUpTo; upTo; applyDownFrom; downFrom
14+
; tabulate; allFin; filter
15+
)
16+
open import Data.List.Membership.Propositional using (_∉_)
1417
open import Data.List.Relation.Binary.Disjoint.Propositional
1518
using (Disjoint)
1619
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
@@ -35,6 +38,9 @@ open import Relation.Nullary.Negation using (¬_)
3538
private
3639
variable
3740
a b c p : Level
41+
A : Set a
42+
x y : A
43+
xs : List A
3844

3945
------------------------------------------------------------------------
4046
-- Introduction (⁺) and elimination (⁻) rules for list operations
@@ -154,3 +160,12 @@ module _ {A : Set a} {P : Pred _ p} (P? : Decidable P) where
154160

155161
filter⁺ : {xs} Unique xs Unique (filter P? xs)
156162
filter⁺ = Setoid.filter⁺ (setoid A) P?
163+
164+
------------------------------------------------------------------------
165+
-- ∷
166+
167+
Unique-dropSnd : Unique (x ∷ y ∷ xs) Unique (x ∷ xs)
168+
Unique-dropSnd = Setoid.Unique-dropSnd (setoid _)
169+
170+
Unique∷⇒head∉tail : Unique (x ∷ xs) x ∉ xs
171+
Unique∷⇒head∉tail = Setoid.Unique∷⇒head∉tail (setoid _)

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
module Data.List.Relation.Unary.Unique.Setoid.Properties where
1010

1111
open import Data.List.Base
12+
import Data.List.Membership.Setoid as Membership
1213
open import Data.List.Membership.Setoid.Properties
1314
open import Data.List.Relation.Binary.Disjoint.Setoid
1415
open import Data.List.Relation.Binary.Disjoint.Setoid.Properties
16+
open import Data.List.Relation.Unary.Any using (here; there)
1517
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
1618
open import Data.List.Relation.Unary.All.Properties using (All¬⇒¬Any)
17-
open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs)
19+
open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs; _∷_)
1820
open import Data.List.Relation.Unary.Unique.Setoid
1921
open import Data.Product.Base using (_×_; _,_; proj₁; proj₂)
2022
open import Data.Product.Relation.Binary.Pointwise.NonDependent using (_×ₛ_)
@@ -156,3 +158,21 @@ module _ (S : Setoid a ℓ) {P : Pred _ p} (P? : Decidable P) where
156158

157159
filter⁺ : {xs} Unique S xs Unique S (filter P? xs)
158160
filter⁺ = AllPairs.filter⁺ P?
161+
162+
------------------------------------------------------------------------
163+
-- ∷
164+
165+
module _ (S : Setoid a ℓ) where
166+
167+
open Setoid S renaming (Carrier to A)
168+
open Membership S using (_∈_; _∉_)
169+
170+
private variable x y : A; xs : List A
171+
172+
Unique-dropSnd : Unique S (x ∷ y ∷ xs) Unique S (x ∷ xs)
173+
Unique-dropSnd ((_ ∷ x∉) ∷ uniq) = x∉ AllPairs.∷ drop⁺ S 1 uniq
174+
175+
Unique∷⇒head∉tail : Unique S (x ∷ xs) x ∉ xs
176+
Unique∷⇒head∉tail uniq@((x∉ ∷ _) ∷ _) = λ where
177+
(here x≈) x∉ x≈
178+
(there x∈) Unique∷⇒head∉tail (Unique-dropSnd uniq) x∈

0 commit comments

Comments
 (0)