diff options
author | Camil Staps | 2015-03-18 10:27:23 +0100 |
---|---|---|
committer | Camil Staps | 2015-03-18 10:27:23 +0100 |
commit | 34b4a8162a94d30974432f5a4f40369c82c08b59 (patch) | |
tree | ddf875253d0239e5cedc228badbf1723cec8dfb5 /week6/camil/9.4.1 | |
parent | w6 camil (diff) |
Added comments
Diffstat (limited to 'week6/camil/9.4.1')
-rw-r--r-- | week6/camil/9.4.1 | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/week6/camil/9.4.1 b/week6/camil/9.4.1 index 0f279ca..d9b2608 100644 --- a/week6/camil/9.4.1 +++ b/week6/camil/9.4.1 @@ -2,10 +2,22 @@ Induction base: Suppose as = []. Then we have: - map f (as ++ bs) = map f ([] ++ bs) = map f bs = [] ++ (map f bs) = (map f []) ++ (map f bs) = (map f as) ++ (map f bs). + + map f (as ++ bs) // assumption as = [] + = map f ([] ++ bs) // definition of ++, rule 1 + = map f bs // definition of ++, rule 1 + = [] ++ (map f bs) // definition of map, rule 3 + = (map f []) ++ (map f bs) // assumption as = [] + = (map f as) ++ (map f bs). Induction step: - Suppose map f (as ++ bs) = (map f as) ++ (map f bs) for certain as and any bs. Then we have: - map f ([a:as] ++ bs) = map f [a:as ++ bs] = [f a : map f (as ++ bs)] = [f a : (map f as) ++ (map f bs)] = [f a : map f as] ++ (map f bs) = (map f [a:as]) ++ (map f bs). + Suppose map f (as ++ bs) = (map f as) ++ (map f bs) for certain as and any bs (induction hypothesis). Then we have: + + map f ([a:as] ++ bs) // definition of ++, rule 2 + = map f [a:as ++ bs] // definition of map, rule 4 + = [f a : map f (as ++ bs)] // induction hypothesis: assumption map f (as ++ bs) = (map f as) ++ (map f bs) + = [f a : (map f as) ++ (map f bs)] // rewriting list + = [f a : map f as] ++ (map f bs) // definition of map, rule 4 + = (map f [a:as]) ++ (map f bs). By the principle of induction we have now proven that map f (as ++ bs) = (map f as) ++ (map f bs) for any finite lists as, bs.
\ No newline at end of file |