Skip to content

Added tabulate+< #2190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ New modules

Additions to existing modules
-----------------------------

* In `Data.List.Relation.Unary.AllPairs.Properties`:
```
tabulate⁺-< : (i < j → R (f i) (f j)) → AllPairs R (tabulate f)
```
18 changes: 11 additions & 7 deletions src/Data/List/Relation/Unary/AllPairs/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
import Data.List.Relation.Unary.All.Properties as All
open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs; []; _∷_)
open import Data.Bool.Base using (true; false)
open import Data.Fin.Base using (Fin)
open import Data.Fin.Properties using (suc-injective)
open import Data.Nat.Base using (zero; suc; _<_; z≤n; s≤s)
open import Data.Fin.Base as F using (Fin)
open import Data.Fin.Properties using (suc-injective; <⇒≢)
open import Data.Nat.Base using (zero; suc; _<_; z≤n; s≤s; z<s; s<s)
open import Data.Nat.Properties using (≤-refl; m<n⇒m<1+n)
open import Function.Base using (_∘_; flip)
open import Level using (Level)
Expand Down Expand Up @@ -115,12 +115,16 @@ module _ {R : Rel A ℓ} where

module _ {R : Rel A ℓ} where

tabulate⁺-< : ∀ {n} {f : Fin n → A} → (∀ {i j} → i F.< j → R (f i) (f j)) →
AllPairs R (tabulate f)
tabulate⁺-< {zero} fᵢ~fⱼ = []
tabulate⁺-< {suc n} fᵢ~fⱼ =
All.tabulate⁺ (λ _ → fᵢ~fⱼ z<s) ∷
tabulate⁺-< (fᵢ~fⱼ ∘ s<s)

tabulate⁺ : ∀ {n} {f : Fin n → A} → (∀ {i j} → i ≢ j → R (f i) (f j)) →
AllPairs R (tabulate f)
tabulate⁺ {zero} fᵢ~fⱼ = []
tabulate⁺ {suc n} fᵢ~fⱼ =
All.tabulate⁺ (λ j → fᵢ~fⱼ λ()) ∷
tabulate⁺ (fᵢ~fⱼ ∘ (_∘ suc-injective))
tabulate⁺ fᵢ~fⱼ = tabulate⁺-< (fᵢ~fⱼ ∘ <⇒≢)

------------------------------------------------------------------------
-- filter
Expand Down