Created
March 13, 2011 05:05
-
-
Save kanak/867880 to your computer and use it in GitHub Desktop.
Solutions to exercises from Chapter 2 of "Discrete Mathematics Using a Computer"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chapter 02 Equational Reasoning | |
of Discrete Mathematics Using a Computer | |
-------------------------------------------------------------------------------- | |
Theorem 1 (length (++)) | |
Let xs, ys :: [a] be arbitrary lists. | |
Then length (xs ++ ys) = length xs + length ys | |
- Proof is by Induction, chapter 4 | |
-------------------------------------------------------------------------------- | |
Theorem 2 (length map) | |
Let xs :: [a] be an arbitray list and f :: a -> b be an arbitrary function. | |
Then, length (map f xs) = length xs | |
- No proof given | |
-------------------------------------------------------------------------------- | |
Theorem 3 (map ++) | |
Let xs, ys :: [a] be arbitrary lists | |
Let f :: a -> b be an arbitrary function | |
Then, map f (xs ++ ys) = (map f xs) ++ (map f ys) | |
-------------------------------------------------------------------------------- | |
Theorem 4 | |
For arbitrary lists xs, ys :: [a] | |
and arbitrary function f :: a -> b, | |
the equation length (map f (xs ++ ys)) = length xs + ys holds. | |
Proof: | |
length (map f (xs ++ ys)) = length (xs ++ ys) by Theorem (length map) | |
= length xs + length ys by Theorem (length (++)) | |
Alternative Proof | |
length (map f (xs ++ ys)) = length ((map f xs) ++ (map f ys)) by Theorem (map ++) | |
= length (map f xs) + length (map f ys) by Theorem (length ++) | |
= length xs + length ys by Theorem (length map) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment