I have started learning Haskell from Introduction to FP using Haskell by Richard Bird, but I am stuck in proving the following:
pair (f, g) . h = pair (f . h, g . h)
The definitions of pair is the following:
pair :: (a -> b, a -> c) -> a -> (b, c)
pair (f, g) x = (f x, g x)
Could someone point me in the right direction? Please keep in mind that I am only at the beginning. Thanks in advance!
One way is to expand all definitions. Remember that f . g = \x -> f (g x) and f a b = ... is the same as f a = \b -> ....
So you can try to expand definitions of pair and . in pair (f, g) . h = pair (f . h, g . h)
You can use extensionality, i.e., if two functions give the same result when acting on any x, then they are considered the same (as pure functions - they may have different code and hence different time/space usage).
So in this case, you could take the equality you're trying to prove, act with each side on some x of the appropriate type, and show you obtain the same result in both cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With