<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mathematics and Computation</title>
	<atom:link href="http://math.andrej.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://math.andrej.com</link>
	<description>Mathematics for computers</description>
	<lastBuildDate>Thu, 29 Jul 2010 13:18:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>An amazing functional</title>
		<link>http://math.andrej.com/2010/07/29/an-amazing-functional/</link>
		<comments>http://math.andrej.com/2010/07/29/an-amazing-functional/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 12:37:54 +0000</pubDate>
		<dc:creator>Andrej Bauer</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://math.andrej.com/?p=532</guid>
		<description><![CDATA[<p>Martín Escardó and Paolo Oliva have been working on the selection monad and related functionals. The selection monad `S(X) = (X -&#62; R) -&#62; X` is a cousin of the continuation monad `C(X) = (X -&#62; R) -&#62; R` and it has a lot of useful and surprising applications. I recommend their recent paper &#8220;What [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cs.bham.ac.uk/~mhe/">Martín Escardó</a> and <a href="http://www.dcs.qmul.ac.uk/~pbo/">Paolo Oliva</a> have been working on the <em>selection monad</em> and related functionals. The selection monad `S(X) = (X -&gt; R) -&gt; X` is a cousin of the continuation monad `C(X) = (X -&gt; R) -&gt; R` and it has a lot of useful and surprising applications. I recommend their recent paper <em><a href="http://www.cs.bham.ac.uk/~mhe/papers/msfp2010/">&#8220;What Sequential Games, the Tychonoff Theorem and the Double-Negation Shift have in Common&#8221;</a></em> which they wrote for <a href="http://cs.ioc.ee/msfp/msfp2010/">MSFP 2010</a> (if you visit the workshop you get to hear Martín live). They explain things via examples written in Haskell, starting off with the innocently looking functional `ox` (which i I am writting as <code>ox</code> in Haskell for &#8220;crossed O&#8221;):</p>
<blockquote>
<pre>ox :: [(x -> r) -> x] -> ([x] -> r) -> [x]
ox [] p = []
ox (e : es) p = a : ox es (p . (a:))
   where a = e (\x -> p (x : ox es (p . (x:))))</pre>
</blockquote>
<p>It is just four lines of code, so how complicated could it be? Well, read the paper to find out. If you are ready for serious math, have a look at <a href="http://www.cs.bham.ac.uk/~mhe/papers/selection-escardo-oliva.pdf">this paper</a> instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://math.andrej.com/2010/07/29/an-amazing-functional/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hardware failure and phishing attacks</title>
		<link>http://math.andrej.com/2010/05/04/hardware-failure-and-phishing-attacks/</link>
		<comments>http://math.andrej.com/2010/05/04/hardware-failure-and-phishing-attacks/#comments</comments>
		<pubDate>Tue, 04 May 2010 12:57:28 +0000</pubDate>
		<dc:creator>Andrej Bauer</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Off topic]]></category>

		<guid isPermaLink="false">http://math.andrej.com/?p=514</guid>
		<description><![CDATA[<p>After more than 1300 days of uninterrupted service, the good old PC that served the blog started to spontaneously reboot every 4 minutes or so. It looks like a hardware failure. I moved the site to a temporary machine. I am seriously considering renting a private virtual server and just forget about buying my own [...]]]></description>
			<content:encoded><![CDATA[<p>After more than 1300 days of uninterrupted service, the good old PC that served the blog started to spontaneously reboot every 4 minutes or so. It looks like a hardware failure. I moved the site to a temporary machine. I am seriously considering renting a private virtual server and just forget about buying my own hardware in the future.</p>
<p>On top of that I discovered that evil forces planted a phishing attack on the blog about two weeks ago. The strategy was this:</p>
<ol>
<li>Create an account on my blog (I stupidly left registration open to everyone).</li>
<li>Elevate account privileges to administrator by exploiting a Wordpress security hole (I do not know which one).</li>
<li>Upload evil files to the upload area.</li>
<li>Direct phishing victims to the uploaded files.</li>
</ol>
<p>So, keep your Wordpress as closed as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://math.andrej.com/2010/05/04/hardware-failure-and-phishing-attacks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Random art in Python</title>
		<link>http://math.andrej.com/2010/04/21/random-art-in-python/</link>
		<comments>http://math.andrej.com/2010/04/21/random-art-in-python/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 07:15:29 +0000</pubDate>
		<dc:creator>Andrej Bauer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random art]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://math.andrej.com/?p=505</guid>
		<description><![CDATA[<p>I get asked every so often to release the source code for my random art project. The original source is written in Ocaml and is not publicly available, but here is a simple example of how you can get random art going in python in 250 lines of code.</p>
<p>Download source: randomart.py</p>
<p></p>
<p>The idea is to generate [...]]]></description>
			<content:encoded><![CDATA[<p>I get asked every so often to release the source code for my <a href="http://www.random-art.org/">random art</a> project. The original source is written in Ocaml and is not publicly available, but here is a simple example of how you can get random art going in python in 250 lines of code.</p>
<p><strong>Download source:</strong> <a title="Random art" href="/wp-content/uploads/2010/04/randomart.py">randomart.py</a></p>
<p><span id="more-505"></span></p>
<p>The idea is to generate expression trees that describe an image. For each point `(x,y)` of the image we evaluate the expression and get a color. A color is represented as a triple `(r,g,b)` where the red, green, blue components are numbers between `-1` and `1`. In computer graphics it is more usual to use the range `[0,1]`, but since many operations are symmetric with respect to the origin it is more convenient to use the interval `[-1,1]`.  I kept the program as simple as possible, and independent of any non-standard Python libraries. Consequently, a number of improvements and further experiments are possible:</p>
<ul>
<li>The most pressing problem right now is that the image is displayed as a large number of rectangles of size 1&#215;1 on the tkinter Canvas, which consumes a great deal of memory. You will not be able to draw large images this way. An improved version would use the Python imagining library (PIL) instead.</li>
<li>The program uses a simple <a href="http://en.wikipedia.org/wiki/RGB_color_model">RGB (Red Green Blue) color model</a>. We could also use the <a href="http://en.wikipedia.org/wiki/HSL_and_HSV">HSV model (Hue Saturation Value)</a>, and others. One possibility is to generate a palette of colors and use only colors that are combinations of those from the palette.</li>
<li>Of course, you can experiment by introducing new operators. If you are going to play with the source, your first exercise should be a new operator. Make sure it maps the range `[-1,1]` back to `[-1,1]`.</li>
<li>The program uses cartesian coordinates. You could experiment with polar coordinates.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://math.andrej.com/2010/04/21/random-art-in-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Proof of negation and proof by contradiction</title>
		<link>http://math.andrej.com/2010/03/29/proof-of-negation-and-proof-by-contradiction/</link>
		<comments>http://math.andrej.com/2010/03/29/proof-of-negation-and-proof-by-contradiction/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 15:00:04 +0000</pubDate>
		<dc:creator>Andrej Bauer</dc:creator>
				<category><![CDATA[Logic]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://math.andrej.com/?p=453</guid>
		<description><![CDATA[<p>I am discovering that mathematicians cannot tell the difference between &#8220;proof by contradiction&#8221; and &#8220;proof of negation&#8221;. This is so for good reasons, but conflation of different kinds of proofs is bad mental hygiene which leads to bad teaching practice and confusion. For reference, here is a short explanation of the difference between proof of [...]]]></description>
			<content:encoded><![CDATA[<p>I am discovering that mathematicians cannot tell the difference between &#8220;proof by contradiction&#8221; and &#8220;proof of negation&#8221;. This is so for good reasons, but conflation of different kinds of proofs is bad mental hygiene which leads to bad teaching practice and confusion. For reference, here is a short explanation of the difference between proof of negation and proof by contradiction.<span id="more-453"></span></p>
<p>By the way, this post is something I have been meaning to write for a while. It was finally prompted by Timothy Gowers&#8217;s blog post <a href="http://gowers.wordpress.com/2010/03/28/when-is-proof-by-contradiction-necessary/">&#8220;When is proof by contradiction necessary?</a>&#8221; in which everything seems to be called &#8220;proof by contradiction&#8221;.</p>
<p>As far as I can tell, &#8220;proof by contradiction&#8221; among ordinary mathematicians means any proof which starts with &#8220;Suppose &#8230;&#8221; and ends with a contradiction. But two kinds of proofs are like that:</p>
<p><strong>Proof of negation</strong> is an inference rule which explains how to prove a negation:</p>
<blockquote><p><em>To prove `not phi`, assume `phi` and derive absurdity.</em></p></blockquote>
<p>The rule for proving negation is the same classically and intuitionistically. I mention this because I have met ordinary mathematicians who think intuitionistic proofs are never allowed to reach an absurdity.</p>
<p><strong>Proof by contradiction</strong>, or <em>reductio ad absurdum</em>, is a different kind of animal. As a reasoning principle it says:</p>
<blockquote><p><em>To prove `phi`, assume `not phi` and derive absurdity.</em></p></blockquote>
<p>As a proposition the principle is written `not not phi =&gt; phi`, which can be proved from the law of excluded middle (and is in fact equivalent to it). In intuitionistic logic this is not a generally valid principle.</p>
<p>Admittedly, the two reasoning principles look very similar. A classical mathematician will quickly remark that we can get either of the two principles from the other by plugging in `not phi` and cancelling the double negation in `not not phi` to get back to `phi`. Yes indeed, but the cancellation of double negation is <em>precisely</em> the reasoning principle we are trying to get. These really <em>are different</em>.</p>
<p>I blame the general confusion on the fact that an informal proof of negation looks almost the same as an informal proof by contradiction.  In order to prove `not phi` a mathematician will typically write:</p>
<blockquote><p><em>&#8220;Suppose `phi`. Then &#8230; bla &#8230; bla &#8230; bla, which is a contradiction. QED.&#8221;</em></p></blockquote>
<p>In order to prove `phi` by contradiction a mathematician will typically write:</p>
<blockquote><p><em>&#8220;Suppose `not phi`. Then &#8230; bla &#8230; bla &#8230; bla, which is a contradiction. QED.&#8221;</em></p></blockquote>
<p>The difference will be further obscured because the text will typically state `not phi` in an equivalent form with negation pushed inwards. That is, if `phi` is something like `exists x, forall y, f(y) &lt; x` and the proof goes by contradiction then the opening statement will be &#8220;Suppose for every `x` there were a `y` such that `f(y) &gt;= x`.&#8221; With such &#8220;optimizations&#8221; we really cannot tell what is going on by looking just at the proof. We have to take into account the surrounding context (such as the original statement being proved).</p>
<p>A second good reason for the confusion is the fact that both proof principles <em>feel</em> the same when we try to use them. In both cases we assume something believed to be false and then we hunt down a contradiction. The difference in placement of negations is not easily appreciated by classical mathematicians because their brains automagically cancel out double negations, just like good students automatically cancel out double negation signs.</p>
<p>Keeping all this in mind, let us look at Timothy Gower&#8217;s blog examples.</p>
<h4>Irrationality of `sqrt(2)`</h4>
<p>The first example is irrationality of `sqrt 2`. Because &#8220;`sqrt(2)` is irrational&#8221; is <em>by definition</em> the same as &#8220;`sqrt(2)` is not rational&#8221; we are clearly talking about a proof of negation. There is a theorem about normal forms of proofs in intuitionistic logic which tells us that every proof of a negation can be rearranged so that it ends with the inference rule cited above. In this sense the method of proof &#8220;assume `sqrt(2)` is rational, &#8230;, contradiction&#8221; is unavoidable.</p>
<p>I want to make two further remarks. The first one is that the usual proof of irrationality of `sqrt(2)` is intuitionistically valid. Let me spell it out:</p>
<blockquote><p><strong>Theorem:</strong> <em>`sqrt(2)` is not rational.</em></p>
<p><em>Proof.</em> Suppose `sqrt(2)` were equal to a fraction `a/b` with `a` and `b` relatively prime. Then we would get `a^2 = 2 b^2`, hence `a^2` is even and so is `a`. Write `a = 2 c` and plug it back in to get `2 c^2 = b^2`, from which we conclude that `b` is even as well. This is a contradiction since `a` and `b` were assumed to be relatively prime. QED.</p></blockquote>
<p>No proof by contradiction here!</p>
<p>My second remark is that this particular example is perhaps not good for discussing proofs of negation because it reduces to inequality of natural numbers, which is a decidable property. That is, as far as intuitionistic logic is concerned, equality and inequality of natural numbers are both equally &#8220;positive&#8221; relations. This is reflected in various variants of the proof given by Gowers on his blog, some of which are &#8220;positive&#8221; in nature.</p>
<p>The situation with reals is different. There we could define the so-called <em>apartness</em> relation `x # y` to mean `x &lt; y or y &lt; x`. The negation of apartness is equality, but the negation of equality is not apartness, at least not intuitionistically (classically of course this whole discussion is a triviality). A proof of inequality `x != y` of real numbers `x` and `y` may thus proceed in two ways:</p>
<ol>
<li>The <em>direct</em> way: assume `x = y` and derive absurdity</li>
<li>Via apartness: prove `x # y` and conclude that `x != y`</li>
</ol>
<p>Note that the proof of `x # y =&gt; x != y` still involves the usual proof of negation in which we assume `x # y and x = y` and derive absurdity.</p>
<h4>A continuous map on `[0,1]` is bounded</h4>
<p>The second example is the statement that a continuous map `f : [0,1] -&gt; RR` is bounded. The direct proof uses the Heine-Borel property of the closed interval to find a finite cover of `[0,1]` such that `f` is bounded on each element of the cover. There is also a proof by contradiction which goes as follows:</p>
<blockquote><p>Suppose `f` were unbounded. Then we could find a sequence `x_n` in `[0,1]` such that the sequence `f(x_n)` is increasing and unbounded (this uses Countable Choice, by the way). By Bolzano-Weierstras there is a convergent subsequence `y_n` of `x_n`. Because `f` is continuous the sequence `f(y_n)` is convergent, which is impossible because it is a subsequence of the increasing and unbounded sequence `f(x_n)`. QED.</p></blockquote>
<p>Can we turn this proof into one that does not use contradiction (but still uses Bolzano-Weierstrass)? Constructive mathematicians are well versed in doing such things. Essentially we have to look at the supremum of `f`, like Timothy Gowers does, but without actually referring to it. The following proof is constructive and direct.</p>
<blockquote><p><strong>Theorem:</strong> <em>If every sequence in a separable space `X` has a convergent subsequence, then every continuous real map on `X` is bounded.</em></p>
<p><em>Proof.</em> Let `(x_n)` be a dense sequence in `X` and `f : X -&gt; RR` continuous. For every `n` there is `k` such that `f(x_k) = max(f(x_1), &#8230;, f(x_n)) &#8211; 1`. By Countable Choice there is a subsequence `(y_n)` of `(x_n)` such that `f(y_n) = max(f(x_1), &#8230;, f(x_n)) &#8211; 1` for every `n`. Let `(z_n)` be a convergent subsequence of `(y_n)`. Since `f(y_n)` is monotone every `i` has a `j` such that `f(y_i) &#8211; 1 &lt;= f(z_j)`. Let `z` be the limit of `(z_n)`. There is `d &gt; 0` such that `f(z_n) &lt;= f(z) + d` for all `n`. Consider any `x in X`. Because `f` is continuous and `(x_n)` is dense there is `x_i` such that `f(x) &lt;= f(x_i) + 1`. There is `j` such that `f(y_i) &#8211; 1 &lt;= f(z_j)`, from which we get `f(x) &lt;= f(x_i) + 1 &lt;= max(f(x_1), &#8230;, f(x_i)) + 1 &lt;= f(y_i) + 2 &lt;= f(z_j) + 3 &lt; f(z) + d + 3.` We have shown that `f(z) + d + 3` is an upper bound for `f`. QED.</p></blockquote>
<p>I am pretty sure with a bit more work we could show that `f` attains its supremum, and in fact this must have been proved by someone constructively.</p>
<p>The moral of the story is: proofs by contradiction can often be avoided, proofs of negation generally cannot, and if you think they are the same thing, you will be confused.</p>
]]></content:encoded>
			<wfw:commentRss>http://math.andrej.com/2010/03/29/proof-of-negation-and-proof-by-contradiction/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>A new style for the blog</title>
		<link>http://math.andrej.com/2010/01/08/a-new-style-for-the-blog/</link>
		<comments>http://math.andrej.com/2010/01/08/a-new-style-for-the-blog/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 23:05:24 +0000</pubDate>
		<dc:creator>Andrej Bauer</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Off topic]]></category>

		<guid isPermaLink="false">http://math.andrej.com/?p=424</guid>
		<description><![CDATA[<p>It was time I changed the old blog style to something a bit more modern. I hope you like it.</p>
<p>Now I just have to figure out how to port 60 blog posts from ASCIIMathML notation to something a bit friendlier that can use MathML but does not require it. What is out there? I know [...]]]></description>
			<content:encoded><![CDATA[<p>It was time I changed the old blog style to something a bit more modern. I hope you like it.</p>
<p>Now I just have to figure out how to port 60 blog posts from <a href="http://www1.chapman.edu/~jipsen/mathml/asciimath.html">ASCIIMathML</a> notation to something a bit friendlier that can use MathML but does not require it. What is out there? I know about <a href="http://www.math.union.edu/~dpvc/jsMath/">jsMath</a>. I am open to suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://math.andrej.com/2010/01/08/a-new-style-for-the-blog/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
