I donβt quite understand how to read the component (init (x β· xs) | (initLast (x β· xs) | initLast xs)) . I suppose my questions; it is possible how and what this term does mean.
This suggests that the value of init (x β· xs) depends on the value of everything that is to the right of | . When you prove something in a function in Agda, your proof will have to have the structure of the original definition.
In this case, you must specify the result of initLast , because the definition of initLast does this before any results are obtained.
init : β {an} {A : Set a} β Vec A (1 + n) β Vec A n init xs with initLast xs -- β§ The first thing this definition does is case on this value init .(ys β·Κ³ y) | (ys , y , refl) = ys
So this is how we write the lemma.
module inithead where open import Data.Nat open import Data.Product open import Data.Vec open import Relation.Binary.PropositionalEquality lem-headInit : {A : Set} {n : β} (xs : Vec A (2 + n)) β head (init xs) β‘ head xs lem-headInit (x β· xs) with initLast xs lem-headInit (x β· .(ys β·Κ³ y)) | ys , y , refl = refl
I made a commitment to generalize your lemma to Vec A , since the lemma is independent of the contents of the vector.
glguy Nov 07 2018-10-11T00: 00Z
source share