| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Properties of fresh lists and functions acting on them |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.List.Fresh.Properties where |
| 10 |
|
| 11 |
open import Data.List.Fresh using (List#; _∷#_; _#_; Empty; NonEmpty; cons; []) |
| 12 |
open import Data.Product.Base using (_,_) |
| 13 |
open import Level using (Level; _⊔_) |
| 14 |
open import Relation.Nullary.Decidable using (Dec; yes; no) |
| 15 |
open import Relation.Nullary.Negation using (¬_) |
| 16 |
open import Relation.Unary as U using (Pred) |
| 17 |
import Relation.Binary.Definitions as B using (_Respectsˡ_; Irrelevant) |
| 18 |
open import Relation.Binary.Core using (Rel) |
| 19 |
|
| 20 |
|
| 21 |
private |
| 22 |
variable |
| 23 |
a b e p r : Level |
| 24 |
A : Set a |
| 25 |
B : Set b |
| 26 |
|
| 27 |
------------------------------------------------------------------------ |
| 28 |
-- Fresh congruence |
| 29 |
|
| 30 |
module _ {R : Rel A r} {_≈_ : Rel A e} (R≈ : R B.Respectsˡ _≈_) where |
| 31 |
|
| 32 |
fresh-respectsˡ : ∀ {x y} {xs : List# A R} → x ≈ y → x # xs → y # xs |
| 33 |
fresh-respectsˡ {xs = []} x≈y x#xs = _ |
| 34 |
fresh-respectsˡ {xs = x ∷# xs} x≈y (r , x#xs) = |
| 35 |
R≈ x≈y r , fresh-respectsˡ x≈y x#xs |
| 36 |
|
| 37 |
------------------------------------------------------------------------ |
| 38 |
-- Empty and NotEmpty |
| 39 |
|
| 40 |
Empty⇒¬NonEmpty : {R : Rel A r} {xs : List# A R} → Empty xs → ¬ (NonEmpty xs) |
| 41 |
Empty⇒¬NonEmpty [] () |
| 42 |
|
| 43 |
NonEmpty⇒¬Empty : {R : Rel A r} {xs : List# A R} → NonEmpty xs → ¬ (Empty xs) |
| 44 |
NonEmpty⇒¬Empty () [] |
| 45 |
|
| 46 |
empty? : {R : Rel A r} (xs : List# A R) → Dec (Empty xs) |
| 47 |
empty? [] = yes [] |
| 48 |
empty? (_ ∷# _) = no (λ ()) |
| 49 |
|
| 50 |
nonEmpty? : {R : Rel A r} (xs : List# A R) → Dec (NonEmpty xs) |
| 51 |
nonEmpty? [] = no (λ ()) |
| 52 |
nonEmpty? (cons x xs pr) = yes (cons x xs pr) |