{-# OPTIONS --cubical-compatible #-}
module Padova2025.ProvingBasics.Equality.Lists where
Results on lists#
open import Padova2025.ProgrammingBasics.Naturals.Base
open import Padova2025.ProgrammingBasics.Naturals.Arithmetic
open import Padova2025.ProgrammingBasics.Lists
open import Padova2025.ProvingBasics.Equality.Base
open import Padova2025.ProvingBasics.Equality.General
Exercise: Double reverse#
For the following exercise, note that reverse (x ∷ xs) is defined as
reverse xs ∷ʳ x.
Exercise 1
reverse-∷ʳreverse-∷ʳ : {A : Set} (ys : List A) (x : A) → reverse (ys ∷ʳ x) ≡ (x ∷ reverse ys)
reverse-∷ʳ = {!!}
Your solution
Exercise 2
reverse-reversereverse-reverse : {A : Set} (xs : List A) → reverse (reverse xs) ≡ xs
reverse-reverse = {!!}
Your solution
Exercise: Associativity of concatenation#
Exercise 3
++-assoc++-assoc : {A : Set} (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs)
++-assoc = {!!}
Your solution
Exercise: Length as a homomorphism#
Exercise 4
length-homolength-homo : {A : Set} (xs ys : List A) → length (xs ++ ys) ≡ length xs + length ys
length-homo = {!!}
Your solution
Exercise: Replication as a natural transformation#
Exercise 5
replicate-naturalreplicate-natural
: {A B : Set} (f : A → B) (n : ℕ) (x : A)
→ map f (replicate n x) ≡ replicate n (f x)
replicate-natural = {!!}
Your solution
Exercise: Replication and snocking#
The following lemma will prove useful in verifying that Markov’s principle fails in some mathematical universes.
Exercise 6
replicate-snocreplicate-snoc : {A : Set} (n : ℕ) (x : A) → x ∷ replicate n x ≡ replicate n x ∷ʳ x
replicate-snoc = {!!}
Your solution
Exercise: Snocking and concatenation#
Exercise 7
snoc-++snoc-++ : {A : Set} (a : A) (xs ys : List A) → (xs ∷ʳ a) ++ ys ≡ xs ++ (a ∷ ys)
snoc-++ = {!!}
Your solution
Exercise 8
++-snoc++-snoc : {A : Set} (a : A) (xs ys : List A) → xs ++ (ys ∷ʳ a) ≡ (xs ++ ys) ∷ʳ a
++-snoc = {!!}
Your solution
Exercise: Length after snocking#
Exercise 9
length-snoclength-snoc : {A : Set} (xs : List A) (y : A) → length (xs ∷ʳ y) ≡ succ (length xs)
length-snoc = {!!}
Your solution
Exercise: Empty list neutral for concatenation#
Exercise 10
++-[]++-[] : {A : Set} (xs : List A) → xs ++ [] ≡ xs
++-[] = {!!}
Your solution