<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Idempotence versus Referential Transparency</title>
	<atom:link href="http://blog.tmorris.net/idempotence-versus-referential-transparency/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/</link>
	<description>The weblog of Tony Morris</description>
	<pubDate>Tue, 06 Jan 2009 03:38:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Malcolm MacDonald</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-5555</link>
		<dc:creator>Malcolm MacDonald</dc:creator>
		<pubDate>Thu, 07 Aug 2008 22:14:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-5555</guid>
		<description>Does a "result" always have to be a return value?  For example I have applied idempotence in a batch process where the system will NOT reprocess transactions it has already processed.  So resubmitting a halted batch will not process transaction that have already processed, it will leave the state of those exactly as they were and continue processing when it reaches a transaction that has NOT previously been processed.  This makes troubleshooting a batch really easy, but is it real idempotence?</description>
		<content:encoded><![CDATA[<p>Does a &#8220;result&#8221; always have to be a return value?  For example I have applied idempotence in a batch process where the system will NOT reprocess transactions it has already processed.  So resubmitting a halted batch will not process transaction that have already processed, it will leave the state of those exactly as they were and continue processing when it reaches a transaction that has NOT previously been processed.  This makes troubleshooting a batch really easy, but is it real idempotence?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-4848</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 06 Aug 2008 04:14:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-4848</guid>
		<description>If you use a "strong computational idempotency" that also requires a consistent return value, which I guess is what many folks do use, then idempotency does imply transparency.

Strongly Computationally idempotent: y:= f() leaves same system state as {f(); y:= f()}, particularly,  both set the same value of y.

Under this defintion, computational idempotency entails referential transparency:

Experiment 1:
Startup Virtual Machine:
var y_0 := f();

Experiment 2:
Startup Virtual Machine:
var y_0 := f(); 
var y_1 := f();

By Idempotency: y_0 == y_1, which proves Referential Transparency.</description>
		<content:encoded><![CDATA[<p>If you use a &#8220;strong computational idempotency&#8221; that also requires a consistent return value, which I guess is what many folks do use, then idempotency does imply transparency.</p>
<p>Strongly Computationally idempotent: y:= f() leaves same system state as {f(); y:= f()}, particularly,  both set the same value of y.</p>
<p>Under this defintion, computational idempotency entails referential transparency:</p>
<p>Experiment 1:<br />
Startup Virtual Machine:<br />
var y_0 := f();</p>
<p>Experiment 2:<br />
Startup Virtual Machine:<br />
var y_0 := f();<br />
var y_1 := f();</p>
<p>By Idempotency: y_0 == y_1, which proves Referential Transparency.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-4844</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 06 Aug 2008 04:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-4844</guid>
		<description>I realize that your main point is that 
"referentially transparent" does not entail "idempotent"
but the converse does not hold either, for several common meanings of "idempotent",
"idempotent" does not entail "referentially transparent"

What are your definitions of "idempotent" and "referentially transparent"?

My definitions:
Mathematically idempotent:  f(f(x) == f(x) 
Computationally idempotent:  f() leaves same system state as {f(); f()}

Referentially transparent: f(x) == f(x)

Assuming some sort of non-referentially transparent random() function, here is a mathematically idempotent function that is not referentially transparent, in pseudocode:

Definitions:
function f(x) := if (x == 0) then  { if random() then {return 1} else {return 2}}   else {return x}
var y_0 := f(0)
var y_n := f(n)

F is idempotent:
f(y_0) == y_0   // always true, but y_0 could be either 1 or 2 each time the program runs.
f(y_n) == y_n == n  // always true, for any n != 0
  
but not referentially transparent:
f(0) == f(0)  -- maybe, maybe not.



Here's a computationally idempotent function that is not referentially transparent:
var x := 0;
function f :=  {y := x;  x := 1 ; return y; }

//Startup Virtual Machine
f();  // returns 0,  x is now 1
f();  // returns 1, but no state change: x is still 1</description>
		<content:encoded><![CDATA[<p>I realize that your main point is that<br />
&#8220;referentially transparent&#8221; does not entail &#8220;idempotent&#8221;<br />
but the converse does not hold either, for several common meanings of &#8220;idempotent&#8221;,<br />
&#8220;idempotent&#8221; does not entail &#8220;referentially transparent&#8221;</p>
<p>What are your definitions of &#8220;idempotent&#8221; and &#8220;referentially transparent&#8221;?</p>
<p>My definitions:<br />
Mathematically idempotent:  f(f(x) == f(x)<br />
Computationally idempotent:  f() leaves same system state as {f(); f()}</p>
<p>Referentially transparent: f(x) == f(x)</p>
<p>Assuming some sort of non-referentially transparent random() function, here is a mathematically idempotent function that is not referentially transparent, in pseudocode:</p>
<p>Definitions:<br />
function f(x) := if (x == 0) then  { if random() then {return 1} else {return 2}}   else {return x}<br />
var y_0 := f(0)<br />
var y_n := f(n)</p>
<p>F is idempotent:<br />
f(y_0) == y_0   // always true, but y_0 could be either 1 or 2 each time the program runs.<br />
f(y_n) == y_n == n  // always true, for any n != 0</p>
<p>but not referentially transparent:<br />
f(0) == f(0)  &#8212; maybe, maybe not.</p>
<p>Here&#8217;s a computationally idempotent function that is not referentially transparent:<br />
var x := 0;<br />
function f :=  {y := x;  x := 1 ; return y; }</p>
<p>//Startup Virtual Machine<br />
f();  // returns 0,  x is now 1<br />
f();  // returns 1, but no state change: x is still 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Porges</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1086</link>
		<dc:creator>Porges</dc:creator>
		<pubDate>Thu, 26 Jul 2007 05:13:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1086</guid>
		<description>More interesting examples are such things as stable sorting functions and their ilk.

As for Dave's point, these functions are (close to, exempting error conditions) idempotent, but have "hidden parameters"---such as the state of the network. The same goes for IntendedAudience's example---where the hidden parameter is the current time.

These hidden parameters can be made explicit in a functional programming language such as Haskell, where they form part of a structure such as a monad.</description>
		<content:encoded><![CDATA[<p>More interesting examples are such things as stable sorting functions and their ilk.</p>
<p>As for Dave&#8217;s point, these functions are (close to, exempting error conditions) idempotent, but have &#8220;hidden parameters&#8221;&#8212;such as the state of the network. The same goes for IntendedAudience&#8217;s example&#8212;where the hidden parameter is the current time.</p>
<p>These hidden parameters can be made explicit in a functional programming language such as Haskell, where they form part of a structure such as a monad.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Clarke</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1085</link>
		<dc:creator>Dave Clarke</dc:creator>
		<pubDate>Fri, 20 Jul 2007 10:00:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1085</guid>
		<description>You also need to consider a more general notion of idempotence, which is probably what some people are thinking of. Sure, you have the mathematical definition, f = f o f. But you also have the notion which is quite important in distributed programming: if a call a function, method, web-service, etc multiple times with the same arguements, then I get the same result. See the bottom of http://en.wikipedia.org/wiki/Idempotence for example.

I do agree that referential transparency and idempotence (either definition) are different. Your argument probably should have considered both definitions of idempotence, as that is where the confusion lies.

Furthermore, using the words necessarily and possibly does not mean you are using modal logic.</description>
		<content:encoded><![CDATA[<p>You also need to consider a more general notion of idempotence, which is probably what some people are thinking of. Sure, you have the mathematical definition, f = f o f. But you also have the notion which is quite important in distributed programming: if a call a function, method, web-service, etc multiple times with the same arguements, then I get the same result. See the bottom of <a href="http://en.wikipedia.org/wiki/Idempotence" onclick="javascript:pageTracker._trackPageview('/outbound/comment/en.wikipedia.org');" rel="nofollow">http://en.wikipedia.org/wiki/Idempotence</a> for example.</p>
<p>I do agree that referential transparency and idempotence (either definition) are different. Your argument probably should have considered both definitions of idempotence, as that is where the confusion lies.</p>
<p>Furthermore, using the words necessarily and possibly does not mean you are using modal logic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IntendedAudience</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1084</link>
		<dc:creator>IntendedAudience</dc:creator>
		<pubDate>Fri, 13 Jul 2007 16:09:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1084</guid>
		<description>I take it the date function is not idempotent?  Even though it has no side effects and its return value is independent of how many times it was called before?</description>
		<content:encoded><![CDATA[<p>I take it the date function is not idempotent?  Even though it has no side effects and its return value is independent of how many times it was called before?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Morris</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1083</link>
		<dc:creator>Tony Morris</dc:creator>
		<pubDate>Thu, 05 Jul 2007 22:24:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1083</guid>
		<description>Thanks augustss.
I considered making this note, but I wanted to keep it simple for the intended audience :)</description>
		<content:encoded><![CDATA[<p>Thanks augustss.<br />
I considered making this note, but I wanted to keep it simple for the intended audience <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: augustss</title>
		<link>http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1082</link>
		<dc:creator>augustss</dc:creator>
		<pubDate>Thu, 05 Jul 2007 08:52:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/idempotence-versus-referential-transparency/#comment-1082</guid>
		<description>Both your sample idempotent functions are identity functions, I just wanted to point out that there are other idempotent functions, like abs.</description>
		<content:encoded><![CDATA[<p>Both your sample idempotent functions are identity functions, I just wanted to point out that there are other idempotent functions, like abs.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
