2008/12/31  <span dir="ltr">&lt;<a href="mailto:raeck@msn.com">raeck@msn.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div style="padding-right: 10px; padding-left: 10px; padding-top: 15px;" name="Compose message area">
<div><font face="Calibri">Dear all,</font></div>
<div><font face="Calibri"></font>&nbsp;</div>
<div><font face="Calibri">Happy New Year!</font></div>
<div><font face="Calibri"></font>&nbsp;</div>
<div><font face="Calibri">I am learning the Induction Proof over Haskell, I saw 
some proofs for the equivalence of two functions will have a case called 
&#39;bottom&#39; but some of them do no have.&nbsp; What kind of situation&nbsp;we 
should also include the bottom case&nbsp;to the&nbsp;proof?&nbsp;How 
about&nbsp;the functions do not&nbsp;have the &#39;bottom&#39; input such 
as:</font></div>
<div><font face="Calibri"></font>&nbsp;</div>
<div><font face="Calibri">foo [] = []</font></div>
<div><font face="Calibri">foo (x:xs) = x : (foo xs)</font></div></div></blockquote><div><br>Okay, I&#39;m not sure what you mean by bottom.&nbsp; You could either mean the base case, or you could mean bottom -- non-terminating inputs -- as in domain theory.<br>
<br>Let&#39;s say you wanted to see if foo is equivalent to id.&nbsp; <br><br>id x = x<br><br>We can do it without considering nontermination, by induction on the structure of the argument:<br><br>&nbsp; First, the <i>base case</i>: empty lists.<br>
&nbsp;&nbsp;&nbsp; foo [] = []<br>&nbsp;&nbsp;&nbsp; id [] = []<br>&nbsp; Just by looking at the definitions of each.<br><br>&nbsp;Now the inductive case.&nbsp; Assume that foo xs = id xs, and show that foo (x:xs) = id (x:xs), for all x (but a fixed xs).<br><br>&nbsp;foo (x:xs) = x : foo xs<br>
&nbsp; foo xs = id xs&nbsp; by our&nbsp; the induction hypothesis, so <br>&nbsp; foo (x:xs) = x : id xs = x : xs<br>&nbsp;And then just by the definition of id:<br>&nbsp; id (x:xs) = x : xs<br><br>And we&#39;re done.<br><br>Now, maybe you meant bottom as in nontermination.&nbsp; In this case, we have to prove that they do the same thing when given _|_ also.&nbsp; This requires a deeper understanding of the semantics of the language, but can be done here.&nbsp;&nbsp; <br>
<br>First, by simple definition, id _|_ = _|_.&nbsp; Now let&#39;s consider foo _|_.&nbsp; The Haskell semantics say that pattern matching on _|_ yields _|_, so foo _|_ = _|_. So they are equivalent on _|_ also.&nbsp; Thus foo and id are exactly the same function.<br>
<br>See <a href="http://en.wikibooks.org/wiki/Haskell/Denotational_semantics">http://en.wikibooks.org/wiki/Haskell/Denotational_semantics</a> for more about _|_.<br><br>Happy mathhacking,<br>Luke<br></div></div>