| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Decidability of the subset relation over setoid equality. |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Relation.Binary.Bundles using (DecSetoid) |
| 10 |
|
| 11 |
module Data.List.Relation.Binary.Subset.DecSetoid {c ℓ} (S : DecSetoid c ℓ) where |
| 12 |
|
| 13 |
open import Function.Base using (_∘_) |
| 14 |
open import Data.List.Base using ([]; _∷_) |
| 15 |
open import Data.List.Relation.Unary.Any using (here; there; map) |
| 16 |
open import Relation.Binary.Definitions using (Decidable) |
| 17 |
open import Relation.Nullary.Decidable.Core using (yes; no) |
| 18 |
|
| 19 |
open DecSetoid S using (setoid; refl; trans) |
| 20 |
open import Data.List.Membership.DecSetoid S using (_∈?_) |
| 21 |
|
| 22 |
-- Re-export definitions |
| 23 |
open import Data.List.Relation.Binary.Subset.Setoid setoid public |
| 24 |
|
| 25 |
infix 4 _⊆?_ |
| 26 |
_⊆?_ : Decidable _⊆_ |
| 27 |
[] ⊆? _ = yes λ () |
| 28 |
(x ∷ xs) ⊆? ys with x ∈? ys |
| 29 |
... | no x∉ys = no λ xs⊆ys → x∉ys (xs⊆ys (here refl)) |
| 30 |
... | yes x∈ys with xs ⊆? ys |
| 31 |
... | no xs⊈ys = no λ xs⊆ys → xs⊈ys (xs⊆ys ∘ there) |
| 32 |
... | yes xs⊆ys = yes λ where (here refl) → map (trans refl) x∈ys |
| 33 |
(there x∈) → xs⊆ys x∈ |