| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Decidability of the disjoint 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.Disjoint.DecSetoid {c ℓ} (S : DecSetoid c ℓ) where |
| 12 |
|
| 13 |
open import Data.Product.Base using (_,_) |
| 14 |
open import Data.List.Relation.Unary.Any using (map) |
| 15 |
open import Data.List.Relation.Unary.All using (all?; lookupₛ) |
| 16 |
open import Data.List.Relation.Unary.All.Properties using (¬All⇒Any¬) |
| 17 |
open import Relation.Binary.Definitions using (Decidable) |
| 18 |
open import Relation.Nullary using (yes; no; decidable-stable) |
| 19 |
open DecSetoid S |
| 20 |
open import Data.List.Relation.Binary.Equality.DecSetoid S |
| 21 |
open import Data.List.Relation.Binary.Disjoint.Setoid setoid public |
| 22 |
open import Data.List.Membership.DecSetoid S |
| 23 |
|
| 24 |
disjoint? : Decidable Disjoint |
| 25 |
disjoint? xs ys with all? (_∉? ys) xs |
| 26 |
... | yes xs♯ys = yes λ (v∈ , v∈′) → |
| 27 |
lookupₛ setoid (λ x≈y ∉ys ∈ys → ∉ys (map (trans x≈y) ∈ys)) xs♯ys v∈ v∈′ |
| 28 |
... | no ¬xs♯ys = let (x , x∈ , ¬∉ys) = find (¬All⇒Any¬ (_∉? _) _ ¬xs♯ys) in |
| 29 |
no λ p → p (x∈ , decidable-stable (_ ∈? _) ¬∉ys) |