[Haskell-beginners] Simple function comparison

Francesco Ariis fa-ml at ariis.it
Wed Nov 25 16:22:50 UTC 2015


On Wed, Nov 25, 2015 at 03:48:08PM +0000, MJ Williams wrote:
> [snip]
> 
> >I don't think there is a way to /prove/ f (g a) == g (f a) if their domain
> >is not finite inside Haskell (you could do it with pen and paper).
> [snip]
>         Just out of interest, could you demonstrate the proof without a
> finite domain?
> 
> Sincerely, Matthew

Say we have:

    f(x) = x + 1
    g(x) = x + 7

Then we can substitute:

    f(g(x))
    f(x+7)
    (x+7) + 1
    x+8

and

    g(f(x))
    g(x+1)
    (x+1) + 7
    x+8

which shows f(g(x)) = g(f(x))

For anything more, my lawyer suggested I say: I have discovered a
truly marvellous proof for it, but the margin of this email is to
narrow to contain it. :P



More information about the Beginners mailing list