Last active
August 4, 2022 21:30
-
-
Save rybla/0a6e390a0288956f199deb7881e95653 to your computer and use it in GitHub Desktop.
transpose and identity of vector-matrices in Agda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open import Data.Nat | |
data Vec : ℕ → Set → Set where | |
nil : ∀ {A} → Vec 0 A | |
cons : ∀ {A n} → A → Vec n A → Vec (suc n) A | |
record Traversable (F : Set → Set) : Set1 where | |
field | |
traverse : ∀ {S T : Set} {G : Set → Set} → (S → G T) → F S → G (F T) | |
open Traversable | |
postulate | |
TraversableVec : ∀ {n} → Traversable (Vec n) | |
TraversableId : Traversable (λ x → x) | |
TraversableComp : ∀ {F G} → Traversable F → Traversable G → Traversable λ x → F (G x) | |
idm : ∀ {T m n} → Vec n (Vec m T) → Vec n (Vec m T) | |
idm {T} {m} {n} v = | |
traverse | |
(TraversableComp | |
-- {λ T → T} {λ T → Vec n (Vec m T)} | |
TraversableId | |
(TraversableComp TraversableVec TraversableVec)) | |
{T} {T} {λ x → x} | |
(λ x → x) v | |
trans : ∀ {T m n} → Vec n (Vec m T) → Vec m (Vec n T) | |
trans {T} {m} {n} v = traverse TraversableVec {Vec _ T} {_} {G = λ T → Vec m T} (λ x → x) v | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment