@@ -26,7 +26,7 @@ open import Data.Product.Base using (_,_; _×_; ∃; ∃₂)
26
26
open import Data.Maybe.Base using (Maybe; just; nothing)
27
27
open import Function.Base using (_∘_; _⟨_⟩_; _$_)
28
28
open import Level using (Level)
29
- open import Relation.Unary using (Pred)
29
+ open import Relation.Unary as Pred using (Pred)
30
30
open import Relation.Binary.Core using (Rel; _Preserves_⟶_; _Preserves₂_⟶_⟶_)
31
31
open import Relation.Binary.Definitions using (_Respects_; Decidable)
32
32
open import Relation.Binary.PropositionalEquality.Core as ≡
@@ -372,6 +372,21 @@ module _ {ℓ} {R : Rel A ℓ} (R? : Decidable R) where
372
372
x ∷ xs ++ y ∷ ys ∎
373
373
where open PermutationReasoning
374
374
375
+ ------------------------------------------------------------------------
376
+ -- filter
377
+
378
+ filter-↭ : ∀ {p} {P : Pred A p} (P? : Pred.Decidable P) → xs ↭ ys → filter P? xs ↭ filter P? ys
379
+ filter-↭ P? refl = refl
380
+ filter-↭ P? (prep x xs↭ys) with P? x
381
+ ... | yes _ = prep x (filter-↭ P? xs↭ys)
382
+ ... | no _ = filter-↭ P? xs↭ys
383
+ filter-↭ P? (swap x y xs↭ys) with P? x in eqˣ | P? y in eqʸ
384
+ ... | yes _ | yes _ rewrite eqˣ rewrite eqʸ = swap x y (filter-↭ P? xs↭ys)
385
+ ... | yes _ | no _ rewrite eqˣ rewrite eqʸ = prep x (filter-↭ P? xs↭ys)
386
+ ... | no _ | yes _ rewrite eqˣ rewrite eqʸ = prep y (filter-↭ P? xs↭ys)
387
+ ... | no _ | no _ rewrite eqˣ rewrite eqʸ = filter-↭ P? xs↭ys
388
+ filter-↭ P? (trans xs↭ys ys↭zs) = ↭-trans (filter-↭ P? xs↭ys) (filter-↭ P? ys↭zs)
389
+
375
390
------------------------------------------------------------------------
376
391
-- catMaybes
377
392
0 commit comments