on-internet
← Community

Agda: proof about `Vec` `last` using `with`

Stack Overflow ·

I'm trying to prove the following statement vecNat : ∀ {n} (xs : Vec ℕ n) → last (xs ∷ʳ 1) ≡ 1 But I get confused the (x ∷ xs) case. vecNat5 : ∀ {n} (xs : Vec ℕ n) → last (xs ∷ʳ 1) ≡ 1 vecNat5 [] = refl vecNat5 (x ∷ xs) = {! 0!} The goal is ?0 : last ((x ∷ xs) ∷ʳ 1) ≡ 1 I first tried this using begin vecNat5 : ∀ {n} (xs : Vec ℕ n) → last (xs ∷ʳ 1) ≡ 1 vecNat5 [] = refl vecNat5 (x ∷ xs) = begin last ((x ∷ xs) ∷ʳ 1) ≡⟨⟩ 1 ∎ but then got this error: 1 != (last (x ∷ (xs ∷ʳ 1)) | (initLast (x ∷ (xs ∷ʳ 1)) | initLast (xs ∷ʳ 1))) of type ℕ when checking that the expression 1 ∎ has type last ((x ∷ xs)

Comments

Sign in or sign up to comment and upvote.

No comments yet.