Last active
June 13, 2023 18:35
-
-
Save ice1000/4a3c83ba5e9e9c1dfa10f7fade8d26fa to your computer and use it in GitHub Desktop.
A question from a groupchat
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
{-# OPTIONS --cubical #-} | |
open import Cubical.Data.Vec | |
open import Cubical.Data.Nat.Base | |
open import Cubical.Data.Equality hiding (map) | |
variable | |
A : Type | |
B : Type | |
n : ℕ | |
insVec : A → Vec A n → Vec A (doubleℕ n) | |
insVec a [] = [] | |
insVec a (x ∷ xs) = a ∷ x ∷ insVec a xs | |
intersperse : A → Vec A n → Vec A (predℕ (doubleℕ n)) | |
intersperse a [] = [] | |
intersperse {n = n} a xs@(x ∷ _) = tail (insVec a xs) | |
lem : {f : A → B} {a : A} (xs : Vec A n) → | |
map f (insVec a xs) ≡ insVec (f a) (map f xs) | |
lem [] = refl | |
lem {f = f} {a = a} (x ∷ xs) = ap (f a ∷_) (ap (_ ∷_) (lem xs)) | |
thm : {f : A → B} {a : A} (xs : Vec A n) → | |
map f (intersperse a xs) ≡ intersperse (f a) (map f xs) | |
thm [] = refl | |
thm (x ∷ xs) = ap (_ ∷_) (lem xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment