Debian Codegraph @

src/Data/List/Relation/Ternary/Interleaving/Setoid/Properties.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Properties of interleaving using setoid equality
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Relation.Binary.Bundles using (Setoid)
10
11 module Data.List.Relation.Ternary.Interleaving.Setoid.Properties
12 {c ℓ} (S : Setoid c ℓ) where
13
14 open import Data.List.Base using (List; []; _∷_; filter; _++_)
15 open import Data.Bool.Base using (true; false)
16 open import Relation.Unary using (Decidable)
17 open import Relation.Nullary.Decidable using (does)
18 open import Relation.Nullary.Decidable using (¬?)
19 open import Function.Base using (_∘_)
20
21 open import Data.List.Relation.Binary.Equality.Setoid S using (≋-refl)
22 open import Data.List.Relation.Ternary.Interleaving.Setoid S
23 open Setoid S renaming (Carrier to A)
24
25 ------------------------------------------------------------------------
26 -- Re-exporting existing properties
27
28 open import Data.List.Relation.Ternary.Interleaving.Properties public
29
30 ------------------------------------------------------------------------
31 -- _++_
32
33 ++-linear : (xs ys : List A) → Interleaving xs ys (xs ++ ys)
34 ++-linear xs ys = ++-disjoint (left ≋-refl) (right ≋-refl)
35
36 ------------------------------------------------------------------------
37 -- filter
38
39 module _ {p} {P : A → Set p} (P? : Decidable P) where
40
41 filter⁺ : ∀ xs → Interleaving (filter P? xs) (filter (¬? ∘ P?) xs) xs
42 filter⁺ [] = []
43 filter⁺ (x ∷ xs) with does (P? x)
44 ... | true = refl ∷ˡ filter⁺ xs
45 ... | false = refl ∷ʳ filter⁺ xs