Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ Additions to existing modules
product≢0 : All NonZero ns → NonZero (product ns)
∈⇒≤product : All NonZero ns → n ∈ ns → n ≤ product ns
concatMap-++ : concatMap f (xs ++ ys) ≡ concatMap f xs ++ concatMap f ys
filter-≐ : P ≐ Q → filter P? ≗ filter Q?
```

* In `Data.List.Relation.Unary.Any.Properties`:
Expand Down
14 changes: 11 additions & 3 deletions src/Data/List/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ open import Relation.Binary.PropositionalEquality.Properties as ≡
open import Relation.Binary.Core using (Rel)
open import Relation.Nullary.Reflects using (invert)
open import Relation.Nullary using (¬_; Dec; does; _because_; yes; no; contradiction)
open import Relation.Nullary.Decidable as Decidable using (isYes; map′; ⌊_⌋; ¬?; _×-dec_)
open import Relation.Unary using (Pred; Decidable; ∁)
open import Relation.Nullary.Decidable as Decidable using (isYes; map′; ⌊_⌋; ¬?; _×-dec_; dec-true; dec-false)
open import Relation.Unary using (Pred; Decidable; ∁; _≐_)
open import Relation.Unary.Properties using (∁?)
import Data.Nat.GeneralisedArithmetic as ℕ

open ≡-Reasoning

private
variable
a b c d e p ℓ : Level
a b c d e p q ℓ : Level
A : Set a
B : Set b
C : Set c
Expand Down Expand Up @@ -1236,6 +1236,14 @@ module _ {P : Pred A p} (P? : Decidable P) where
... | true = cong (x ∷_) ih
... | false = ih

module _ {P : Pred A p} {Q : Pred A q} (P? : Decidable P) (Q? : Decidable Q) where

filter-≐ : P ≐ Q → filter P? ≗ filter Q?
filter-≐ P≐Q [] = refl
filter-≐ P≐Q (x ∷ xs) with P? x
... | yes P[x] rewrite dec-true (Q? x) (proj₁ P≐Q P[x]) = cong (x ∷_) (filter-≐ P≐Q xs)
... | no ¬P[x] rewrite dec-false (Q? x) (¬P[x] ∘ proj₂ P≐Q) = filter-≐ P≐Q xs

------------------------------------------------------------------------
-- derun and deduplicate

Expand Down