diff options
| author | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2025-10-28 17:20:33 -0500 |
|---|---|---|
| committer | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2025-10-28 17:20:33 -0500 |
| commit | 0bf55c23ad3bee621d0e7425f5a5e875254e3450 (patch) | |
| tree | ea5dbac95aa1fa9449b785cb5be3078790a88aea /Data/Permutation | |
| parent | 2cd74f160389fe2ab2b30ab628fbb9b712f06faf (diff) | |
| parent | 2439066ad6901ed1e083f48fb7ac4fd7a7840d27 (diff) | |
Merge branch 'hypergraph-conversion'
Diffstat (limited to 'Data/Permutation')
| -rw-r--r-- | Data/Permutation/Sort.agda | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Data/Permutation/Sort.agda b/Data/Permutation/Sort.agda new file mode 100644 index 0000000..8d097f2 --- /dev/null +++ b/Data/Permutation/Sort.agda @@ -0,0 +1,29 @@ +{-# OPTIONS --without-K --safe #-} + +open import Relation.Binary.Bundles using (DecTotalOrder) + +module Data.Permutation.Sort {ℓ₁ ℓ₂ ℓ₃} (dto : DecTotalOrder ℓ₁ ℓ₂ ℓ₃) where + +open DecTotalOrder dto using (module Eq; totalOrder) renaming (Carrier to A) + +open import Data.List.Base using (List) +open import Data.List.Relation.Binary.Equality.Setoid Eq.setoid using (_≋_) +open import Data.List.Relation.Binary.Permutation.Setoid Eq.setoid using (_↭_; module PermutationReasoning) +open import Data.List.Relation.Unary.Sorted.TotalOrder.Properties using (↗↭↗⇒≋) +open import Data.List.Sort dto using (sortingAlgorithm) +open import Data.List.Sort.Base totalOrder using (SortingAlgorithm) +open SortingAlgorithm sortingAlgorithm using (sort; sort-↭ₛ; sort-↗) + +sorted-≋ + : {xs ys : List A} + → xs ↭ ys + → sort xs ≋ sort ys +sorted-≋ {xs} {ys} xs↭ys = ↗↭↗⇒≋ totalOrder (sort-↗ xs) (sort-↗ ys) sort-xs↭sort-ys + where + open PermutationReasoning + sort-xs↭sort-ys : sort xs ↭ sort ys + sort-xs↭sort-ys = begin + sort xs ↭⟨ sort-↭ₛ xs ⟩ + xs ↭⟨ xs↭ys ⟩ + ys ↭⟨ sort-↭ₛ ys ⟨ + sort ys ∎ |
