Question: Give an inductive proof the fact that consecutively mapping two functions over a list is equivalent to mapping their composition over the list. That is:

Give an inductive proof the fact that consecutively mapping two functions over a list is equivalent to mapping their composition over the list. That is: map f (map g xs) map (f.g) xs The definitions of map and compose (.) are: Cl M1 M2 map f [] map f (x:xs) - f x : map f xs a) State and prove the base case goal b) State the inductive hypothesis c) State and prove the step case goal Now consider the following functions defined on lists over an arbitrary type a takew :: (a -> Bool) -> [a] -> [a] takew p 0-D takew p (x:xs) if (p x) then x: (takew p xs) else [] dropw :: (a-> Bool) -> [a] -> [a] dropvp [] = [] dropw p (x:xs) = if p x then (dropw p xs) else (x:xs) together with the append function and the standard equations for if [1 (x:xs) ++ ys = x : (xs ++ ys) -- A2 Show, using structural induction on lists, that the property A1 if True then p else _- Tp if False then-else q = q-12 ++ys =ys P(xs) = takew p xs ++ dropw p xs = xs holds for all lists xs and all functions p :: a -> Bool. In all proofs indicate the justification (eg, the line of a definition used) for each step. a) State and prove the base case of the proof of P. b) State the inductive hypotheses of the proof of P. c) State and prove the step case goal of the proof of P
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
