<?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>Existential Type</title>
	<atom:link href="http://existentialtype.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://existentialtype.wordpress.com</link>
	<description>Abstract types are existential types.</description>
	<lastBuildDate>Mon, 13 Feb 2012 02:51:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='existentialtype.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/4192ff5d4a07fc7f4fa2a2ff285af64e?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Existential Type</title>
		<link>http://existentialtype.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://existentialtype.wordpress.com/osd.xml" title="Existential Type" />
	<atom:link rel='hub' href='http://existentialtype.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Referential transparency</title>
		<link>http://existentialtype.wordpress.com/2012/02/09/referential-transparency/</link>
		<comments>http://existentialtype.wordpress.com/2012/02/09/referential-transparency/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 04:19:31 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[assignables]]></category>
		<category><![CDATA[references]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=540</guid>
		<description><![CDATA[After reading some of the comments on my Words Matter post, I realized that it might be worthwhile to clarify the treatment of references in PFPL. Most people are surprised to learn that I have separated the concept of a reference from the concept of mutable storage. I realize that my treatment is not standard, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=540&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After reading some of the comments on my <a title="Words matter" href="http://existentialtype.wordpress.com/2012/02/01/words-matter/">Words Matter</a> post, I realized that it might be worthwhile to clarify the treatment of references in <a title="Practical Foundations for Programming Languages" href="http://www.cs.cmu.edu/~rwh/plbook/book.pdf" target="_blank">PFPL</a>. Most people are surprised to learn that I have separated the concept of a reference from the concept of mutable storage. I realize that my treatment is not standard, but I consider that one thing I learned in writing the book is how to do formulate references so that the concept of a reference is divorced from the thing to which it refers. Doing so allows for a nicely uniform account of references arising in many disparate situations, and is the basis for, among other things, a non-standard, but I think clearer, treatment of communication in process calculi.</p>
<p>It&#8217;s not feasible for me to reproduce the entire story here in a short post, so I will confine myself to a few remarks that will perhaps serve as encouragement to read the full story in <a title="Practical Foundations for Programming Languages" href="http://www.cs.cmu.edu/~rwh/plbook/book.pdf" target="_blank">PFPL</a>.</p>
<p>There is, first of all, a general concept of a <em>symbol</em>, or <em>name</em>, on which much of the development builds. Perhaps the most important thing to realize about symbols in my account is that <em>symbols are not forms of value</em>. They are, rather, a <em>indices</em> for an infinite, open-ended (expansible) family of operators for forming expressions. For example, when one introduces a symbol <em>a</em> as the name of an assignable, what one is doing is introducing two new operators, <em>get[a]</em> and <em>set[a]</em>, for getting and setting the contents of that assignable. Similarly, when one introduces a symbol <em>a</em> to be used as a channel name, then one is introducing operators <em>send[a]</em> and <em>receive[a]</em> that act on the channel named <em>a.</em> The point is that these operators <em>interpret</em> the symbol; for example, in the case of mutable state, the <em>get[a]</em> and <em>set[a]</em> operators are what make it be state, as opposed to some other use of the symbol <em>a</em> as an index for some other operator. There is no requirement that the state be formulated using &#8220;cells&#8221;; one could as well use the framework of algebraic effects pioneered by Plotkin and Power to give a dynamics to these operators. For present purposes I don&#8217;t care about how the dynamics is formulated; I only care about the laws that it obeys (this is the essence of the Plotkin/Power approach as I understand it).</p>
<p>Associated with each symbol <em>a</em> is a type that is, I hasten to emphasize <em>not</em> the type of the symbol <em>a</em> itself (the symbol inhabits no type), but is merely <em>associated</em> with it. For example, if <em>a</em> has the associated type <em>nat</em>, then <em>get[a]</em> will be a command returning a number, and <em>set[a](e)</em> will take a number, <em>e</em>, as argument. Similarly for channels, and other uses of symbols as indices of other operators.</p>
<p>Given a symbol <em>a</em> with associated type <em>T</em>, one may form a <em>reference</em> to <em>a</em>, written <em>&amp;a</em>, as a value whose type, in the case of a reference to an assignable, will be, say, <em>T assignable reference</em>, or similar terminology. This type is interpreted by elimination forms that take a <em>value</em> as argument, and transition to the corresponding operator for that assignable: <em>getref(&amp;a)</em> transitions to <em>get[a]</em>, and <em>setref(&amp;a;e)</em> transitions to <em>set[a](e)</em>. Similar rules govern other uses of symbols. The &#8220;ref&#8221; operations simply dereference the symbol (determine which assignable it references, in the case of assignables), and defer to the underlying interpretation of the referenced symbol. In the case of process calculi channel passing is effected using references to channels, and there are operations that determine an event based on the referent of a value of channel reference type. (This greatly clarifies, in my view, some messiness in the π-calculus, and leads to a much better-behaved theory of process equivalence.)</p>
<p>The scoping of symbols, or names, is handled independently of their interpretation. One may use either a scoped or a scope-free interpretation of symbols. Scoped symbols have a limited extent; free symbols have unlimited extent. The concept of a <em>mobile type</em>, adapted from our work on ML5, manages the interaction between scoped declarations and evaluation (for which see the book). One consequence is that <em>one may form references to both scoped and unscoped assignables, independently of the scope discipline</em>. In other words I am deliberately breaking the conventional (and, I think, mistaken) linkage between the <em>extent</em> of an assignable and the formation of a reference to it. Usually people conflate reference with state and with global extent; I am deliberately not following that convention, because I think it muddles things up in ways that are better handled in the manner I&#8217;m describing. So, for example, in my account of Algol I have no difficulty in allowing references to scoped assignables, and passing them as arguments to procedures, for example. I found this surprising, at first, but then quite natural once I had dissected the situation more carefully.</p>
<p>Finally, let me mention that the critical property of assignables (in fact, symbols in general) is that they admit <em>disequality. </em>Two different assignables, say <em>a </em>and <em>b</em>, can never, under any execution scenario, be aliases for one another: an assignment to one will never affect the content of the other. Aliasing is a property of <em>references</em>, because two references, say bound to variables <em>x</em> and <em>y</em>, may refer to the same underlying assignable, but two different assignables can never be aliases for one another. This is why &#8220;assignment conversion&#8221; as it is called in Scheme is not in any way an adequate response to my plea for a change of terminology!  Assignables and variables are different things, and references are yet different from those.</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/research/'>Research</a>, <a href='http://existentialtype.wordpress.com/category/teaching-2/'>Teaching</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/assignables/'>assignables</a>, <a href='http://existentialtype.wordpress.com/tag/references/'>references</a>, <a href='http://existentialtype.wordpress.com/tag/variables/'>variables</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/540/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/540/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/540/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/540/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/540/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/540/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/540/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/540/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/540/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/540/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/540/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/540/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/540/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/540/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=540&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2012/02/09/referential-transparency/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>Words matter</title>
		<link>http://existentialtype.wordpress.com/2012/02/01/words-matter/</link>
		<comments>http://existentialtype.wordpress.com/2012/02/01/words-matter/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 02:05:47 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[imperative programming]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/2012/02/01/words-matter/</guid>
		<description><![CDATA[Yesterday, during a very nice presentation by Ohad Kammar at Carnegie Mellon, the discussion got derailed, in part, because of a standard, and completely needless, terminological confusion involving the word &#8220;variable&#8221;.  I&#8217;m foolish enough to try to correct it. The problem is that we&#8217;ve all been taught to confuse variables with variables&#8212;that is, program variables [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=529&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday, during a very nice presentation by <a title="Ohad Kammar" href="http://homepages.inf.ed.ac.uk/s0894694/">Ohad Kammar</a> at Carnegie Mellon, the discussion got derailed, in part, because of a standard, and completely needless, terminological confusion involving the word &#8220;variable&#8221;.  I&#8217;m foolish enough to try to correct it.</p>
<p>The problem is that we&#8217;ve all been taught to confuse variables with variables&#8212;that is, program variables with mathematical variables.  The distinction is basic.  Since time immemorial (well, at least since <a title="al Khwarizmi" href="http://en.wikipedia.org/wiki/Muḥammad_ibn_Mūsā_al-Khwārizmī" target="_blank">al Khwarizmi</a>) we have had the notion of a variable, properly so-called, which is given meaning by substitution.  A variable is an unknown, or indeterminate, quantity that can be replaced by any value of its type (a type being, at least since <a title="Bertrand Russell" href="http://en.wikipedia.org/wiki/Bertrand_Russell" target="_blank">Russell</a>, the range of significance of a variable).  <a title="Gottlob Frege" href="http://en.wikipedia.org/wiki/Frege" target="_blank">Frege</a> gave the first systematic study of the quantifiers, and <a title="Alonzo Church" href="http://en.wikipedia.org/wiki/Alonzo_Church" target="_blank">Church</a> exploited the crucial concept of a variable to give the most sharply original and broadly applicable model of computation, the <img src='http://s0.wp.com/latex.php?latex=%5Clambda&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;lambda' title='&#92;lambda' class='latex' />-calculus.</p>
<p>Since the dawn of <a title="Fortran" href="http://en.wikipedia.org/wiki/Fortran" target="_blank">Fortran</a> something that is <em>not</em> a variable has come to be <em>called</em> a variable.  A program variable, in the sense of Fortran and every imperative language since, is not given meaning by substitution.  Rather, it is given meaning by (at least) two operations associated with it, one to <em>get</em> its contents and one to <em>put</em> new contents into it.  (And, maybe, an operation to form a <em>reference</em> to it, as in C or even Algol.)  Now as many of you know, I think that the concept of a program variable in this sense is by and large a bad idea, or at any rate not nearly as important as it has been made out to be in conventional (including object-oriented) languages, but that&#8217;s an argument for another occasion.</p>
<p>Instead, I&#8217;m making a plea.  Let&#8217;s continue to call variables variables.  It&#8217;s a perfectly good name, and refers to what is perhaps one of the greatest achievements of the human mind, the fundamental concept of algebra, the variable.  But let&#8217;s stop calling those other things variables!  In my <a title="Practical Foundation for Programming Languages" href="http://www.cs.cmu.edu/~rwh/plbook/book.pdf" target="_blank">Practical Foundations for Programming Languages</a> I coined (as far as I know) a word that seems perfectly serviceable, namely an <em>assignable</em>.  The things called variables in imperative languages should, rather, be called assignables.  The word is only a tad longer than <em>variable</em>, and rolls off the tongue just as easily, and has the advantage of being an accurate description of what it really is.  What&#8217;s not to like?</p>
<p>Why bother?  For one thing, some languages have <em>both</em> concepts, a necessity if you want your language to be mathematically civilized (and you do).  For another, in the increasingly important world of program verification, the specification formalisms, being mathematical in nature, make use of variables, which most definitely are not assignables!  But the real reason to make the distinction is, after all, because <em>words matter</em>.  Two different things deserve to have two different names, and it only confuses matters to use the same word for both.  This week&#8217;s confusion was only one example of many that I have seen over the years.</p>
<p>So, my suggestion: let&#8217;s call variables <em>variables</em>, and let&#8217;s call those other things <em>assignables</em>.  In the fullnesss of time (i.e., once the scourge of imperative programming has been lifted) we may not need the distinction any longer.  But until then, why not draw the distinction properly?</p>
<p><em>Addendum:</em> It seems worth mentioning that in PFPL I have a novel (afaik) treatment of the concept of a reference, which is clarified in a <a title="Referential transparency" href="http://existentialtype.wordpress.com/2012/02/09/referential-transparency/">subsequent post</a>.</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/programming/'>Programming</a>, <a href='http://existentialtype.wordpress.com/category/research/'>Research</a>, <a href='http://existentialtype.wordpress.com/category/teaching-2/'>Teaching</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/functional-programming/'>functional programming</a>, <a href='http://existentialtype.wordpress.com/tag/imperative-programming/'>imperative programming</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/529/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=529&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2012/02/01/words-matter/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>Heartbeat</title>
		<link>http://existentialtype.wordpress.com/2011/09/26/heartbeat/</link>
		<comments>http://existentialtype.wordpress.com/2011/09/26/heartbeat/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 20:51:56 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Teaching]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=377</guid>
		<description><![CDATA[Just a note in response to several requests to say that I am still around, and plan to resume blogging soon.   I have been distracted by more pressing concerns, including teaching at the Oregon Programming Languages Summer School (OPLSS), preparing a submission to  POPL, visiting the Max Planck Institute for Software Systems, and trying hard to finish [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=377&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a note in response to several requests to say that I am still around, and plan to resume blogging soon.   I have been distracted by more pressing concerns, including teaching at the <a title="Oregon Programming Languages Summer School" href="http://www.cs.uoregon.edu/Activities/summerschool/summer11/" target="_blank">Oregon Programming Languages Summer School (OPLSS)</a>, preparing a <a title="Canonicity for Two-Dimensional Type Theory" href="http://www.cs.cmu.edu/~rwh/papers.htm#2dtt-can" target="_blank">submission</a> to  <a href="http://www.cse.psu.edu/popl/12/" target="_blank">POPL</a>, visiting the <a title="Max Planck Institute for Software Systems" href="http://www.mpi-sws.org" target="_blank">Max Planck Institute for Software Systems</a>, and trying hard to finish my <a title="Practical Foundations for Programming Languages" href="http://www.cs.cmu.edu/~rwh/plbook/book.pdf" target="_blank">book</a> (on which I&#8217;ve made substantial progress over the summer).</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/programming/'>Programming</a>, <a href='http://existentialtype.wordpress.com/category/research/'>Research</a>, <a href='http://existentialtype.wordpress.com/category/teaching-2/'>Teaching</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/377/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/377/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/377/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=377&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/09/26/heartbeat/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>Types and Cells</title>
		<link>http://existentialtype.wordpress.com/2011/06/07/types-and-cells/</link>
		<comments>http://existentialtype.wordpress.com/2011/06/07/types-and-cells/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 20:37:13 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[type theory]]></category>
		<category><![CDATA[category theory]]></category>
		<category><![CDATA[groupoids]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=347</guid>
		<description><![CDATA[The doctrine of computational trinitarianism implies that there should be a categorial analogue of two-dimensional type theory &#8230; and indeed there is.  It is called, oddly enough, two-dimensional category theory, which arose first for numerous reasons.  What is two-dimensional category theory?  And how does it relate to two-dimensional type theory? Two-dimensional category theory may be seen [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=347&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The doctrine of <a title="The Holy Trinity" href="http://existentialtype.wordpress.com/2011/03/27/the-holy-trinity/">computational trinitarianism </a>implies that there should be a categorial analogue of <a title="Higher-Dimensional Type Theory" href="http://existentialtype.wordpress.com/2011/05/30/higher-dimensional-type-theory/">two-dimensional type theory</a> &#8230; and indeed there is.  It is called, oddly enough, two-dimensional category theory, which arose first for numerous reasons.  What is two-dimensional category theory?  And how does it relate to two-dimensional type theory?</p>
<p>Two-dimensional category theory may be seen as an instance of the general concept of <em>enriched </em>categories in which the collection of morphisms between any two objects is endowed with some additional structure. A <em>locally small</em> category is one for which the maps between any two objects form a set, called the <em>hom set</em>.  An <em>order-enriched</em> category is one in which the morphisms form an ordered set, which is a set equipped with a pre-order (reflexive and transitive relation) on maps such that composition is monotone.  Order-enriched categories were used by Mitchell Wand and Gordon Plotkin and Mike Smyth in their development of the category-theoretic interpretation of recursive types.  Specifically, an <em>O-category</em> is an order-enriched category whose objects are cpo&#8217;s (pre-orders closed under sup&#8217;s of chains, and hence containing a least element) and whose hom sets are themselves cpo&#8217;s and for which composition is continuous (monotone and preserves suprema of chains).</p>
<p>More generally still, one may  consider (different forms of) <em>category-enriched</em> categories, in which the hom sets are structured as categories with their own<em> vertical </em>notion of identity and composition that meshes well with the <em>horizontal</em> notion of identity and composition of the category itself.  (I will not give here the precise meaning of &#8220;meshes well with&#8221;, since there are several possible notions and I will be discussing this structure in the type-theoretic setting below.)  The vertical maps are <em>maps between maps</em> that can be interpreted in several ways.  One way is as &#8220;witnesses&#8221; to an ordering relation among maps, viewing a category as a &#8220;pre-order with witnesses&#8221;, perhaps an approximation relation among maps such as arises in domain theory.  Another is to view these maps as homotopies between continuous functions on a space; these are the continuous deformations of one map into another.  (This is usually expressed by introducing a &#8220;time&#8221; coordinate ranging over the unit interval, and stating that a homotopy <em>h</em> between maps <em>f </em>and <em>g</em> is a continuous mapping such that at time zero <em>h</em> agrees with <em>f</em>, at time 1 agrees with <em>g</em>, and smoothly varies at times between.)  An important special case of category-enriched categories are those whose morphisms form (not just a category but also) a <em>groupoid</em>, a category in which each map is invertible.  These can be thought of as &#8220;equivalence relations with evidence&#8221;; the vertical maps are &#8220;proofs&#8221; that two horizontal maps are equivalent (for example, homotopic).</p>
<p>The sort of category-enriched categories that I have in mind are called <em>(strict)</em> <em>2-categories</em>.  And as the terminology suggests, there is nothing special about the number 2 here; one can consider <img src='http://s0.wp.com/latex.php?latex=n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n' title='n' class='latex' />-categories for any number <img src='http://s0.wp.com/latex.php?latex=n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n' title='n' class='latex' />, and even <img src='http://s0.wp.com/latex.php?latex=%5Cinfty&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;infty' title='&#92;infty' class='latex' />-categories that incorporate all of these into one grand structure (strictly or weakly).  To help manage this structure, the categorists have a uniform terminology that I wish to introduce here, called <em>cells</em>.  The objects in a category are the <em>0-cells</em>, the maps are the <em>1-cells</em>, the maps between maps (transformations, homotopies, &#8230;) are the <em>2-cells</em>, and so forth.  A 2-category is one for which we stop at 2-cells; all higher cells being degenerate and hence ignored.  Often the 2-cells (and higher) form groupoids (in one of two senses that I will come back to later); a (2,1)-category is a 2-category in which the 2-cells form a groupoid (but the 1-cells need only form a category).  The class of <img src='http://s0.wp.com/latex.php?latex=%28%5Cinfty%2C1%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(&#92;infty,1)' title='(&#92;infty,1)' class='latex' />-categories are the subject of intense interest these days, in part because of their importance in homotopy theory.  They are, however, notoriously hard to manage, and, from what I understand, it is not yet clear what is even the correct definition.</p>
<p>Returning to <a title="Higher-Dimensional Type Theory" href="http://existentialtype.wordpress.com/2011/05/30/higher-dimensional-type-theory/">two-dimensional type theory</a>, and applying the types-as-categories correspondence, we get that types are 0-cells, terms (with free variables) are 1-cells, and transformations are 2-cells.  General terms are not invertible, but transformations are, giving rise to a <a title="Transformations as strict groupoids" href="http://existentialtype.wordpress.com/2011/05/30/transformations-as-strict-groupoids/">(strict) groupoid structure</a> expressed by the judgement <img src='http://s0.wp.com/latex.php?latex=%5Calpha%3A%3AM%5Csimeq+N%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha::M&#92;simeq N:A' title='&#92;alpha::M&#92;simeq N:A' class='latex' />.  The rules for composition of transformations expresses the vertical structure as forming a strict groupoid.  Ordinary substitution expresses the horizontal structure of terms as maps (plugging in terms for free variables).  But how do these interact?  In strict two-dimensional type theory this interaction is expressed by definitional equalities that express the <em>interchange law</em> between horizontal and vertical composition.  Specifically, we have the following rule:</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B++%7Bx%3AB%5Cvdash+%5Calpha%3A%3AM%5Csimeq+N%3AA+%5Cqquad+%5Cvdash+%5Cbeta%3A%3AP%5Csimeq+Q%3AB%7D%5Cover%7B%5Calpha%5B%5Cbeta%5D%3A%3A%5Ctextit%7Bmap%7D%5C%7Bx%3AB.A%5C%7D%5B%5Cbeta%5D%28M%5BP%2Fx%5D%29%5Csimeq+N%5BQ%2Fx%5D%3AA%5BQ%2Fx%5D%7D++%7D+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{  {x:B&#92;vdash &#92;alpha::M&#92;simeq N:A &#92;qquad &#92;vdash &#92;beta::P&#92;simeq Q:B}&#92;over{&#92;alpha[&#92;beta]::&#92;textit{map}&#92;{x:B.A&#92;}[&#92;beta](M[P/x])&#92;simeq N[Q/x]:A[Q/x]}  } ' title='&#92;displaystyle{  {x:B&#92;vdash &#92;alpha::M&#92;simeq N:A &#92;qquad &#92;vdash &#92;beta::P&#92;simeq Q:B}&#92;over{&#92;alpha[&#92;beta]::&#92;textit{map}&#92;{x:B.A&#92;}[&#92;beta](M[P/x])&#92;simeq N[Q/x]:A[Q/x]}  } ' class='latex' /></p></blockquote>
<p>(More generally one must consider arbitrary contexts, and transformations between substitutions, but this instance of the general case expresses the essential idea.)</p>
<p>This &#8220;substitution&#8221; principle must satisfy some equational laws that amount to the following conditions:</p>
<ol>
<li>Identity: <img src='http://s0.wp.com/latex.php?latex=%5Calpha%5B%5Ctextit%7Bid%7D%5D%5Cequiv%5Calpha&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha[&#92;textit{id}]&#92;equiv&#92;alpha' title='&#92;alpha[&#92;textit{id}]&#92;equiv&#92;alpha' class='latex' />.</li>
<li>Composition: <img src='http://s0.wp.com/latex.php?latex=%5Calpha%5B%5Cbeta%5B%5Cgamma%5D%5D%5Cequiv+%5Calpha%5B%5Cbeta%5D%5B%5Cgamma%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha[&#92;beta[&#92;gamma]]&#92;equiv &#92;alpha[&#92;beta][&#92;gamma]' title='&#92;alpha[&#92;beta[&#92;gamma]]&#92;equiv &#92;alpha[&#92;beta][&#92;gamma]' class='latex' />.</li>
<li>Interchange: <img src='http://s0.wp.com/latex.php?latex=%28%5Calpha%5Ccirc%5Calpha%27%29%5B%5Cbeta%5Ccirc%5Cbeta%27%5D+%3D+%5Calpha%5B%5Cbeta%5D+%5Ccirc+%5Ctextit%7Bresp%7D%5C%7Bmap%5B%5Cbeta%5D%5C%7D+%28%5Calpha%27%5B%5Cbeta%27%5D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(&#92;alpha&#92;circ&#92;alpha&#039;)[&#92;beta&#92;circ&#92;beta&#039;] = &#92;alpha[&#92;beta] &#92;circ &#92;textit{resp}&#92;{map[&#92;beta]&#92;} (&#92;alpha&#039;[&#92;beta&#039;])' title='(&#92;alpha&#92;circ&#92;alpha&#039;)[&#92;beta&#92;circ&#92;beta&#039;] = &#92;alpha[&#92;beta] &#92;circ &#92;textit{resp}&#92;{map[&#92;beta]&#92;} (&#92;alpha&#039;[&#92;beta&#039;])' class='latex' />.</li>
<li>Delegation: <img src='http://s0.wp.com/latex.php?latex=%28%5Ctextit%7Bid%7D_M%29%5B%5Cdelta%5D%5Cequiv+M%5B%5Cdelta%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(&#92;textit{id}_M)[&#92;delta]&#92;equiv M[&#92;delta]' title='(&#92;textit{id}_M)[&#92;delta]&#92;equiv M[&#92;delta]' class='latex' />.</li>
</ol>
<p>(Here <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7Bresp%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{resp}' title='&#92;textit{resp}' class='latex' /> is the application of a transformation to a term; it is there to &#8220;get the types right&#8221;.)  The interchange law is the type-theoretic analogue of the required interaction between 1-composition and 2-composition in a <a title="Strict 2-Category" href="http://ncatlab.org/nlab/show/strict+2-category" target="_blank">(strict) 2-category</a>.</p>
<p>This is the judgmental structure of strict two-dimensional type theory.  There are several directions we can go from here.  One is to clarify the strict/weak distinction that has been underlying our discussions so far.  Another is to consider how to extend this to three- and higher-dimensional (or, dare I say it, infinite-dimensional) type theory.  The crucial ingredient for both of these discussions is one particular type constructor (more precisely, family of type constructors) that <em>internalizes</em> the hom structure as a type.  In the groupoidal case, where the higher structure is symmetric (invertible), this corresponds to (a version of) the Martin-Löf identity type.  The introduction rule is reflexivity, and the elimination rule is, in essence, the Yoneda Lemma from category theory.  When interpreted in terms of homotopy theory, this is the type of <em>paths </em>in a space, which is critical for defining the fundamental group(oid) of a space, and to clarifying the hinted-at distinction between weak and strict structure in higher dimensions.  More on that later!</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/research/'>Research</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/category-theory/'>category theory</a>, <a href='http://existentialtype.wordpress.com/tag/groupoids/'>groupoids</a>, <a href='http://existentialtype.wordpress.com/tag/type-theory/'>type theory</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/347/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/347/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/347/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=347&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/06/07/types-and-cells/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>Transformations as strict groupoids</title>
		<link>http://existentialtype.wordpress.com/2011/05/30/transformations-as-strict-groupoids/</link>
		<comments>http://existentialtype.wordpress.com/2011/05/30/transformations-as-strict-groupoids/#comments</comments>
		<pubDate>Tue, 31 May 2011 01:39:22 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[type theory]]></category>
		<category><![CDATA[category theory]]></category>
		<category><![CDATA[homotopy theory]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=312</guid>
		<description><![CDATA[The distinguishing feature of higher-dimensional type theory is the concept of equivalence of the members of a type that must be respected by all families of types.  To be sufficiently general it is essential to regard equivalence as a structure, rather than a property.  This is expressed by the judgement which states that and are equivalent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=312&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The distinguishing feature of higher-dimensional type theory is the concept of <em>equivalence</em> of the members of a type that must be respected by all families of types.  To be sufficiently general it is essential to regard equivalence as a <em>structure, </em>rather than a <em>property.  </em>This is expressed by the judgement</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5CGamma%5Cvdash+%5Calpha%3A%3AM%5Csimeq+N%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;Gamma&#92;vdash &#92;alpha::M&#92;simeq N:A' title='&#92;displaystyle &#92;Gamma&#92;vdash &#92;alpha::M&#92;simeq N:A' class='latex' /></p></blockquote>
<p>which states that <img src='http://s0.wp.com/latex.php?latex=M&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='M' title='M' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> are equivalent members of type <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' />, as evidenced by the transformation <img src='http://s0.wp.com/latex.php?latex=%5Calpha&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha' title='&#92;alpha' class='latex' />.  Respect for equivalence is ensured by the rule</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%7B%5CGamma%2Cx%3AA%5Cvdash+B%5C%2C%5Ctextsf%7Btype%7D%5Cquad++%5CGamma%5Cvdash+%5Calpha+%3A%3A+M%5Csimeq+N%3AA+%5Cquad++%5CGamma%5Cvdash+P%3AB%5BM%2Fx%5D%7D%5Cover++%7B%5CGamma%5Cvdash+%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D%5B%5Calpha%5D%28P%29%3AB%5BN%2Fx%5D%7D%7D%2C&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{{&#92;Gamma,x:A&#92;vdash B&#92;,&#92;textsf{type}&#92;quad  &#92;Gamma&#92;vdash &#92;alpha :: M&#92;simeq N:A &#92;quad  &#92;Gamma&#92;vdash P:B[M/x]}&#92;over  {&#92;Gamma&#92;vdash &#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](P):B[N/x]}},' title='&#92;displaystyle{{&#92;Gamma,x:A&#92;vdash B&#92;,&#92;textsf{type}&#92;quad  &#92;Gamma&#92;vdash &#92;alpha :: M&#92;simeq N:A &#92;quad  &#92;Gamma&#92;vdash P:B[M/x]}&#92;over  {&#92;Gamma&#92;vdash &#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](P):B[N/x]}},' class='latex' /></p></blockquote>
<p>which states that equivalent members determine equivalent instances of a family of types.  The equivalence between instances is mediated by the operation <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D%5B%5Calpha%5D%28-%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](-)' title='&#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](-)' class='latex' />, which sends members of <img src='http://s0.wp.com/latex.php?latex=B%5BM%2Fx%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B[M/x]' title='B[M/x]' class='latex' /> to members of <img src='http://s0.wp.com/latex.php?latex=B%5BN%2Fx%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B[N/x]' title='B[N/x]' class='latex' />.  We call this mapping the <em>action </em>of the family <img src='http://s0.wp.com/latex.php?latex=x%3AA.B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x:A.B' title='x:A.B' class='latex' /> on the transformation <img src='http://s0.wp.com/latex.php?latex=%5Calpha&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha' title='&#92;alpha' class='latex' />.</p>
<p>For reasons that will only become apparent as we go along, it is important that &#8220;equivalence&#8221; really be an equivalence: it must be, in an appropriate sense, reflexive, symmetric, and transitive.  The &#8220;appropriate sense&#8221; is precisely that we require the existence of transformations</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5CGamma%5Cvdash+%5Ctextit%7Bid%7D%3A%3AM%5Csimeq+M%3AA%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;Gamma&#92;vdash &#92;textit{id}::M&#92;simeq M:A}' title='&#92;displaystyle{&#92;Gamma&#92;vdash &#92;textit{id}::M&#92;simeq M:A}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%7B%5CGamma%5Cvdash%5Calpha%3A%3AM%5Csimeq+N%3AA%7D%5Cover%7B%5CGamma%5Cvdash%5Calpha%5E%7B-1%7D%3A%3AN%5Csimeq+M%3AA%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{{&#92;Gamma&#92;vdash&#92;alpha::M&#92;simeq N:A}&#92;over{&#92;Gamma&#92;vdash&#92;alpha^{-1}::N&#92;simeq M:A}}' title='&#92;displaystyle{{&#92;Gamma&#92;vdash&#92;alpha::M&#92;simeq N:A}&#92;over{&#92;Gamma&#92;vdash&#92;alpha^{-1}::N&#92;simeq M:A}}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%7B%5CGamma%5Cvdash+%5Cbeta%3AN%5Csimeq+P%3AA%5Cquad++%5CGamma%5Cvdash+%5Calpha%3AM%5Csimeq+N%3AA%7D%5Cover%7B%5CGamma%5Cvdash%5Cbeta%5Ccirc%5Calpha%3AM%5Csimeq+P%3AA%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{{&#92;Gamma&#92;vdash &#92;beta:N&#92;simeq P:A&#92;quad  &#92;Gamma&#92;vdash &#92;alpha:M&#92;simeq N:A}&#92;over{&#92;Gamma&#92;vdash&#92;beta&#92;circ&#92;alpha:M&#92;simeq P:A}}' title='&#92;displaystyle{{&#92;Gamma&#92;vdash &#92;beta:N&#92;simeq P:A&#92;quad  &#92;Gamma&#92;vdash &#92;alpha:M&#92;simeq N:A}&#92;over{&#92;Gamma&#92;vdash&#92;beta&#92;circ&#92;alpha:M&#92;simeq P:A}}' class='latex' /></p></blockquote>
<p>Moreover, these transformations must be respected by the action of any family, in a sense that we shall make clear momentarily.  Before doing so, let us observe that these transformations constitute the operations of a <em>groupoid</em>, which we may think of either as <em>an equivalence relation equipped with evidence</em> or <em>a category in which every map is invertible (a generalized group)</em>.  While the former interpretation may not suggest it, the latter formulation implies that we should impose some requirements on how these transformations interact, namely the axioms of a groupoid:</p>
<ol>
<li>Composition (multiplication) is <em>associative</em>: <img src='http://s0.wp.com/latex.php?latex=%5Cgamma%5Ccirc%28%5Cbeta%5Ccirc%5Calpha%29%5Cequiv+%28%5Cgamma%5Ccirc%5Cbeta%29%5Ccirc%5Calpha%3A%3AM%5Csimeq+N%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;gamma&#92;circ(&#92;beta&#92;circ&#92;alpha)&#92;equiv (&#92;gamma&#92;circ&#92;beta)&#92;circ&#92;alpha::M&#92;simeq N:A' title='&#92;gamma&#92;circ(&#92;beta&#92;circ&#92;alpha)&#92;equiv (&#92;gamma&#92;circ&#92;beta)&#92;circ&#92;alpha::M&#92;simeq N:A' class='latex' />.</li>
<li>Identity is the <em>unit</em> of composition: <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7Bid%7D%5Ccirc%5Calpha%5Cequiv%5Calpha%3A%3AM%5Csimeq+N%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{id}&#92;circ&#92;alpha&#92;equiv&#92;alpha::M&#92;simeq N:A' title='&#92;textit{id}&#92;circ&#92;alpha&#92;equiv&#92;alpha::M&#92;simeq N:A' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Calpha%5Ccirc%5Ctextit%7Bid%7D%5Cequiv%5Calpha%3A%3AM%5Csimeq+N%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha&#92;circ&#92;textit{id}&#92;equiv&#92;alpha::M&#92;simeq N:A' title='&#92;alpha&#92;circ&#92;textit{id}&#92;equiv&#92;alpha::M&#92;simeq N:A' class='latex' />.</li>
<li>Inverses <em>cancel</em>: <img src='http://s0.wp.com/latex.php?latex=%5Calpha%5E%7B-1%7D%5Ccirc%5Calpha%5Cequiv%5Ctextit%7Bid%7D%3A%3AM%5Csimeq+M%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha^{-1}&#92;circ&#92;alpha&#92;equiv&#92;textit{id}::M&#92;simeq M:A' title='&#92;alpha^{-1}&#92;circ&#92;alpha&#92;equiv&#92;textit{id}::M&#92;simeq M:A' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Calpha%5Ccirc%5Calpha%5E%7B-1%7D%5Cequiv%5Ctextit%7Bid%7D%3A%3AN%5Csimeq+N%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha&#92;circ&#92;alpha^{-1}&#92;equiv&#92;textit{id}::N&#92;simeq N:A' title='&#92;alpha&#92;circ&#92;alpha^{-1}&#92;equiv&#92;textit{id}::N&#92;simeq N:A' class='latex' />.</li>
</ol>
<div>These conditions, which impose <em>equalities</em> on transformations, demand that the second-dimensional structure of a type form a <em>strict groupoid</em>.  I will come back to an important weakening of these requirements later.</div>
<p>We further require that the action of a type family preserve the groupoid structure.  For this it is enough to require that it preserve identities and composition:</p>
<blockquote>
<div><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D%5B%5Ctextit%7Bid%7D%5D%28-%29+%5Cequiv+%5Ctextit%7Bid%7D%28-%29%3AB%5BM%2Fx%5D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;textit{map}&#92;{x:A.B&#92;}[&#92;textit{id}](-) &#92;equiv &#92;textit{id}(-):B[M/x]}' title='&#92;displaystyle{&#92;textit{map}&#92;{x:A.B&#92;}[&#92;textit{id}](-) &#92;equiv &#92;textit{id}(-):B[M/x]}' class='latex' /></div>
</blockquote>
<p>and</p>
<blockquote>
<div><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Cbegin%7Barray%7D%7Bc%7D%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D%5B%5Cbeta%5Ccirc%5Calpha%5D%28-%29%5C%5C%5Cequiv%5C%5C%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D%5B%5Cbeta%5D%28%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D%5B%5Calpha%5D%28-%29%29%5Cend%7Barray%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;begin{array}{c}&#92;textit{map}&#92;{x:A.B&#92;}[&#92;beta&#92;circ&#92;alpha](-)&#92;&#92;&#92;equiv&#92;&#92;&#92;textit{map}&#92;{x:A.B&#92;}[&#92;beta](&#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](-))&#92;end{array}}' title='&#92;displaystyle{&#92;begin{array}{c}&#92;textit{map}&#92;{x:A.B&#92;}[&#92;beta&#92;circ&#92;alpha](-)&#92;&#92;&#92;equiv&#92;&#92;&#92;textit{map}&#92;{x:A.B&#92;}[&#92;beta](&#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](-))&#92;end{array}}' class='latex' />.</div>
</blockquote>
<p>Thinking of a groupoid as a category, these conditions state that the action of a type family be <em>(strictly) </em><em>functorial</em>.  (Here again we are imposing strong requirements in order to facilitate the exposition; eventually we will consider a relaxation of these conditions that will admit a richer range of applications.)</p>
<p>(The alert reader will note that I have not formally introduced the concept of a transformation between<em> types</em>, nor the equality of these, into the theory.  There are different ways to skin this cat; for now, I will be a bit loose about the axiomatics in order to focus attention on the main ideas.  Rest assured that everything can be made precise!)</p>
<p>By demanding that the groupoid axioms hold strictly (as equalities) and that the action of families be strictly functorial, we have simplified the theory considerably by restricting it to dimension 2.  To relax these restrictions requires higher dimensions.  For example, we may demand only that the groupoid conditions hold <em>up to a transformation of transformations</em>, but hold strictly from then on; this is the 3-dimensional case.  Or we can relax all such conditions to hold only up to a higher transformation, resulting in <em>finite dimensional type theory</em>.  Similar considerations will apply to other conditions that we shall impose on the action of families, in particular to specify the action of type constructors on transformations, which I will discuss next time.  The presentation of finite-dimensional type theory will be aided by the introduction of <em>identity types</em> (also called <em>path types</em>).  Identity types avoid the need for an ever-expanding nesting of transformations between transformations between &#8230;.  More on that later!</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/research/'>Research</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/category-theory/'>category theory</a>, <a href='http://existentialtype.wordpress.com/tag/homotopy-theory/'>homotopy theory</a>, <a href='http://existentialtype.wordpress.com/tag/type-theory/'>type theory</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/312/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=312&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/05/30/transformations-as-strict-groupoids/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>Higher-Dimensional Type Theory</title>
		<link>http://existentialtype.wordpress.com/2011/05/30/higher-dimensional-type-theory/</link>
		<comments>http://existentialtype.wordpress.com/2011/05/30/higher-dimensional-type-theory/#comments</comments>
		<pubDate>Mon, 30 May 2011 04:38:58 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[type theory]]></category>
		<category><![CDATA[category theory]]></category>
		<category><![CDATA[homotopy theory]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=254</guid>
		<description><![CDATA[Ideas have their time, and it&#8217;s not for us to choose when they arrive.  But when they do, they almost always occur to many people at more or less the same time, often in a slightly disguised form whose underlying unity becomes apparent only later.  This is perhaps not too surprising, the same seeds taking [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=254&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ideas have their time, and it&#8217;s not for us to choose when they arrive.  But when they do, they almost always occur to many people at more or less the same time, often in a slightly disguised form whose underlying unity becomes apparent only later.  This is perhaps not too surprising, the same seeds taking root in many a fertile mind.  A bit harder to explain, though, is the moment in time when an idea comes to fruition.  Often all of the ingredients are available, and yet no one thinks to put two-and-two together and draw what seems, in retrospect, to be the obvious inference.  Until, suddenly, everyone does.  Why didn&#8217;t we think of that ages ago?  Nothing was stopping us, we just didn&#8217;t notice the opportunity!</p>
<p>The recent development of higher-dimensional structure in type theory seems to be a good example.  All of the ingredients have been present since the 1970&#8242;s, yet as far as I know no one, until quite recently, no one quite put together all the pieces to expose the beautiful structure that has been sitting there all along.  Like many good ideas, one can see clearly that the ideas were foreshadowed by many earlier developments whose implications are only now becoming understood.  My plan is to explain higher type theory (HTT) to the well-informed non-expert, building on ideas developed by various researchers, including Thorsten Altenkirch, Steve Awodey, Richard Garner, Martin Hofmann, Dan Licata, Peter Lumsdaine, Per Martin-Löf, Mike Shulman, Thomas Streicher, Vladimir Voevodsky, and Michael Warren.  It will be useful in the sequel to be familiar with <a title="The Holy Trinity" href="http://existentialtype.wordpress.com/2011/03/27/the-holy-trinity/">The Holy Trinity</a>, at least superficially, and preferably well enough to be able to move back and forth between the three manifestations that I&#8217;ve previously outlined.</p>
<p>One-dimensional dependent type theory is defined by derivation rules for these four fundamental forms of judgement (and, usually, some others that we suppress here for the sake of concision):</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5CGamma%5Cvdash+A%5C%2C%5Cmathsf%7Btype%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;Gamma&#92;vdash A&#92;,&#92;mathsf{type}' title='&#92;displaystyle &#92;Gamma&#92;vdash A&#92;,&#92;mathsf{type}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5CGamma%5Cvdash+M+%3A+A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;Gamma&#92;vdash M : A' title='&#92;displaystyle &#92;Gamma&#92;vdash M : A' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5CGamma%5Cvdash+M+%5Cequiv+N+%3A+A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;Gamma&#92;vdash M &#92;equiv N : A' title='&#92;displaystyle &#92;Gamma&#92;vdash M &#92;equiv N : A' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5CGamma%5Cvdash+A%5Cequiv+B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;Gamma&#92;vdash A&#92;equiv B' title='&#92;displaystyle &#92;Gamma&#92;vdash A&#92;equiv B' class='latex' /></p></blockquote>
<p>A <em>context</em>, <img src='http://s0.wp.com/latex.php?latex=%5CGamma&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;Gamma' title='&#92;Gamma' class='latex' />, consists of a sequence of declarations of variables of the form <img src='http://s0.wp.com/latex.php?latex=x_1%3AA_1%2C%5Cdots%2Cx_n%3AA_n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x_1:A_1,&#92;dots,x_n:A_n' title='x_1:A_1,&#92;dots,x_n:A_n' class='latex' />, where it is presupposed, for each <img src='http://s0.wp.com/latex.php?latex=1%5Cleq+i%5Cleq+n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='1&#92;leq i&#92;leq n' title='1&#92;leq i&#92;leq n' class='latex' />, that <img src='http://s0.wp.com/latex.php?latex=x_1%3AA_1%2C%5Cdots%2Cx_%7Bi-1%7D%3AA_%7Bi-1%7D%5Cvdash+A_i%5C%2C%5Cmathsf%7Btype%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x_1:A_1,&#92;dots,x_{i-1}:A_{i-1}&#92;vdash A_i&#92;,&#92;mathsf{type}' title='x_1:A_1,&#92;dots,x_{i-1}:A_{i-1}&#92;vdash A_i&#92;,&#92;mathsf{type}' class='latex' /> is derivable.</p>
<p>The key notion of dependent type theory is that of a <em>family of types</em> indexed by (zero or more) variables ranging over a type.  The judgement <img src='http://s0.wp.com/latex.php?latex=%5CGamma%5Cvdash+A%5C%2C%5Cmathsf%7Btype%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;Gamma&#92;vdash A&#92;,&#92;mathsf{type}' title='&#92;Gamma&#92;vdash A&#92;,&#92;mathsf{type}' class='latex' /> states that <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' /> is a family of types indexed by the variables given by <img src='http://s0.wp.com/latex.php?latex=%5CGamma&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;Gamma' title='&#92;Gamma' class='latex' />.  For example, we may have <img src='http://s0.wp.com/latex.php?latex=%5Cvdash%5Ctextit%7BNat%7D%5C%2C%5Ctextsf%7Btype%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;vdash&#92;textit{Nat}&#92;,&#92;textsf{type}' title='&#92;vdash&#92;textit{Nat}&#92;,&#92;textsf{type}' class='latex' />, specifying that <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7BNat%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{Nat}' title='&#92;textit{Nat}' class='latex' /> is a closed type (a degenerate family of types), and <img src='http://s0.wp.com/latex.php?latex=x%7B%3A%7D%5Ctextit%7BNat%7D%5Cvdash%5Ctextit%7BSeq%7D%28x%29%5C%2C%5Ctextsf%7Btype%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x{:}&#92;textit{Nat}&#92;vdash&#92;textit{Seq}(x)&#92;,&#92;textsf{type}' title='x{:}&#92;textit{Nat}&#92;vdash&#92;textit{Seq}(x)&#92;,&#92;textsf{type}' class='latex' />, specifying that <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7BSeq%7D%28n%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{Seq}(n)' title='&#92;textit{Seq}(n)' class='latex' /> is a type (say, of sequences of naturals of length <img src='http://s0.wp.com/latex.php?latex=n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n' title='n' class='latex' />) for each <img src='http://s0.wp.com/latex.php?latex=%5Cvdash+n%3A%5Ctextit%7BNat%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;vdash n:&#92;textit{Nat}' title='&#92;vdash n:&#92;textit{Nat}' class='latex' />.  The rules of type theory ensure, either directly or indirectly, that the <a title="Modules Matter Most" href="http://existentialtype.wordpress.com/2011/04/16/modules-matter-most/">structural properties </a>of the hypothetical/general judgement are valid.  In particular <em>families of types respect equality of indices</em>:</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%7B%5CGamma%2Cx%3AA%5Cvdash+B%5C%2C%5Ctextsf%7Btype%7D%5Cquad+%5CGamma%5Cvdash+M%5Cequiv+N%3AA+%5Cquad+%5CGamma%5Cvdash+P%3AB%5BM%2Fx%5D%7D%5Cover++%7B%5CGamma%5Cvdash+P%3AB%5BN%2Fx%5D%7D%7D.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{{&#92;Gamma,x:A&#92;vdash B&#92;,&#92;textsf{type}&#92;quad &#92;Gamma&#92;vdash M&#92;equiv N:A &#92;quad &#92;Gamma&#92;vdash P:B[M/x]}&#92;over  {&#92;Gamma&#92;vdash P:B[N/x]}}.' title='&#92;displaystyle{{&#92;Gamma,x:A&#92;vdash B&#92;,&#92;textsf{type}&#92;quad &#92;Gamma&#92;vdash M&#92;equiv N:A &#92;quad &#92;Gamma&#92;vdash P:B[M/x]}&#92;over  {&#92;Gamma&#92;vdash P:B[N/x]}}.' class='latex' /></p></blockquote>
<p>In words, if <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' /> is a family of types indexed by <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' />, and if <img src='http://s0.wp.com/latex.php?latex=M&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='M' title='M' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> are equal members of type <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' />, then every member of <img src='http://s0.wp.com/latex.php?latex=B%5BM%2Fx%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B[M/x]' title='B[M/x]' class='latex' /> is also a member of <img src='http://s0.wp.com/latex.php?latex=B%5BN%2Fx%5D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B[N/x]' title='B[N/x]' class='latex' />.</p>
<p>The generalization to two- (and higher-) dimensional type theory can be motivated in several ways.  One natural source of higher-dimensional structure is a <em>universe</em>, a type whose elements correspond to types.  For example, we may have a universe<em> </em>of <em>sets</em> given as follows:</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Cvdash+%5Ctextit%7BSet%7D%5C%2C%5Ctextsf%7Btype%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;vdash &#92;textit{Set}&#92;,&#92;textsf{type}' title='&#92;displaystyle &#92;vdash &#92;textit{Set}&#92;,&#92;textsf{type}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+x%3A%5Ctextit%7BSet%7D%5Cvdash+%5Ctextit%7BElt%7D%28x%29%5C%2C%5Ctextsf%7Btype%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle x:&#92;textit{Set}&#92;vdash &#92;textit{Elt}(x)&#92;,&#92;textsf{type}' title='&#92;displaystyle x:&#92;textit{Set}&#92;vdash &#92;textit{Elt}(x)&#92;,&#92;textsf{type}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Cvdash+%5Ctextit%7Bnat%7D%3A%5Ctextit%7BSet%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;vdash &#92;textit{nat}:&#92;textit{Set}' title='&#92;displaystyle &#92;vdash &#92;textit{nat}:&#92;textit{Set}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Cvdash+%5Ctextit%7BElt%7D%28%5Ctextit%7Bnat%7D%29%5Cequiv%5Ctextit%7BNat%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;vdash &#92;textit{Elt}(&#92;textit{nat})&#92;equiv&#92;textit{Nat}' title='&#92;displaystyle &#92;vdash &#92;textit{Elt}(&#92;textit{nat})&#92;equiv&#92;textit{Nat}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+a%3A%5Ctextit%7BSet%7D%2Cb%3A%5Ctextit%7BSet%7D%5Cvdash+a%5Ctimes+b+%3A+%5Ctextit%7BSet%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle a:&#92;textit{Set},b:&#92;textit{Set}&#92;vdash a&#92;times b : &#92;textit{Set}' title='&#92;displaystyle a:&#92;textit{Set},b:&#92;textit{Set}&#92;vdash a&#92;times b : &#92;textit{Set}' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+a%3A%5Ctextit%7BSet%7D%2Cb%3A%5Ctextit%7BSet%7D%5Cvdash+%5Ctextit%7BElt%7D%28a%5Ctimes+b%29%5Cequiv+%5Ctextit%7BElt%7D%28a%29%5Ctimes%5Ctextit%7BElt%7D%28b%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle a:&#92;textit{Set},b:&#92;textit{Set}&#92;vdash &#92;textit{Elt}(a&#92;times b)&#92;equiv &#92;textit{Elt}(a)&#92;times&#92;textit{Elt}(b)' title='&#92;displaystyle a:&#92;textit{Set},b:&#92;textit{Set}&#92;vdash &#92;textit{Elt}(a&#92;times b)&#92;equiv &#92;textit{Elt}(a)&#92;times&#92;textit{Elt}(b)' class='latex' /></p></blockquote>
<p>and so forth, ensuring that <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7BSet%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{Set}' title='&#92;textit{Set}' class='latex' /> is closed under typical set-forming operations whose interpretations are given by <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7BElt%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{Elt}' title='&#92;textit{Elt}' class='latex' /> in terms of standard type-theoretic concepts.</p>
<p>In many situations, including much of informal (yet entirely rigorous) mathematics, it is convenient to <em>identify</em> sets that are <em>isomorphic</em>, so that, for example, the sets <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7Bnat%7D%5Ctimes%5Ctextit%7Bnat%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{nat}&#92;times&#92;textit{nat}' title='&#92;textit{nat}&#92;times&#92;textit{nat}' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7B2%7D%5Cto%5Ctextit%7Bnat%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{2}&#92;to&#92;textit{nat}' title='&#92;textit{2}&#92;to&#92;textit{nat}' class='latex' /> would be interchangeable.  In particular, these sets should have the &#8220;same&#8221; (type of) elements.  But obviously these two sets do not have the <em>same</em> elements (one consists of pairs, the other of functions, under the natural interpretation of the sets as types), so we cannot hope to treat <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7BElt%7D%28%5Ctextit%7Bnat%7D%5Ctimes%5Ctextit%7Bnat%7D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{Elt}(&#92;textit{nat}&#92;times&#92;textit{nat})' title='&#92;textit{Elt}(&#92;textit{nat}&#92;times&#92;textit{nat})' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7BElt%7D%28%5Ctextit%7B2%7D%5Cto%5Ctextit%7Bnat%7D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{Elt}(&#92;textit{2}&#92;to&#92;textit{nat})' title='&#92;textit{Elt}(&#92;textit{2}&#92;to&#92;textit{nat})' class='latex' /> as <em>equal</em>, though we may wish to regard them as <em>equivalent </em>in some sense.  Moreover, since two sets can be isomorphic in different ways, isomorphism must be considered a <em>structure on sets</em>, rather than a <em>property of sets</em>.  For example, <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7B2%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{2}' title='&#92;textit{2}' class='latex' /> is isomorphic to itself in two different ways, by the identity and by negation (swapping).  Thus, equivalence of the elements of two isomorphic sets must take account of the isomorphism itself, and hence must have computational significance.</p>
<p>It is precisely the desire to accommodate equivalences such as this that gives rise to higher dimensions in type theory.  Specifically, we introduce two-dimensional structure by adding a new judgement to type theory stating that two members of a type are related by a specified <em>transformation</em>:</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5CGamma%5Cvdash+%5Calpha+%3A%3A+M%5Csimeq+N+%3A+A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle &#92;Gamma&#92;vdash &#92;alpha :: M&#92;simeq N : A' title='&#92;displaystyle &#92;Gamma&#92;vdash &#92;alpha :: M&#92;simeq N : A' class='latex' /></p></blockquote>
<p>Crucially, families of types must respect transformation:</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%7B%5CGamma%2Cx%3AA%5Cvdash+B%5C%2C%5Ctextsf%7Btype%7D%5Cquad+%5CGamma%5Cvdash+%5Calpha+%3A%3A+M%5Csimeq+N%3AA+%5Cquad+%5CGamma%5Cvdash+P%3AB%5BM%2Fx%5D%7D%5Cover++%7B%5CGamma%5Cvdash+%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D%5B%5Calpha%5D%28P%29%3AB%5BN%2Fx%5D%7D%7D.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{{&#92;Gamma,x:A&#92;vdash B&#92;,&#92;textsf{type}&#92;quad &#92;Gamma&#92;vdash &#92;alpha :: M&#92;simeq N:A &#92;quad &#92;Gamma&#92;vdash P:B[M/x]}&#92;over  {&#92;Gamma&#92;vdash &#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](P):B[N/x]}}.' title='&#92;displaystyle{{&#92;Gamma,x:A&#92;vdash B&#92;,&#92;textsf{type}&#92;quad &#92;Gamma&#92;vdash &#92;alpha :: M&#92;simeq N:A &#92;quad &#92;Gamma&#92;vdash P:B[M/x]}&#92;over  {&#92;Gamma&#92;vdash &#92;textit{map}&#92;{x:A.B&#92;}[&#92;alpha](P):B[N/x]}}.' class='latex' /></p></blockquote>
<p>A transformation should be thought of as <em>evidence of interchangeability</em> of the members of a type; the <em>map</em> operation puts the evidence to work.</p>
<p>Returning to our example of the universe of sets, let us specify that a transformation from one set to another is an <em>pair of functions</em> constituting a bijection between the elements of the two sets:</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B++%7B%5Cbegin%7Barray%7D%7Bc%7D++%5CGamma%2Cx%3A%5Ctextit%7BElt%7D%28a%29%5Cvdash+f%28x%29%3A%5Ctextit%7BElt%7D%28b%29+%5C%5C++%5CGamma%2Cx%3A%5Ctextit%7BElt%7D%28b%29%5Cvdash+g%28x%29%3A%5Ctextit%7BElt%7D%28a%29+%5C%5C++%5CGamma%2Cx%3A%5Ctextit%7BElt%7D%28a%29%5Cvdash+g%28f%28x%29%29%5Cequiv+x%3A%5Ctextit%7BElt%7D%28a%29+%5C%5C++%5CGamma%2Cx%3A%5Ctextit%7BElt%7D%28b%29%5Cvdash+f%28g%28x%29%29%5Cequiv+x%3A%5Ctextit%7BElt%7D%28b%29++%5Cend%7Barray%7D%7D++%5Cover++%7B%5CGamma%5Cvdash%5Ctextit%7Biso%7D%28f%2Cg%29%3A%3Aa%5Csimeq+b%3A%5Ctextit%7BSet%7D%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{  {&#92;begin{array}{c}  &#92;Gamma,x:&#92;textit{Elt}(a)&#92;vdash f(x):&#92;textit{Elt}(b) &#92;&#92;  &#92;Gamma,x:&#92;textit{Elt}(b)&#92;vdash g(x):&#92;textit{Elt}(a) &#92;&#92;  &#92;Gamma,x:&#92;textit{Elt}(a)&#92;vdash g(f(x))&#92;equiv x:&#92;textit{Elt}(a) &#92;&#92;  &#92;Gamma,x:&#92;textit{Elt}(b)&#92;vdash f(g(x))&#92;equiv x:&#92;textit{Elt}(b)  &#92;end{array}}  &#92;over  {&#92;Gamma&#92;vdash&#92;textit{iso}(f,g)::a&#92;simeq b:&#92;textit{Set}}}' title='&#92;displaystyle{  {&#92;begin{array}{c}  &#92;Gamma,x:&#92;textit{Elt}(a)&#92;vdash f(x):&#92;textit{Elt}(b) &#92;&#92;  &#92;Gamma,x:&#92;textit{Elt}(b)&#92;vdash g(x):&#92;textit{Elt}(a) &#92;&#92;  &#92;Gamma,x:&#92;textit{Elt}(a)&#92;vdash g(f(x))&#92;equiv x:&#92;textit{Elt}(a) &#92;&#92;  &#92;Gamma,x:&#92;textit{Elt}(b)&#92;vdash f(g(x))&#92;equiv x:&#92;textit{Elt}(b)  &#92;end{array}}  &#92;over  {&#92;Gamma&#92;vdash&#92;textit{iso}(f,g)::a&#92;simeq b:&#92;textit{Set}}}' class='latex' /></p></blockquote>
<p>(The equational conditions here are rather strong; I will return to this point in a future post.  For now, let us just take this as the defining criterion of isomorphism between two sets.)</p>
<p>Evidence for the isomorphism of two sets induces a transformation on types given by the following equation:</p>
<blockquote><p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B++%7B%5CGamma%5Cvdash+M%3A%5Ctextit%7BElt%7D%28a%29%7D%5Cover++%7B%5CGamma%5Cvdash+%5Ctextit%7Bmap%7D%5C%7B%5Ctextit%7BElt%7D%5C%7D%5B%5Ctextit%7Biso%7D%28f%2Cg%29%5D%28M%29%5Cequiv+f%28M%29+%3A+%5Ctextit%7BElt%7D%28b%29%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{  {&#92;Gamma&#92;vdash M:&#92;textit{Elt}(a)}&#92;over  {&#92;Gamma&#92;vdash &#92;textit{map}&#92;{&#92;textit{Elt}&#92;}[&#92;textit{iso}(f,g)](M)&#92;equiv f(M) : &#92;textit{Elt}(b)}}' title='&#92;displaystyle{  {&#92;Gamma&#92;vdash M:&#92;textit{Elt}(a)}&#92;over  {&#92;Gamma&#92;vdash &#92;textit{map}&#92;{&#92;textit{Elt}&#92;}[&#92;textit{iso}(f,g)](M)&#92;equiv f(M) : &#92;textit{Elt}(b)}}' class='latex' /></p></blockquote>
<p>(suppressing the obvious typing premises for <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' /> and <img src='http://s0.wp.com/latex.php?latex=g&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='g' title='g' class='latex' />).  In words an isomorphism between sets <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' /> and <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' /> induces a transformation between their elements given by the isomorphism itself.</p>
<p>This, then, is the basic structure of two-dimensional type theory, but there is much more to say!  In future posts I intend to develop the ideas further, including a discussion of these topics:</p>
<ol>
<li>The definition of <img src='http://s0.wp.com/latex.php?latex=%5Ctextit%7Bmap%7D%5C%7Bx%3AA.B%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;textit{map}&#92;{x:A.B&#92;}' title='&#92;textit{map}&#92;{x:A.B&#92;}' class='latex' /> is given by induction over the structure of <img src='http://s0.wp.com/latex.php?latex=x%3AA.B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x:A.B' title='x:A.B' class='latex' />.  The above equation covers only one case; there are more, corresponding to each way of forming a family of types <img src='http://s0.wp.com/latex.php?latex=x%3AA.B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x:A.B' title='x:A.B' class='latex' />.  The extension to function types will expose the role of the inverse of the isomorphism between sets.</li>
<li>The judgement <img src='http://s0.wp.com/latex.php?latex=%5Calpha%3A%3AM%5Csimeq+N%3AA&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha::M&#92;simeq N:A' title='&#92;alpha::M&#92;simeq N:A' class='latex' /> may be <em>internalized</em> as a type, which will turn out to correspond to the <em>identity type</em> in Martin-Löf&#8217;s type theory, albeit with a different interpretation given by Altenkirch.  The identity type plays an important role in the extension to all higher dimensions.</li>
<li>To ensure coherence and to allow for greater expressiveness we must also discuss <em>equality</em> and <em>equivalence of transformations</em> and how these influence the induced transformation of families of types.  In particular transformations admit a <em>groupoid structure</em> which expresses reflexivity, symmetry, and transitivity of transformation; these conditions can be considered to hold <em>strongly </em>or <em>weakly</em>, giving rise to different applications and interpretations.</li>
<li>Higher-dimensional type theory admits a fascinating interpretation in terms of <em>homotopy theory </em>which types are interpreted as spaces, members as points in those spaces, and transformations as <em>paths</em>, or <em>homotopies</em>.  This, together with a generalization of the treatment of universes outlined above, is the basis for Voevodsky&#8217;s work on <em>univalent foundations of mathematics</em>.</li>
<li>One may consider relaxing the groupoid structure on transformations to a &#8220;monoidoid&#8221; (that is, category) structure by not requiring symmetry (inverses).  The structure of type theory changes significantly in the absence of symmetry, posing significant open problems, but admitting a wider range of applications of higher-dimensional structure in both CS and mathematics.</li>
</ol>
<div>To keep up to date with the latest developments in this area, please visit the <a title="Homotopy Type Theory" href="http://homotopytypetheory.org" target="_blank">Homotopy Type Theory</a> blog!</div>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/research/'>Research</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/category-theory/'>category theory</a>, <a href='http://existentialtype.wordpress.com/tag/homotopy-theory/'>homotopy theory</a>, <a href='http://existentialtype.wordpress.com/tag/type-theory/'>type theory</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/254/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=254&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/05/30/higher-dimensional-type-theory/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>The semester&#8217;s over</title>
		<link>http://existentialtype.wordpress.com/2011/05/04/the-semesters-over/</link>
		<comments>http://existentialtype.wordpress.com/2011/05/04/the-semesters-over/#comments</comments>
		<pubDate>Thu, 05 May 2011 02:55:49 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Teaching]]></category>
		<category><![CDATA[functional programming]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=247</guid>
		<description><![CDATA[One reason that I started this blog was to record my experiences with a new course on functional programming for freshmen at Carnegie Mellon.  Classes have ended, the final exam is graded, and we are in the process of taking stock of what we accomplished, and what we could do better.  This was the first [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=247&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One reason that I started this blog was to record my experiences with a <a title="Teaching FP to freshmen" href="http://existentialtype.wordpress.com/2011/03/15/teaching-fp-to-freshmen/">new course on functional programming</a> for freshmen at Carnegie Mellon.  Classes have ended, the final exam is graded, and we are in the process of taking stock of what we accomplished, and what we could do better.  This was the first instance of the course, taught to 83 first-year computer science students who volunteered to be part of the new curriculum.  (This represents about 2/3 of the freshman class.)  All had taken a new course on imperative programming taught by Frank Pfenning the previous semester, and all were simultaneously taking 251, the legendary theory foundation course developed here over the last dozen or so years.</p>
<p>Starting this fall the course will be part of the standard curriculum, and will be taught to a broader range of students, including the electrical engineers and the full class of CS students.  We&#8217;re still working out whether the standard order will be imperative, then functional, or functional, then imperative.  Much depends on the mathematical maturity of the incoming students.  Those with weak mathematical skills (the vast majority), but some programming experience, will likely start with imperative programming, which they will take simultaneously with a standard discrete math course taught in the mathematics department.  Those with strong mathematical skills, or high ambitions, will start with functional programming.  A small number will park for one semester, taking discrete math and a programming course primarily intended for non-majors, to bring themselves up to speed.</p>
<p>Our new data structures and algorithms course, being developed by Guy Blelloch, will be offered in the fall for students who have already have the IP and FP classes.  Guy plans to make heavy use of functional programming, and will be stressing parallel algorithms on persistent data structures as the common case, leaving the traditional sequential, ephemeral case to the imperative programming class.  Guy&#8217;s course is essentially a continuation (ahem) of the FP class that emphasizes more sophisticated data structures and algorithms, and more complex programming problems.</p>
<p>For those who might be interested, I&#8217;m attaching the final exam for the course.  The students did exceptionally well (average score of 88%), even though we feared it was too long and difficult beforehand.  The spread was very narrow, perhaps because the exam was too easy, or because this being a class of volunteers, their skills were unusually strong and uniform.  We&#8217;ll know more after the fall once we&#8217;ve taught the class to a broader range of students.  I do think the exam is representative of what we expected them to be able to do at the end, and they showed us that they can do it.  A clear success!</p>
<p><a href="http://existentialtype.files.wordpress.com/2011/05/final.pdf">15-150 Final Exam (Spring 2011)</a></p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/teaching-2/'>Teaching</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/functional-programming/'>functional programming</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=247&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/05/04/the-semesters-over/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>Of Course ML Has Monads!</title>
		<link>http://existentialtype.wordpress.com/2011/05/01/of-course-ml-has-monads/</link>
		<comments>http://existentialtype.wordpress.com/2011/05/01/of-course-ml-has-monads/#comments</comments>
		<pubDate>Sun, 01 May 2011 20:09:43 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[imperative programming]]></category>
		<category><![CDATA[modularity]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=232</guid>
		<description><![CDATA[A popular meme in the world of PL&#8217;s is that &#8220;Haskell has monads&#8221;, with the implication that this is a distinctive feature of the language, separate from all others.  While it is true that Haskell has popularized the use of monads as a program structuring device, the idea of a monad is not so much [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=232&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A popular meme in the world of PL&#8217;s is that &#8220;Haskell has monads&#8221;, with the implication that this is a distinctive feature of the language, separate from all others.  While it is true that Haskell has popularized the use of monads as a program structuring device, the idea of a monad is not so much an issue of <em>language</em> design (apart from the <em>ad hoc</em> syntactic support provided by Haskell), but rather one of <em>library</em> design.  After all, a monad is just one of a zillion signatures (type classes) with which to structure programs, and there is no particular reason why this one cannot be used in any language that supports even a modicum of <a title="Modules Matter Most" href="http://existentialtype.wordpress.com/2011/04/16/modules-matter-most/">modularity</a>.  There <em>is</em> a particular reason why monads <em>had</em> to arise in Haskell, though, which is to defeat the scourge of laziness.  But even in the presence of monads, one still needs things like <em>seq</em> to sequentialize evaluation, because the <a title="The Point of Laziness" href="http://existentialtype.wordpress.com/2011/04/24/the-real-point-of-laziness/">lazy cost model</a> is so disadvantageous.  In an ironic twist the emphasis on monads in Haskell means that programming in Haskell is rather like programming in an <a title="Practical Foundations for Programming Languages" href="http://www.cs.cmu.edu/~rwh/plbook/book.pdf" target="_blank">updated dialect of Algol</a> with a richer type structure than the original, but the same overall structure.</p>
<p>Examined from the point of view of ML, monads are but a particular of use of modules.  The signature of monads is given by the definition</p>
<blockquote>
<pre>signature MONAD = sig
  type 'a monad
  val ret : 'a -&gt; 'a monad
  val bnd : 'a monad -&gt; ('a -&gt; 'b monad) -&gt; 'b monad
end</pre>
</blockquote>
<p>There are many, many, many structures that satisfy this signature; I needn&#8217;t (and, in any case, can&#8217;t) rehearse them all here.  One particularly simple example should suffice to give the general idea:</p>
<blockquote>
<pre>structure Option : MONAD = struct
  type 'a monad = 'a option
  fun ret x = SOME x
  fun bnd (SOME x) k = k x
    | bnd NONE k = NONE
end</pre>
</blockquote>
<p>This is of course the option monad, which is sometimes used to model the data flow aspects of exceptions, perhaps with some elaboration of the NONE case to associate an exceptional value with a non-result.  (The control flow aspects are not properly modeled this way, however.  For that one needs, in addition, access to some sort of jump mechanism.)</p>
<p>Examples like this one proliferate.  A monad is represented by a structure.  Any structure that provides the facilities specified by the MONAD signature gives rise to the characteristic sequentialization mechanisms codified by it.  Monad transformers are functors that transform one monad into another, with no fuss or bother, and no <em>ad hoc</em> mechanisms required.  Standard modular programming techniques suffice to represent monads; moreover, the techniques involved are fully general, and are equally applicable to other signatures of interest (arrows, or quivers, or bows, or what have you).  Moreover, it is shown in my paper with Chakravarty and Dreyer how to integrate modules into the type inference mechanism of ML so that one can get automatic functor instantiation in those limited cases where it is self-evident what is intended.  This has been implemented by Karl Crary in a prototype compiler for an extension of Standard ML, and it would be good to see this supported in more broadly available compilers for the language.</p>
<p>The bulk of the mania about monads is therefore accounted for by modules.  I have no doubt, however, that you are wondering about the infamous IO monad in Haskell (and it&#8217;s associated work-around, unsafePerformIO).  Isn&#8217;t that a fundamental feature of the language that cannot be replicated in ML?  Hardly!  It&#8217;s entirely a matter of designing the signatures of the standard basis library modules, and nothing more.  The default basis library does not attempt to segregate effects into a monad, but it is perfectly straightforward to do this yourself, by providing your own layer over the standard basis, or to reorganize the standard basis to enforce the separation.  For example, the signature of reference cells might look like this:</p>
<blockquote>
<pre>signature REF = sig
  type 'a ref
  val ref : 'a -&gt; 'a ref IO.monad
  val ! : 'a ref -&gt; 'a IO.monad
  val := : 'a ref -&gt; 'a -&gt; unit IO.monad
end</pre>
</blockquote>
<p>Here we are presuming that we have a fixed declaration</p>
<blockquote>
<pre>structure IO : MONAD = ...</pre>
</blockquote>
<p>that packages up the basic IO primitives that are already implemented in the run-time system of ML, more or less like in Haskell.  The other signatures, such as those for mutable arrays or for performing input and output, would be modified in a similar manner to push effects into the IO monad.  <em>Et voila</em>, you have monadic effects, just like in Haskell.</p>
<p>There&#8217;s really nothing to it.  In fact, the whole exercise was carried out by a Carnegie Mellon student, Phillippe Ajoux, a couple of years ago.  He also wrote a number of programs in this style just to see how it all goes: swimmingly.  He also devised syntactic extensions to the Moscow ML compiler that provide a nicer notation for programming with monads, much as in Haskell, but better aligned with ML&#8217;s conventions.  (Ideally it should be possible to provide syntactic support for <em>any</em> signature, not just monads, but I&#8217;m not aware of a worked-out design for the general case, involving as it would an intermixing of parsing and elaboration.)</p>
<p>My point is that the ML module system can be deployed by you to impose the sorts of effect segregation imposed on you by default in Haskell.  There is nothing special about Haskell that makes this possible, and nothing special about ML that inhibits it.  It&#8217;s all a mode of use of modules.</p>
<p>So why don&#8217;t we do this by default?  Because it&#8217;s not such a great idea.  Yes, I know it sounds wonderful at first, but then you realize that it&#8217;s pretty horrible.  Once you&#8217;re in the IO monad, you&#8217;re stuck there forever, and are reduced to Algol-style imperative programming.  You cannot easily convert between functional and monadic style without a radical restructuring of code.  And you inevitably need unsafePerformIO to get anything serious done.  In practical terms, you are deprived of the useful concept of a <em>benign effect</em>, and that just stinks!</p>
<p>The moral of the story is that of course ML &#8220;has monads&#8221;, just like Haskell.  Whether you want to use them is up to you; they are just as useful, and just as annoying, in ML as they are in Haskell.  But they are not forced on you by the language designers!</p>
<p><em>Update</em>: This post should&#8217;ve been called &#8220;ML Has Monads, Why Not?&#8221;, or &#8220;Of Course ML Has Comonads!&#8221;, but then no one was wondering about that.</p>
<p><em>Update</em>: I now think that the last sentence is excessive.  My main point is simply that it&#8217;s very simple to go one way or the other with effects, if you have modules to structure things; it&#8217;s all a matter of library design.  A variant of ML that enforced the separation of effects is very easily constructed; the question is whether it is useful or not.  I&#8217;ve suggested that the monadic separation is beguiling, but not clearly a great idea.  Alternatively, one can say that we&#8217;re not that far away from eliminating laziness from Haskell, at least in this respect: just re-do the standard basis library in ML, and you&#8217;re a good ways there.  Plus you have modules, and we understand how to integrate type classes with modules, so the gap is rather small.</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/programming/'>Programming</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/functional-programming/'>functional programming</a>, <a href='http://existentialtype.wordpress.com/tag/imperative-programming/'>imperative programming</a>, <a href='http://existentialtype.wordpress.com/tag/modularity/'>modularity</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=232&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/05/01/of-course-ml-has-monads/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>The Point of Laziness</title>
		<link>http://existentialtype.wordpress.com/2011/04/24/the-real-point-of-laziness/</link>
		<comments>http://existentialtype.wordpress.com/2011/04/24/the-real-point-of-laziness/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 03:16:05 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Teaching]]></category>
		<category><![CDATA[laziness]]></category>
		<category><![CDATA[processes]]></category>
		<category><![CDATA[streams]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=210</guid>
		<description><![CDATA[As I&#8217;ve discussed previously, there are a number of good reasons why Haskell is not suitable for teaching introductory functional programming.  Chief among these is laziness, which in the context of a pure functional language has fatal side effects.  First, Haskell suffers from a paucity of types.  It is not possible in Haskell to define [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=210&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ve discussed <a title="What is a functional language?" href="http://existentialtype.wordpress.com/2011/03/16/what-is-a-functional-language/">previously</a>, there are a number of good reasons why Haskell is not suitable for teaching <a title="Teaching FP to freshmen" href="http://existentialtype.wordpress.com/2011/03/15/teaching-fp-to-freshmen/">introductory functional programming</a>.  Chief among these is laziness, which in the context of a pure functional language has fatal side effects.  First, Haskell suffers from a <em>paucity of types</em>.  It is not possible in Haskell to define the type of natural numbers, nor the type of lists of natural numbers (or lists of anything else),<em> </em>nor any other inductive type!  (In Carollian style there are types called naturals and lists, but that&#8217;s only what they&#8217;re <em>called</em>, it&#8217;s not what they <em>are</em>.)  Second, the language has<em> </em>a <em>problematic cost model</em>.  It is monumentally difficult to reason about the time, and especially space, usage of a Haskell program.  Worse, parallelism arises naturally in an <em>eager</em>, not a <em>lazy</em>, language&#8212;for example, computing every element of a finite sequence is fundamental to parallel computing, yet is not compatible with the ideology of laziness, which specifies that we should only compute those elements that are required later.</p>
<p>The arguments in favor of laziness never seem convincing to me.  One claim is that the equational theory of lazy programs is said to be more convenient; for example, beta reduction holds without restriction.  But this is significant only insofar as you ignore the other types in the language.  As Andrzej Filinski pointed out decades ago, whereas lazy languages have products, but not sums, eager languages have sums, but not products.  Take your pick.  Similarly, where lazy languages rely on strictness conditions, eager languages rely on totality conditions.  The costs and benefits are dual, and there seems to be no reason to insist a priori on one set of equations as being more important than the other.</p>
<p>Another claim is that laziness supports the definition of <em>infinite</em> data types, such as infinite sequences of values of some type.  But laziness is not essential, or even particularly useful, for this purpose.  For example, the type nat-&gt;nat is a natural representation of infinite sequences of natural numbers that supports many, but not all, of the operations that finite sequences (but not, for example, operations such a reverse, which make no sense in the infinite case).   More generally, there is no inherent connection between laziness and such infinitary types.  Noam Zeilberger has developed an elegant theory of eager and lazy types based on distinguishing positive from negative <em>polarities</em> of type constructors, the positive including the inductive and the negative including the coinductive.   Coinductive types are no more about laziness than inductive types are about pointers.</p>
<p>I wish to argue that laziness <em>is</em> important, but not for pure functional programming, but rather only in conjunction with effects.  This is the <em>Kahn-MacQueen Principle</em> introduced in the 1970&#8242;s by Gilles Kahn and David MacQueen in their seminal paper on recursive networks of stream transducers.  Dan Licata and I have emphasized this viewpoint in our lectures on laziness in our <a title="Functional Programming" href="http://www.cs.cmu.edu/~15150" target="_blank">new course</a> on functional programming for freshmen.</p>
<p>Let&#8217;s use streams as a motivating example, contrasting them with lists, with which they are confused in Haskell.  A list is an example of a <em>positive</em> type, one that is defined by its membership conditions (constructors).  Defining a function on a list amounts to pattern matching, giving one case for each constructor (nil and cons), and using recursion to apply the function to the tail of the list.  A stream is an example of a <em>negative</em> type, one that is defined by its behavioral conditions (destructors).  Defining a stream amounts to defining how it behaves when its head and tail are computed.  The crucial thing about lists, or any positive type, is that they are <em>colimits</em>; we know as part of their semantics how a value of list type are constructed.  The crucial thing about streams, or any negative type, is that they are <em>limits</em>; we know as part of their semantics how they behave when destructed.</p>
<p>Since we have no access to the &#8220;inside&#8221; of a stream, we should think of it not as a static data structure, but as a dynamic <em>process</em> that produces, upon request, successive elements of the stream.  Internally, the stream keeps track of whatever is necessary to determine successive outputs; it has its own state that is not otherwise visible from the outside.  But if a stream is to be thought of as given by a process of generation, then it is inherently an <em>ephemeral</em> data structure.  Interacting with a stream changes its state; the &#8220;old&#8221; stream is lost when the &#8220;new&#8221; stream is created.  But, as we have <a title="Persistence of Memory" href="http://existentialtype.wordpress.com/2011/04/09/persistence-of-memory/" target="_blank">discussed previously</a>, ephemeral data structures are of limited utility.  The role of <em>memoization </em>is to transform an ephemeral process into a persistent data structure by recording the successive values produced by the process so that they can be &#8220;replayed&#8221; as necessary to permit the stream to have multiple futures.  Thus, rather than being a matter of <em>efficiency</em>, memoization is a matter of <em>functionality</em>, providing a persistent interface to an underlying ephemeral process.</p>
<p>To see how this works in practice, let&#8217;s review the signatures PROCESS and STREAM that Dan Licata and I developed for our class.  Here&#8217;s a snippet of the signature of processes:</p>
<blockquote>
<pre>signature PROCESS = sig
  type 'a process = unit -&gt; 'a option
  val stdin : char process
  val random : real process
end</pre>
</blockquote>
<p>A process is a function that, when applied, generates a value of some type, or indicates that it is finished.  The process stdin represents the Unix standard input; the process random is a random number generator.  The signature of streams looks essentially like this:</p>
<blockquote>
<pre>signature STREAM = sig
  type 'a stream
  datatype 'a front = Nil | Cons of 'a * 'a stream
  val expose : 'a stream -&gt; 'a front
  val memo : 'a Process.process -&gt; 'a stream
  val fix : ('a stream -&gt; 'a stream) -&gt; 'a stream
end</pre>
</blockquote>
<p>The type &#8216;a front is the type of values that arise when a stream is exposed; it can either terminate, or present an element and another stream.  The memo constructor creates a persistent stream from an ephemeral process of creation for its elements.  The fix operation is used to create recursive networks of streams.  There are other operations as well, but these illustrate the essence of the abstraction.</p>
<p>Using these signatures as a basis, it is extremely easy to put together a package of routines for scripting.  The fundamental components are processes that generate the elements of a stream.  Combinators on streams, such as composition or mapping and reducing, are readily definable, and may be deployed to build up higher levels of abstraction.  For example, Unix utilities, such as grep, are stream transducers that take streams as inputs and produce streams as outputs.  These utilities <em>do not perform input/output</em>; they merely transform streams.  Moreover, since streams are persistent, there is never any issue with &#8220;buffering&#8221; or &#8220;lookahead&#8221; or &#8220;backtracking&#8221;; you just manipulate the stream like any other (persistent) data structure, and everything works automagically.  The classical Bell Labs style of intermixing I/O with processing is eliminated, leading not only to cleaner code, but also greater flexibility and re-use.  This is achieved not by the double-backflips required by the inheritance mechanisms of oopl&#8217;s, but rather by making a crisp semantic distinction between the processing of streams and the streaming of processes.  True reuse operates at the level of <em>abstractions</em>, not at the level of the <em>code</em> that gives rise to them.</p>
<p><em>Update</em>: It seems worthwhile to point out that memoization to create a persistent from an ephemeral data structure is a premier example of a benign effect, the use of state to evince functional behavior.  But benign effects are not programmable in Haskell, because of the segregation of effects into the IO monad.</p>
<p><em>Update</em>: Lennart Augustsson gives <a href="http://augustss.blogspot.com/2011/05/more-points-for-lazy-evaluation-in.html" target="_blank">his reasons</a> for liking laziness.</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/programming/'>Programming</a>, <a href='http://existentialtype.wordpress.com/category/teaching-2/'>Teaching</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/laziness/'>laziness</a>, <a href='http://existentialtype.wordpress.com/tag/processes/'>processes</a>, <a href='http://existentialtype.wordpress.com/tag/streams/'>streams</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/210/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=210&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/04/24/the-real-point-of-laziness/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
		<item>
		<title>Some thoughts on teaching FP</title>
		<link>http://existentialtype.wordpress.com/2011/04/17/some-advice-on-teaching-fp/</link>
		<comments>http://existentialtype.wordpress.com/2011/04/17/some-advice-on-teaching-fp/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 03:34:19 +0000</pubDate>
		<dc:creator>Robert Harper</dc:creator>
				<category><![CDATA[Teaching]]></category>
		<category><![CDATA[abstraction]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[parallelism]]></category>
		<category><![CDATA[verification]]></category>

		<guid isPermaLink="false">http://existentialtype.wordpress.com/?p=185</guid>
		<description><![CDATA[A number of people have asked some very good questions about the details of how we teach certain concepts in our new functional programming class for freshmen at Carnegie Mellon.  Rather than spray responses among the various comments, I&#8217;ll summarize a few major points here in hopes of helping others who may wish to teach [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=185&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A number of people have asked some very good questions about the details of how we teach certain concepts in our <a href="http://www.cs.cmu.edu/~15150">new functional programming class</a> for freshmen at Carnegie Mellon.  Rather than spray responses among the various comments, I&#8217;ll summarize a few major points here in hopes of helping others who may wish to teach a similar course.  So this post is not really meant for a broad audience, but rather for the specialist; feel free to skip it if it seems too focused for your interests.  I promise to write some more controversial material of more general interest soon!  Meanwhile, here are a few thoughts presented in no particular order of importance.</p>
<p>Because the class is intended for beginners, we start from scratch with a <a title="Languages and Machines" href="http://existentialtype.wordpress.com/2011/03/16/languages-and-machines/">language-based model of computation</a>.  This means that, with <a title="Functions Are Values" href="http://existentialtype.wordpress.com/2011/04/02/functions-are-values/">one regrettable misstep </a>on our part, we never talk about extra-linguistic concepts like &#8220;run-time stacks&#8221; or &#8220;compilers.&#8221;  The students are taught to think in terms of the language itself, and to reason directly about both the correctness and efficiency of the code they actually write, not the code that it allegedly compiles to or translates to.  One beautiful feature of the language-based approach is that we start with a very familiar model of computation, the evaluation of polynomials over the reals.  It&#8217;s very familiar for all students, and I think they find it very satisfying precisely because it has a direct computational flavor.  You plug in for variables and simplify, and out comes the answer.  We can draw on this as our starting point; programs are just generalized polynomials.  In particular, in a functional language <em>variables are variables</em>: the mathematical concept of variables, which is given meaning by substitution, is precisely the programming concept of variable.  It&#8217;s not analogous, <em>it&#8217;s the same</em>.  So we can draw on their experience and ask them to prove things about programs using methods that build directly on what they already know.  It&#8217;s extremely natural, and very beautiful, and leads easily to an integrated view of mathematics and programming.  Moreover, it&#8217;s a level playing field.  Students with prior &#8220;programming experience&#8221; are, if anything, at a disadvantage, because they think they know things that are either wrong or inapplicable.  One consequence is <em>gender equity</em>, because even with American society being what it is, the women have no particular disadvantage with respect to the men when it comes to our style of thinking and programming.  It&#8217;s a <em>win-win-win</em> situation.</p>
<p>Moving to a more technical level, the use of <a title="Languages and Machines" href="http://existentialtype.wordpress.com/2011/03/16/languages-and-machines/">structural operational semantics</a> is indispensable for providing a rigorous foundation for understanding program execution, reasoning about program correctness, and for defining a cost model to support reasoning about asymptotic complexity.  There is no substitute for this!  Without a crisp formulation of the semantics of the language, it is impossible to discuss any of these issues in a meaningful and technically precise way.  With it you can readily resolve any questions about &#8220;what happens if &#8230;&#8221;, giving the students a tool that they can use themselves to answer such questions.  Moreover, as program verification becomes more important in industrial practice, as well as academic research, it is essential that students be educated in the tools of semantics.  Structural operational semantics is very easy to teach, and presents no problems for the students.  We just use it, and they get it without any fuss or bother.  It is a natural extension of their experience with high school algebra.  Be not afraid of using these tools to teach programming!</p>
<p>As I&#8217;ve explained previously, it is a very good idea to <a title="Boolean Blindness" href="http://existentialtype.wordpress.com/2011/03/15/boolean-blindness/">avoid Booleans</a> as much as possible.  And, above all, <a title="Don’t mention equality!" href="http://existentialtype.wordpress.com/2011/03/15/dont-mention-equality/">don&#8217;t mention equality</a>!  The equals sign in programming languages <em>is not</em> the equals sign of mathematics.  Propositions are not Booleans, and it only confuses matters to use notations that encourage this misconception.  Related to this, <em>avoid if-then-else</em> entirely, and instead <em>use only case analysis</em> for branching, even when the value to be discriminated is a Boolean.  We consistently write things like</p>
<blockquote>
<pre>case Int.compare(x,y) of
  LESS =&gt; ...
| GREATER =&gt; ...
| EQUAL =&gt; ...</pre>
</blockquote>
<p>rather than a nested conditional branch.  It encourages students to think in terms of pattern matching, and prepares the ground for later developments, including a smooth transition to pattern matching over more complex data structures and reasoning inductively when programming recursively.</p>
<p>Teaching <a title="Parallelism is not concurrency" href="http://existentialtype.wordpress.com/2011/03/17/parallelism-is-not-concurrency/">parallelism</a> is completely straightforward, because the model of computation inherently avoids unnatural and unnecessary problems of interference, and focuses attention on the critical issue of data dependencies among computations in a program.  Students have no trouble computing the work (sequential time complexity) or span (parallel time complexity) of a program, and have no problems reading off recurrences for the respective time complexities.  Later, when we introduce sequences, the idea of computing in parallel with the entire sequence, rather than item-by-iterm (as encouraged by the dreadful iterators so beloved in the oo world), comes naturally and easily.  The key to this, of course, is that data structures in a functional language are naturally <a title="Persistence of Memory" href="http://existentialtype.wordpress.com/2011/04/09/persistence-of-memory/">persistent</a>; it is monstrously hard to use ephemeral data structures in a parallel computation, and is not something we could hope to teach freshmen.</p>
<p>A major decision for us is how to teach the expression and enforcement of abstraction in a program.  In a departure from our previous approach, we have decided <em>against</em> using opaque ascription (sealing) as a means of enforcing abstraction.  It has its virtues, but the problem is that it does not mesh well with other language features, in particular with substructures and type classes (views).  For example, consider the signature of a mapping whose domain is an ordered type of keys:</p>
<blockquote>
<pre>signature MAPPING = sig
  structure Key : ORDERED
  type 'a mapping
  val lookup : Key.t -&gt; 'a mapping -&gt; 'a
  ...
end</pre>
</blockquote>
<p>Unfortunately, sealing a structure with this signature renders the module useless:</p>
<blockquote>
<pre>structure IntMapping :&gt; MAPPING = struct
 structure Key = Int
 type 'a mapping = 'a bst
 ...
end</pre>
</blockquote>
<p>The trouble is that not only is the type &#8216;a IntMapping.mapping abstract, as intended, but so is IntMapping.Key.t, which is not at all intended!  To get around this we we must create a specialization of the signature MAPPING using one of several means such as</p>
<blockquote>
<pre>signature INT_MAPPING = MAPPING where type Key.t=int
structure IntMapping :&gt; INT_MAPPING = ...</pre>
</blockquote>
<p>Of course one need not name the signature, but this illustrates the general problem.  As things get more complicated, you have more and more clauses that specify the types of things (sharing specifications).</p>
<p>The alternative, which has worked very well for us, is to eschew opaque ascription, and instead rely on the datatype mechanism to make types abstract.  So to give an implementation of the abstract type of mappings with keys being integers, we proceed as follows:</p>
<blockquote>
<pre>structure IntMapping : MAPPING = struct
  structure Key : ORDERED = Int
  datatype 'a bst = Empty | Node of 'a bst * (Key.t * 'a) * 'a bst
  type 'a mapping = 'a bst
  val insert = ...
end</pre>
</blockquote>
<p>The point is that since the constructors of the type &#8216;a bst are not exported in the interface, the type &#8216;a IntMapping.mapping is abstract.  Note as well that the use of transparent ascription on the structure Key ensures that keys really are integers (of type Int.int), and are not abstract, exactly as intended.  This formulation allows us to state simple rules of signature matching (every specification in the signature has a corresponding declaration in the structure), and allows us to enforce abstraction boundaries with a minimum of fuss.  The students have had absolutely no trouble with this at all, and we have had no trouble structuring our code this way.</p>
<p>When using functors (parameterized modules) to combine modules it is, of course, necessary to impose sharing constraints to ensure that only coherent compositions are possible.  (Rather than take the space to explain this here, I will rely on the reader&#8217;s experience to understand what is involved here.)  These sorts of sharing specifications are perfectly natural, easily explained, and have presented absolutely no difficulties for the students.  We illustrated their use in our game tree search example, in which the &#8220;referee&#8221; module is parameterized by the two &#8220;player&#8221; modules, which must of course cohere on their concept of a &#8220;game&#8221; (it&#8217;s no use pitting a chess player against a checkers player!).  The code looks like this</p>
<blockquote>
<pre>functor Referee
  (structure Player1 : PLAYER and Player2 : PLAYER
   sharing type Player1.Game.t = Player2.Game.t) : REFEREE = ...</pre>
</blockquote>
<p>The sharing specification states precisely and concisely the natural coherence constraint governing the two players.  Here again, the dog we feared never barked, and the students found it all quite intuitive and unproblematic.  This allowed them to expend their time on the actual complexities of the problem at hand, such as how to think about alpha-beta pruning in a parallel game-tree search, rather than get all tied up with the bureaucracy of structuring the code itself.</p>
<p>The virtue of teaching bright young students is that they are bright and they are young.  Their brilliance is, of course, a pleasure.  We have to work hard to come up with sufficiently challenging exercises, and many students challenge us with their solutions to our problems.  Their youth means that they come to us with a minimum of misconceptions and misinformation that they&#8217;ve picked up on the street, and are open to learning methods that are entirely non-standard (at least for now) with respect to what their friends are learning at other universities.  What makes Carnegie Mellon a special place is precisely that the students are pushed into thinking hard in ways that they might not be.  Personally, I hope that more universities worldwide build on what we have started, and give their students the same benefits that ours are already enjoying.</p>
<br />Filed under: <a href='http://existentialtype.wordpress.com/category/teaching-2/'>Teaching</a> Tagged: <a href='http://existentialtype.wordpress.com/tag/abstraction/'>abstraction</a>, <a href='http://existentialtype.wordpress.com/tag/modules/'>modules</a>, <a href='http://existentialtype.wordpress.com/tag/parallelism/'>parallelism</a>, <a href='http://existentialtype.wordpress.com/tag/verification/'>verification</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/existentialtype.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/existentialtype.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/existentialtype.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/existentialtype.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/existentialtype.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/existentialtype.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/existentialtype.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/existentialtype.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/existentialtype.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/existentialtype.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/existentialtype.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/existentialtype.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/existentialtype.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/existentialtype.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=existentialtype.wordpress.com&amp;blog=2157150&amp;post=185&amp;subd=existentialtype&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://existentialtype.wordpress.com/2011/04/17/some-advice-on-teaching-fp/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a3bf4aba89a3d8f593ec29e75e5884a?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">abstract type</media:title>
		</media:content>
	</item>
	</channel>
</rss>
