@@ -35,28 +35,26 @@ isCons (x::xs) = True
3535-- Indexing into lists
3636--------------------------------------------------------------------------------
3737
38−%assert_total
3938head : (l : List a) -> (isCons l = True) -> a
40−head (x::xs) p = x
39+head [] refl impossible
40+head (x::xs) p = x
4141
4242head' : (l : List a) -> Maybe a
4343head' [] = Nothing
4444head' (x::xs) = Just x
4545
46−%assert_total
4746tail : (l : List a) -> (isCons l = True) -> List a
48−tail (x::xs) p = xs
47+tail [] refl impossible
48+tail (x::xs) p = xs
4949
5050tail' : (l : List a) -> Maybe (List a)
5151tail' [] = Nothing
5252tail' (x::xs) = Just xs
5353
54−%assert_total
5554last : (l : List a) -> (isCons l = True) -> a
56−last (x::xs) p =
57− case xs of
58− [] => x
59− y::ys => last (y::ys) ?lastProof
55+last [] refl impossible
56+last [x] p = x
57+last (x::y::ys) p = last (y::ys) refl
6058
6159last' : (l : List a) -> Maybe a
6260last' [] = Nothing
@@ -65,12 +63,10 @@ last' (x::xs) =
6563 [] => Just x
6664 y::ys => last' xs
6765
68−%assert_total
6966init : (l : List a) -> (isCons l = True) -> List a
70−init (x::xs) p =
71− case xs of
72− [] => []
73− y::ys => x :: init (y::ys) ?initProof
67+init [] refl impossible
68+init [x] p = []
69+init (x::y::ys) p = x :: init (y::ys) refl
7470
7571init' : (l : List a) -> Maybe (List a)
7672init' [] = Nothing
@@ -175,17 +171,21 @@ instance Functor List where
175171-- Zips and unzips
176172--------------------------------------------------------------------------------
177173
178−%assert_total
179174zipWith : (f : a -> b -> c) -> (l : List a) -> (r : List b) ->
180175 (length l = length r) -> List c
181−zipWith f [] [] p = []
182−zipWith f (x::xs) (y::ys) p = f x y :: (zipWith f xs ys ?zipWithTailProof)
176+zipWith f [] (y::ys) refl impossible
177+zipWith f (x::xs) [] refl impossible
178+zipWith f [] [] p = []
179+zipWith f (x::xs) (y::ys) p = f x y :: (zipWith f xs ys ?zipWithTailProof)
183180
184−%assert_total
185181zipWith3 : (f : a -> b -> c -> d) -> (x : List a) -> (y : List b) ->
186182 (z : List c) -> (length x = length y) -> (length y = length z) -> List d
187−zipWith3 f [] [] [] refl refl = []
188−zipWith3 f (x::xs) (y::ys) (z::zs) p q =
183+zipWith3 f _ [] (z::zs) p refl impossible
184+zipWith3 f _ (y::ys) [] p refl impossible
185+zipWith3 f [] (y::ys) _ refl q impossible
186+zipWith3 f (x::xs) [] _ refl q impossible
187+zipWith3 f [] [] [] p q = []
188+zipWith3 f (x::xs) (y::ys) (z::zs) p q =
189189 f x y z :: (zipWith3 f xs ys zs ?zipWith3TailProof ?zipWith3TailProof')
190190
191191zip : (l : List a) -> (r : List b) -> (length l = length r) -> List (a, b)
@@ -562,16 +562,6 @@ hasAnyByNilFalseStepCase = proof {
562562 trivial;
563563}
564564
565−initProof = proof {
566− intros;
567− trivial;
568−}
569−
570−lastProof = proof {
571− intros;
572− trivial;
573−}
574−
575565appendNilRightNeutralStepCase = proof {
576566 intros;
577567 rewrite inductiveHypothesis;