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

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: map f [l map f (x:xs) = f x : map f xs M1 M2 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] -> [aj] takew p takew p (x:xs) = if (p x) then x: (takew p xs) else [] dropw :: (a-> Bool) -> [a] -> [a] dropw p [00 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 A1 if True then p else _-p -- I1 if False then _ else q-q I2 ++ ys = ys (x:xs) ++ ys- x : (xs ++ ys) -- A2 Show, using structural induction on lists, that the property 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!