Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago