Skip to content

Commit 99319e8

Browse files
Smarter trans for propositional permutations (#1117)
1 parent 563b575 commit 99319e8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,10 @@ Other minor additions
702702
deduplicate⁻ : Any P (deduplicate Q? xs) → Any P xs
703703
```
704704

705+
* The implementation of `↭-trans` has been altered in
706+
`Data.List.Relation.Binary.Permutation.Inductive` to avoid
707+
adding unnecessary `refl`s, hence improving it's performance.
708+
705709
* Added new functions to `Data.List.Relation.Binary.Permutation.Setoid`:
706710
```agda
707711
↭-prep : xs ↭ ys → x ∷ xs ↭ x ∷ ys

src/Data/List/Relation/Binary/Permutation/Propositional.agda

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ data _↭_ : Rel (List A) a where
4646
↭-sym (swap x y xs↭ys) = swap y x (↭-sym xs↭ys)
4747
↭-sym (trans xs↭ys ys↭zs) = trans (↭-sym ys↭zs) (↭-sym xs↭ys)
4848

49+
-- A smart version of trans that avoids unnecessary `refl`s (see #1113).
4950
↭-trans : Transitive _↭_
50-
↭-trans = trans
51+
↭-trans refl ρ₂ = ρ₂
52+
↭-trans ρ₁ refl = ρ₁
53+
↭-trans ρ₁ ρ₂ = trans ρ₁ ρ₂
5154

5255
↭-isEquivalence : IsEquivalence _↭_
5356
↭-isEquivalence = record
5457
{ refl = refl
5558
; sym = ↭-sym
56-
; trans = trans
59+
; trans = ↭-trans
5760
}
5861

5962
↭-setoid : Setoid _ _

0 commit comments

Comments
 (0)