<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>XOO&#039;s</title>
	<atom:link href="http://xcycl.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xcycl.wordpress.com</link>
	<description>The world inside the whole world is just a point.</description>
	<lastBuildDate>Fri, 09 Dec 2011 10:46:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xcycl.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>XOO&#039;s</title>
		<link>http://xcycl.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xcycl.wordpress.com/osd.xml" title="XOO&#039;s" />
	<atom:link rel='hub' href='http://xcycl.wordpress.com/?pushpress=hub'/>
		<item>
		<title>An equational way to prove associativity of least upper bounds</title>
		<link>http://xcycl.wordpress.com/2011/03/02/an-equational-way-to-prove-associativity-of-least-upper-bounds/</link>
		<comments>http://xcycl.wordpress.com/2011/03/02/an-equational-way-to-prove-associativity-of-least-upper-bounds/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 02:05:16 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1306</guid>
		<description><![CDATA[Traditionally, to prove the associativity of the least upper bounds, i.e. we need few lines to prove the inequality from the left hand side and conversely. However, by turning the definition of finit join to the adjunction form, we have &#8230; <a href="http://xcycl.wordpress.com/2011/03/02/an-equational-way-to-prove-associativity-of-least-upper-bounds/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1306&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Traditionally, to prove the associativity of the least upper bounds, i.e. <img src='http://s0.wp.com/latex.php?latex=x+%5Cvee+%28y+%5Cvee+z%29+%3D+%28x+%5Cvee+y%29+%5Cvee+z&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;vee (y &#92;vee z) = (x &#92;vee y) &#92;vee z' title='x &#92;vee (y &#92;vee z) = (x &#92;vee y) &#92;vee z' class='latex' /> we need few lines to prove the inequality from the left hand side and conversely. However, by turning the definition of finit join to the adjunction form, we have a more compact and algebraic-like way to do it.<span id="more-1306"></span></p>
<p>Let <img src='http://s0.wp.com/latex.php?latex=P&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='P' title='P' class='latex' /> be a poset and <img src='http://s0.wp.com/latex.php?latex=P%5E2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='P^2' title='P^2' class='latex' /> be the Cartesian product with Cartesian order which is induced by the product diagram. Note <img src='http://s0.wp.com/latex.php?latex=x+%5Cvee+y+%5Cleq+z+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;vee y &#92;leq z ' title='x &#92;vee y &#92;leq z ' class='latex' /> if and only if <img src='http://s0.wp.com/latex.php?latex=%5Clangle+x%2C+y+%5Crangle+%5Cleq+%5Clangle+z%2C+z+%5Crangle&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;langle x, y &#92;rangle &#92;leq &#92;langle z, z &#92;rangle' title='&#92;langle x, y &#92;rangle &#92;leq &#92;langle z, z &#92;rangle' class='latex' /> where <img src='http://s0.wp.com/latex.php?latex=z+%5Cin+P%2C+%5Clangle+x%2C+y+%5Crangle+%5Cin+P%5E2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z &#92;in P, &#92;langle x, y &#92;rangle &#92;in P^2' title='z &#92;in P, &#92;langle x, y &#92;rangle &#92;in P^2' class='latex' />. Therefore <img src='http://s0.wp.com/latex.php?latex=x+%5Cvee+%28y+%5Cvee+z%29+%5Cleq+a++%5Cequiv+%5Clangle+x%2C+y+%5Cvee+z+%5Crangle+%5Cleq+%5Clangle+a%2C+a+%5Crangle++%5Cequiv+%5Clangle+x%2C+%5Clangle+y%2C+z+%5Crangle+%5Crangle+%5Cleq+%5Clangle+a%2C+%5Clangle+a%2C+a+%5Crangle+%5Crangle++%5Cequiv+%5Clangle+%5Clangle+x%2C+y+%5Crangle%2C+z+%5Crangle+%5Cleq+%5Clangle+%5Clangle+a%2C+a+%5Crangle%2C+a+%5Crangle++%5Cequiv+%28x+%5Cvee+y%29+%5Cvee+z+%5Cleq+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;vee (y &#92;vee z) &#92;leq a  &#92;equiv &#92;langle x, y &#92;vee z &#92;rangle &#92;leq &#92;langle a, a &#92;rangle  &#92;equiv &#92;langle x, &#92;langle y, z &#92;rangle &#92;rangle &#92;leq &#92;langle a, &#92;langle a, a &#92;rangle &#92;rangle  &#92;equiv &#92;langle &#92;langle x, y &#92;rangle, z &#92;rangle &#92;leq &#92;langle &#92;langle a, a &#92;rangle, a &#92;rangle  &#92;equiv (x &#92;vee y) &#92;vee z &#92;leq a' title='x &#92;vee (y &#92;vee z) &#92;leq a  &#92;equiv &#92;langle x, y &#92;vee z &#92;rangle &#92;leq &#92;langle a, a &#92;rangle  &#92;equiv &#92;langle x, &#92;langle y, z &#92;rangle &#92;rangle &#92;leq &#92;langle a, &#92;langle a, a &#92;rangle &#92;rangle  &#92;equiv &#92;langle &#92;langle x, y &#92;rangle, z &#92;rangle &#92;leq &#92;langle &#92;langle a, a &#92;rangle, a &#92;rangle  &#92;equiv (x &#92;vee y) &#92;vee z &#92;leq a' class='latex' />.  Finally, <img src='http://s0.wp.com/latex.php?latex=%28x+%5Cvee+y%29+%5Cvee+z+%5Cleq+a+%5Cequiv+x+%5Cvee+%28y+%5Cvee+z%29+%5Cleq+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(x &#92;vee y) &#92;vee z &#92;leq a &#92;equiv x &#92;vee (y &#92;vee z) &#92;leq a' title='(x &#92;vee y) &#92;vee z &#92;leq a &#92;equiv x &#92;vee (y &#92;vee z) &#92;leq a' class='latex' /> for every <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' /> implies <img src='http://s0.wp.com/latex.php?latex=%28x+%5Cvee+y%29+%5Cvee+z+%3D+x+%5Cvee+%28y+%5Cvee+z%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(x &#92;vee y) &#92;vee z = x &#92;vee (y &#92;vee z)' title='(x &#92;vee y) &#92;vee z = x &#92;vee (y &#92;vee z)' class='latex' />.</p>
<p>We can also prove some properties automatically from this form. To see <img src='http://s0.wp.com/latex.php?latex=x+%5Cvee+x+%3D+x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;vee x = x' title='x &#92;vee x = x' class='latex' />, just replace <img src='http://s0.wp.com/latex.php?latex=%5Clangle+x%2C+y+%5Crangle&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;langle x, y &#92;rangle' title='&#92;langle x, y &#92;rangle' class='latex' /> with <img src='http://s0.wp.com/latex.php?latex=%5Clangle+x%2C+x+%5Crangle&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;langle x, x &#92;rangle' title='&#92;langle x, x &#92;rangle' class='latex' />; to see <img src='http://s0.wp.com/latex.php?latex=x+%5Cleq+x+%5Cvee+y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;leq x &#92;vee y' title='x &#92;leq x &#92;vee y' class='latex' /> replace <img src='http://s0.wp.com/latex.php?latex=z&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z' title='z' class='latex' /> with <img src='http://s0.wp.com/latex.php?latex=x+%5Cvee+y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;vee y' title='x &#92;vee y' class='latex' /> itself.</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1306/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1306&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2011/03/02/an-equational-way-to-prove-associativity-of-least-upper-bounds/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>
	</item>
		<item>
		<title>Well-definedness</title>
		<link>http://xcycl.wordpress.com/2010/07/25/well-definedness/</link>
		<comments>http://xcycl.wordpress.com/2010/07/25/well-definedness/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 22:09:48 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1280</guid>
		<description><![CDATA[脫稿好久，而且還不是本來預定要寫的東西，只是最近即便是這簡單的例子，也發現把事情講清楚的重要性。 給定一個等價類 ，事實上這個 relation 的性質跟等式一樣，因此作 quotient set 的意義實際上是替代原本的等式，換成這個 relation，所以就有 若且唯若 這件事情。實際上構造也很簡單，就是定義 . 接下來的問題是，我們要怎麼在 quotient set 上定義函數呢？事實上就跟一般函數的定義方式一樣，取 指定對應的對象就好了。但是既然 quotient set 可以寫成 ，我們是不是能根據 來定義呢？可以的，但是數學教科書都會寫，必須是良好定義的，也就是若 ，那麼 ，白話來講，原本被看作一樣的東西，對應過去也是要一樣的。 那為甚麼在一般的集合上定義不需要呢？若是根據 的 表示來定義，事實上我們定義的是一個從原本集合 為定義域的函數，而不是 這個新的集合，而為了要說這個函數可以沿用到 上，我們自然必須檢查是否還是個集合。 若是用範疇論的語言來解釋的話，考慮 其中箭頭代表兩個投影函數 分別對應成 和 的投影而已，那麼 quotient set 事實上是該 diagram 的 &#8230; <a href="http://xcycl.wordpress.com/2010/07/25/well-definedness/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1280&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>脫稿好久，而且還不是本來預定要寫的東西，只是最近即便是這簡單的例子，也發現把事情講清楚的重要性。</p>
<p>給定一個等價類 <img src='http://s0.wp.com/latex.php?latex=%5Cequiv&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;equiv' title='&#92;equiv' class='latex' />，事實上這個 relation 的性質跟等式一樣，因此作 quotient set 的意義實際上是替代原本的等式，換成這個 relation，所以就有 <img src='http://s0.wp.com/latex.php?latex=%5Ba%5D+%3D+%5Bb%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='[a] = [b]' title='[a] = [b]' class='latex' /> 若且唯若 <img src='http://s0.wp.com/latex.php?latex=a+%5Cequiv+b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a &#92;equiv b' title='a &#92;equiv b' class='latex' /> 這件事情。實際上構造也很簡單，就是定義 <img src='http://s0.wp.com/latex.php?latex=%5Ba%5D+%3D+%5C%7B+x+%5Cin+X+%3A+a+%5Cequiv+x+%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='[a] = &#92;{ x &#92;in X : a &#92;equiv x &#92;}' title='[a] = &#92;{ x &#92;in X : a &#92;equiv x &#92;}' class='latex' />.</p>
<p>接下來的問題是，我們要怎麼在 quotient set 上定義函數呢？事實上就跟一般函數的定義方式一樣，取 <img src='http://s0.wp.com/latex.php?latex=C+%5Cin+X%2F%5Cequiv&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='C &#92;in X/&#92;equiv' title='C &#92;in X/&#92;equiv' class='latex' /> 指定對應的對象就好了。但是既然 quotient set 可以寫成 <img src='http://s0.wp.com/latex.php?latex=%5C%7B+%5Ba%5D+%5Csubseteq+X+%3A+a+%5Cin+X+%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{ [a] &#92;subseteq X : a &#92;in X &#92;}' title='&#92;{ [a] &#92;subseteq X : a &#92;in X &#92;}' class='latex' />，我們是不是能根據 <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' /> 來定義呢？可以的，但是數學教科書都會寫，必須是良好定義的，也就是若 <img src='http://s0.wp.com/latex.php?latex=%5Ba%5D+%3D+%5Bb%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='[a] = [b]' title='[a] = [b]' class='latex' />，那麼 <img src='http://s0.wp.com/latex.php?latex=f%28%5Ba%5D%29+%3D+f%28%5Bb%5D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f([a]) = f([b])' title='f([a]) = f([b])' class='latex' />，白話來講，原本被看作一樣的東西，對應過去也是要一樣的。</p>
<p>那為甚麼在一般的集合上定義不需要呢？若是根據 <img src='http://s0.wp.com/latex.php?latex=%5Ba%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='[a]' title='[a]' class='latex' /> 的 <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' /> 表示來定義，事實上我們定義的是一個從原本集合 <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X' title='X' class='latex' /> 為定義域的函數，而不是 <img src='http://s0.wp.com/latex.php?latex=X%2F%5Cequiv&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X/&#92;equiv' title='X/&#92;equiv' class='latex' /> 這個新的集合，而為了要說這個函數可以沿用到 <img src='http://s0.wp.com/latex.php?latex=X%2F%5Cequiv&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X/&#92;equiv' title='X/&#92;equiv' class='latex' /> 上，我們自然必須檢查是否還是個集合。</p>
<p>若是用範疇論的語言來解釋的話，考慮 <img src='http://s0.wp.com/latex.php?latex=%5Cequiv+%5Coverset%7B%5Cpi_1%2C+%5Cpi_2%7D%7B%5Clongrightarrow%7D+X&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;equiv &#92;overset{&#92;pi_1, &#92;pi_2}{&#92;longrightarrow} X' title='&#92;equiv &#92;overset{&#92;pi_1, &#92;pi_2}{&#92;longrightarrow} X' class='latex' /> 其中箭頭代表兩個投影函數 <img src='http://s0.wp.com/latex.php?latex=%28x%2C+y%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(x, y)' title='(x, y)' class='latex' /> 分別對應成 <img src='http://s0.wp.com/latex.php?latex=x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x' title='x' class='latex' /> 和 <img src='http://s0.wp.com/latex.php?latex=y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y' title='y' class='latex' /> 的投影而已，那麼 quotient set 事實上是該 diagram 的 coequalizer ，那麼定義 <img src='http://s0.wp.com/latex.php?latex=f+%3A+X+%5Crightarrow+Y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f : X &#92;rightarrow Y' title='f : X &#92;rightarrow Y' class='latex' />  用表示來定義的函數，若是對所有 <img src='http://s0.wp.com/latex.php?latex=%28x%2C+y%29+%5Cin+R&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(x, y) &#92;in R' title='(x, y) &#92;in R' class='latex' /> 都滿足 <img src='http://s0.wp.com/latex.php?latex=f%28x%29+%3D+f%28y%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f(x) = f(y)' title='f(x) = f(y)' class='latex' /> 的話，那麼自然從 coequalizer 會有一個唯一的映射到 <img src='http://s0.wp.com/latex.php?latex=Y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Y' title='Y' class='latex' />，而那就是 quotient set 上的函數。</p>
<p>用箭頭語言講的好處是，我們清楚知道是哪些物件在作用，每個步驟都是 diagram 裡的一部分，但是我們又不限定多餘的東西：誰說 quotient set 一定要是 <img src='http://s0.wp.com/latex.php?latex=%5C%7B%5Ba%5D+%5Csubseteq+X+%3A+a+%5Cin+X%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{[a] &#92;subseteq X : a &#92;in X&#92;}' title='&#92;{[a] &#92;subseteq X : a &#92;in X&#92;}' class='latex' />呢？因為與 quotient set 相等的集合有很多，只要有一對一且映成的函數連結起來就夠了。</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1280&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2010/07/25/well-definedness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>
	</item>
		<item>
		<title>A technical difficulity of modelling transition systems</title>
		<link>http://xcycl.wordpress.com/2010/06/15/a-technical-difficulity-of-modelling-transition-systems/</link>
		<comments>http://xcycl.wordpress.com/2010/06/15/a-technical-difficulity-of-modelling-transition-systems/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 19:49:59 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1253</guid>
		<description><![CDATA[To be precise, the title should be read as &#8220;a technical &#8230; using well-founded set theory such as ZFC axioms&#8221;. One of the major achievement  in mathematics is to find a standard or canonical form of a formula, a system &#8230; <a href="http://xcycl.wordpress.com/2010/06/15/a-technical-difficulity-of-modelling-transition-systems/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1253&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To be precise, the title should be read as &#8220;a technical &#8230; using well-founded set theory such as ZFC axioms&#8221;. One of the major achievement  in mathematics is to find a standard or canonical form of a formula, a system or any mathematical entity.<span id="more-1253"></span></p>
<p>Take the matrix theory as an example. We know that change of basis doesn&#8217;t affect the matrix essentially, and the change matrix is always invertible. Therefore, we usually identify (on some level) matrices by changes of basis, i.e. <img src='http://s0.wp.com/latex.php?latex=A+%5Csim+B+%5Cequiv+A+%3D+PBP%5E%7B-1%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A &#92;sim B &#92;equiv A = PBP^{-1}' title='A &#92;sim B &#92;equiv A = PBP^{-1}' class='latex' />. They are said to be similar. Since there are different appearances of matrices of the same type, can we have a canonical form of each type and every matrix be described by that? Luckily the answer is positive. One of answers is <a href="http://en.wikipedia.org/wiki/Jordan_normal_form">Jordan form</a>.</p>
<p>Now, here is a question for computer scientists. Transition systems are so common in computer science as a way to model automata, concurrent systems, and the behaviour of programming languages. It usually consists of this form <img src='http://s0.wp.com/latex.php?latex=x+%5Coverset%7Bact%7D%7B%5Crightarrow%7D+y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;overset{act}{&#92;rightarrow} y' title='x &#92;overset{act}{&#92;rightarrow} y' class='latex' /> where <img src='http://s0.wp.com/latex.php?latex=act&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='act' title='act' class='latex' /> means an &#8220;action&#8221; and <img src='http://s0.wp.com/latex.php?latex=x%2C+y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x, y' title='x, y' class='latex' /> are states. It just tells us that from the state <img src='http://s0.wp.com/latex.php?latex=x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x' title='x' class='latex' /> it gets the state <img src='http://s0.wp.com/latex.php?latex=y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y' title='y' class='latex' /> after performing the action <img src='http://s0.wp.com/latex.php?latex=act&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='act' title='act' class='latex' />.</p>
<p>Image that we input a number into a calculator after switching on. Originally, it showed nothing but a zero, but immediately it shows the number you just typed. Regardless of the internal states,we can say it changes from the state <img src='http://s0.wp.com/latex.php?latex=0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='0' title='0' class='latex' /> to the state you just typed. This is what we can observe externally.</p>
<p>Without any prior knowledge and tools, we can only observe that something changed on the screen. It is reasonable to assume that it is impossible to change anything observable without internally or externally triggering any changes. It reminds same if we don&#8217;t touch it, but it may switch off by itself after few minutes. However, there is still something changed inside, e.g. &#8220;something&#8221; triggering an event to &#8220;switch off&#8221;. Usually, there is no need to have a timer, but it is going to power off while there is no energy.</p>
<p>Beware of the difference of internal states and external states. We can only observe that it turns on and off, but we cannot definitely tell the level of power. The former is the external state we can observe and the later is the internal state that we can&#8217;t observe. To be clear, we only consider states we can observe, but we can use internal states to describe a system which leads to a notion of equivalence, bisimilarity.</p>
<p>Bisimilarity is the best we can say to the equivalence of systems from observations. Since the only way to know the system is to observe the behaviour, we identity systems by their behaviour. To identify them is not only merely by the set of actions, but also the behaviour after every action.</p>
<p>We say <img src='http://s0.wp.com/latex.php?latex=R&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='R' title='R' class='latex' /> is a bisimulation relation if <img src='http://s0.wp.com/latex.php?latex=x+R+y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x R y' title='x R y' class='latex' /> implies every <img src='http://s0.wp.com/latex.php?latex=a+%5Cin+Act&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a &#92;in Act' title='a &#92;in Act' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=x+%5Coverset%7Ba%7D%7B%5Crightarrow%7D+x%27&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;overset{a}{&#92;rightarrow} x&#039;' title='x &#92;overset{a}{&#92;rightarrow} x&#039;' class='latex' />, there is some <img src='http://s0.wp.com/latex.php?latex=y%27&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y&#039;' title='y&#039;' class='latex' /> reachable from <img src='http://s0.wp.com/latex.php?latex=y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y' title='y' class='latex' /> via <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' />, i.e. <img src='http://s0.wp.com/latex.php?latex=%5Cexists+y%27+.+%28y+%5Coverset%7Ba%7D%7B%5Crightarrow%7D+y%27%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;exists y&#039; . (y &#92;overset{a}{&#92;rightarrow} y&#039;)' title='&#92;exists y&#039; . (y &#92;overset{a}{&#92;rightarrow} y&#039;)' class='latex' /> with <img src='http://s0.wp.com/latex.php?latex=x%27+R+y%27&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x&#039; R y&#039;' title='x&#039; R y&#039;' class='latex' />and vice versa for every <img src='http://s0.wp.com/latex.php?latex=y%27&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y&#039;' title='y&#039;' class='latex' />. Thus, we say that <img src='http://s0.wp.com/latex.php?latex=x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x' title='x' class='latex' /> is bisimilar to <img src='http://s0.wp.com/latex.php?latex=y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y' title='y' class='latex' /> if there exists a bisimulaion <img src='http://s0.wp.com/latex.php?latex=R&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='R' title='R' class='latex' /> such that <img src='http://s0.wp.com/latex.php?latex=x+R+y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x R y' title='x R y' class='latex' />.</p>
<p>Our question is</p>
<blockquote><p>&#8220;Is there any canonical form under bisimilarity for transition systems?&#8221;</p></blockquote>
<p>One of attempts is to model the states itself as sets. To be precise, an unlabelled transition system consists of a set of states <img src='http://s0.wp.com/latex.php?latex=S&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='S' title='S' class='latex' /> and a transition function <img src='http://s0.wp.com/latex.php?latex=%5Cdelta+%3A+S+%5Crightarrow+%5Cmathcal%7BP%7D%28S%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;delta : S &#92;rightarrow &#92;mathcal{P}(S)' title='&#92;delta : S &#92;rightarrow &#92;mathcal{P}(S)' class='latex' />. The canonical form of systems should possess the property <img src='http://s0.wp.com/latex.php?latex=s+%3D+%5C%7Bs%27+%5Cin+S+%3A+s+%5Crightarrow+s%27+%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='s = &#92;{s&#039; &#92;in S : s &#92;rightarrow s&#039; &#92;}' title='s = &#92;{s&#039; &#92;in S : s &#92;rightarrow s&#039; &#92;}' class='latex' />. For a simple system only consists of one state without any move, i.e. <img src='http://s0.wp.com/latex.php?latex=%5Cdelta%28s_0%29+%3D+%5Cemptyset&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;delta(s_0) = &#92;emptyset' title='&#92;delta(s_0) = &#92;emptyset' class='latex' />. Its canonical form is <img src='http://s0.wp.com/latex.php?latex=s_0+%3D+%5Cemptyset&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='s_0 = &#92;emptyset' title='s_0 = &#92;emptyset' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Cdelta+%3D+id_S&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;delta = id_S' title='&#92;delta = id_S' class='latex' />. Also, it seems easy to find a canonical form of any given system by replacing each state with its successor set. Let us consider the following example.</p>
<p><img src='http://s0.wp.com/latex.php?latex=a+%5Crightarrow+b+%5Crightarrow+a+%5Crightarrow+%5Cdots+...+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a &#92;rightarrow b &#92;rightarrow a &#92;rightarrow &#92;dots ... ' title='a &#92;rightarrow b &#92;rightarrow a &#92;rightarrow &#92;dots ... ' class='latex' /></p>
<p>So, we have <img src='http://s0.wp.com/latex.php?latex=a+%3D+%5C%7Bb%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a = &#92;{b&#92;}' title='a = &#92;{b&#92;}' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=b+%3D+%5C%7Ba%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b = &#92;{a&#92;}' title='b = &#92;{a&#92;}' class='latex' /> &#8230; !?</p>
<p>Obviously, it doesn&#8217;t work in general! Although we can prove that any two bisimiar systems have the same canonical system, and the canonical system is bisimilar to its original system, but it only works for a very limited kind of system. Because of <a href="http://en.wikipedia.org/wiki/Axiom_of_regularity">axiom of regularity</a> (or, axiom of foundation) in ZFC set theory, it results that there is no infinite <img src='http://s0.wp.com/latex.php?latex=%5Cin&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;in' title='&#92;in' class='latex' />-sequence, namely <img src='http://s0.wp.com/latex.php?latex=a_0+%5Cin+a_1+%5Cin+%5Cdots+%5Cin+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a_0 &#92;in a_1 &#92;in &#92;dots &#92;in a' title='a_0 &#92;in a_1 &#92;in &#92;dots &#92;in a' class='latex' /> is always finite and it is not possible that <img src='http://s0.wp.com/latex.php?latex=a+%5Cin+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a &#92;in a' title='a &#92;in a' class='latex' /> (which is just a special case of an infinite <img src='http://s0.wp.com/latex.php?latex=%5Cin&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;in' title='&#92;in' class='latex' />-sequence). Therefore, not only a system with any infinite traces is not allowed but also a system with <img src='http://s0.wp.com/latex.php?latex=s+%5Crightarrow+s&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='s &#92;rightarrow s' title='s &#92;rightarrow s' class='latex' /> is not possible to have a canonical form.</p>
<p>One of the solutions is to weaken ZFC set theory to include more valid sets. The simplest answer for the above problem is to drop the axiom of foundation and to require a unique solution for the above equations! Using non-well-founded set theory, we can model every transition system as a set.</p>
<p>Of course, we shall explain on what we mean by equations and solutions, but it should be enough to see why non-well-founded set theory is useful.</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1253/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1253&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2010/06/15/a-technical-difficulity-of-modelling-transition-systems/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>
	</item>
		<item>
		<title>Yoneda argument &#8211; Application</title>
		<link>http://xcycl.wordpress.com/2010/04/22/yoneda-argument-application/</link>
		<comments>http://xcycl.wordpress.com/2010/04/22/yoneda-argument-application/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 10:22:09 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1233</guid>
		<description><![CDATA[A simple application of Yoneda argument is to prove that in Cartesian closed category. Lemma. In Cartesian closed category, where is terminal. Proof. for all objects . Hene . It&#8217;s also quite easy to see that since .  Hence . &#8230; <a href="http://xcycl.wordpress.com/2010/04/22/yoneda-argument-application/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1233&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A simple application of Yoneda argument is to prove that <img src='http://s0.wp.com/latex.php?latex=a%5E1+%5Ccong+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a^1 &#92;cong a' title='a^1 &#92;cong a' class='latex' /> in Cartesian closed category.</p>
<p style="padding-left:30px;"><strong>Lemma. </strong>In Cartesian closed category, <img src='http://s0.wp.com/latex.php?latex=a%5E1+%5Ccong+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a^1 &#92;cong a' title='a^1 &#92;cong a' class='latex' /> where <img src='http://s0.wp.com/latex.php?latex=1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='1' title='1' class='latex' /> is terminal.</p>
<p style="padding-left:30px;"><strong>Proof.</strong> <img src='http://s0.wp.com/latex.php?latex=hom%28b%2C+a%29+%5Ccong+hom%28b+%5Ctimes+1%2C+a%29+%5Ccong+hom%28b%2C+a%5E1%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='hom(b, a) &#92;cong hom(b &#92;times 1, a) &#92;cong hom(b, a^1)' title='hom(b, a) &#92;cong hom(b &#92;times 1, a) &#92;cong hom(b, a^1)' class='latex' /> for all objects <img src='http://s0.wp.com/latex.php?latex=b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b' title='b' class='latex' />. Hene <img src='http://s0.wp.com/latex.php?latex=a+%5Ccong+a%5E1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a &#92;cong a^1' title='a &#92;cong a^1' class='latex' />.</p>
<p>It&#8217;s also quite easy to see that <img src='http://s0.wp.com/latex.php?latex=a%5E%7Bb+%5Ctimes+c%7D+%5Ccong+%28a%5Eb%29%5Ec&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a^{b &#92;times c} &#92;cong (a^b)^c' title='a^{b &#92;times c} &#92;cong (a^b)^c' class='latex' /> since <img src='http://s0.wp.com/latex.php?latex=hom%28d%2C+a%5E%7Bb+%5Ctimes+c%7D%29+%5Ccong+hom%28d+%5Ctimes+b+%5Ctimes+c%2C+a%29+%5Ccong+hom%28d+%5Ctimes+c%2C+a%5Eb%29+%5Ccong+hom%28d%2C+%28a%5Eb%29%5Ec%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='hom(d, a^{b &#92;times c}) &#92;cong hom(d &#92;times b &#92;times c, a) &#92;cong hom(d &#92;times c, a^b) &#92;cong hom(d, (a^b)^c)' title='hom(d, a^{b &#92;times c}) &#92;cong hom(d &#92;times b &#92;times c, a) &#92;cong hom(d &#92;times c, a^b) &#92;cong hom(d, (a^b)^c)' class='latex' />.  Hence <img src='http://s0.wp.com/latex.php?latex=a%5E%7Bb+%5Ctimes+c%7D+%5Ccong+%28a%5Eb%29%5Ec&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a^{b &#92;times c} &#92;cong (a^b)^c' title='a^{b &#92;times c} &#92;cong (a^b)^c' class='latex' />. It&#8217;s just like that we prvoe the equality <img src='http://s0.wp.com/latex.php?latex=c+%5Cwedge+b+%5Crightarrow+a+%3D+c+%5Crightarrow+%28b+%5Crightarrow+a%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='c &#92;wedge b &#92;rightarrow a = c &#92;rightarrow (b &#92;rightarrow a)' title='c &#92;wedge b &#92;rightarrow a = c &#92;rightarrow (b &#92;rightarrow a)' class='latex' /> in the Heyting algebra!</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1233&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2010/04/22/yoneda-argument-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>
	</item>
		<item>
		<title>Yoneda argument</title>
		<link>http://xcycl.wordpress.com/2010/04/21/yoneda-argument/</link>
		<comments>http://xcycl.wordpress.com/2010/04/21/yoneda-argument/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 18:15:03 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1212</guid>
		<description><![CDATA[I don&#8217;t want to repeat the Yoneda lemma, but one of the important corollary should be emphasized. Roughly speaking, given any object in the category , is determined by its morphisms up to isomorphism. That is, the natural isomorphism between &#8230; <a href="http://xcycl.wordpress.com/2010/04/21/yoneda-argument/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1212&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t want to repeat the Yoneda lemma, but one of the important corollary should be emphasized. Roughly speaking, given any object <img src='http://s0.wp.com/latex.php?latex=c&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='c' title='c' class='latex' /> in the category <img src='http://s0.wp.com/latex.php?latex=%5Cmathcal%7BC%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathcal{C}' title='&#92;mathcal{C}' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=c&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='c' title='c' class='latex' /> is determined by its morphisms up to isomorphism. That is, the natural isomorphism between hom-sets corresponds to the isomorphism between objects, i.e. <img src='http://s0.wp.com/latex.php?latex=hom%28-%2C+c%29+%5Ccong+hom%28-%2C+d%29+%5CLeftrightarrow+c+%5Ccong+d&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='hom(-, c) &#92;cong hom(-, d) &#92;Leftrightarrow c &#92;cong d' title='hom(-, c) &#92;cong hom(-, d) &#92;Leftrightarrow c &#92;cong d' class='latex' />. How do we prove it? Well, let&#8217;s see a simpler analogy in partial orders.</p>
<p style="padding-left:30px;"><strong>Lemma</strong>. <img src='http://s0.wp.com/latex.php?latex=%5Cuparrow+x+%3D+%5Cuparrow+y+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;uparrow x = &#92;uparrow y ' title='&#92;uparrow x = &#92;uparrow y ' class='latex' /> if and only if <img src='http://s0.wp.com/latex.php?latex=x+%3D+y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x = y' title='x = y' class='latex' />.<br />
<strong>Proof.</strong> If <img src='http://s0.wp.com/latex.php?latex=%5Cuparrow+x+%3D+%5Cuparrow+y+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;uparrow x = &#92;uparrow y ' title='&#92;uparrow x = &#92;uparrow y ' class='latex' />, then <img src='http://s0.wp.com/latex.php?latex=a+%5Cin+%5Cuparrow+b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a &#92;in &#92;uparrow b' title='a &#92;in &#92;uparrow b' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=b+%5Cin+%5Cuparrow+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b &#92;in &#92;uparrow a' title='b &#92;in &#92;uparrow a' class='latex' /> which imply <img src='http://s0.wp.com/latex.php?latex=a+%5Cleq+b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a &#92;leq b' title='a &#92;leq b' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=b+%5Cleq+a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b &#92;leq a' title='b &#92;leq a' class='latex' />. Hence <img src='http://s0.wp.com/latex.php?latex=a+%3D+b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a = b' title='a = b' class='latex' />. The converse is quite trivial.</p>
<p>First, we can prove it by brute force method.</p>
<p style="padding-left:30px;"><strong>Lemma. </strong><img src='http://s0.wp.com/latex.php?latex=hom%28+-+%2C+c+%29+%5Ccong+hom%28+-+%2C+d+%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='hom( - , c ) &#92;cong hom( - , d )' title='hom( - , c ) &#92;cong hom( - , d )' class='latex' /> if and only if <img src='http://s0.wp.com/latex.php?latex=c+%5Ccong+d&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='c &#92;cong d' title='c &#92;cong d' class='latex' />.<br />
<strong>Proof.</strong> Consider the following diagrams,</p>
<p style="padding-left:30px;"><img class="alignnone" src="http://latex.codecogs.com/gif.latex?\xymatrix{&amp;space;hom(c,c)&amp;space;\ar[d]_f&amp;space;\ar[r]^{\phi_c}&amp;space;&amp;&amp;space;hom(c,d)&amp;space;\ar[d]^f\\&amp;space;hom(d,c)&amp;space;\ar[r]_{\phi_d}&amp;space;&amp;&amp;space;hom(d,d)}" alt="" width="195" height="98" /></p>
<p style="padding-left:30px;">by replacing <img src='http://s0.wp.com/latex.php?latex=f&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f' title='f' class='latex' /> with <img src='http://s0.wp.com/latex.php?latex=%5Cphi%5E%7B-1%7D_%7Bd%7D%28id_%7Bd%7D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;phi^{-1}_{d}(id_{d})' title='&#92;phi^{-1}_{d}(id_{d})' class='latex' />, we will see that <img src='http://s0.wp.com/latex.php?latex=id_%7Bd%7D+%3D+%5Cphi_%7Bc%7D%28id_c%29+%5Ccirc+%5Cphi%5E%7B-1%7D_%7Bd%7D%28id_%7Bd%7D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='id_{d} = &#92;phi_{c}(id_c) &#92;circ &#92;phi^{-1}_{d}(id_{d})' title='id_{d} = &#92;phi_{c}(id_c) &#92;circ &#92;phi^{-1}_{d}(id_{d})' class='latex' /> and we will have the other isomorphism by replacing <img src='http://s0.wp.com/latex.php?latex=f&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f' title='f' class='latex' /> with <img src='http://s0.wp.com/latex.php?latex=%5Cphi_%7Bc%7D%28id_c%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;phi_{c}(id_c)' title='&#92;phi_{c}(id_c)' class='latex' /> and reversing the arrows.</p>
<p>However, the diagram above is exactly used in Yoneda lemma, and of course we can use Yoneda lemma to prove it.</p>
<p>First recall that Yoneda lemma states that <img src='http://s0.wp.com/latex.php?latex=Nat+%28+hom+%28+-+%2C+r+%29%2C+K+%29+%5Ccong+Kr&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Nat ( hom ( - , r ), K ) &#92;cong Kr' title='Nat ( hom ( - , r ), K ) &#92;cong Kr' class='latex' /> where <img src='http://s0.wp.com/latex.php?latex=K&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='K' title='K' class='latex' /> is a <strong>Set</strong>-valued functor and <img src='http://s0.wp.com/latex.php?latex=r&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='r' title='r' class='latex' /> is an object in a locally small category <img src='http://s0.wp.com/latex.php?latex=%5Cmathcal%7BC%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathcal{C}' title='&#92;mathcal{C}' class='latex' />. Let <img src='http://s0.wp.com/latex.php?latex=K&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='K' title='K' class='latex' /> be the hom-set functor <img src='http://s0.wp.com/latex.php?latex=hom%28-%2C+s%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='hom(-, s)' title='hom(-, s)' class='latex' />. It gives the isomorphism between <img src='http://s0.wp.com/latex.php?latex=Nat%28hom%28-%2C+r%29%2C+hom%28-%2C+s%29%29+%5Ccong+hom%28r%2C+s%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Nat(hom(-, r), hom(-, s)) &#92;cong hom(r, s)' title='Nat(hom(-, r), hom(-, s)) &#92;cong hom(r, s)' class='latex' />. Hence, it indeed tells you that <img src='http://s0.wp.com/latex.php?latex=Y%28d%29+%3D+hom%28-%2C+d%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Y(d) = hom(-, d)' title='Y(d) = hom(-, d)' class='latex' /> is fully faithful. Therefore, we have the second proof.</p>
<p style="padding-left:30px;"><strong>Proof2.</strong> Given that <img src='http://s0.wp.com/latex.php?latex=Y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Y' title='Y' class='latex' /> is fully faithful, thus the natural isomorphisms <img src='http://s0.wp.com/latex.php?latex=Y+%28+d+%29+%5Ccong+Y+%28+c+%29+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Y ( d ) &#92;cong Y ( c ) ' title='Y ( d ) &#92;cong Y ( c ) ' class='latex' /> actually correspond to the isomorphism <img src='http://s0.wp.com/latex.php?latex=d+%5Ccong+c&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='d &#92;cong c' title='d &#92;cong c' class='latex' /> and vice verse. That&#8217;s it!</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1212/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1212&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2010/04/21/yoneda-argument/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>

		<media:content url="http://latex.codecogs.com/gif.latex?xymatrix&#038;space;hom(c,c)&#038;space;ard_f&#038;space;arrphi_c&#038;space;&#038;&#038;space;hom(c,d)&#038;space;ardf&#038;space;hom(d,c)&#038;space;arr_phi_d&#038;space;&#038;&#038;space;hom(d,d)" medium="image" />
	</item>
		<item>
		<title>為甚麼是 Functional Programming？&#8211; call by need</title>
		<link>http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f-call-by-need/</link>
		<comments>http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f-call-by-need/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 23:14:49 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1199</guid>
		<description><![CDATA[call-by-need 是另外一點值得強調的部份。程式基本上只能作有限的計算，而回傳資料也總是有限的，所以不大可能在程式語言中，有個值完整代表無理數，或者是無窮的資料，只是有限的估計而已。是這樣嗎？ well &#8230; 在 call-by-need 代表有需要值才會被計算。所以如果有一個常數函數，總是回傳資料 0 ，那麼即使傳入的參數，在 imperative language 中的運算方式不會停止，但我們仍可以得到結果。因為我們不需要去計算參數的資料，就可以得到結果了。 但這跟無窮有什麼關係呢？因為這樣的特性，所以即便我們有無窮的資料，但我們總是可以看到有限的片段，而不需要將所有的資料算出來。例如底下的 Haskell 程式 from :: Nat -&#62; [ Nat ] from n = n : from (n + 1) from 是一個函數從 Nat 到 Nat 的串列用 [ Nat ] &#8230; <a href="http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f-call-by-need/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1199&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>call-by-need 是另外一點值得強調的部份。程式基本上只能作有限的計算，而回傳資料也總是有限的，所以不大可能在程式語言中，有個值完整代表無理數，或者是無窮的資料，只是有限的估計而已。是這樣嗎？<span id="more-1199"></span></p>
<p>well &#8230; 在 call-by-need 代表有需要值才會被計算。所以如果有一個常數函數，總是回傳資料 0 ，那麼即使傳入的參數，在 imperative language 中的運算方式不會停止，但我們仍可以得到結果。因為我們不需要去計算參數的資料，就可以得到結果了。</p>
<p>但這跟無窮有什麼關係呢？因為這樣的特性，所以即便我們有無窮的資料，但我們總是可以看到有限的片段，而不需要將所有的資料算出來。例如底下的 Haskell 程式</p>
<p>from :: Nat -&gt; [ Nat ]<br />
from n = n : from (n + 1)</p>
<p>from 是一個函數從 Nat 到 Nat 的串列用 [ Nat ] 代表，他的開頭第一個元素是  n 接下來是 from (n + 1) 該串列，而展開 from (n + 1) 的定義，又會得到它開頭是 n + 1 並且串接一個 from (n + 2)，不斷展開下去，我們得到</p>
<p>from n = n : n + 1 : n +2 : &#8230; : n + k : &#8230;</p>
<p>一直下去沒完沒了，在 imperative language 中我們避免這樣的函數，因為會讓程式進入無窮迴圈。但是在 Haskell 這樣的函數並不會直接被計算，除非你要 Haskell 展開這個函數。而我們可以定義一個函數，取出至多前面 k 個元素形成新的串列如</p>
<p>take :: Nat -&gt; [Nat] -&gt; [ Nat ]<br />
take n [] = []<br />
take 0 xs = []<br />
take n xs = (head x) : (take (n &#8211; 1) (tail xs))</p>
<p>前面兩個代表兩種情況，一個是給定的串列是空的話，那麼就傳回空串列，第二個則是說當要取的個數為零的話，我們也回傳空串列，最後當串列不是空的而且個數也不為零，那麼我們就取出第一個元素，並且接上 take (n &#8211; 1) (tail xs)。最後的 tail xs 代表是第一個之後的串列。</p>
<p>所以呢，我們可以寫 take 3 (from 4) 得到 4 : 5 : 6 : [] 這樣的串列，也就是依序是 4, 5, 6 的串列，最後的 [] 代表著串列的結束。為甚麼？take 3 (from 4) ，會先展開 from 4 成 4 : from 5，然後套用第三個敘述變成 4 : take 2 (from 5)，再來是 4 : 5 : take 1 (from 6) , 4 : 5 : 6 : []。中間跳了一些步驟，有興趣可以再從網路找找資料。</p>
<p>另外，我們也可以定義一個自己接自己的串列如</p>
<p>itself :: [Nat]<br />
itself = 3 : itself</p>
<p>就寫程式的方便性而言，我們不寫一個函數產生 n 到 m ，而是結合前面兩個函數來得到 n 到 m，一來重複使用我們的函數，二來會比直接寫一個 n 到 m 來得直覺一些（如果習慣這樣的方式的話）。但我們也會注意到，from n 本身是無窮的資料，但我們仍然可以得到一些資訊。從這邊得到一個，即便是無限也是有限的估計，或者說無限其實是所有有限資訊的聯集。</p>
<p>雖然這些還不夠精確，但希望會有個概念，在程式裡頭仍然可以擁有概念上無限的資料結構，或者當作是有限資料的極限點。不過這有機會再說吧。</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1199&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f-call-by-need/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>
	</item>
		<item>
		<title>為甚麼是 Functional Programming？</title>
		<link>http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f/</link>
		<comments>http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 22:20:30 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1195</guid>
		<description><![CDATA[正在 Midlands Graduate School 2010 上課，想到一些東西寫點輕鬆的。 我第一個學的語言，嚴格講起來應該是小學二年級的 GW-Basic，姊姊正在念高職時，借她的課本來看，稍微玩一下。不過並沒有認真學，到最後電腦只是拿來玩電動而已。在那之後過很久，高中電子辭典有些內建 gw-basic，那時候還稍微記得上課會寫些東西打發時間，但就只是玩玩而已。 接下來因緣際會學了 Python 拿來寫些小東西，一路慢慢學到 C 跟 C++ (大一)，這時候對程式語言有個想法，反正會寫了 C 之後，大部分的語言都差不多。大三修程式語言時，雖然稍微提過 Scheme（無型別的 Functional Programming），但那時只覺得礙手礙腳，看不出來有什麼必要，老師也只是丟習題下來，沒解釋太多，而該堂課就一直介紹語言設計的原則，還有如 call-by-value, call-by-reference 這些。 令人驚訝的是，大學畢業等當兵的時期，玩一些 C++ template 的泛型程式設計，以及 meta-programming 的東西，漸漸發現這東西好像以前學的 Scheme，沒有 side-effect 副作用，程式展開的基本技巧是數學歸納法，一層一層的 template 實現，玩到 meta-programming 的時候有 type list 等等奇巧淫技，還可以在 &#8230; <a href="http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1195&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>正在 <a href="http://mgs2010.group.shef.ac.uk/home">Midlands Graduate School 2010</a> 上課，想到一些東西寫點輕鬆的。</p>
<p>我第一個學的語言，嚴格講起來應該是小學二年級的 GW-Basic，姊姊正在念高職時，借她的課本來看，稍微玩一下。不過並沒有認真學，到最後電腦只是拿來玩電動而已。在那之後過很久，高中電子辭典有些內建 gw-basic，那時候還稍微記得上課會寫些東西打發時間，但就只是玩玩而已。<span id="more-1195"></span></p>
<p>接下來因緣際會學了 Python 拿來寫些小東西，一路慢慢學到 C 跟 C++ (大一)，這時候對程式語言有個想法，反正會寫了 C 之後，大部分的語言都差不多。大三修程式語言時，雖然稍微提過 Scheme（無型別的 Functional Programming），但那時只覺得礙手礙腳，看不出來有什麼必要，老師也只是丟習題下來，沒解釋太多，而該堂課就一直介紹語言設計的原則，還有如 call-by-value, call-by-reference 這些。</p>
<p>令人驚訝的是，大學畢業等當兵的時期，玩一些 C++ template 的泛型程式設計，以及 meta-programming 的東西，漸漸發現這東西好像以前學的 Scheme，沒有 side-effect 副作用，程式展開的基本技巧是數學歸納法，一層一層的 template 實現，玩到 meta-programming 的時候有 type list 等等奇巧淫技，還可以在 template 裡頭再包一層 template，上網搜尋 functional programming (FP) 跟 C++ template 還真有關係，不過這時候也差不多結束去當兵了。</p>
<p>退伍之後進入中研院，穆信成老師實驗室工作，開始學習 Haskell 跟 Agda，邊看些跟 FP 有關的基礎知識，關於 FP 有幾點是 C\C++ 等 imperative language 等沒有的。</p>
<p>第一個是函數是 first-class object，函數在 Haskell 裡頭就跟其他型別如整數，浮點數等一樣，可以當作參數傳來傳去，所以要寫個函數合成的程序，不過就是</p>
<p>comp :: (a -&gt; b) -&gt; (b -&gt; c) -&gt; (a -&gt; c)<br />
comp f g x = g (f x)</p>
<p>看起來就跟數學函數差不多！</p>
<p>再來是 currying 的部份，正如前面說函數是 first-class object，除了傳參數以外，也可以當作回傳值傳回來，前面的例子的型別其實是</p>
<p>(a -&gt; b) -&gt; ( (b -&gt; c) -&gt; (a -&gt; c))</p>
<p>也就是給定一個函數 f 從 a 到 b，回傳一個函數從 (b -&gt; c) 到 (a -&gt; c)，函數的定義域與值域是函數空間 b -&gt;c 跟 a -&gt; c！所以我們可以將原本取多個參數的函數如</p>
<p>(a x b) -&gt; c</p>
<p>取「像是」集合的卡氏積為定義域，其值域是 c，這可以轉成</p>
<p>a -&gt; (b -&gt; c)</p>
<p>也是給定一個元素來自 a ，傳回函數 b -&gt;c。在 C++ 這就沒辦法輕鬆作到了。</p>
<p>再來是沒有副作用，一開始把程式語言的函數看作是數學上的函數，這看起來好像沒什麼問題，但是副作用的存在不能保證每次呼叫的時候，傳回來的東西都會一樣，也就是程序本身，並不是獨立於程式語言其他的部份。所以當程式出錯的時候，得把所有碰到的部份走過一遍，才能確定是哪邊出來問題。我不擅於處理太複雜的東西，所以希望簡化整合程式，用各種方式讓他看起來更有結構些，但這點副作用讓我很為難。</p>
<p>FP 函數沒有副作用，即便要使用變數等，也必須用其他方式明確指出這件事情。所以每次呼叫函數的時候，總是可以確定傳回來的值不會變，也因此要寫對程式，也變得比較容易，或許比較難寫些，但相較於 C\C++ 好寫但容易錯比起來，我寧願多花點時間寫正確的程式。</p>
<p>再來一個優點，則是因為沒有副作用，所以可以把計算過的值記起來，以便下次再呼叫的時候直接拿來用，也就是 lazy evaluation 的精神。這使得在 C\C++ 必須自己做的事情，在程式語言方面可以幫你處理。</p>
<p>最後非常吸引人的是，algebraic data type。例如數學上自然數基本上是定義 0 (anyway, 有時候從 1 開始)，或者是其他數字的下一個，也就是一個函數 suc 從自然數到自然數。在 Haskell 中要定義這樣的結構，只要寫</p>
<p>data Nat = zero | suc Nat</p>
<p>中間的 | 代表或者，左邊 zero 只有給一個名稱屬於 Nat；右邊是一個函數 suc 取一個 Nat 當作元素，也是屬於 Nat。類似地，要定義一個串列結構只要寫</p>
<p>data List a = empty | cons a (List a)</p>
<p>小寫的 a 是一個變數，可以是任何的型別，而右邊的 cons 長得跟 suc 有點像，不過它取一個元素來自 a 以及令一個 List a 。這同時也說明了，在 Haskell 要作 C++ template 是非常簡單的，這樣的串列不限於任何型別。我們還有稱為 polymorphic type 的型別，可以對任意的型別操作。</p>
<p>其他有趣的特色，例如更豐富的型別系統，可以透過 Curry-Howard isomorphism 將型別當作邏輯述句，程式本身作為推演的證明。以及更深刻的理論將型別理論連結範疇論，作為範疇論的 internal language。或者給予數學結構，發展程式邏輯（program logic），以及如何說明什麼是正確的程式。而 functional programming 也比 imperative language 適合進行程式推導，說明如何利用之中的代數結構，將程式 A 推導成程式 B 等等。</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1195/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1195&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2010/03/28/%e7%82%ba%e7%94%9a%e9%ba%bc%e6%98%af-functional-programming%ef%bc%9f/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>
	</item>
		<item>
		<title>恭喜 Josh ~</title>
		<link>http://xcycl.wordpress.com/2010/03/27/%e6%81%ad%e5%96%9c-josh/</link>
		<comments>http://xcycl.wordpress.com/2010/03/27/%e6%81%ad%e5%96%9c-josh/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 22:15:05 +0000</pubDate>
		<dc:creator>XOO</dc:creator>
				<category><![CDATA[閒聊]]></category>

		<guid isPermaLink="false">http://xcycl.wordpress.com/?p=1189</guid>
		<description><![CDATA[恭喜 Josh 獲得 Clarendon Scholarship &#8211; University College MPLS Scholarship！（當然同時也獲得入學許可了），原文在此。 這代表我以後去 Oxford 可以住 University College 了嗎？XD Filed under: 閒聊<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1189&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>恭喜 Josh 獲得 Clarendon Scholarship &#8211; University College MPLS Scholarship！（當然同時也獲得入學許可了），原文<a href="http://joshkos.blogspot.com/2010/03/fourth-offer.html">在此</a>。</p>
<p>這代表我以後去 Oxford 可以住 University College 了嗎？XD</p>
<br />Filed under: <a href='http://xcycl.wordpress.com/category/%e9%96%92%e8%81%8a/'>閒聊</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xcycl.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xcycl.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xcycl.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xcycl.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xcycl.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xcycl.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xcycl.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xcycl.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xcycl.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xcycl.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xcycl.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xcycl.wordpress.com/1189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xcycl.wordpress.com/1189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xcycl.wordpress.com/1189/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xcycl.wordpress.com&amp;blog=46314&amp;post=1189&amp;subd=xcycl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xcycl.wordpress.com/2010/03/27/%e6%81%ad%e5%96%9c-josh/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/039a609a85ea8c2bc5b324572e99d401?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">xcycl</media:title>
		</media:content>
	</item>
	</channel>
</rss>
