-- module Demo where open import Relation.Binary.PropositionalEquality -- NATURAL NUMBERS data ℕ : Set where zero : ℕ succ : ℕ → ℕ -- Addition _+_ : ℕ → ℕ → ℕ zero + b = b succ a + b = succ (a + b) -- BOOLEANS data Bool : Set where true : Bool false : Bool -- Negation ¬ : Bool → Bool ¬ true = false ¬ false = true -- Proof not-not : (b : Bool) → ¬(¬ b) ≡ b not-not true = refl not-not false = refl -- ******* -- -- LIST data List (A : Set) : Set where [] : List A _::_ : A → List A → List A {-# BUILTIN NATURAL ℕ #-} infixr 5 _::_ example = 1 :: 2 :: [] -- Concatenation _++_ : {A : Set} → List A → List A → List A [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) -- Define length function for lists length : {A : Set} → List A → ℕ length [] = 0 length (x :: xs) = 1 + length xs -- Proof -- length (xs ++ ys) ≡ length xs + length ys length-concat : {A : Set} (xs ys : List A) → length (xs ++ ys) ≡ length xs + length ys length-concat [] ys = {! !} length-concat (x :: xs) ys = cong succ (length-concat xs ys) -- VECTOR data Vec (A : Set) : ℕ → Set where [] : Vec A 0 _::_ : {n : ℕ} → A → Vec A n → Vec A (1 + n) -- Head head : {A : Set} {n : ℕ} -> Vec A (1 + n) -> A head (x :: xs) = x