Created
June 13, 2023 18:37
-
-
Save ice1000/0012296f7d2fe9d5422507af5ac78307 to your computer and use it in GitHub Desktop.
A question from a groupchat
This file contains 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.List | |
open import Cubical.Data.Nat.Base | |
open import Cubical.Data.Equality hiding (map) | |
variable | |
A : Type | |
B : Type | |
n : ℕ | |
insVec : A → List A → List A | |
insVec a [] = [] | |
insVec a (x ∷ xs) = a ∷ x ∷ insVec a xs | |
dropHead : List A → List A | |
dropHead [] = [] | |
dropHead (x ∷ xs) = xs | |
intersperse : A → List A → List A | |
intersperse a xs = dropHead (insVec a xs) | |
lem : {f : A → B} {a : A} (xs : List A) → | |
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 : List A) → | |
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