Question: Now consider the following functions defined on lists over an arbitrary type a takew : (a -> Bool) -> [a] -> [aj] takew p (x:xs)

 Now consider the following functions defined on lists over an arbitrary

Now consider the following functions defined on lists over an arbitrary type a takew : (a -> Bool) -> [a] -> [aj] takew p (x:xs) = if (p x) then x: (takew p xs) else [] dropw (a ->Bool) -> [a] -> [a] 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 Cl (x:xs) if True then p else-= p-11 if False then _ else q-q I2 A1 ++ ys ++ ys = 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. Now consider the following functions defined on lists over an arbitrary type a takew : (a -> Bool) -> [a] -> [aj] takew p (x:xs) = if (p x) then x: (takew p xs) else [] dropw (a ->Bool) -> [a] -> [a] 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 Cl (x:xs) if True then p else-= p-11 if False then _ else q-q I2 A1 ++ ys ++ ys = 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!