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

  • SEARCH
  • Home
  • 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

I have tried to do some reading about it, but I failed to find
Failed to load database information. Details: The database DLL crdb_ado.dll could not be loaded.
BizTalk Server complains from time to time: Reading error. Failed to recover from previous
I am reading through LYAH, and in Chapter 9, I found a curious problem.
I am reading GNU/Linux application programming the 2nd edition ,you can reach what am
While reading Programming Ruby , I ran across this code snippet: while gets num1,
I was reading here about problems in PHP when using include() or required() with
I'm reading a rss feed and I get an image url and now I
I'm reading a binary file and storing each record into a byte[] . Now
Reading TDPL about function and delegate literals (5.6.1) auto f = (int i) {};

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.