Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:16:49+00:00 2026-05-15T20:16:49+00:00

I failed at reading RWH; and not one to quit, I ordered Haskell: The

  • 0

I failed at reading RWH; and not one to quit, I ordered Haskell: The Craft of Functional Programming. Now I’m curious about these functional proofs on page 146. Specifically I’m trying to prove 8.5.1 sum (reverse xs) = sum xs. I can do some of the induction proof but then I get stuck..

HYP:

sum ( reverse xs ) = sum xs

BASE:

sum ( reverse [] ) = sum []

Left  = sum ( [] ) (reverse.1)
      = 0          (sum.1)

Right = 0          (sum.1)

INDUCTION:

sum ( reverse (x:xs) ) = sum (x:xs) 

Left = sum ( reverse xs ++ [x] )    (reverse.2)

Right = sum (x:xs)   
      = x + sum xs                  (sum.2)

So now I’m just trying ot prove that Left sum ( reverse xs ++ [x] ) is equal to Right x + sum xs, but that isn’t too far off from where I started sum ( reverse (x:xs) ) = sum (x:xs).

I’m not quite sure why this needs to be proved, it seems totally reasonable to use the symbolic proof of reverse x:y:z = z:y:x (by defn), and because + is commutative (arth) then reverse 1+2+3 = 3+2+1,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:16:50+00:00Added an answer on May 15, 2026 at 8:16 pm
    sum (reverse [])     = sum []                     -- def reverse
    sum (reverse (x:xs)) = sum (reverse xs ++ [x])    -- def reverse
                         = sum (reverse xs) + sum [x] -- sum lemma below
                         = sum (reverse xs) + x       -- def sum
                         = x + sum (reverse xs)       -- commutativity assumption!
                         = x + sum xs                 -- inductive hypothesis
                         = sum (x:xs)                 -- definition of sum
    

    However, there are underlying assumptions of associativity and commutativity that are not strictly warranted and this will not work properly for a number of numerical types such as Float and Double where those assumptions are violated.

    Lemma: sum (xs ++ ys) == sum xs + sum ys given the associativity of (+)

    Proof:

    sum ([] ++ ys)     = sum ys           -- def (++)
                       = 0 + sum ys       -- identity of addition
                       = sum [] ++ sum ys -- def sum
    
    sum ((x:xs) ++ ys) = sum (x : (xs ++ ys))  -- def (++)
                       = x + sum (xs ++ ys)    -- def sum 
                       = x + (sum xs + sum ys) -- inductive hypothesis
                       = (x + sum xs) + sum ys -- associativity assumption!
                       = sum (x:xs) + sum ys   -- def sum
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a lot of modules on CPAN about reading/writing INI files, but every
what's wrong with my code? sorry about my bad English package sockettest; import java.io.*;
I am writing the program for reading contacts from android.when i am executing the
I tried to run a command by reading it from a textfile, but it
Thank you so much for reading this! I think the fix is relatively easy,
I would like to determine the type of a file (generally UTF-8) by reading
Ok so im having a bit of an issue here. basically Im reading shared
in the first, i try t install this software ztemtEVDO_1.1.8-0sue1_i386 but it's give this
I have written some code in C to read a binary file containing complex
I have looked all over the internet to find an answer to my problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.