3 | module Data.List1.Properties
5 | import Control.Function
7 | import public Data.Maybe
15 | consInjective : (x ::: xs) === (y ::: ys) -> (x === y, xs === ys)
16 | consInjective Refl = (Refl, Refl)
19 | Biinjective (:::) where
20 | biinjective Refl = (Refl, Refl)
23 | {x : a} -> Injective (x :::) where
24 | injective Refl = Refl
27 | {ys : List a} -> Injective (::: ys) where
28 | injective Refl = Refl
33 | listLength : (xs : List1 a) -> length xs = length (forget xs)
34 | listLength (head ::: tail) = Refl
40 | appendlNilRightNeutral : (l : List1 a) -> l `appendl` [] = l
41 | appendlNilRightNeutral (_:::xs) = rewrite appendNilRightNeutral xs in Refl
44 | lappendNilLeftNeutral : (l : List1 a) -> [] `lappend` l = l
45 | lappendNilLeftNeutral l = Refl
48 | appendAssociative : (l, c, r : List1 a) -> l ++ (c ++ r) = (l ++ c) ++ r
49 | appendAssociative (l:::ls) (c:::cs) (r:::rs) = rewrite appendAssociative ls (c::cs) (r::rs) in Refl
52 | toListAppendl : (xs : List1 a) -> (ys : List a) -> toList (xs `appendl` ys) = forget xs ++ ys
53 | toListAppendl (x:::xs) ys = Refl
56 | toListLappend : (xs : List a) -> (ys : List1 a) -> toList (xs `lappend` ys) = xs ++ forget ys
57 | toListLappend [] ys = Refl
58 | toListLappend (x::xs) ys = Refl
61 | toListAppend : (xs, ys : List1 a) -> toList (xs ++ ys) = toList xs ++ toList ys
62 | toListAppend (x:::xs) (y:::ys) = Refl
65 | fromListAppend : (xs, ys : List a) -> fromList (xs ++ ys) = (fromList xs <+> fromList ys) @{Deep}
66 | fromListAppend [] ys with (fromList ys)
69 | fromListAppend (x::xs) ys with (fromList ys) proof prf
70 | fromListAppend (x::xs) [] | Nothing = rewrite appendNilRightNeutral xs in Refl
71 | fromListAppend (x::xs) (y::ys) | (Just $
l:::ls) =
72 | let (Refl, Refl) = biinjective $
injective prf in Refl