on master help sign in
Merge pull request #1210 from DanielWaterworth/vect_append_associative

Added a proof that (x ++ (y ++ z)) = ((x ++ y) ++ z) for Vects

commite4155420274af4576b769ba8f1090f26b97fb4e1 authorDavid Christiansen <david@davidchristiansen.dk> dateWed 7 May 2014, 23:28 (12 years ago) parentf97961409c8283
1 file changed+10−3
libs/prelude/Prelude/Vect.idr+10−3
libs/prelude/Prelude/Vect.idr+10−3
@@ -452,11 +452,18 @@ range {n=S _} = fZ :: map fS range
452452-- Properties
453453--------------------------------------------------------------------------------
454454
455+vectConsCong : (x : a) -> (xs : Vect n a) -> (ys : Vect m a) -> (xs = ys) -> (x :: xs = x :: ys)
456+vectConsCong x xs xs refl = refl
457+
455458vectNilRightNeutral : (xs : Vect n a) -> xs ++ [] = xs
456459vectNilRightNeutral [] = refl
457−vectNilRightNeutral (x :: xs) = tailCong _ _ (vectNilRightNeutral xs)
458− where tailCong : (xs : Vect n a) -> (ys : Vect m a) -> (xs = ys) -> (x :: xs = x :: ys)
459− tailCong xs xs refl = refl
460+vectNilRightNeutral (x :: xs) =
461+ vectConsCong _ _ _ (vectNilRightNeutral xs)
462+
463+vectAppendAssociative : (x : Vect xLen a) -> (y : Vect yLen a) -> (z : Vect zLen a) -> x ++ (y ++ z) = (x ++ y) ++ z
464+vectAppendAssociative [] y z = refl
465+vectAppendAssociative (x :: xs) ys zs =
466+ vectConsCong _ _ _ (vectAppendAssociative xs ys zs)
460467
461468
462469--------------------------------------------------------------------------------