<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">

<channel>
	<title>Planet Haskell</title>
	<link>http://planet.haskell.org/</link>
	<language>en</language>
	<description>Planet Haskell - http://planet.haskell.org/</description>

<item>
	<title>Brent Yorgey: Brent</title>
	<guid isPermalink="false">http://byorgey.wordpress.com/?p=63</guid>
	<link>http://byorgey.wordpress.com/2008/04/17/collecting-unstructured-information-with-the-monoid-of-partial-knowledge/</link>
	<description>&lt;div class=&quot;snap_preview&quot;&gt;&lt;br /&gt;&lt;p&gt;In &lt;a href=&quot;http://byorgey.wordpress.com/2008/04/17/an-interesting-monoid/&quot;&gt;my last post&lt;/a&gt;, I described what I&amp;#8217;m calling the &amp;#8220;monoid of partial knowledge&amp;#8221;, a way of creating a monoid over sets of elements from a preorder, which is a generalization of the familiar monoid &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%28S%2C%5Cmax%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;(S,\max)&quot; title=&quot;(S,\max)&quot; class=&quot;latex&quot; /&gt; over a set with a total order and a smallest element.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s actually one situation where a special case of this monoid is commonly used in Haskell.  Suppose you have a record type which contains several fields, and you would like to parse some input to create a value of this type.  The problem is that the input is not very nice: the bits of input which designate values for various fields are not in any particular order; some occur more than once; some might even be missing.  How to deal with this?&lt;/p&gt;
&lt;p&gt;One common solution is to wrap the type of each field in the record with Maybe, and create a Monoid instance which allows you to combine two partial records into one (hopefully less partial) record.  Using this framework, you can just parse each bit of input into a mostly-blank record, with one (or more) fields filled in, then combine all the records (with mconcat) into one summary record.  For example:&lt;/p&gt;
&lt;pre&gt;
import Data.Monoid
import Control.Monad  -- for the MonadPlus instance of Maybe

data Record = R { name  :: Maybe String,
                  age   :: Maybe Int }
  deriving (Eq, Show)

instance Monoid Record where
  mempty = R Nothing Nothing
  mappend r1 r2 = R { name = name r1 `mplus` name r2
                    , age  = age r1  `mplus` age r2
                    }
&lt;/pre&gt;
&lt;p&gt;The mplus function, from the MonadPlus instance for Maybe, simply takes the first Just value that it finds.  This is nice and simple, and works just great:&lt;/p&gt;
&lt;pre&gt;
&amp;gt; mempty :: Record
R {name = Nothing, age = Nothing}
&amp;gt; mconcat [mempty { name = Just &quot;Brent&quot; }]
R {name = Just &amp;#8220;Brent&amp;#8221;, age = Nothing}
&amp;gt; mconcat [mempty { name = Just &quot;Brent&quot; }, mempty { age = Just 26 }]
R {name = Just &amp;#8220;Brent&amp;#8221;, age = Just 26}
&amp;gt; mconcat [mempty { name = Just &quot;Brent&quot; }, mempty { age = Just 26 }, mempty { age = Just 23 }]
R {name = Just &amp;#8220;Brent&amp;#8221;, age = Just 26}
&lt;/pre&gt;
&lt;p&gt;Note how the appending is left-biased, because mplus is left-biased: after seeing the first age, all subsequent ages are ignored.&lt;/p&gt;
&lt;p&gt;Now, really what we&amp;#8217;re doing here is using the monoid (as in my previous post) induced by the preorder which says that any name is &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt; any other name, and any age is &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt; any other age, and names and ages can&amp;#8217;t be compared! &lt;/p&gt;
&lt;p&gt;Some code is in order.  First, we create a class for preorders, and a newtype to contain sets of elements (there&amp;#8217;s already a Monoid instance for Set, so we need a newtype to give a different semantics).  Then we translate the specification from my previous post directly into a Monoid instance.&lt;/p&gt;
&lt;pre&gt;
import qualified Data.Set as S

-- laws:
-- if x == y, then x &amp;lt;~ y
-- if x &amp;lt;~ y  and y &amp;lt;~ z, then x &amp;lt;~ z
class (Eq p) =&amp;gt; Preorder p where
  (&amp;lt;~) :: p -&amp;gt; p -&amp;gt; Bool

newtype PStar p = PStar { unPStar :: (S.Set p) }
  deriving Show

instance (Preorder p, Ord p) =&amp;gt; Monoid (PStar p) where
  mempty      = PStar S.empty
  mappend (PStar ss) (PStar ts) = PStar $
    S.filter (\s -&amp;gt; all (\t -&amp;gt; s == t || t &amp;lt;~ s || not (s &amp;lt;~ t)) $ S.toList ts) ss
    `S.union`
    S.filter (\t -&amp;gt; all (\s -&amp;gt; s == t || not (t &amp;lt;~ s)) $ S.toList ss) ts
&lt;/pre&gt;
&lt;p&gt;Pretty straightforward!  Of course, there are probably more efficient ways to do this, but I don&amp;#8217;t care about that at the moment: let&amp;#8217;s get some working proof-of-concept code, and worry about efficiency later.  Now, one thing you may notice is that our Monoid instance requires an Ord instance for p!  &amp;#8220;But I thought we only needed a preorder?&amp;#8221; I hear you cry.  Well, the Ord is just there so that we can use an efficient implementation of Set.  In particular, note that the Ord instance need have nothing at all to do with the Preorder instance, and won&amp;#8217;t affect the semantics of this Monoid instance in any way.  If we wanted, we could do away with the Ord entirely and use lists of unique elements (or something like that) instead of Sets.&lt;/p&gt;
&lt;p&gt;So, how do we translate our record example from above into this new framework?  Easy, we just create a data type to represent the different kinds of facts we want to represent, along with a convenience method or two, and make it an instance of Preorder:&lt;/p&gt;
&lt;pre&gt;
data Fact = Name String | Age Int
  deriving (Eq,Show,Ord)

fact :: Fact -&amp;gt; PStar Fact
fact f = PStar (S.singleton f)

instance Preorder Fact where
  (Name _) &amp;lt;~ (Name _) = True
  (Age _)  &amp;lt;~ (Age _)  = True
  _        &amp;lt;~ _        = False
&lt;/pre&gt;
&lt;p&gt;Let&amp;#8217;s try it!&lt;/p&gt;
&lt;pre&gt;
&amp;gt; mempty :: PStar Fact
PStar {unPStar = fromList []}
&amp;gt; mconcat . map fact $ [Name &quot;Brent&quot;]
PStar {unPStar = fromList [Name &quot;Brent&quot;]}
&amp;gt; mconcat . map fact $ [Name &quot;Brent&quot;, Age 26]
PStar {unPStar = fromList [Name &quot;Brent&quot;,Age 26]}
&amp;gt; mconcat . map fact $ [Name &quot;Brent&quot;, Age 26, Age 23]
PStar {unPStar = fromList [Name &quot;Brent&quot;,Age 26]}
&lt;/pre&gt;
&lt;p&gt;Neato!  But the really cool thing is all the extra power we get now: we can easily tweak the semantics of the Monoid instance by altering the Preorder instance.  For example, suppose we want the first name that we see, but the &lt;i&gt;oldest&lt;/i&gt; age.  Easy peasy:&lt;/p&gt;
&lt;pre&gt;
instance Preorder Fact where
  (Name _) &amp;lt;~ (Name _) = True
  (Age m)  &amp;lt;~ (Age n)  = m &amp;lt;= n
  _        &amp;lt;~ _        = False

&amp;gt; mconcat . map fact $ [Age 23, Name &quot;Brent&quot;]
PStar {unPStar = fromList [Name &quot;Brent&quot;,Age 23]}
&amp;gt; mconcat . map fact $ [Age 23, Name &quot;Brent&quot;, Age 24]
PStar {unPStar = fromList [Name &quot;Brent&quot;,Age 24]}
&amp;gt; mconcat . map fact $ [Age 23, Name &quot;Brent&quot;, Age 24, Name &quot;Joe&quot;, Age 26]
PStar {unPStar = fromList [Name &quot;Brent&quot;,Age 26]}
&lt;/pre&gt;
&lt;p&gt;Of course, we could have done this with the Record model, but it wouldn&amp;#8217;t be terribly elegant.  But we&amp;#8217;re not done: let&amp;#8217;s say we want to remember the oldest age we find, and the first name, unless the age is over 50, in which case we don&amp;#8217;t want to remember the name (I admit this is a bit contrived)?  That&amp;#8217;s not too hard either:&lt;/p&gt;
&lt;pre&gt;
instance Preorder Fact where
  (Name _) &amp;lt;~ (Name _) = True
  (Age m)  &amp;lt;~ (Age n)  = m &amp;lt;= n
  (Name _) &amp;lt;~ (Age n)  = n &amp;gt; 50
  _        &amp;lt;~ _        = False

&amp;gt; mconcat . map fact $ [Name &quot;Brent&quot;, Age 26]
PStar {unPStar = fromList [Name &quot;Brent&quot;,Age 26]}
&amp;gt; mconcat . map fact $ [Name &quot;Brent&quot;, Age 26, Age 45]
PStar {unPStar = fromList [Name &quot;Brent&quot;,Age 45]}
&amp;gt; mconcat . map fact $ [Name &quot;Brent&quot;, Age 26, Age 45, Age 53]
PStar {unPStar = fromList [Age 53]}
&lt;/pre&gt;
&lt;p&gt;This would have been a huge pain to do with the Record model!  Now, this isn&amp;#8217;t an unqualified improvement; there are several things we can&amp;#8217;t do here.  One is if we want to be able to combine facts into larger compound facts: we can do that fairly straightforwardly with the Record-of-Maybes model, but not with the preorder-monoid model.  We also can&amp;#8217;t easily choose to have some fields be left-biased and some right-biased (the Monoid instance for PStar has left-bias built in!).  But it&amp;#8217;s certainly an interesting approach.&lt;/p&gt;
&lt;p&gt;Now, one thing we do have to be careful of is that our Preorder instances really do define a preorder! For example, at first I tried using &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=n+%3C+18&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;n &amp;lt; 18&quot; title=&quot;n &amp;lt; 18&quot; class=&quot;latex&quot; /&gt; in the above Preorder instance instead of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=n+%3E+50&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;n &amp;gt; 50&quot; title=&quot;n &amp;gt; 50&quot; class=&quot;latex&quot; /&gt;, and was confused by the weird results I got.  But such a Preorder instance violates transitivity, so no wonder I was getting weird semantics. =)  It would be interesting to reformulate this in a dependently typed language like &lt;a href=&quot;http://appserv.cs.chalmers.se/users/ulfn/wiki/agda.php&quot;&gt;Agda&lt;/a&gt;, where creating a Preorder could actually require a proof that it satisfied the preorder axioms.&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href=&quot;http://conal.net/&quot;&gt;Conal Elliott&lt;/a&gt; for some suggestions on making the formulation in the previous post more elegant &amp;#8212; we&amp;#8217;ll see what comes of it!&lt;/p&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/categories/byorgey.wordpress.com/63/&quot; /&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/tags/byorgey.wordpress.com/63/&quot; /&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gocomments/byorgey.wordpress.com/63/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/byorgey.wordpress.com/63/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godelicious/byorgey.wordpress.com/63/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/byorgey.wordpress.com/63/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gostumble/byorgey.wordpress.com/63/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/byorgey.wordpress.com/63/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godigg/byorgey.wordpress.com/63/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/byorgey.wordpress.com/63/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/goreddit/byorgey.wordpress.com/63/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/byorgey.wordpress.com/63/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://stats.wordpress.com/b.gif?host=byorgey.wordpress.com&amp;amp;blog=1152889&amp;amp;post=63&amp;amp;subd=byorgey&amp;amp;ref=&amp;amp;feed=1&quot; /&gt;&lt;/div&gt;</description>
	<pubDate>Thu, 17 Apr 2008 21:32:00 +0000</pubDate>
	<dc:creator>Brent</dc:creator>
</item>
<item>
	<title>Brent Yorgey: Brent</title>
	<guid isPermalink="false">http://byorgey.wordpress.com/?p=62</guid>
	<link>http://byorgey.wordpress.com/2008/04/17/an-interesting-monoid/</link>
	<description>&lt;div class=&quot;snap_preview&quot;&gt;&lt;br /&gt;&lt;p&gt;The other day I was just sort of letting my mind wander, and I came up with an interesting monoid, which I&amp;#8217;m calling the &amp;#8220;monoid of partial knowledge&amp;#8221;. So I thought I&amp;#8217;d write about it here, partly just because it&amp;#8217;s interesting, and partly to see whether anyone has any pointers to any literature (I&amp;#8217;m sure I&amp;#8217;m not the first to come up with it).&lt;/p&gt;
&lt;p&gt;Recall that a &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Monoid&quot;&gt;&lt;i&gt;monoid&lt;/i&gt;&lt;/a&gt; is a set with an associative binary operation and a distinguished element which is the identity for the operation.&lt;/p&gt;
&lt;p&gt;Now, given a &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Total_order&quot;&gt;&lt;i&gt;total order&lt;/i&gt;&lt;/a&gt; on a set &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S&quot; title=&quot;S&quot; class=&quot;latex&quot; /&gt; with a smallest element &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=e&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;e&quot; title=&quot;e&quot; class=&quot;latex&quot; /&gt;, we get a monoid &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%28S%2C+%5Cmax%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;(S, \max)&quot; title=&quot;(S, \max)&quot; class=&quot;latex&quot; /&gt;, where &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cmax&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\max&quot; title=&quot;\max&quot; class=&quot;latex&quot; /&gt; denotes the function which determines the larger of two elements, according to the total order on &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S&quot; title=&quot;S&quot; class=&quot;latex&quot; /&gt;.  &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cmax&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\max&quot; title=&quot;\max&quot; class=&quot;latex&quot; /&gt; is clearly associative, and has identity &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=e&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;e&quot; title=&quot;e&quot; class=&quot;latex&quot; /&gt;.  Taking a list of elements of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S&quot; title=&quot;S&quot; class=&quot;latex&quot; /&gt; and summarizing it via this monoid corresponds to finding the maximum element in the list.  If you think of receiving the elements of the list one by one, and applying &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cmax&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\max&quot; title=&quot;\max&quot; class=&quot;latex&quot; /&gt; to each new incoming value and the value of an accumulator (storing the result back into the accumulator, which should obviously be initialized to &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=e&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;e&quot; title=&quot;e&quot; class=&quot;latex&quot; /&gt;), at any given time the value of the accumulator represents the &amp;#8216;current best&amp;#8217;, i.e. the largest element among those received so far.&lt;/p&gt;
&lt;p&gt;The idea I had was to generalize this from a total order to a preorder.  Recall that a &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Preorder&quot;&gt;&lt;i&gt;preorder&lt;/i&gt;&lt;/a&gt; is a set &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S&quot; title=&quot;S&quot; class=&quot;latex&quot; /&gt; equipped with a reflexive, transitive binary relation, often denoted &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt;.  That is, for any &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x%2Cy%2Cz+%5Cin+S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x,y,z \in S&quot; title=&quot;x,y,z \in S&quot; class=&quot;latex&quot; /&gt;, we have &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim x&quot; title=&quot;x \lesssim x&quot; class=&quot;latex&quot; /&gt;; and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+y+%5Cland+y+%5Clesssim+z&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim y \land y \lesssim z&quot; title=&quot;x \lesssim y \land y \lesssim z&quot; class=&quot;latex&quot; /&gt; implies &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+z&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim z&quot; title=&quot;x \lesssim z&quot; class=&quot;latex&quot; /&gt;. If &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt; is also antisymmetric, that is, &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+y+%5Cland+y+%5Clesssim+x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim y \land y \lesssim x&quot; title=&quot;x \lesssim y \land y \lesssim x&quot; class=&quot;latex&quot; /&gt; implies &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%3D+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x = y&quot; title=&quot;x = y&quot; class=&quot;latex&quot; /&gt;, it is called a &lt;i&gt;partial order&lt;/i&gt;, or &lt;i&gt;poset&lt;/i&gt;.  Then if &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim y&quot; title=&quot;x \lesssim y&quot; class=&quot;latex&quot; /&gt; or &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=y+%5Clesssim+x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;y \lesssim x&quot; title=&quot;y \lesssim x&quot; class=&quot;latex&quot; /&gt; for any two elements &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x&quot; title=&quot;x&quot; class=&quot;latex&quot; /&gt; and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;y&quot; title=&quot;y&quot; class=&quot;latex&quot; /&gt;, we get a total order, but for a general preorder some pairs of elements may not be comparable &amp;#8212; that is, there may be elements &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x&quot; title=&quot;x&quot; class=&quot;latex&quot; /&gt; and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;y&quot; title=&quot;y&quot; class=&quot;latex&quot; /&gt; for which neither &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim y&quot; title=&quot;x \lesssim y&quot; class=&quot;latex&quot; /&gt; nor &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=y+%5Clesssim+x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;y \lesssim x&quot; title=&quot;y \lesssim x&quot; class=&quot;latex&quot; /&gt; holds.&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s think about this.  Suppose we are given a preorder &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%28P%2C%5Clesssim%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;(P,\lesssim)&quot; title=&quot;(P,\lesssim)&quot; class=&quot;latex&quot; /&gt; with an &lt;i&gt;initial object&lt;/i&gt; &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=e&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;e&quot; title=&quot;e&quot; class=&quot;latex&quot; /&gt; (an initial object in this context is an element which is &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt; all other elements).  We&amp;#8217;ll initialize an accumulator to &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=e&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;e&quot; title=&quot;e&quot; class=&quot;latex&quot; /&gt;, and imagine receiving elements of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; one at a time.  For a concrete example, suppose we are dealing with the preorder (actually also a poset) of positive integers under the divisibility relation, so our accumulator is initialized to 1.  Let&amp;#8217;s say we receive the integer 4.  Clearly, 1 divides 4, so we should replace the 1 in our accumulator with 4.  But now suppose we next receive the integer 5.  4 does not divide 5 or vice versa, so what should we do?  We would be justified in neither throwing the 5 away nor replacing the 4, since 4 and 5 are not related to each other under the divisibility relation.  Somehow we need to keep the 4 &lt;i&gt;and&lt;/i&gt; the 5 around.&lt;/p&gt;
&lt;p&gt;The solution is that instead of creating a monoid over &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; itself, as we can for sets with a total order, we create a monoid over &lt;i&gt;subsets&lt;/i&gt; of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt;.  In particular, consider the set &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; of subsets of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; which do not contain two distinct elements &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x%2Cy&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x,y&quot; title=&quot;x,y&quot; class=&quot;latex&quot; /&gt; for which &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim y&quot; title=&quot;x \lesssim y&quot; class=&quot;latex&quot; /&gt;.  Since we are dealing with subsets of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt;, we can actually drop the restriction that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; contain an initial object; the empty set will serve as the identity for the monoid.&lt;/p&gt;
&lt;p&gt;We then define the monoid operation &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt; on two such subsets as&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Coplus+T+%3D+%28S+%5Ctriangleleft+T%29+%5Ccup+%28S+%5Ctriangleright+T%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \oplus T = (S \triangleleft T) \cup (S \triangleright T)&quot; title=&quot;S \oplus T = (S \triangleleft T) \cup (S \triangleright T)&quot; class=&quot;latex&quot; /&gt;&lt;/p&gt;
&lt;p&gt;where&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ctriangleleft+T+%3D+%5C%7B+s+%5Cin+S+%5Cmid+%5Cforall+t+%5Cin+T%2C+s+%3D+t+%5Cmbox%7B+or+%7D+t+%5Clesssim+s+%5Cmbox%7B+or+%7D+s+%5Cnot+%5Clesssim+t+%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \triangleleft T = \{ s \in S \mid \forall t \in T, s = t \mbox{ or } t \lesssim s \mbox{ or } s \not \lesssim t \}&quot; title=&quot;S \triangleleft T = \{ s \in S \mid \forall t \in T, s = t \mbox{ or } t \lesssim s \mbox{ or } s \not \lesssim t \}&quot; class=&quot;latex&quot; /&gt;&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ctriangleright+T+%3D+%5C%7B+t+%5Cin+T+%5Cmid+%5Cforall+s+%5Cin+S%2C+s+%3D+t+%5Cmbox%7B+or+%7D+t+%5Cnot+%5Clesssim+s+%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \triangleright T = \{ t \in T \mid \forall s \in S, s = t \mbox{ or } t \not \lesssim s \}&quot; title=&quot;S \triangleright T = \{ t \in T \mid \forall s \in S, s = t \mbox{ or } t \not \lesssim s \}&quot; class=&quot;latex&quot; /&gt;.&lt;/p&gt;
&lt;p&gt;In words, we combine subsets &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S&quot; title=&quot;S&quot; class=&quot;latex&quot; /&gt; and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;T&quot; title=&quot;T&quot; class=&quot;latex&quot; /&gt; by forming the set of objects from &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ccup+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \cup T&quot; title=&quot;S \cup T&quot; class=&quot;latex&quot; /&gt; which are not &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt; any others, with the exception of objects &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=s+%5Cin+S%2C+t+%5Cin+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;s \in S, t \in T&quot; title=&quot;s \in S, t \in T&quot; class=&quot;latex&quot; /&gt; where both &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=s+%5Clesssim+t&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;s \lesssim t&quot; title=&quot;s \lesssim t&quot; class=&quot;latex&quot; /&gt; and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=t+%5Clesssim+s&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;t \lesssim s&quot; title=&quot;t \lesssim s&quot; class=&quot;latex&quot; /&gt;; in this case we keep &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=s&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;s&quot; title=&quot;s&quot; class=&quot;latex&quot; /&gt; but not &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=t&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;t&quot; title=&quot;t&quot; class=&quot;latex&quot; /&gt;. This introduces a &amp;#8220;left bias&amp;#8221; to &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt;; there is also an equally valid version with right bias (in particular, &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Coplus%27+T+%3D+%28T+%5Ctriangleleft+S%29+%5Ccup+%28T+%5Ctriangleright+S%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \oplus&amp;#039; T = (T \triangleleft S) \cup (T \triangleright S)&quot; title=&quot;S \oplus&amp;#039; T = (T \triangleleft S) \cup (T \triangleright S)&quot; class=&quot;latex&quot; /&gt;).&lt;/p&gt;
&lt;p&gt;Now, let&amp;#8217;s show that this really does define a valid monoid.  First, we need to show that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt; is closed over &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt;. Suppose &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S%2C+T+%5Cin+P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S, T \in P_*&quot; title=&quot;S, T \in P_*&quot; class=&quot;latex&quot; /&gt;.  Suppose also that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x%2Cy+%5Cin+S+%5Coplus+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x,y \in S \oplus T&quot; title=&quot;x,y \in S \oplus T&quot; class=&quot;latex&quot; /&gt; are distinct elements of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; with &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Clesssim+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \lesssim y&quot; title=&quot;x \lesssim y&quot; class=&quot;latex&quot; /&gt;; we&amp;#8217;ll derive a contradiction.  First, we cannot have &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x%2Cy+%5Cin+S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x,y \in S&quot; title=&quot;x,y \in S&quot; class=&quot;latex&quot; /&gt; or &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x%2Cy+%5Cin+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x,y \in T&quot; title=&quot;x,y \in T&quot; class=&quot;latex&quot; /&gt; by definition of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt;.  Now suppose &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Cin+T%2C+y+%5Cin+S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \in T, y \in S&quot; title=&quot;x \in T, y \in S&quot; class=&quot;latex&quot; /&gt;.  The fact that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Cin+S+%5Coplus+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \in S \oplus T&quot; title=&quot;x \in S \oplus T&quot; class=&quot;latex&quot; /&gt; together with the definition of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ctriangleright+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \triangleright T&quot; title=&quot;S \triangleright T&quot; class=&quot;latex&quot; /&gt; imply that we must have &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Cnot+%5Clesssim+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \not \lesssim y&quot; title=&quot;x \not \lesssim y&quot; class=&quot;latex&quot; /&gt;, a contradiction.  Finally, suppose &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Cin+S%2C+y+%5Cin+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \in S, y \in T&quot; title=&quot;x \in S, y \in T&quot; class=&quot;latex&quot; /&gt;.  Again, by the definition of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ctriangleright+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \triangleright T&quot; title=&quot;S \triangleright T&quot; class=&quot;latex&quot; /&gt; we must have &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=y+%5Cnot+%5Clesssim+x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;y \not \lesssim x&quot; title=&quot;y \not \lesssim x&quot; class=&quot;latex&quot; /&gt;.  But then the fact that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Cin+S+%5Coplus+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \in S \oplus T&quot; title=&quot;x \in S \oplus T&quot; class=&quot;latex&quot; /&gt;, together with the definition of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ctriangleleft+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \triangleleft T&quot; title=&quot;S \triangleleft T&quot; class=&quot;latex&quot; /&gt; and the facts that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Cneq+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \neq y&quot; title=&quot;x \neq y&quot; class=&quot;latex&quot; /&gt; and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=y+%5Cnot+%5Clesssim+x&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;y \not \lesssim x&quot; title=&quot;y \not \lesssim x&quot; class=&quot;latex&quot; /&gt; imply that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=x+%5Cnot+%5Clesssim+y&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;x \not \lesssim y&quot; title=&quot;x \not \lesssim y&quot; class=&quot;latex&quot; /&gt;, a contradiction again.  Hence &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Coplus+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \oplus T&quot; title=&quot;S \oplus T&quot; class=&quot;latex&quot; /&gt; contains no such pair of elements.&lt;/p&gt;
&lt;p&gt;The fact that the empty set &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cvarnothing&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\varnothing&quot; title=&quot;\varnothing&quot; class=&quot;latex&quot; /&gt; is the identity for &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt; is clear. (Incidentally, this is why we require that none of the sets in &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; contain two distinct elements with one &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt; the other: if &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S&quot; title=&quot;S&quot; class=&quot;latex&quot; /&gt; were such a set, we would have &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cvarnothing+%5Coplus+S+%5Cneq+S&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\varnothing \oplus S \neq S&quot; title=&quot;\varnothing \oplus S \neq S&quot; class=&quot;latex&quot; /&gt;.)  I leave the associativity of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt; as an exercise for the reader (translation: this post is already getting long, the associativity of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt; seems intuitively obvious to me, and I don&amp;#8217;t feel like formalizing it at the moment &amp;#8212; perhaps I&amp;#8217;ll try writing it up later).  I also leave as an interesting exercise the following theorem: if &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S%2C+T+%5Cin+P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S, T \in P_*&quot; title=&quot;S, T \in P_*&quot; class=&quot;latex&quot; /&gt; are both finite and nonempty, then &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Coplus+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \oplus T&quot; title=&quot;S \oplus T&quot; class=&quot;latex&quot; /&gt; is also finite and nonempty.&lt;/p&gt;
&lt;p&gt;In our example from before, we could now begin with &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B1%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{1\}&quot; title=&quot;\{1\}&quot; class=&quot;latex&quot; /&gt; in our accumulator.  After receiving the singleton set &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B4%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{4\}&quot; title=&quot;\{4\}&quot; class=&quot;latex&quot; /&gt;, our accumulator would have that singleton set as its new value.  Upon receiving &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B5%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{5\}&quot; title=&quot;\{5\}&quot; class=&quot;latex&quot; /&gt;, our accumulator would become &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B4%2C5%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{4,5\}&quot; title=&quot;\{4,5\}&quot; class=&quot;latex&quot; /&gt;.  Receiving &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B10%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{10\}&quot; title=&quot;\{10\}&quot; class=&quot;latex&quot; /&gt; would result in &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B4%2C10%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{4,10\}&quot; title=&quot;\{4,10\}&quot; class=&quot;latex&quot; /&gt; (5 divides 10, so the 5 is discarded); if we later received &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B20%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{20\}&quot; title=&quot;\{20\}&quot; class=&quot;latex&quot; /&gt;, we would simply have &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7B20%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{20\}&quot; title=&quot;\{20\}&quot; class=&quot;latex&quot; /&gt; in our accumulator (both 4 and 10 divide 20).&lt;/p&gt;
&lt;p&gt;I like to think of this as the monoid of &lt;i&gt;partial knowledge&lt;/i&gt;.  If we consider &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; to be a set of facts or beliefs, some better (more reliable, useful, correct, complete, etc.) than others, then elements of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; correspond to possible sets of beliefs.  &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt; describes how a set of beliefs changes upon encountering a new set of facts; some of the new facts may supersede and replace old ones, some may not impart any new information, and some may be completely new facts that aren&amp;#8217;t related to any currently known.&lt;/p&gt;
&lt;p&gt;Now, why can this be thought of as a generalization of the monoid &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%28P%2C+%5Cmax%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;(P, \max)&quot; title=&quot;(P, \max)&quot; class=&quot;latex&quot; /&gt; on a totally ordered set?  Well, look what happens when we replace &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; in the definitions above with a totally ordered set with relation &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cleq&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\leq&quot; title=&quot;\leq&quot; class=&quot;latex&quot; /&gt;: first of all, the restriction on &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; (no two elements of a set in &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; should be related by &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cleq&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\leq&quot; title=&quot;\leq&quot; class=&quot;latex&quot; /&gt;) means that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; contains only the empty set and singleton sets, so (ignoring the empty set) &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; is isomorphic to &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt;.  Now look at the definition of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ctriangleleft+T&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \triangleleft T&quot; title=&quot;S \triangleleft T&quot; class=&quot;latex&quot; /&gt;, with &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\lesssim&quot; title=&quot;\lesssim&quot; class=&quot;latex&quot; /&gt; replaced by &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cleq&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\leq&quot; title=&quot;\leq&quot; class=&quot;latex&quot; /&gt; (and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Cnot+%5Clesssim&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\not \lesssim&quot; title=&quot;\not \lesssim&quot; class=&quot;latex&quot; /&gt; replaced by &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%3E&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;&amp;gt;&quot; title=&quot;&amp;gt;&quot; class=&quot;latex&quot; /&gt;):&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://l.wordpress.com/latex.php?latex=S+%5Ctriangleleft+T+%3D+%5C%7B+s+%5Cin+S+%5Cmid+%5Cforall+t+%5Cin+T%2C+s+%3D+t+%5Cmbox%7B+or+%7D+t+%5Cleq+s+%5Cmbox%7B+or+%7D+s+%3E+t+%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;S \triangleleft T = \{ s \in S \mid \forall t \in T, s = t \mbox{ or } t \leq s \mbox{ or } s &amp;gt; t \}&quot; title=&quot;S \triangleleft T = \{ s \in S \mid \forall t \in T, s = t \mbox{ or } t \leq s \mbox{ or } s &amp;gt; t \}&quot; class=&quot;latex&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=s+%3D+t&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;s = t&quot; title=&quot;s = t&quot; class=&quot;latex&quot; /&gt; and &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=s+%3E+t&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;s &amp;gt; t&quot; title=&quot;s &amp;gt; t&quot; class=&quot;latex&quot; /&gt; are both subsumed by &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=t+%5Cleq+s&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;t \leq s&quot; title=&quot;t \leq s&quot; class=&quot;latex&quot; /&gt;, so we can rewrite this as&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7Bs%5C%7D+%5Ctriangleleft+%5C%7Bt%5C%7D+%3D+%5C%7Bs%5C%7D+%5Cmbox%7B+if+%7D+s+%5Cgeq+t%2C+%5Cmbox%7B+or+%7D+%5Cvarnothing+%5Cmbox%7B+otherwise+%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{s\} \triangleleft \{t\} = \{s\} \mbox{ if } s \geq t, \mbox{ or } \varnothing \mbox{ otherwise }&quot; title=&quot;\{s\} \triangleleft \{t\} = \{s\} \mbox{ if } s \geq t, \mbox{ or } \varnothing \mbox{ otherwise }&quot; class=&quot;latex&quot; /&gt;.&lt;/p&gt;
&lt;p&gt;An analysis of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Ctriangleright&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\triangleright&quot; title=&quot;\triangleright&quot; class=&quot;latex&quot; /&gt; is similar, and it is clear that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5C%7Bs%5C%7D+%5Coplus+%5C%7Bt%5C%7D+%3D+%5C%7B%5Cmax%28s%2Ct%29%5C%7D&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\{s\} \oplus \{t\} = \{\max(s,t)\}&quot; title=&quot;\{s\} \oplus \{t\} = \{\max(s,t)\}&quot; class=&quot;latex&quot; /&gt;.&lt;/p&gt;
&lt;p&gt;I note in passing that although it might appear shady that I swept that &amp;#8220;ignoring the empty set&amp;#8221; bit under the rug, everything really does check out: technically, to see a direct generalization of &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%28P%2C%5Cmax%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;(P,\max)&quot; title=&quot;(P,\max)&quot; class=&quot;latex&quot; /&gt; to &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%28P_%2A%2C+%5Coplus%29&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;(P_*, \oplus)&quot; title=&quot;(P_*, \oplus)&quot; class=&quot;latex&quot; /&gt;, we can require that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P&quot; title=&quot;P&quot; class=&quot;latex&quot; /&gt; have an initial object and that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=P_%2A&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;P_*&quot; title=&quot;P_*&quot; class=&quot;latex&quot; /&gt; contains only finite, nonempty sets.  Then it requires a bit more work to prove that &lt;img src=&quot;http://l.wordpress.com/latex.php?latex=%5Coplus&amp;amp;bg=ffffff&amp;amp;fg=333333&amp;amp;s=0&quot; alt=&quot;\oplus&quot; title=&quot;\oplus&quot; class=&quot;latex&quot; /&gt; is closed, but it still goes through.  I used the formulation I did since it seems more general and requires less proving.&lt;/p&gt;
&lt;p&gt;Anyway, this ended up being longer than I originally anticipated (why does that always happen!? =), so I&amp;#8217;ll stop here for now, but next time I&amp;#8217;ll give some actual Haskell code (which I think ends up being pretty neat!), and talk about one relatively common design pattern which is actually a special case of this monoid.&lt;/p&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/categories/byorgey.wordpress.com/62/&quot; /&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/tags/byorgey.wordpress.com/62/&quot; /&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gocomments/byorgey.wordpress.com/62/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/byorgey.wordpress.com/62/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godelicious/byorgey.wordpress.com/62/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/byorgey.wordpress.com/62/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gostumble/byorgey.wordpress.com/62/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/byorgey.wordpress.com/62/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godigg/byorgey.wordpress.com/62/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/byorgey.wordpress.com/62/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/goreddit/byorgey.wordpress.com/62/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/byorgey.wordpress.com/62/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://stats.wordpress.com/b.gif?host=byorgey.wordpress.com&amp;amp;blog=1152889&amp;amp;post=62&amp;amp;subd=byorgey&amp;amp;ref=&amp;amp;feed=1&quot; /&gt;&lt;/div&gt;</description>
	<pubDate>Thu, 17 Apr 2008 19:37:24 +0000</pubDate>
	<dc:creator>Brent</dc:creator>
</item>
<item>
	<title>Joachim Breitner: Announcing DarcsWatch</title>
	<guid isPermalink="false">http://www.joachim-breitner.de/blog/archives/290-guid.html</guid>
	<link>http://www.joachim-breitner.de/blog/archives/290-Announcing-DarcsWatch.html</link>
	<description>&lt;p&gt;A lot of haskell-related projects use the &lt;a href=&quot;http://darcs.net/&quot;&gt;darcs&lt;/a&gt; version control system. Darcs has the nice feature that you can easily submit a patch by e-mail, usually sent to the project maintainer or a mailing list. What has bothered me in the past was that I had to manually check whether my patch was applied yet.&lt;/p&gt;&lt;p&gt;So this week, I wrote &lt;a href=&quot;http://darcs.nomeata.de/&quot;&gt;DarcsWatch&lt;/a&gt;. DarcsWatch receives submitted patches and compares them to the repositories it knows about, whether the patch is missing there or not. You either send your patches to DarcsWeb directly when submitting them, using CC, or DarcsWatch is subscribed to the project mailing list itself, which is the case for the &lt;a href=&quot;http://lists.osuosl.org/mailman/listinfo/darcs-devel&quot;&gt;darcs-devel&lt;/a&gt; and &lt;a href=&quot;http://www.haskell.org/mailman/listinfo/xmonad&quot;&gt;xmonad&lt;/a&gt; lists. Other than that, not much is to do, and you’ll find a nice overview of your patches, like this &lt;a href=&quot;http://darcswatch.nomeata.de/user_mail@joachim-breitner.de.html&quot;&gt;overview of my patches&lt;/a&gt;, with diffs and download links.&lt;/p&gt;&lt;p&gt;If you want to use DarcsWatch for your contributions to other projects, or for your own projects, have a look the &lt;a href=&quot;http://darcs.nomeata.de/darcswatch/documentation.html&quot;&gt;documentation&lt;/a&gt;. There are probably still bugs around, and the problem of marking patches as obsolete is not really solved yet, so if you have ideas about it, mail me, comment here, or come to #darcs on freenode. Patches are always welcome, you can get the source from &lt;a href=&quot;http://darcs.nomeata.de/darcswatch/&quot;&gt;DarcsWatch’s repository&lt;/a&gt;.&lt;/p&gt;</description>
	<pubDate>Thu, 17 Apr 2008 17:25:15 +0000</pubDate>
	<dc:creator>mail@joachim-breitner.de (nomeata)</dc:creator>
</item>
<item>
	<title>Mark Jason Dominus: Is blood a transitive relation?</title>
	<guid isPermalink="false">tag:blog.plover.com,2008:/oops/blood-relatives</guid>
	<link>http://blog.plover.com/oops/blood-relatives.html</link>
	<description>When you're first teaching high school students about the idea of a
relation, you give examples of the important properties of relations.
Relations can be some, none, or all of reflexive, symmetric,
antisymmetric, or transitive.  You start with examples that everyone
is already familiar with, such as the identity relation, which is
reflexive, symmetric, and transitive, and the &amp;le; relation, which is
antisymmetric and transitive.  Other good examples include familial
relations: &quot;sister-in-law of&quot; is symmetric on the set of women, but
not on the larger set of people; &quot;ancestor of&quot; is transitive but not
symmetric.&lt;p&gt;

It might seem at first glance that &quot;is related to&quot; is transitive, but,
at least under conventional definitions, it isn't, because my wife is
not related to my cousins.&lt;p&gt;

(I was once invited to speak at Haverford College, and,
since I have no obvious qualifications in &lt;a href=&quot;http://perl.plover.com/yak/cftalk/&quot;&gt;the topic on which I was speaking&lt;/a&gt;, I was asked how I
had come to be there.  I explained that it was because &lt;a href=&quot;http://www.haverford.edu/math/lbutler.html&quot;&gt;my wife's mother's
younger brother's daughter's husband's older brother's wife was the
chair of the mathematics department&lt;/a&gt;.  Remember, it's not what you
know, it's who you know.)&lt;p&gt;

I think I had sometimes tried to turn &quot;related to&quot; into a transitive
relation by restricting it to &quot;is related to by blood&quot;.  This rules
out the example above of my wife being unrelated to my cousins,
because my relationship with my wife is not one of blood.  I don't
quite remember using &quot;related by blood&quot; as an example of a transitive
relation, but I think I might have, because I was quite surprised when
I realized that it didn't work.  I spent a lot of time that morning
going over my counterexample in detail, writing it up in my head, as
it were.  I was waiting around in Trevose for the mechanic to finish
examining my car, and had nothing better to do that morning.  If I had
had a blog then, I would probably have posted it.  But it is a good
thing that I didn't, because in spite of all my thought about it, I
missed something important.&lt;p&gt;

The example is as follows.  &lt;i&gt;A&lt;/i&gt; and &lt;i&gt;B&lt;/i&gt; have a child,
&lt;i&gt;X&lt;/i&gt;.  (You may suppose that they marry beforehand, and divorce
afterward, if your morality requires it.)  Similarly, &lt;i&gt;C&lt;/i&gt; and
&lt;i&gt;D&lt;/i&gt; have a child, &lt;i&gt;Z&lt;/i&gt;.  Then &lt;i&gt;B&lt;/i&gt; and &lt;i&gt;C&lt;/i&gt; have a
child &lt;i&gt;Y&lt;/i&gt;.  &lt;i&gt;Y&lt;/i&gt; is now the half-sibling of both &lt;i&gt;X&lt;/i&gt; and
&lt;i&gt;Z&lt;/i&gt;, and so is unquestionably a blood relative of both, but
&lt;i&gt;X&lt;/i&gt; and &lt;i&gt;Z&lt;/i&gt; are entirely unrelated.  They are not even
step-siblings.&lt;p&gt;

Well, this is all very well, but the reason I have filed it under &lt;a href=&quot;http://blog.plover.com/oops/&quot;&gt;oops/&lt;/a&gt;, and the reason it's a good thing I
didn't post it on my (then nonexistent) blog is that this elaborate
counterexample contains a much simpler one:  &lt;i&gt;X&lt;/i&gt; is the child and
hence the blood relative of
both &lt;i&gt;A&lt;/i&gt; and &lt;i&gt;B&lt;/i&gt;, who are not in general related to
each other.  &lt;i&gt;C&lt;/i&gt;, &lt;i&gt;D&lt;/i&gt;, &lt;i&gt;Y&lt;/i&gt;, and &lt;i&gt;Z&lt;/i&gt; are wholly
unnecessary.&lt;p&gt;

I wish I had some nice conclusion to draw here, but if there's
something I could learn from it I can't think would it might be.&lt;p&gt;

&lt;!--

That is all I meant to write about, but I am in the waiting room at
the Parking Authority, waiting to protest a ticket, so I have lots of
time, and I may as well go on for a while.&lt;p&gt;

At my last regular job, one of my co-workers observed that everyone on
the corridor was part-Asian.  Her mother was Japanese; another
colleague's was Thai.  One colleague was Bengali.  &quot;I am on this
corridor,&quot; I said, &quot;and I am not Asian.&quot;  &quot;You have blood relatives
who are Asian,&quot; she pointed out, which I had not really though of
before.  Iris had recently been born, and she is half-Korean.&lt;p&gt;

When Iris was still &lt;i&gt;in utero&lt;/i&gt;, Lorrie and I visited a genetic
counselor whose job was to judge the chance that Iris might come out
with some hereditary disorder.  She asked me many questions about my
forebears, which I answered in my characteristically guarded way: &quot;Is
there any history of Tay-Sachs disease in your family?&quot;  &quot;Not so far
as I know.&quot;  &quot;I am not aware of any.&quot;  &quot;I believe not.&quot;  And so on.&lt;p&gt;

But then she got to a more general question: &quot;Is there any possibility
that you and Lorrie might be related?&quot;  And I laughed, and said
heartily, &quot;None whatsoever!&quot;.   &lt;p&gt;

--&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</description>
	<pubDate>Thu, 17 Apr 2008 17:05:00 +0000</pubDate>
	<dc:creator>Mark Dominus</dc:creator>
</item>
<item>
	<title>Conrad Parker: :rikaichan for Vimperator</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-9101292118679422945.post-8373941523429907668</guid>
	<link>http://blog.kfish.org/2008/04/rikaichan-for-vimperator.html</link>
	<description>&lt;p&gt;
Some of my favourite Firefox plugins are:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.polarcloud.com/rikaichan/&quot;&gt;Rikaichan&lt;/a&gt;, a Japanese dictionary, which adds instant translation popups when you mouse over a word;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://vimperator.mozdev.org/&quot;&gt;Vimperator&lt;/a&gt;, which provides &lt;tt&gt;vi&lt;/tt&gt;-like user interface;&lt;/li&gt;
&lt;li&gt;and &lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/1337&quot;&gt;Hide Tab Bar&lt;/a&gt;, because Vimperator's buffer list is more useful.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Vimperator hides the menu bar by default. &lt;b&gt;Tools-&gt;Toggle Rikaichan&lt;/b&gt; has no default keybinding, and the keybindings to navigate the menubar are not available if the menubar is not visible, so Rikaichan can no longer be activated.
&lt;/p&gt;
&lt;p&gt;
The following adds a vimperator command &lt;tt&gt;:rikaichan&lt;/tt&gt;; save it to &lt;tt&gt;.vimperator/plugin/toggleRikaichan.js&lt;/tt&gt;:

&lt;blockquote&gt;&lt;pre&gt;
(function(){
    vimperator.commands.add(new vimperator.Command(
        ['rikaichan', 'rikai'],
        function(){
            rcxMain.inlineToggle();
        }
    ))
}) ();
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
It is aliased to &lt;tt&gt;:rikai&lt;/tt&gt; for short, but unfortunately vimperator won't recognize &lt;tt&gt;:理解&lt;/tt&gt;.
Thanks to ktsukagoshi for the explanation of how to write a vimperator plugin (&lt;a href=&quot;http://d.hatena.ne.jp/ktsukagoshi/20080305/1204730962&quot;&gt;vimperatorのプラグインの作成&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;Remember, &lt;a href=&quot;http://www.vergenet.net/~conrad/syre/&quot;&gt;the interface is inside your mind&lt;/a&gt;.&lt;/i&gt;
&lt;/p&gt;&lt;/p&gt;</description>
	<pubDate>Thu, 17 Apr 2008 16:01:22 +0000</pubDate>
	<dc:creator>Conrad Parker</dc:creator>
</item>
<item>
	<title>Philip Wadler: Fun with correlation and citations</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-9757377.post-9088874984566084902</guid>
	<link>http://wadler.blogspot.com/2008/04/fun-with-correllation-and-citations.html</link>
	<description>I'm sure I'll want to cite this someday, possibly in class but perhaps in the pub.  What I'll be citing it as an example of, I'm not yet sure.  Thanks to Leonid Libkin for spotting this.</description>
	<pubDate>Thu, 17 Apr 2008 10:00:50 +0000</pubDate>
	<dc:creator>Philip Wadler</dc:creator>
</item>
<item>
	<title>Kenn Knowles: Drawing fractals in Haskell with a cursor graphics DSEL and a cute list representation</title>
	<guid isPermalink="false">http://www.kennknowles.com/blog/2008/04/16/drawing-fractals-in-haskell-with-a-cursor-graphics-dsel-and-a-cute-list-representation/</guid>
	<link>http://www.kennknowles.com/blog/2008/04/16/drawing-fractals-in-haskell-with-a-cursor-graphics-dsel-and-a-cute-list-representation/</link>
	<description>&lt;p&gt;I'm reading the very fun &lt;em&gt;Measure, Topology, and Fractal Geometry&lt;/em&gt; by GA Edgar, and thought I'd hack up some of the examples in Haskell.  So this post implements cursor graphics in OpenGL in (I think) DSEL style, demonstrating the &lt;code&gt;StateT&lt;/code&gt; and &lt;code&gt;Writer&lt;/code&gt; monad gadgets from the
standard library and a cool &quot;novel representation of lists&quot; due to R Hughes. On the fractal side, the examples will hopefully convince you that fractals are not just cute pictures, but extremely important illustrations that the real numbers are weird.  As usual, you can save this post to &lt;code&gt;Fractals.lhs&lt;/code&gt; and compile it with &lt;code&gt;ghc --make Fractals&lt;/code&gt;
 &lt;a href=&quot;http://www.kennknowles.com/blog/2008/04/16/drawing-fractals-in-haskell-with-a-cursor-graphics-dsel-and-a-cute-list-representation/#more-42&quot; class=&quot;more-link&quot;&gt;(more&amp;#8230;)&lt;/a&gt;&lt;/p&gt;</description>
	<pubDate>Wed, 16 Apr 2008 18:02:52 +0000</pubDate>
	<dc:creator>Kenn</dc:creator>
</item>
<item>
	<title>Luke Palmer: Symphonic Poem no. 1</title>
	<guid isPermalink="false">http://luqui.org/blog?p=517</guid>
	<link>http://luqui.org/blog/archives/2008/04/16/symphonic-poem-no-1/</link>
	<description>&lt;p&gt;I just finished, in some sense, &lt;a href=&quot;http://luqui.org/music/progress/symphonic_poems/01.mp3&quot;&gt;the first&lt;/a&gt; of a series (hopefully) of symphonic poems.  I took a long break in the middle of writing this, so I could be mistaken, but I think it took about 20 hours total.  It still needs a little tweaking; in particular some of the harmonies on the climaxes are drowned out by the percussion and poor instrument balancing, and I&amp;#8217;m not sure if I&amp;#8217;m happy with the ending (it&amp;#8217;s meant to be a little unsettling&amp;#8230;).  But the idea is there.&lt;/p&gt;</description>
	<pubDate>Wed, 16 Apr 2008 11:21:47 +0000</pubDate>
	<dc:creator>Luke</dc:creator>
</item>
<item>
	<title>John Goerzen (CosmicRay): datapacker</title>
	<guid isPermalink="false">http://changelog.complete.org/posts/707-guid.html</guid>
	<link>http://changelog.complete.org/posts/707-datapacker.html</link>
	<description>Every so often, I come across some utility that need.  I think it &lt;b&gt;must&lt;/b&gt; have been written before, but I can't find it.&lt;br /&gt;
&lt;br /&gt;
Today I needed a tool to take a set of files and split them up into directories in a size that will fit on DVDs.  I wanted a tool that could either produce the minimum number of DVDs, or keep the files in order.  I couldn't find one.  So I wrote &lt;a href=&quot;http://software.complete.org/datapacker&quot;&gt;datapacker&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
datapacker is a tool to group files by size. It is perhaps most often used to fit a set of files onto the minimum number of CDs or DVDs.&lt;br /&gt;
&lt;br /&gt;
datapacker is designed to group files such that they fill fixed-size containers (called &quot;bins&quot;) using the minimum number of containers. This is useful, for instance, if you want to archive a number of files to CD or DVD, and want to organize them such that you use the minimum possible number of CDs or DVDs.&lt;br /&gt;
&lt;br /&gt;
In many cases, datapacker executes almost instantaneously. Of particular note, the hardlink action can be used to effectively copy data into bins without having to actually copy the data at all.&lt;br /&gt;
&lt;br /&gt;
datapacker is a tool in the traditional Unix style; it can be used in pipes and call other tools.&lt;br /&gt;
&lt;br /&gt;
I have, of course, uploaded it to sid.  But while it sits in NEW, you can download the source tarball (with debian/ directory) from the project homepage at &lt;a href=&quot;http://software.complete.org/datapacker&quot;&gt;http://software.complete.org/datapacker&lt;/a&gt;.  I've also got an &lt;a href=&quot;http://software.complete.org/datapacker/static/doc/datapacker.html&quot;&gt;HTML version of the manpage&lt;/a&gt; online, so you can see all the cool features of datapacker.  It works nicely with find, xargs, mkisofs, and any other Unixy pipe-friendly program.&lt;br /&gt;
&lt;br /&gt;
Those of you that know me will not be surprised that I wrote datapacker in Haskell.  For this project, I added a &lt;a href=&quot;http://en.wikipedia.org/wiki/Bin_packing_problem&quot;&gt;bin-packing&lt;/a&gt; module and support for parsing inputs like &lt;tt&gt;1.5g&lt;/tt&gt; to &lt;a href=&quot;http://software.complete.org/missingh&quot;&gt;MissingH&lt;/a&gt;.  So everyone else that needs to do that sort of thing can now use library functions for it.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Update...&lt;/b&gt;  I should have mentioned the &lt;b&gt;really cool thing&lt;/b&gt; about this.  After datapacker compiled and ran, I had only &lt;b&gt;one mistake&lt;/b&gt; that was not caught by the Haskell compiler: I said &amp;lt; where I should have said &amp;lt;= one place.  This is one of the very nice things about Haskell: the language lends itself to compilers that can catch so much.  It's not that I'm a perfect programmer, just that my compiler is pretty crafty.</description>
	<pubDate>Wed, 16 Apr 2008 04:09:53 +0000</pubDate>
	<dc:creator>nospam@example.com (John Goerzen)</dc:creator>
</item>
<item>
	<title>Nick Mudge: Inelegance of Combining HTML and Code</title>
	<guid isPermalink="false">http://nickmudge.info?post=92</guid>
	<link>http://nickmudge.info?post=92</link>
	<description>&lt;p&gt;
I thought I’d shoot off an idea about programming webpages.
&lt;/p&gt;
&lt;p&gt;
To me writing a script to generate HTML has always been a problem. It’s a problem because you have to mix a bunch of code with HTML.  No matter how you mix more than a little bit of code and HTML the result is inelegance, ugly code, hard to read code. It’s not very good because you’re mixing two different syntaxes together in a jumbled fashion. Code that is just code without HTML in it so much nicer and easy to follow and read. And gosh, I’m always perturbed about how to indent code and HTML together so that structure and things can be made clearer. The elegance, clarity and structure provided by indentation is reduced a lot by the combination of programming logic and HTML intermingled, at least from my experience.
&lt;/p&gt;
&lt;p&gt;
There’s been various ways to help make this better. For instance in PHP you can move in and out of HTML and PHP modes which makes the transitions nicer sometimes. The &lt;a href=&quot;http://www.smarty.net/&quot;&gt;Smarty templating system&lt;/a&gt; is largely a system to make this easier. The Smarty language syntax and tools integrate nicer with HTML and help keep programming away from HTML. This also has a nice benefit of being nice to designers that need to work with HTML and CSS but don’t want to hassle with programming.
&lt;/p&gt;
&lt;p&gt;
Smarty is a nice improvement and the best solution I’ve used so far but the problem is still there. Sometimes you want to add quite a bit of logic to your Smarty templates,  adding loops, and inner loops, adding lots of if conditions, making function calls etc. You might want to do this because the display of the  webpage you are making is complex and requires lots of if conditions and loops or because you want to reuse the same templates for different webpages (this cuts down the amount of work you need to do and manage – reuse is good) and so need to add additional logic that runs depending on which page the template is being used to generate. Too much logic in Smarty templates quickly gets inelegant and hard.
&lt;/p&gt;
&lt;p&gt;
Things get inelegant and harder to follow when you start adding a bunch of logic to HTML pages. It’s like HTML wasn’t meant to have logic in it.
&lt;/p&gt;
&lt;p&gt;
A related problem that is also a big problem with HTML is that it does not scale. The bigger an HTML file gets the harder it is to follow and work with. With a zillion div tags and table tags it gets harder and harder to know what exactly is happening anywhere in a document. It just doesn’t scale. This combined with logic makes for general ickyness. 
&lt;/p&gt;
&lt;p&gt;
I wonder if there is another way.
&lt;/p&gt;
&lt;p&gt;
I’ve looked into Lisp a little in the past and what I’ve seen is that in Common Lisp the combination of programming and HTML are handled in a completely different way.  I wonder if something here could be a real solution to this inelegance pest, and actually really bring about an elegance and smoothness in the combination of programming logic and HTML.
&lt;/p&gt;
&lt;p&gt;
From what I've seen in Common Lisp when you program webpages you don’t really mix HTML and programming. Instead you make it all programming.  I’m thinking it might be something along these lines: You have a library of functions and/or macors.  Each function or macro or arguement corresponds to an HTML tag. For instance you have the div function that is used to generate the HTML for a div tag etc. You just use all these functions that generate all the HTML for you. And it’s easy and natural to add logic because it’s all consistent programming code. You keep the consistency, elegance and scalability of a programming language by only programming in the programming language.
&lt;/p&gt;
&lt;p&gt;
The main problem I see with this approach of using functions to generate HTML is that HTML is highly flexible -- some tags can have certain attributes and can be nestled within some tags but not others and there’s a ton of variance and things you can do in HTML. In lots of programming languages I think functions are probably not flexible enough to cope with all the possibilities. I think these functions would limit what you could do with HTML and cut your flexibility of how you want the HTML to be. It really might not be very workable. I certainly don’t like to code with constraints on me.
&lt;/p&gt;
&lt;p&gt;
But maybe it’s possible with something like Lisp. You’d need finely grained functions/macros that had the same flexibility and limitations as the HTML tags. And I think that’s something Lisp might be able to provide. In Lisp you have finely grained control on what your functions are and how they work – more than I’ve seen anywhere. In addition Lisp has powerful macro abilities that enable you to mold the syntax and semantics of the language to your will. This fine grainess of control on the syntax and semantics of the language might enable you to write a library of HTML functions that you could use to write pure elegant code that generates all the HTML you need and with as much flexibility as you need. Perhaps this already exists.
&lt;/p&gt;
&lt;p&gt;
I think something like this would make it much easier and faster to work with webpages because pure well written code is much easier to write and read than a mess of HTML and code together. With code you have one consistent syntax and it scales better than HTML does. In addition if your functions are perfect (have no bugs in their implementation), then any HTML you generate with them should automatically be perfect too – that’s real scalability power when talking about HTML correctness.
&lt;/p&gt;
&lt;p&gt;
Of course this pure programming way of handling HTML might not be so good for designers. So I was thinking that there could be some kind of separate interface for designers – like CSS is a separate interface into the display of HTML and a webpage. One idea is that a designer could design stuff in pure HTML and CSS and then feed it into a program that analyses it and if it is correct HTML and CSS generates or modifies the programming code to generate that HTML and CSS and if it is wrong spits the HTML and CSS back to the designer to fix.
&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;
From Chris Minnick:
&lt;/p&gt;
&lt;p&gt;
Good thoughts, Nick.
&lt;/p&gt;
&lt;p&gt;
I see what you’re getting at, but I’m skeptical of solutions to make code or HTML more 'pure'. It seems like no matter what you do, someone is going to start slipping some HTML in where it doesn’t belong, or is going to put something that should be in the CSS into the HTML, or is going to use tables for layout, or what-have-you. Usually, people resist doing things the 'right' way because the right way is more difficult or doesn't work right.
&lt;/p&gt;
&lt;p&gt;
CSS positioning is a perfect example: purists insist that all Web page layout should be done with divs and CSS, and that tables should only be used for tabular data. This makes perfect sense, of course, but the reality is that you just can’t do some of the things you can do with tables using divs, or it’s very difficult—especially considering browser differences. 
&lt;/p&gt;
&lt;p&gt;
So, what usually ends up happening as a result of this is that the people who were insisting on purity start backing off … so, now RSS 2.0 is popular, while the strict RDF version (RSS 1.1) was a big flop, and HTML 5 is going to be the successor to XHTML because people continued to use the much more flexible HTML 4.01 years and years after the stricter XHTML 1.0 came out.
&lt;/p&gt;
&lt;p&gt;
My question is: would the benefits of writing HTML using functions outweigh the added complexity and inconvenience to people who design webpages?
&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;
From Nick Mudge:
&lt;/p&gt;
&lt;p&gt;
Hey Chris,
&lt;/p&gt;
&lt;p&gt;
I totally agree and excellent point. Your email made me realize that ideally the functions should be flexible enough to allow people to be as non-standard and/or hacky as they want. I think people should have the freedom to do things how they want.  I think the functions should prevent obvious errors like a &amp;lt;div&amp;gt; without a &amp;lt;/div&amp;gt; and things that will obviously break webpages in web browsers. It would be nice if it could also help people be as standard as they want by letting them set some global setting or something so that functions enforce more strictness to a standard or whatever they want.
&lt;/p&gt;
&lt;p&gt;
I think the goal of a library like this would be to enable programmers to combine programming and HTML in way that is syntactically consistent, easier to read, write and maintain without loosing the flexibility that they want. Or to achieve a scalable elegance with the combination of logic and HTML. Perhaps a secondary goal would be to help people create HTML as correct or as standard/unstandard as they want.
&lt;/p&gt;
&lt;p&gt;
Any system around the functions/macro library such as a program that translates HTML into code that generates the same HTML should be as flexible to the user as the functions.
&lt;/p&gt;
&lt;p&gt;
I think a designer who does HTML and CSS work would use some program that does an HTML to code translation and the designer should have a way to specify how loose the translator is in accepting HTML and CSS. And I think programmers would just work in the code. 
&lt;/p&gt;</description>
	<pubDate>Tue, 15 Apr 2008 00:00:00 +0000</pubDate>
</item>
<item>
	<title>Luke Palmer: SNW Backlogging</title>
	<guid isPermalink="false">http://luqui.org/blog?p=516</guid>
	<link>http://luqui.org/blog/archives/2008/04/14/snw-backlogging/</link>
	<description>&lt;p&gt;SNW is dead  &lt;tt&gt;:-(&lt;/tt&gt;.  But I still have some recordings lying around that I&amp;#8217;m gradually editing.  Here&amp;#8217;s the first batch, from March 20:&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;a href=&quot;http://luqui.org/music/improv/2008-03-20_01.mp3&quot;&gt;01&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;http://luqui.org/music/improv/2008-03-20_02.mp3&quot;&gt;02&lt;/a&gt; - a minimalist (in the classical sense) exercise&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;http://luqui.org/music/improv/2008-03-20_03.mp3&quot;&gt;03&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;http://luqui.org/music/improv/2008-03-20_04.mp3&quot;&gt;04&lt;/a&gt; - fun and funky&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;http://luqui.org/music/improv/2008-03-20_05.mp3&quot;&gt;05&lt;/a&gt; - a long piece with many sections, pretty upbeat&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;#01 and #03 are included for completeness; they suck &lt;tt&gt;:-p&lt;/tt&gt;.  The rest are pretty good.&lt;/p&gt;</description>
	<pubDate>Mon, 14 Apr 2008 21:28:13 +0000</pubDate>
	<dc:creator>Luke</dc:creator>
</item>
<item>
	<title>Conrad Parker: Continuation Fest 2008: Continuations for video decoding and scrubbing</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-9101292118679422945.post-8478267578838678327</guid>
	<link>http://blog.kfish.org/2008/04/continuation-fest-2008-continuations.html</link>
	<description>&lt;p&gt;
Yesterday was &lt;a href=&quot;http://logic.cs.tsukuba.ac.jp/Continuation/&quot;&gt;Continuation Fest 2008&lt;/a&gt;,
at the University of Tokyo's campus in Akihabara (a very nice venue!).
It was very well attended; latecomers overflowed to a second room and participated by video conference. It was a little strange to see so many people interested in such an
&lt;strike&gt;obscure, troublesome and malignant&lt;/strike&gt; expressively powerful
programming construct; the breadth of talks made for a very inspiring and practical introduction to the theory, applications and implementation of continuations in many different languages.
&lt;/p&gt;
&lt;p&gt;
I recommend reading
&lt;a href=&quot;http://pllab.is.ocha.ac.jp/~asai/&quot;&gt;Kenichi Asai&lt;/a&gt;'s
introduction to delimited continuations
(&lt;a href=&quot;http://pllab.is.ocha.ac.jp/~asai/papers/contfest08slide.pdf&quot;&gt;slides&lt;/a&gt; [PDF]).
He introduced the &lt;tt&gt;shift&lt;/tt&gt; and &lt;tt&gt;reset&lt;/tt&gt; operators
through the problem of expressing exceptional control flow, and
then explained how to use these to type (ie. determine a concrete type for)
&lt;tt&gt;printf&lt;/tt&gt;. The main point was that
&lt;tt&gt;shift/reset&lt;/tt&gt; provide a high-level abstraction over control flow, with minimal impact
on the implementation of your existing functions.
&lt;/p&gt;
&lt;p&gt;
&lt;a href=&quot;http://okmij.org/ftp/&quot;&gt;Oleg Kiselyov&lt;/a&gt; demonstrated some new code for transactional
web applications, using delimited continuations for explicit state sharing between parallel connections. The result is that the user has a consistent view across multiple tabs are open on the same site, and the state is transactional so that there is no need for warnings like &quot;Do not press the BUY button more than once!&quot;. He said that everyone already understands delimited continuations, they just don't realize it.
&lt;/p&gt;
&lt;p&gt;
The topic of my presentation at Continuation Fest was
&lt;b&gt;Continuations for video decoding and scrubbing&lt;/b&gt;:
&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
Playback of encoded video involves scheduling the decoding of audio and video frames and synchronizing their playback. &quot;Scrubbing&quot; is the ability to quickly seek to and display an arbitrary frame, and is a common user interface requirement for a video editor. The implementation of playback and scrubbing is complicated by data dependencies in compressed video formats, which require setup and manipulation of decoder state.
&lt;/p&gt;&lt;p&gt;
We present the preliminary design of a continuation-based system for video decoding, reified as a cursor into a stream of decoded video frames. Frames are decoded lazily, and decoder states are recreated or restored when seeking. To reduce space requirements, a sequence of decoded frames can be replaced after use by the continuation which created them.
&lt;strike&gt;We outline implementations in Haskell and C.&lt;/strike&gt;
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://seq.kfish.org/~conrad/static/continuation-fest-2008/continuations-for-video.pdf&quot;&gt;Slides&lt;/a&gt; [383KB PDF]&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://seq.kfish.org/~conrad/static/continuation-fest-2008/continuations-for-video.article.pdf&quot;&gt;Article&lt;/a&gt; [215KB PDF]&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;

&lt;p&gt;I'll be introducing the code for this over the next few months.
Whereas in my presentation about
&lt;a href=&quot;http://blog.kfish.org/2008/03/bossa-2008-video-player-internals.html&quot;&gt;video player internals&lt;/a&gt; at BOSSA I outlined the problem space in designing a multimedia architecture,
at Continuation Fest I tried to break it down into subproblems and considered
useful data structures and programming techniques for dealing with them.
&lt;/p&gt;
&lt;p&gt;
I got a lot of great feedback, and I think I succeeded in my mission to introduce this problem space to some really smart people.
Thanks particularly to
&lt;a href=&quot;http://www.cs.rutgers.edu/~ccshan&quot;&gt;Chung-chieh Shan&lt;/a&gt; for some insightful ideas
about how to deal with existing stateful codec implementations. It was also very interesting to
talk with
&lt;a href=&quot;http://www.ie.u-ryukyu.ac.jp/~kono/index-e.html&quot;&gt;Shinji Kono&lt;/a&gt; about
&lt;a href=&quot;http://sourceforge.jp/projects/cbc/&quot;&gt;Continuation-based C (cBc)&lt;/a&gt;
(&lt;a href=&quot;http://www.ie.u-ryukyu.ac.jp/~kono/tmp/cf08-kono.tgz&quot;&gt;slides&lt;/a&gt; [HTML tarball]),
a C-like language capable of expressing continuations, non-local jumps, multiple function entry-points, and assorted other ways to shoot yourself in the foot. He suggested that it was designed for exactly the kind of thing I'm doing, and I'll be interested to try it
out. It is implemented in a modifed GCC 4.x as an RTL code generator, so should now be (fairly)
architecture-independent.
&lt;/p&gt;
&lt;p&gt;
Thanks to the organizers of Continuation Fest 2008 for putting together such a useful and interesting event. I look forward to implementing just some of the things I learned :-)
&lt;/p&gt;</description>
	<pubDate>Mon, 14 Apr 2008 18:10:56 +0000</pubDate>
	<dc:creator>Conrad Parker</dc:creator>
</item>
<item>
	<title>John Goerzen (CosmicRay): Backup Software</title>
	<guid isPermalink="false">http://changelog.complete.org/posts/706-guid.html</guid>
	<link>http://changelog.complete.org/posts/706-Backup-Software.html</link>
	<description>&lt;p&gt;I think most people reading my blog would agree that backups are extremely important.  So much important data is on computers these days: family photos, emails, financial records.  So I take backups seriously.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
A little while back, I purchased two identical 400GB external hard disks.  One is kept at home, and the other at a safe deposit box in a bank in a different town.  Every week or two, I swap drives, so that neither one ever becomes too dated.  This process is relatively inexpensive (safe deposit boxes big enough to hold the drive go for $25/year), and works well.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
I have been using &lt;a href=&quot;http://www.nongnu.org/rdiff-backup/&quot;&gt;rdiff-backup&lt;/a&gt; to make these backups for several years now.  (Since at least 2004, when I submitted a patch to make it record all metadata on MacOS X).  rdiff-backup is quite nice.  It is designed for storage to a hard disk.  It stores on the disk a current filesystem mirror along with some metadata files that include permissions information.  History is achieved by storing compressed rdiff (rsync) deltas going backwards in time.  So restoring &quot;most recent&quot; files is a simple copy plus application of metadata, and restoring older files means reversing history.  rdiff-backup does both automatically.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
This is a nice system and has served me well for quite some time.  But it has its drawbacks.  One is that you always have to have the current image, uncompressed, which uses up lots of space.  Another is that you can't encrypt these backups with something like gpg for storage on a potentially untrusted hosting service (say, rsync.net).  Also, when your backup disk fills up, it takes forever to figure out what to delete, since rdiff-backup --list-increment-sizes must stat tens of thousands of files.  So I went looking for alternatives.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
The author of rdiff-backup actually wrote one, called &lt;a href=&quot;http://duplicity.nongnu.org/&quot;&gt;duplicity&lt;/a&gt;.  Duplicity works by, essentially, storing a tarball full backup with its rdiff signature, then storing tarballs of rdiff deltas going forward in time.  The reason rdiff-backup must have the full mirror is that it must generate rdiff deltas &quot;backwards&quot;, which requires the full prior file available.  Duplicity works around this.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
However, the problem with duplicity is that if the full backup gets lost or corrupted, nothing newer than it can be restored.   You must make new full backups periodically so that you can remove the old history.  The other big problem with duplicity is that it doesn't grok hard links at all.  That makes it unsuitable for backing up /sbin, /bin, /usr, and my /home, in which I frequently use hard links for preparing CD images, linking DVCS branches, etc.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
So I went off searching out other projects and thinking about the problem myself.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
One potential solution is to simply store tarballs and rdiff deltas going forward.  That would require performing an entire full backup every day, which probably isn't a problem for me now, but I worry about the load that will place on my hard disks and the additional power it would consume to process all that data.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
So what other projects are out there?  Two caught my attention.  The first is &lt;a href=&quot;http://www.boxbackup.org/&quot;&gt;Box Backup&lt;/a&gt;.  It is similar in concept to rdiff-backup.  It has its own archive format, and otherwise operates on a similar principle to rdiff-backup.  It stores the most recent data in its archive format, compressed, along with the signatures for it.  Then it generates reverse deltas similar to rdiff-backup.  It supports encryption out of the box, too.  It sounded like a perfect solution.  Then I realized it &lt;a href=&quot;http://lists.warhead.org.uk/pipermail/boxbackup/2008-April/004338.html&quot;&gt;doesn't store hard links&lt;/a&gt;, device entries, etc., and has a design flaw that causes it to miss some changes to config files in /etc on Gentoo.  That's a real bummer, because it sounded so nice otherwise.  But I just can't trust my system to a program where I have to be careful not to use certain OS features because they won't be backed up right.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
The other interesting one is &lt;a href=&quot;http://dar.linux.free.fr/&quot;&gt;dar&lt;/a&gt;, the Disk ARchive tool, described by its author as the great grandson of tar -- and a pretty legitimate claim at that.  Traditionally, if you are going to back up a Unix box, you have to choose between two not-quite-perfect options.  You could use something like tar, which backs up all your permissions, special files, hard links, etc, but doesn't support random access.  So to extract just one file, tar will read through the 5GB before it in the archive.  Or you could use zip, which doesn't handle all the special stuff, but does support random access.  Over the years, many backup systems have improved upon this in various ways.  Bacula, for instance, is incredibly fast for tapes as it creates new tape &quot;files&quot; every so often and stores the precise tape location of each file in its database.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
But none seem quite as nice as dar for disk backups.  In addition to supporting all the special stuff out there, dar sports built-in compression and encryption.  Unlike tar, compression is applied per-file, and encryption is applied per 10K block, which is really slick.  This allows you to extract one file without having to decrypt and decompress the entire archive.  dar also maintains a catalog which permits random access, has built-in support for splitting archives across removable media like CD-Rs, has a nice incremental backup feature, and sports a host of tools for tweaking archives -- removing files from them, changing compression schemes, etc.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
But dar does not use binary deltas.  I thought this would be quite space-inefficient, so I decided I would put it to the test, against a real-world scenario that would probably be pretty much a worst case scenario for it and a best case for rdiff-backup.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
I track Debian sid and haven't updated my home box in quite some time.  I have over 1GB of .debs downloaded which represent updates.  Many of these updates are going to touch tons of files in /usr, though often making small changes, or even none at all.  Sounds like rdiff-backup heaven, right?
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
I ran rdiff-backup to a clean area before applying any updates, and used dar to create a full backup file of the same data.  Then I ran apt-get upgrade, and made incrementals with both rdiff-backup and dar.  Finally I ran apt-get dist-upgrade, and did the same thing.  So I have three backups with each system.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
Let's look at how rdiff-backup did first.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
According to rdiff-backup --list-increment-sizes, my /usr backup looks like this:
&lt;/p&gt;&lt;br /&gt;
&lt;pre&gt;
        Time                       Size        Cumulative size
-----------------------------------------------------------------------------
Sun Apr 13 18:37:56 2008         5.15 GB           5.15 GB   (current mirror)
Sun Apr 13 08:51:30 2008          405 MB           5.54 GB
Sun Apr 13 03:08:07 2008          471 MB           6.00 GB
&lt;/pre&gt;&lt;br /&gt;

&lt;p&gt;
So what we see here is that we're using 5.15GB for the mirror of the current state of /usr.  The delta between the old state of /usr and the state after apt-get upgrade was 471MB, and the delta representing dist-upgrade was 405MB, for total disk consumption of 6GB.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
But if I run du -s over the /usr storage area in rdiff, it says that 7.0GB was used.  du -s --apparent-size shows 6.1GB.  The difference is that all the tens of thousands of files each waste some space at the end of their blocks, and that adds up to an entire gigabyte.  rdiff-backup effectively consumed 7.0GB of space.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
Now, for dar:
&lt;/p&gt;&lt;br /&gt;
&lt;pre&gt;
-rw-r--r-- 1 root root 2.3G Apr 12 22:47 usr-l00.1.dar
-rw-r--r-- 1 root root 826M Apr 13 11:34 usr-l01.1.dar
-rw-r--r-- 1 root root 411M Apr 13 19:05 usr-l02.1.dar
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;
This was using bzip2 compression, and backed up the exact same files and data that rdiff-backup did.  The initial mirror was 2.3GB, much smaller than the 5.1GB that rdiff-backup consumes.  The apt-get upgrade differential was 826MB compared to the 471MB in rdiff-backup -- not really a surprise.  But the dist-upgrade differential -- still a pathologically bad case for dar, but less so -- was only 6MB larger than the 405MB rdiff-backup case.  And the total actual disk consumption of dar was only 3.5GB -- half the 7.0GB rdiff-backup claimed!
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
I still expect that, over an extended time, rdiff-backup could chip away at dar's lead...  or maybe not, if lots of small files change.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
But this was a completely unexpected result.  I am definitely going to give dar a closer look.
&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;
Also, before I started all this, I converted my external hard disk from ext3 to XFS because of ext3's terrible performance with rdiff-backup.
&lt;/p&gt;</description>
	<pubDate>Mon, 14 Apr 2008 00:35:00 +0000</pubDate>
	<dc:creator>nospam@example.com (John Goerzen)</dc:creator>
</item>
<item>
	<title>"FP Lunch": The shortest beta-normalizer</title>
	<guid isPermalink="false">http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=95</guid>
	<link>http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=95</link>
	<description>&lt;p&gt;I presented the shortest implementation of a normalizer for beta equality for untyped lambda calculus which is based on Normalisation by Evaluation. &lt;/p&gt;
&lt;p&gt;We start with the definition of lambda terms using de Bruijn levels:&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/6b2c3e05c957460fa08ae20bdfeb1753.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;data T = Var Int | Lam T | App T T deriving Show&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;data T = Var Int | Lam T | App T T deriving Show&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The reason for using de Bruijn levels is that weakening comes for free. The other side of the coin is that one has to reindex bound variables when substituting. However, this is not an issue because we never do that.&lt;/p&gt;
&lt;p&gt;We define values by solving a negative domain equation:&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/8025c23de1c08f7c265a350cb637a688.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;data V = Fun (V -&amp;gt; V)&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;data V = Fun (V -&amp;gt; V)&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It is easy to define application:&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/4c3e28203bdc418b9bb3483ee2e3f79d.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;app :: V -&amp;gt; V -&amp;gt; V&amp;#10;app (Fun f) v = f v&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;app :: V -&amp;gt; V -&amp;gt; V&amp;#10;app (Fun f) v = f v&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We can evaluate lambda terms in the Value domain using a list of values as the environment:&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/2e59405e96890b4c97292547d66c775d.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;eval :: T -&amp;gt; [V] -&amp;gt; V&amp;#10;eval (Var x) e = e !! x&amp;#10;eval (Lam t) e = Fun (\ v -&amp;gt; eval t (e++[v]))&amp;#10;eval (App t u) e = app (eval t e) (eval u e)&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;eval :: T -&amp;gt; [V] -&amp;gt; V&amp;#10;eval (Var x) e = e !! x&amp;#10;eval (Lam t) e = Fun (\ v -&amp;gt; eval t (e++[v]))&amp;#10;eval (App t u) e = app (eval t e) (eval u e)&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;All we have to do now is to invert evaluation, i.e. to define a function&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/5742dab51f5ea1b7a4673a4a7ef21e5e.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;quote :: V -&amp;gt; T&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;quote :: V -&amp;gt; T&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;To be able to do this we have first to extend values with variables. Then to be able to extend app, we also have to represent stuck applications, or neutral values:&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/232e1b86c01bdb2e1330d22055bbace9.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;data V = Fun (V -&amp;gt; V) | NVar Int | NApp V V&amp;#10;&amp;#10;app :: V -&amp;gt; V -&amp;gt; V&amp;#10;app (Fun f) v  = f v&amp;#10;app n v         = NApp n v&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;data V = Fun (V -&amp;gt; V) | NVar Int | NApp V V&amp;#10;&amp;#10;app :: V -&amp;gt; V -&amp;gt; V&amp;#10;app (Fun f) v  = f v&amp;#10;app n v         = NApp n v&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;br /&gt;
The code for eval remains unchanged. Now we can implement quote, though we need an extra parameter to keep track of the free variables:&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/4d9eaf056742b7d605ac1ad380045eee.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;quote :: Int -&amp;gt; V -&amp;gt; T&amp;#10;quote x (Fun f)        = Lam (quote (x+1) (f (NVar x)))&amp;#10;quote x (NVar y)     = Var y&amp;#10;quote x (NApp n v)  = App (quote x n) (quote x v)&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;quote :: Int -&amp;gt; V -&amp;gt; T&amp;#10;quote x (Fun f)        = Lam (quote (x+1) (f (NVar x)))&amp;#10;quote x (NVar y)     = Var y&amp;#10;quote x (NApp n v)  = App (quote x n) (quote x v)&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;br /&gt;
Now nf just evaluates and quotes the result:&lt;br /&gt;
&lt;img src=&quot;http://sneezy.cs.nott.ac.uk/fplunch/weblog/latexrender/pictures/36c4c25141994c1cf3af73da66418a49.png&quot; title=&quot;&amp;#10;\begin{code}&amp;#10;nf :: T -&amp;gt; T&amp;#10;nf t = quote 0 (eval t [])&amp;#10;\end{code}&amp;#10;&quot; alt=&quot;&amp;#10;\begin{code}&amp;#10;nf :: T -&amp;gt; T&amp;#10;nf t = quote 0 (eval t [])&amp;#10;\end{code}&amp;#10;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We discussed how to verify such a normalisation function - I suggested to use the partiality monad.&lt;/p&gt;</description>
	<pubDate>Sun, 13 Apr 2008 08:16:37 +0000</pubDate>
	<dc:creator>Thorsten</dc:creator>
</item>
<item>
	<title>Ulisses Costa: Lexical Analysis - Wikipedia</title>
	<guid isPermalink="false">http://caos.di.uminho.pt/~ulisses/blog/2008/04/13/lexical-analysis-wikipedia/</guid>
	<link>http://caos.di.uminho.pt/~ulisses/blog/2008/04/13/lexical-analysis-wikipedia/</link>
	<description>&lt;h2 id=&quot;58_intro_1&quot;&gt;Intro&lt;/h2&gt;
&lt;p&gt;This year I started to learn processing languages. I started by regular expressions and past few days I began to study the &lt;a href=&quot;http://flex.sourceforge.net/&quot;&gt;Flex&lt;/a&gt;, as with regular expressions we can&amp;#8217;t create text filters.&lt;br /&gt;
The first job I did was a kind of a dictionary. Getting a source of words and a faithful translation, add all the information in one document.&lt;/p&gt;
&lt;p&gt;The problem was finding a good document with many Portuguese words and their translations into English.&lt;/p&gt;
&lt;p&gt;With this post I want to teach what I learned from this work.&lt;/p&gt;
&lt;h2 id=&quot;58_wikipedia-xml-struct_1&quot;&gt;Wikipedia XML structure&lt;/h2&gt;
&lt;p&gt;I started by picking up the last dump of Wikipedia-PT and &amp;#8220;decipher&amp;#8221; the XML where it is stored. The structure is something like that:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;xml&quot;&gt;&lt;span&gt;&lt;span&gt;&amp;lt;page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    ...
&lt;span&gt;&lt;span&gt;&amp;lt;/page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;&amp;lt;page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    ...
&lt;span&gt;&lt;span&gt;&amp;lt;/page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And each &lt;strong&gt;page&lt;/strong&gt; tag, expanded, have this structure:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;xml&quot;&gt;&lt;span&gt;&lt;span&gt;&amp;lt;page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;TITLE&lt;span&gt;&lt;span&gt;&amp;lt;/title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;PAGE_ID_NUMBER&lt;span&gt;&lt;span&gt;&amp;lt;/id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;revision&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;ID_REVISION_NUMBER&lt;span&gt;&lt;span&gt;&amp;lt;/id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;timestamp&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;TIMESTAMP&lt;span&gt;&lt;span&gt;&amp;lt;/timestamp&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;contributor&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span&gt;&lt;span&gt;&amp;lt;username&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;USERNAME&lt;span&gt;&lt;span&gt;&amp;lt;/username&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span&gt;&lt;span&gt;&amp;lt;id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;ID_CONTRIBUTOR&lt;span&gt;&lt;span&gt;&amp;lt;/id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;/contributor&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;comment&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;COMMENT&lt;span&gt;&lt;span&gt;&amp;lt;/comment&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;text&lt;/span&gt; &lt;span&gt;xml:space&lt;/span&gt;=&lt;span&gt;&amp;quot;preserve&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;WIKIPEDIA_ENTRY&lt;span&gt;&lt;span&gt;&amp;lt;/text&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;/revision&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span&gt;&lt;span&gt;&amp;lt;/page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So, here we have the variables: TITLE, PAGE_ID_NUMBER, ID_REVISION_NUMBER, TIMESTAMP, USERNAME, ID_CONTRIBUTOR, COMMENT and WIKIPEDIA_ENTRY.&lt;/p&gt;
&lt;p&gt;TITLE is the Portuguese word, because the Wikipedia I&amp;#8217;ve downloaded is in Portuguese.&lt;br /&gt;
But so far, no English word.&lt;/p&gt;
&lt;p&gt;Lets expand WIKIPEDIA_ENTRY:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;xml&quot;&gt;&lt;span&gt;&lt;span&gt;&amp;lt;text&lt;/span&gt; &lt;span&gt;xml:space&lt;/span&gt;=&lt;span&gt;&amp;quot;preserve&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    ...
    [[categoria:CATEGORY]]
    ...
    [[en:ENGLISH]]
    ...
&lt;span&gt;&lt;span&gt;&amp;lt;/text&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here we have the ENGLISH variable that is the corresponding word in English to TITLE. I also want the CATEGORY variable that indicates from what category this entry belong.&lt;/p&gt;
&lt;p&gt;As some entries in the Wikipedia have multiple categories lines I am also interested in keep them all.&lt;br /&gt;
I want that the output of my program became something like that:&lt;/p&gt;
&lt;pre&gt;
PT - TITLE1
EN - ENGLISH1
Categoria - CATEGORY11
            CATEGORY12
            ...
            CATEGORY1j
...
PT - TITLEi
EN - ENGLISHi
Categoria - CATEGORYi1
            CATEGORYi2
            ...
            CATEGORYij
...&lt;/pre&gt;
&lt;p&gt;Some entries in the Portuguese Wikipedia do not have the English correspondent version so I will not want those entries.&lt;/p&gt;
&lt;h2 id=&quot;58_lexing_1&quot;&gt;&lt;em&gt;Lexing&lt;/em&gt;&lt;/h2&gt;
&lt;p&gt;A Lex file have this aspect:&lt;/p&gt;
&lt;pre&gt;
definitions
%%
rules
%%
user code
&lt;/pre&gt;
&lt;p&gt;Let&amp;#8217;s focus in &lt;strong&gt;rules&lt;/strong&gt; part:&lt;/p&gt;
&lt;p&gt;Rules have the following structure;&lt;/p&gt;
&lt;pre&gt;
%%
REGEX    code
REGEX    code
%%
&lt;/pre&gt;
&lt;p&gt;I know Regular Expressions (REGEX) now, so let&amp;#8217;s start to build that thing!&lt;/p&gt;
&lt;p&gt;I got me to realize that the part of the TITLE may have not only the entries name, also has the Wikipedia contributors pages, among other things that do not interest me to save.&lt;br /&gt;
I start to do a list of all those pages:&lt;br /&gt;
{Wikipedia,Usuário,Discussão,Ajuda,Anexo,MediaWiki,Categoria}&lt;/p&gt;
&lt;p&gt;So, I have to, somehow, throw away all the pages with the following structure:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;xml&quot;&gt;  &lt;span&gt;&lt;span&gt;&amp;lt;page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;[&amp;quot;Wikipedia&amp;quot;&amp;quot;Usuario&amp;quot;&amp;quot;Discussao&amp;quot;&amp;quot;Ajuda&amp;quot;&amp;quot;Anexo&amp;quot;&amp;quot;MediaWiki&amp;quot;&amp;quot;Categoria&amp;quot;]:TITLE&lt;span&gt;&lt;span&gt;&amp;lt;/title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;ID_PAGE&lt;span&gt;&lt;span&gt;&amp;lt;/id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;revision&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;ID_REVISION&lt;span&gt;&lt;span&gt;&amp;lt;/id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;timestamp&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;TIMESTAMP&lt;span&gt;&lt;span&gt;&amp;lt;/timestamp&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;contributor&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span&gt;&lt;span&gt;&amp;lt;username&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;USERNAME&lt;span&gt;&lt;span&gt;&amp;lt;/username&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span&gt;&lt;span&gt;&amp;lt;id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;ID_CONTRIBUTOR&lt;span&gt;&lt;span&gt;&amp;lt;/id&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;/contributor&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;comment&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;COMMENT&lt;span&gt;&lt;span&gt;&amp;lt;/comment&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;span&gt;&amp;lt;text&lt;/span&gt; &lt;span&gt;xml:space&lt;/span&gt;=&lt;span&gt;&amp;quot;preserve&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;ENTRY&lt;span&gt;&lt;span&gt;&amp;lt;/text&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;/revision&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span&gt;&lt;span&gt;&amp;lt;/page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After a dozen of lines I start to understand that I have to some how &amp;#8220;explain&amp;#8221; Lex the structure of the Wikipedia XML file. That way will be easier.&lt;/p&gt;
&lt;p&gt;I start to read the &lt;a href=&quot;http://flex.sourceforge.net/manual/&quot;&gt;Flex manual&lt;/a&gt; and I find the &lt;a href=&quot;http://flex.sourceforge.net/manual/Start-Conditions.html#Start-Conditions&quot;&gt;Start Conditions&lt;/a&gt;, a very clever way to treat a block of information.&lt;/p&gt;
&lt;p&gt;Languages like C, HTML and XML are structured by blocks, so Start Conditions may be the way to easily get the information from those.&lt;/p&gt;
&lt;h2 id=&quot;58_start-conditions_1&quot;&gt;Start Conditions&lt;/h2&gt;
&lt;p&gt;If you have a block of code that have this aspect:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;xml&quot;&gt;&lt;span&gt;&lt;span&gt;&amp;lt;title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;TITLE&lt;span&gt;&lt;span&gt;&amp;lt;/title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Our block start with &amp;#8220;&amp;#8221; string.&lt;/p&gt;
&lt;p&gt;So in Lex, we must use Start Conditions and produce the following code:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;c&quot;&gt;%x title_sc
anything .|&lt;span&gt;&amp;#91;&lt;/span&gt;\n\t\r&lt;span&gt;&amp;#93;&lt;/span&gt;
%%
&lt;span&gt;&amp;quot;&amp;lt;title&amp;gt;&amp;quot;&lt;/span&gt;            BEGIN&lt;span&gt;&amp;#40;&lt;/span&gt;title_sc&lt;span&gt;&amp;#41;&lt;/span&gt;;
&amp;lt;title_sc&amp;gt;&lt;span&gt;&amp;#91;&lt;/span&gt;^&amp;gt;&lt;span&gt;&amp;#93;&lt;/span&gt;+      &lt;span&gt;&amp;#123;&lt;/span&gt;&lt;span&gt;printf&lt;/span&gt;&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;quot;title=%s&lt;span&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;,yytext&lt;span&gt;&amp;#41;&lt;/span&gt;;&lt;span&gt;&amp;#125;&lt;/span&gt;
&amp;lt;title_sc&amp;gt;&lt;span&gt;&amp;quot;&amp;lt;/title&amp;gt;&amp;quot;&lt;/span&gt; BEGIN&lt;span&gt;&amp;#40;&lt;/span&gt;INITIAL&lt;span&gt;&amp;#41;&lt;/span&gt;;
&lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;           &lt;span&gt;&amp;#123;&lt;/span&gt;;&lt;span&gt;&amp;#125;&lt;/span&gt; &lt;span&gt;/* do nothing*/&lt;/span&gt;
%%
main&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt; &lt;span&gt;&amp;#123;&lt;/span&gt;
        yylex&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
&lt;span&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;%x title_sc&lt;/code&gt; declaration is to declare a state exclusive, that means; while we are inside &lt;code&gt;code_sc&lt;/code&gt; Flex won&amp;#8217;t look rules outside of that, until &lt;code&gt;BEGIN(INITAIL)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In &lt;strong&gt;definitions&lt;/strong&gt; part we can declare variables &lt;code&gt;anything .|[\n\t\r]&lt;/code&gt; to use in &lt;strong&gt;rules&lt;/strong&gt; part as &lt;code&gt;{anything}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;BEGIN(title_sc)&lt;/code&gt; statement makes Lex jump to the first line of  rule and it start to match the rules that finds there.&lt;/p&gt;
&lt;p&gt;We can rewrite the above code like that:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;c&quot;&gt;%x title_sc
anything .|&lt;span&gt;&amp;#91;&lt;/span&gt;\n\t\r&lt;span&gt;&amp;#93;&lt;/span&gt;
%%
&lt;span&gt;&amp;quot;&amp;lt;title&amp;gt;&amp;quot;&lt;/span&gt;            BEGIN&lt;span&gt;&amp;#40;&lt;/span&gt;title_sc&lt;span&gt;&amp;#41;&lt;/span&gt;;
&amp;lt;title_sc&amp;gt;&lt;span&gt;&amp;#123;&lt;/span&gt;
        &lt;span&gt;&amp;#91;&lt;/span&gt;^&amp;gt;&lt;span&gt;&amp;#93;&lt;/span&gt;+        &lt;span&gt;&amp;#123;&lt;/span&gt;&lt;span&gt;printf&lt;/span&gt;&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;quot;title=%s&lt;span&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;,yytext&lt;span&gt;&amp;#41;&lt;/span&gt;;&lt;span&gt;&amp;#125;&lt;/span&gt;
        &lt;span&gt;&amp;quot;&amp;lt;/title&amp;gt;&amp;quot;&lt;/span&gt;   BEGIN&lt;span&gt;&amp;#40;&lt;/span&gt;INITIAL&lt;span&gt;&amp;#41;&lt;/span&gt;;
&lt;span&gt;&amp;#125;&lt;/span&gt;
&lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;           &lt;span&gt;&amp;#123;&lt;/span&gt;;&lt;span&gt;&amp;#125;&lt;/span&gt; &lt;span&gt;/* do nothing*/&lt;/span&gt;
%%
main&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt; &lt;span&gt;&amp;#123;&lt;/span&gt;
        yylex&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
&lt;span&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When Lex find &lt;code&gt;BEGIN(INITIAL)&lt;/code&gt; statement it jumps to the first &lt;code&gt;BEGIN(XXX)&lt;/code&gt;, so we can never be able to use block&amp;#8217;s inside other block&amp;#8217;s (like XML does).&lt;/p&gt;
&lt;p&gt;Of course that&amp;#8217;s not true.&lt;/p&gt;
&lt;h2 id=&quot;58_start-conditions-ins_1&quot;&gt;Start Conditions inside Start Conditions&lt;/h2&gt;
&lt;p&gt;Lex have a brilliant way to deal with that. It uses Stack&amp;#8217;s to store the state were we are!&lt;/p&gt;
&lt;p&gt;The idea is something like that, imagine a mathematical expression:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://caos.di.uminho.pt/~ulisses/blog/wp-content/latex/87e/87e6b04da406d2885e69188f49514a2b-FFFFFF000000.png&quot; alt=&quot;(1+2)-(3*(4/5))&quot; title=&quot;(1+2)-(3*(4/5))&quot; class=&quot;latex&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I can say:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2 or [1,2]&lt;/li&gt;
&lt;li&gt;3 or [2,1]&lt;/li&gt;
&lt;li&gt;5 or [2,2,2]&lt;/li&gt;
&lt;li&gt;and so on&amp;#8230;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;#8217;s all about keeping the path, our actual position in the tree.&lt;/p&gt;
&lt;p&gt;So, now we replace the &lt;code&gt;BEGIN(state)&lt;/code&gt; to &lt;code&gt;yy_push_state(state)&lt;/code&gt;, and to go to the previously block I say &lt;code&gt;yy_pop_state()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;With that now I can read structures like that one:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;xml&quot;&gt;  &lt;span&gt;&lt;span&gt;&amp;lt;page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span&gt;&lt;span&gt;&amp;lt;title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;TITLE&lt;span&gt;&lt;span&gt;&amp;lt;/title&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      ...
      &lt;span&gt;&lt;span&gt;&amp;lt;text&lt;/span&gt; &lt;span&gt;xml:space&lt;/span&gt;=&lt;span&gt;&amp;quot;preserve&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
        ...
        [[Categoria:CATEGORY]]
        ...
        [[en:ENGLISH]]
        ...
      &lt;span&gt;&lt;span&gt;&amp;lt;/text&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span&gt;&lt;span&gt;&amp;lt;/page&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And to do so, I write that Lex code:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;c&quot;&gt;%x PAGE TITLE TEXT CATEGORIA EN
%option stack
anything .|&lt;span&gt;&amp;#91;&lt;/span&gt;\n\t\r&lt;span&gt;&amp;#93;&lt;/span&gt;
notPage &lt;span&gt;&amp;#91;&lt;/span&gt;&lt;span&gt;&amp;quot;Wikipedia&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;quot;Usuário&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;quot;Discussão&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;quot;Ajuda&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;quot;Anexo&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;quot;MediaWiki&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;quot;Categoria&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;#93;&lt;/span&gt;
%%
&lt;span&gt;&amp;quot;&amp;lt;page&amp;gt;&amp;quot;&lt;/span&gt;                        yy_push_state&lt;span&gt;&amp;#40;&lt;/span&gt;PAGE&lt;span&gt;&amp;#41;&lt;/span&gt;;
&amp;lt;PAGE&amp;gt;&lt;span&gt;&amp;#123;&lt;/span&gt;
        &lt;span&gt;&amp;quot;&amp;lt;title&amp;gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;#123;&lt;/span&gt;notPagina&lt;span&gt;&amp;#125;&lt;/span&gt;    yy_pop_state&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;; &lt;span&gt;// not a valid page&lt;/span&gt;
        &lt;span&gt;&amp;quot;&amp;lt;title&amp;gt;&amp;quot;&lt;/span&gt;               yy_push_state&lt;span&gt;&amp;#40;&lt;/span&gt;TITLE&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;quot;&amp;lt;text&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;#91;&lt;/span&gt;^&amp;gt;&lt;span&gt;&amp;#93;&lt;/span&gt;+&lt;span&gt;&amp;quot;&amp;gt;&amp;quot;&lt;/span&gt;         yy_push_state&lt;span&gt;&amp;#40;&lt;/span&gt;TEXT&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;quot;&amp;lt;/page&amp;gt;&amp;quot;&lt;/span&gt;               yy_pop_state&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;              &lt;span&gt;/* do nothing */&lt;/span&gt;
&lt;span&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;lt;TEXT&amp;gt;&lt;span&gt;&amp;#123;&lt;/span&gt;
        &lt;span&gt;&amp;quot;[[&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;#91;&lt;/span&gt;cC&lt;span&gt;&amp;#93;&lt;/span&gt;&lt;span&gt;&amp;quot;ategoria:&amp;quot;&lt;/span&gt;     yy_push_state&lt;span&gt;&amp;#40;&lt;/span&gt;CATEGORIA&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;quot;[[en:&amp;quot;&lt;/span&gt;                 yy_push_state&lt;span&gt;&amp;#40;&lt;/span&gt;EN&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;quot;&amp;lt;/text&amp;gt;&amp;quot;&lt;/span&gt;               yy_pop_state&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;              &lt;span&gt;/* do nothing */&lt;/span&gt;
&lt;span&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;lt;TITLE&amp;gt;&lt;span&gt;&amp;#123;&lt;/span&gt;
        &lt;span&gt;&amp;#91;&lt;/span&gt;^&amp;lt;&lt;span&gt;&amp;#93;&lt;/span&gt;+                   &lt;span&gt;&amp;#123;&lt;/span&gt;
                                        i=&lt;span&gt;0&lt;/span&gt;;
                                        imprime&lt;span&gt;&amp;#40;&lt;/span&gt;cat, pt, en&lt;span&gt;&amp;#41;&lt;/span&gt;;
                                        limpa&lt;span&gt;&amp;#40;&lt;/span&gt;cat&lt;span&gt;&amp;#41;&lt;/span&gt;;
                                        pt=&lt;span&gt;NULL&lt;/span&gt;; en=&lt;span&gt;NULL&lt;/span&gt;;
                                        pt=strdup&lt;span&gt;&amp;#40;&lt;/span&gt;yytext&lt;span&gt;&amp;#41;&lt;/span&gt;;
                                &lt;span&gt;&amp;#125;&lt;/span&gt;
        &lt;span&gt;&amp;quot;&amp;lt;/title&amp;gt;&amp;quot;&lt;/span&gt;              yy_pop_state&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;              &lt;span&gt;/* do nothing */&lt;/span&gt;
&lt;span&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;lt;EN&amp;gt;&lt;span&gt;&amp;#123;&lt;/span&gt;
        &lt;span&gt;&amp;#91;&lt;/span&gt;^\&lt;span&gt;&amp;#93;&lt;/span&gt;&lt;span&gt;&amp;#93;&lt;/span&gt;+                  en=strdup&lt;span&gt;&amp;#40;&lt;/span&gt;yytext&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;#91;&lt;/span&gt;\&lt;span&gt;&amp;#93;&lt;/span&gt;&lt;span&gt;&amp;#93;&lt;/span&gt;+                   yy_pop_state&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;quot;]&amp;quot;&lt;/span&gt;\n&lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;         &lt;span&gt;/* do nothing */&lt;/span&gt;
&lt;span&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;lt;CATEGORIA&amp;gt;&lt;span&gt;&amp;#123;&lt;/span&gt;
        &lt;span&gt;&amp;#91;&lt;/span&gt; \&lt;span&gt;#\!\*\|]+            yy_pop_state();&lt;/span&gt;
        &lt;span&gt;&amp;#91;&lt;/span&gt;^\&lt;span&gt;&amp;#93;&lt;/span&gt;\|\n&lt;span&gt;&amp;#93;&lt;/span&gt;+              &lt;span&gt;&amp;#123;&lt;/span&gt;
                                        cat&lt;span&gt;&amp;#91;&lt;/span&gt;i&lt;span&gt;&amp;#93;&lt;/span&gt;=strdup&lt;span&gt;&amp;#40;&lt;/span&gt;yytext&lt;span&gt;&amp;#41;&lt;/span&gt;;
                                        i++;
                                &lt;span&gt;&amp;#125;&lt;/span&gt;
        &lt;span&gt;&amp;#91;&lt;/span&gt;\&lt;span&gt;&amp;#93;&lt;/span&gt;&lt;span&gt;&amp;#93;&lt;/span&gt;+                   yy_pop_state&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;&amp;quot;]&amp;quot;&lt;/span&gt;\n&lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;         &lt;span&gt;/* do nothing */&lt;/span&gt;
&lt;span&gt;&amp;#125;&lt;/span&gt;
&lt;span&gt;&amp;#123;&lt;/span&gt;anything&lt;span&gt;&amp;#125;&lt;/span&gt;                      &lt;span&gt;/* do nothing */&lt;/span&gt;
%%
&lt;span&gt;int&lt;/span&gt; main&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt; &lt;span&gt;&amp;#123;&lt;/span&gt;
        yylex&lt;span&gt;&amp;#40;&lt;/span&gt;&lt;span&gt;&amp;#41;&lt;/span&gt;;
        &lt;span&gt;return&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;;
&lt;span&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As you can see we are all the time matching a rule that makes lex jump to another state until one terminal rule (in this case variables affectations) or until pop.&lt;/p&gt;
&lt;p&gt;To see all the code &lt;a href=&quot;http://caos.di.uminho.pt/~ulisses/code/pl/trab1/trab.lex&quot;&gt;go here&lt;/a&gt;(.lex).&lt;/p&gt;
&lt;p&gt;If you understand Portuguese and feel interested in more information you can &lt;a href=&quot;http://caos.di.uminho.pt/~ulisses/code/pl/trab1/rel/online/index.html&quot;&gt;go here&lt;/a&gt;(.html).&lt;/p&gt;
&lt;h3 id=&quot;58_references_1&quot;&gt;References&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://flex.sourceforge.net/&quot;&gt;flex: The Fast Lexical Analyzer&lt;/a&gt;&lt;/p&gt;
 &lt;span class=&quot;post2pdf_span&quot;&gt;&lt;a href=&quot;http://caos.di.uminho.pt/~ulisses/blog/wp-content/plugins/post2pdf/generate.php?post=58&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://caos.di.uminho.pt/~ulisses/blog/wp-content/plugins/post2pdf/icon/pdf.png&quot; width=&quot;16px&quot; height=&quot;16px&quot; /&gt;convert this post to pdf.&lt;/a&gt;&lt;/span&gt;</description>
	<pubDate>Sun, 13 Apr 2008 06:50:50 +0000</pubDate>
	<dc:creator>ulisses</dc:creator>
</item>
<item>
	<title>David R. MacIver: Blog move</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-2789077809400086800.post-2114636340936909669</guid>
	<link>http://unenterprise.blogspot.com/2008/04/blog-move.html</link>
	<description>&lt;p&gt;Well, I've been meaning to set up a site of my own for ages. I finally got around to it. I can now be found at &lt;a href=&quot;http://www.drmaciver.com/&quot;&gt;http://www.drmaciver.com&lt;/a&gt;/ &lt;/p&gt;

&lt;p&gt;This blog will be moving to the &quot;programming&quot; category there. I'll update the various aggregator sites that have it on to point there instead.&lt;/p&gt;</description>
	<pubDate>Sun, 13 Apr 2008 06:50:09 +0000</pubDate>
	<dc:creator>David R. MacIver</dc:creator>
</item>
<item>
	<title>Nick Mudge: A New Operating System</title>
	<guid isPermalink="false">http://nickmudge.info?post=91</guid>
	<link>http://nickmudge.info?post=91</link>
	<description>&lt;p&gt;
I've decided to attempt to write an operating system.
&lt;/p&gt;
&lt;p&gt;
Basically I want to be able to understand a whole system as much as I can and I want to make it as easy as possible for others to understand it as well. This is the main reason I want to write an operating system.
&lt;/p&gt;
&lt;p&gt;
The reason I'm not just studying an existing operating system like &lt;a href=&quot;http://www.kernel.org/&quot;&gt;Linux&lt;/a&gt; or &lt;a href=&quot;http://www.minix3.org/&quot;&gt;Minix&lt;/a&gt; or &lt;a href=&quot;http://mikeos.berlios.de/&quot;&gt;MikeOS&lt;/a&gt; is because I think I will understand a system better if I write it myself and it seems more fun to me. I am of course studying those operating systems to learn to write my own.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Goals and Guides&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The design of the system is pretty loose so far but I do have some general guides and goals for the system.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt; 
Designed to explicitly take advantage of 64 bit processors.
&lt;/li&gt;
&lt;li&gt;
Designed to explicitly take advantage of multi-core or multi-cpu processors.
&lt;/li&gt;
&lt;li&gt;
Designed to take advantage of and provide virtualization i.e. operating system virtualization etc.
&lt;/li&gt;
&lt;li&gt;
It's a server operating system. Not designed to be a desktop operating system or anything else.
&lt;/li&gt;
&lt;li&gt;
It needs to be designed so that the system can be understood as easily as possible. It must be simple. The code base must be as small as possible.
&lt;/li&gt;
&lt;li&gt;
It must be good.
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
I'm not sure if the kernel will be a microkernel or monolithic or something else. 
&lt;/p&gt;</description>
	<pubDate>Sun, 13 Apr 2008 00:00:00 +0000</pubDate>
</item>
<item>
	<title>Dan Piponi (sigfpe): Negative Probabilities</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-11295132.post-5498552306554187806</guid>
	<link>http://sigfpe.blogspot.com/2008/04/negative-probabilities.html</link>
	<description>I'm always interested in new ways to present the ideas of quantum mechanics to a wider audience. Unfortunately the conventional description of quantum mechanics requires knowledge of complex numbers and vector spaces making it difficult to avoid falling back on misleading analogies and metaphors. But there's another approach to quantum mechanics, due to Feynman, that I have never seen mentioned in the popular science literature. It assumes only basic knowledge of &lt;a href=&quot;http://simple.wikipedia.org/wiki/Probability&quot;&gt;probability theory&lt;/a&gt; and &lt;a href=&quot;http://simple.wikipedia.org/wiki/Negative_number&quot;&gt;negative numbers&lt;/a&gt; to get a foot on the ladder.&lt;br /&gt;&lt;br /&gt;We start with tweaking probability theory a bit. One of the axioms of probability theory says that all probabilities must lie in the range zero to one. However, we could imagine relaxing this rule even though on the face of it it seems meaningless. For example, suppose we have a coin that has a 3/2 chance of landing heads and a -1/2 chance of landing tails. We can still reason that the chance of getting two heads in a row is 3/2&amp;times;3/2=9/4 by the usual multiplication rule. But obviously no situation like this could ever arise in the real world because after tossing such a coin 10 times we'd expect to see -5 tails on average.&lt;br /&gt;&lt;br /&gt;But what if we could contrive a system with some kind of internal state governed by negative probabilities even though we couldn't observe it directly? So consider this case: a machine produces boxes with (ordererd) pairs of bits in them, each bit viewable through its own door. Let's suppose the probability of each possible combination of two bits is given by the following table:&lt;br /&gt;&lt;table&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;First bit&lt;/td&gt;&lt;td&gt;Second bit&lt;/td&gt;&lt;td&gt;Probability&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;-1/2&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1/2&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;1/2&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1/2&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;Obviously if we were able to look through both doors we'd end up with the meaningless prediction that we'd expect to see 00 a negative number of times. But suppose that things are arranged so that we can only look through one door. Maybe the boxes self-destruct if one or other door is opened but you still get enough time to see what was behind the door. Now what happens?&lt;br /&gt;&lt;br /&gt;If you look through the first door the probability of seeing 1 is P(10)+P(11)=1. We get the same result if we look through the second door. We only get probabilities in the range zero to one. As long as we're restricted to one door we get meaningful results.&lt;br /&gt;&lt;br /&gt;If we were to perform this experiment repeatedly with different runs of the machine, each time picking a random door to look through, we'd eventually become very confident that every box contained 11. After all, if we freely choose which door to look through, and we always see 1, there's no place 0's could be 'hiding'.&lt;br /&gt;&lt;br /&gt;But now suppose a new feature is added to the box that allows us to compare the two bits to see if they are equal. It reveals nothing about what the bits are, just their state of equality. And of course, after telling us, it self-destructs. We now find that the probability of the two bits being different is P(01)+P(10)=1. So if we randomly chose one of the three possible observations each time the machine produced the box we'd quickly run into the strange situation that the two bits both appear to be 1, and yet are different. But note that although the situation is weird, it's not meaningless. As long as we never get to see both bits at the same time we never directly observe a paradox. If we met such boxes in the real world we'd be forced to conclude that maybe the boxes knew which bit you were going to look at and changed value as a result, or that maybe you didn't have the free will to choose door that you thought you had, or maybe, even more radically, you'd conclude that the bits generated by the machine were described by negative probabilities.&lt;br /&gt;&lt;br /&gt;That's all very well, but obviously the world doesn't really work like this and we never see boxes like this. Except that actually it does! The &lt;a href=&quot;http://en.wikipedia.org/wiki/EPR_Paradox&quot;&gt;EPR&lt;/a&gt; experiment has many similarities to the scenario I described above. The numbers aren't quite the same, and we're not talking about bits in boxes, but we do end up with a scenario involving observations of bits that simply don't add up. If we do try to explain what's going on using probability theory, we either conclude there's something weird about our assumptions of locality or causality or we end up assigning negative probabilities to the internal states of our systems. In fact, you can read the details in an article by &lt;a href=&quot;http://www.drchinese.com/David/Bell_Theorem_Negative_Probabilities.htm&quot;&gt;David Schneider&lt;/a&gt;. Being forced to conclude that we have negative probabilities in a physical system is usually taken as a sign that we have a contradiction. In the case of &lt;a href=&quot;http://en.wikipedia.org/wiki/Bell's_theorem&quot;&gt;Bell's theorem&lt;/a&gt; it shows that we can't interpret what we see in terms of probability theory and hence that the weirdness of quantum mechanics can't be explained in terms of some hidden random variable that we can't see. QM simply doesn't obey the rules you'd expect of hidden variables we can't see.&lt;br /&gt;&lt;br /&gt;But in a paper called &lt;a href=&quot;http://en.wikipedia.org/wiki/Negative_probability&quot;&gt;Negative Probability&lt;/a&gt;, Feynman tried taking the idea of negative probabilities seriously. He showed that you could reformulate quantum mechanics completely in terms of them so that you no longer needed to think in terms of the complex number valued 'amplitudes' that physicists normally use. This means the above isn't just an analogy, it's actually a formal system within which you can do QM, although I haven't touched on the bit that refers to the dynamics of quantum systems. So if you can get your head around the ideas I've talked about above you're well on your way to understanding some reasons why quantum mechanics seems so paradoxical.&lt;br /&gt;&lt;br /&gt;At this point you may be wondering how nature contrives to hide these negative probabilities from direct observation. Her trick is that making one kind of observation disturbs up the state of what you've observed so that you can't make the other kind of observation on a pristine state. You have to pick one kind of observation or the other. Electrons and photons really are a lot like the boxes I just described.&lt;br /&gt;&lt;br /&gt;So why don't physicists use this formulation? Despite the fact that negative numbers seem simpler to most people than imaginary numbers, the negative number formulation of QM is much more complicated. What's more, because it makes exactly the same predictions as regular QM there's no compelling reason to switch to it. And anyway, it's not as if directly observing negative probabilities is any more intuitive or meaningful than imaginary ones. Once you've introduced negative ones, you might as well go all the way!&lt;br /&gt;&lt;br /&gt;This all ties in with what I said a &lt;a href=&quot;http://sigfpe.blogspot.com/2006/05/quantum-mechanics-and-probability.html&quot;&gt;while back&lt;/a&gt;. The important thing about QM is that having two ways to do something can make it &lt;em&gt;less&lt;/em&gt; likely to happen, not more.&lt;br /&gt;&lt;br /&gt;For a different perspective &lt;a href=&quot;http://www.lns.cornell.edu/spr/2002-03/msg0040195.html&quot;&gt;this&lt;/a&gt; is an interesting comment.&lt;br /&gt;&lt;br /&gt;Footnote: We can embed QM in negative probability theory. But can we do the converse? Can every negative probability distribution be physically realised in a quantum system? I've a hunch the answer is obvious but I'm too stupid to see it.</description>
	<pubDate>Sat, 12 Apr 2008 17:02:00 +0000</pubDate>
	<dc:creator>sigfpe</dc:creator>
</item>
<item>
	<title>Shin-Cheng Mu: Terminating Unfolds (2)</title>
	<guid isPermalink="false">http://www.iis.sinica.edu.tw/~scm/?p=49</guid>
	<link>http://www.iis.sinica.edu.tw/~scm/2008/terminating-unfolds-2/</link>
	<description>&lt;p&gt;After seeing &lt;a href=&quot;http://www.iis.sinica.edu.tw/~scm/2008/terminating-unfolds-1/&quot;&gt;our code&lt;/a&gt;, &lt;a href=&quot;http://www.cs.nott.ac.uk/~nad/&quot;&gt;Nils Anders Danielsson&lt;/a&gt; suggested two improvements. Firstly, to wrap the bound in the seed. The terminating &lt;code&gt;unfoldr↓&lt;/code&gt; would thus have a simpler type as well as a simpler implemenation:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;unfoldr↓ : {a : Set}(b : ℕ -&gt; Set){n : ℕ} -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(f : forall {i} -&gt; b (suc i) -&gt; ⊤ ⊎ (a × b i)) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b n -&gt; [ a ]&lt;br /&gt;
unfoldr↓ b {zero} f y = []&lt;br /&gt;
unfoldr↓ b {suc i} f y with f y&lt;br /&gt;
... | inj₁ _ = []&lt;br /&gt;
... | inj₂ (x , y') = unfoldr↓ b {i} f y'&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The definition passes the termination check, apparently, because &lt;code&gt;unfoldr↓&lt;/code&gt; is defined inductively on &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To generate a descending a list, one may invent a datatype &lt;code&gt;Wrap&lt;/code&gt; that wraps the seed, whose bound is simply the seed itself:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;data Wrap : ℕ -&gt; Set where&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;W : (n : ℕ) -&gt; Wrap n&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The list may then be generated by an unfold:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;dec : forall {i} -&gt; Wrap (suc i) -&gt; ⊤ ⊎ (ℕ × Wrap i)&lt;br /&gt;
dec {i} (W .(suc i)) = inj₂ (i , W i)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;down↓ : ℕ -&gt; [ ℕ ]&lt;br /&gt;
down↓ n = unfoldr↓ Wrap dec (W n)&lt;br /&gt;
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Of course, this would defeat my original goal of reusing the non-dependently typed &lt;code&gt;dec&lt;/code&gt;, which is probably a bad idea anyway.&lt;/p&gt;
&lt;p&gt;To show that the bound need not be exact, let&amp;#8217;s try to generate a descending list whose elements are decremented by 2 in each step. We may use this slightly generalised wrapper:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;data Wrap2 : ℕ -&gt; Set where&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;W2 : (x : ℕ) -&gt; (bnd : ℕ) -&gt; x ≤ bnd -&gt; Wrap2 bnd&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;and a function &lt;code&gt;dec2&lt;/code&gt; that decrements a &lt;code&gt;suc i&lt;/code&gt;-bounded seed by 2 but showing that the new seed is bounded by &lt;code&gt;i&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;dec2 : forall {i} -&gt; Wrap2 (suc i) -&gt; ⊤ ⊎ (ℕ × WAlt i)&lt;br /&gt;
dec2 {i} (W2 0 .(1 + i) _) = inj₁ tt&lt;br /&gt;
dec2 {i} (W2 1 .(1 + i) _) = inj₁ tt&lt;br /&gt;
dec2 {i} (W2 (suc (suc n)) .(1 + i) 2+n≤1+i) =&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; inj₂ (n , W2 n i (suc-≤-weaken-l (≤-pred 2+n≤1+i)))&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The list can then be unfolded by:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;down↓2 : ℕ -&gt; [ ℕ ]&lt;br /&gt;
down↓2 n = unfoldr↓ Wrap2 dec2 (W2 n n ≤-refl)&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;where &lt;code&gt;suc-≤-weaken-l&lt;/code&gt; is a proof of &lt;code&gt;forall {m n} -&gt; suc m ≤ n -&gt; m ≤ n&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Unfolding a Tree&lt;/h3&gt;
&lt;p&gt;It is an easy exercise to come up with a tree version of the unfold above:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;unfoldT↓ : {a : Set}(b : ℕ -&gt; Set){n : ℕ} -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(f : forall {i} -&gt; b (suc i) -&gt; a ⊎ (b i × b i)) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;B n -&gt; Tree a&lt;br /&gt;
unfoldT↓ b {0} f y = Nul&lt;br /&gt;
unfoldT↓ b {suc i} f y with f y&lt;br /&gt;
... | inj₁ x = Tip x&lt;br /&gt;
... | inj₂ (y₁ , y₂) =&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Bin (unfoldT↓ b {i} f y₁) (unfoldT↓ b {i} f y₂)&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To deal with the second task of building a roughly balanced binary tree, one may try this wrapper:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;data Split (a : Set): ℕ -&gt; Set where&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Sp : (xs : [ a ]) -&gt; (bnd : ℕ) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;length xs  bnd -&gt; Split a bnd&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;and try to code up a generator function &lt;code&gt;split↓&lt;/code&gt; having this type:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;split↓ : forall {a i} -&gt; Split a (suc i) -&gt;  a ⊎ (Split a i × Split a i)&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The function &lt;code&gt;split↓&lt;/code&gt; I eventually come up with, however, is much more complicated than I had wished. Even worse, it is now &lt;code&gt;split↓&lt;/code&gt; that fails to pass the termination check.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.cs.chalmers.se/~ulfn/&quot;&gt;Ulf Norell&lt;/a&gt; suggested some possible fixes. The difficulties, however, is probably a hint that there is something wrong in my approach in the first place. Rather than trying to fix it, Nils showed me how he would tackle the problem from the beginning.&lt;/p&gt;
&lt;h3&gt;Using Well-Founded Recursion&lt;/h3&gt;
&lt;p&gt;Nils showed me how to define &lt;code&gt;unfoldT↓&lt;/code&gt; using &lt;em&gt;well-founded recursion&lt;/em&gt;. For a simplified explanation, the &lt;a href=&quot;http://appserv.cs.chalmers.se/users/ulfn/wiki/agda.php?n=Libraries.StandardLibrary&quot;&gt;Standard Library&lt;/a&gt; provides a function &lt;code&gt;-rec&lt;/code&gt; having type (after normalisation):&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;-rec : (P : ℕ -&gt; Set) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(f : (i : ℕ) -&gt; (rec : (j : ℕ) -&gt; j ′ i -&gt; P j) -&gt; P i) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(x : ℕ) -&gt; P x &lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;With &lt;code&gt;-rec&lt;/code&gt; one can define functions on natural numbers by recursion, provided that the argument strictly decreases in each recursive call. &lt;code&gt;P&lt;/code&gt; is the type of the result, parameterised by the input. The function &lt;code&gt;f&lt;/code&gt; is a template that specifies the body of the recursion which, given &lt;code&gt;i&lt;/code&gt;, computes some result of type &lt;code&gt;P i&lt;/code&gt;. The functional argument &lt;code&gt;rec&lt;/code&gt; is supposed to be the recursive call. The constraint &lt;code&gt;j ′ i&lt;/code&gt;, however, guarantees that it accepts only inputs strictly smaller than &lt;code&gt;i&lt;/code&gt; (the ordering &lt;code&gt;′ &lt;/code&gt; is a variation of &lt;code&gt;&amp;lt;&lt;/code&gt; that is more suitable for this purpose). One may perhaps think of &lt;code&gt;-rec&lt;/code&gt; as a fixed-point operator computing the fixed-point of &lt;code&gt;f&lt;/code&gt;, only that &lt;code&gt;f&lt;/code&gt; has to take &lt;code&gt;i&lt;/code&gt; before &lt;code&gt;rec&lt;/code&gt; because the latter depends on the former.&lt;/p&gt;
&lt;p&gt;Let us try to define an unfold on trees using &lt;code&gt;-rec&lt;/code&gt;. The &amp;#8220;base-functor&amp;#8221; of the datatype &lt;code&gt;Tree⁺ a&lt;/code&gt; is &lt;code&gt;F b = a ⊎ b × b&lt;/code&gt;. One of the lessons we have learnt is that it would be more convenient for the generating function to return the bound information. We could use a type like this:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;F a b k = a ⊎ ∃ (ℕ × ℕ) (\(i , j) -&gt; b i × b j × i ′ k × j ′ k)&lt;/code&gt;
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;But it is perhaps more reader-friendly to define the base functor as a datatype:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;data Tree⁺F (a : Set) (b : ℕ -&gt; Set) : ℕ -&gt; Set where&lt;br /&gt;
&amp;nbsp;&amp;nbsp;tip : forall {k} -&gt; a -&gt; Tree⁺F a b k&lt;br /&gt;
&amp;nbsp;&amp;nbsp;bin : forall {i j k} -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b i -&gt; b j -&gt; i ′ k -&gt; j ′ k -&gt; Tree⁺F a b k&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The generating function for the unfold should thus have type &lt;code&gt;forall {a b i} -&gt; b i -&gt; Tree⁺F a b i&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The function &lt;code&gt;unfoldT↓F&lt;/code&gt; is the template for &lt;code&gt;unfoldT↓&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;unfoldT↓F : {a : Set} {b : ℕ -&gt; Set} -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(f : forall {i} -&gt; b i -&gt; Tree⁺F a b i) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(n : ℕ) -&gt; ((i : ℕ) -&gt; i ′ n -&gt; b i -&gt; Tree⁺ a) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b n -&gt; Tree⁺ a&lt;br /&gt;
unfoldT↓F f n rec y with f y&lt;br /&gt;
&amp;#8230; | tip a = Tip⁺ a&lt;br /&gt;
&amp;#8230; | bin {i} {j} y₁ y₂ i&amp;lt;n j&amp;lt;n =&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Bin⁺ (rec i i&amp;lt;n y₁) (rec j j&amp;lt;n y₂)&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now &lt;code&gt;unfoldT↓&lt;/code&gt; can be defined by:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;unfoldT↓ : {a : Set} {b : ℕ -&gt; Set} -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(f : forall {i} -&gt; b i -&gt; Tree⁺F a b i) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;forall {n} -&gt; b n -&gt; Tree⁺ a&lt;br /&gt;
unfoldT↓ {a}{b} f {n} y =&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-rec (\n -&gt; b n -&gt; Tree⁺ a) (unfoldT↓F f) n y &lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;All the definition above makes no recursive calls. All the tricks getting us through the termination check are hidden in &lt;code&gt;-rec&lt;/code&gt;. How is it defined?&lt;/p&gt;
&lt;h3&gt;Well-Founded Recursion Defined on ′&lt;/h3&gt;
&lt;p&gt;Currently, well-founded recursion are defined in &lt;code&gt;Logic.Induction&lt;/code&gt; and its sub-modules. They are very interesting modules to study. The definitions there, however, are very abstract. To understand how &lt;code&gt;-rec&lt;/code&gt; works, let&amp;#8217;s try to implement our own.&lt;/p&gt;
&lt;p&gt;This is the definition of &lt;code&gt;′&lt;/code&gt; from &lt;code&gt;Data.Nat&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;data _≤′_ : Rel ℕ where&lt;br /&gt;
  ≤′-refl : forall {n} -&gt; n ≤′ n&lt;br /&gt;
  ≤′-step : forall {m n} -&gt; m ≤′ n -&gt; m ≤′ suc n&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;_′_ : Rel ℕ&lt;br /&gt;
m ′ n = suc m ≤′ n&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Recall that the recursion template &lt;code&gt;f&lt;/code&gt; has type &lt;code&gt;forall i -&gt; (forall j -&gt; j ′ i -&gt; P j) -&gt; P i&lt;/code&gt;. That is, given &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;f&lt;/code&gt; computes &lt;code&gt;P i&lt;/code&gt;, provided that we know of a method to compute &lt;code&gt;P j&lt;/code&gt; for all &lt;code&gt;j ′ i&lt;/code&gt;. Let us try to construct such a method using &lt;code&gt;f&lt;/code&gt;. The function &lt;code&gt; guard f i&lt;/code&gt; computes &lt;code&gt;f&lt;/code&gt;, provided that the input is strictly smaller than &lt;code&gt;i&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;guard : {P : ℕ -&gt; Set} -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(forall i -&gt; (forall j -&gt; j ′ i -&gt; P j) -&gt; P i) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;forall i -&gt; forall j -&gt; j ′ i -&gt; P j&lt;br /&gt;
guard f zero _ ()&lt;br /&gt;
guard f .(suc j) j ≤′-refl = f j (guard f j)&lt;br /&gt;
guard f (suc i) j (≤′-step j&amp;lt;i) = guard f i j j&amp;lt;i &lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Observe that &lt;code&gt;guard&lt;/code&gt; terminates because it is defined inductively on &lt;code&gt;i&lt;/code&gt;. If we discard the type information, all what &lt;code&gt;guard f i j&lt;/code&gt; is to make a call to &lt;code&gt;f j&lt;/code&gt;. Before doing so, however, it checks through the proof to make sure that &lt;code&gt;j&lt;/code&gt; is strictly smaller than &lt;code&gt;i&lt;/code&gt;. In &lt;code&gt;f j (guard f j)&lt;/code&gt;, the call to &lt;code&gt;guard f j&lt;/code&gt; ensures that subsequent calls to &lt;code&gt;f&lt;/code&gt; are given arguments smaller than &lt;code&gt;j&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now &lt;code&gt;-rec&lt;/code&gt; can be defined by:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;-rec : (P : ℕ -&gt; Set) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(forall i -&gt; (forall j -&gt; j ′ i -&gt; P j) -&gt; P i) -&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;forall n -&gt; P n&lt;br /&gt;
-rec P f n = f n (guard f n)&lt;/code&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In &lt;code&gt;Logic.Induction.Nat&lt;/code&gt;, &lt;code&gt;-rec&lt;/code&gt; is an instance of well-founded recursion defined using the concept of &lt;em&gt;accessibility&lt;/em&gt;, defined in &lt;code&gt;Logic.Induction.WellFounded&lt;/code&gt;. I find them very interesting modules which I hope to understand more.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To be continued&amp;#8230;&lt;/strong&gt;&lt;/p&gt;</description>
	<pubDate>Sat, 12 Apr 2008 16:22:42 +0000</pubDate>
	<dc:creator>Shin</dc:creator>
</item>
<item>
	<title>Joel Reymont: Cross-platform bytecode anyone?</title>
	<guid isPermalink="false">tag:typepad.com,2003:post-48340944</guid>
	<link>http://feeds.feedburner.com/~r/TenerifeSkunkworks/~3/268946453/cross-platform.html</link>
	<description>&lt;p&gt;Suppose I want to generate bytecode or executable code on Mac OSX or Linux and run it on Windows. Assume that I want to do that in a web application and that I only target x86.&lt;/p&gt;

&lt;p&gt;What are my options?&lt;/p&gt;
&lt;p&gt;The other qualifier is that the generated code should be .NET or should run in a VM that would, in turn, talk to .NET.&lt;/p&gt;

&lt;p&gt;I could try Mono but I read someplace that generated assemblies cannot be used on Windows due to signing issues. I'm not sure this is the case, can someone correct me?&lt;/p&gt;

&lt;p&gt;I could try Factor and write the COM interface on the Windows side. The Factor VM is reasonably small and the bytecode should run without change.&lt;/p&gt;

&lt;p&gt;What else?&lt;/p&gt;
&lt;div class=&quot;feedflare&quot;&gt;
&lt;a href=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?a=8YdbBgG&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?i=8YdbBgG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?a=NvKO8Mg&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?i=NvKO8Mg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?a=9FRJRPg&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?i=9FRJRPg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?a=vDRgsTG&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?i=vDRgsTG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?a=5I1ReAg&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~f/TenerifeSkunkworks?i=5I1ReAg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src=&quot;http://feeds.feedburner.com/~r/TenerifeSkunkworks/~4/268946453&quot; height=&quot;1&quot; width=&quot;1&quot; /&gt;</description>
	<pubDate>Sat, 12 Apr 2008 13:09:35 +0000</pubDate>
	<dc:creator>Joel Reymont</dc:creator>
</item>
<item>
	<title>Neil Mitchell: darcs Feature Request (Part II)</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-7094652.post-3201719101251968153</guid>
	<link>http://neilmitchell.blogspot.com/2008/04/darcs-feature-request-part-ii.html</link>
	<description>I &lt;a href=&quot;http://neilmitchell.blogspot.com/2008/01/darcs-feature-request.html&quot;&gt;previously requested&lt;/a&gt; a feature for darcs. I always pull from an http repo, and push over SSH. I have to push using &lt;tt&gt;--no-set-default&lt;/tt&gt; and typing the ssh repo in full, which I automate with a &lt;a href=&quot;http://darcs.haskell.org/packages/filepath/push.bat&quot;&gt;.bat file&lt;/a&gt; in each repo.&lt;br /&gt;&lt;br /&gt;Today I noticed that darcs has &lt;tt&gt;_darcs/prefs/repos&lt;/tt&gt;, which seems to list the repo's that darcs has used. In one of my typical repo files, I have an http entry and an SSH entry. To get darcs to behave the way I want, all I need to do is push using the first non-http repo in that list.&lt;br /&gt;&lt;br /&gt;I have implemented my version of the darcs push command inside my paper tool, the code is all &lt;a href=&quot;http://www.cs.york.ac.uk/fp/darcs/paper/Paper/Push.hs&quot;&gt;online here&lt;/a&gt;. Now I can delete all my push.bat scripts, and just type &lt;tt&gt;paper push&lt;/tt&gt; from any darcs repo. As an added bonus, I now don't need to change to the root directory to perform a push.&lt;br /&gt;&lt;br /&gt;It would be really nice if someone could incorporate this feature into the main darcs codebase. However, I'm quite happy using my paper tool for now. I certainly don't have time to patch, or even build darcs :-)</description>
	<pubDate>Sat, 12 Apr 2008 11:20:00 +0000</pubDate>
	<dc:creator>Neil Mitchell</dc:creator>
</item>
<item>
	<title>Conrad Parker: Release: Sweep 0.9.3</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-9101292118679422945.post-6484626782594667327</guid>
	<link>http://blog.kfish.org/2008/04/release-sweep-093.html</link>
	<description>This is a bugfix release of &lt;a href=&quot;http://www.metadecks.org/software/sweep/&quot;&gt;Sweep&lt;/a&gt;,
addressing &lt;a href=&quot;http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-1686&quot;&gt;CVE-2008-1686&lt;/a&gt;.
For details, see my earlier post about
&lt;a href=&quot;http://blog.kfish.org/2008/04/release-libfishsound-091.html&quot;&gt;libfishsound 0.9.1&lt;/a&gt;.
Thanks to Peter Shorthose for managing this release.</description>
	<pubDate>Sat, 12 Apr 2008 07:50:09 +0000</pubDate>
	<dc:creator>Conrad Parker</dc:creator>
</item>
<item>
	<title>Ulisses Costa: Life After People, Documentary</title>
	<guid isPermalink="false">http://caos.di.uminho.pt/~ulisses/blog/2008/04/12/life-after-people-documentary/</guid>
	<link>http://caos.di.uminho.pt/~ulisses/blog/2008/04/12/life-after-people-documentary/</link>
	<description>&lt;p&gt;&lt;!--post2pdf_exclude--&gt;Last week, after making a work for the university, I was stumbling around and found an excellent documentary to see. Life after people is a documentary from History channel that try to respond the question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p id=&quot;result_box&quot; dir=&quot;ltr&quot;&gt;&lt;em&gt; What would happen to planet earth if the human race were to suddenly disappear forever?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The idea is just great! Probably everyone at some point thought about that, and maybe didn&amp;#8217;t have the imagination or the knowledge to get a clear picture like those in this documentary.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://caos.di.uminho.pt/~ulisses/blog/img/buildings_decomposing.jpg&quot; align=&quot;left&quot; height=&quot;164&quot; width=&quot;297&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The documentary have a lot of speculative facts, just a little bit americanized, but the idea of see all the things that we created being destroyed by the land there we live is fascinating.&lt;/p&gt;
&lt;p&gt;Remember us that our planet is alive, and live by it self, and in some aspects needs help. We are small but at the same time we can do a lot of changes in our planet.&lt;/p&gt;
&lt;p&gt;Well, I really liked this imaginative documentary, here is the &amp;#8220;trailer&amp;#8221;:&lt;/p&gt;
&lt;p&gt;

&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.history.com/minisites/life_after_people&quot;&gt;Here&lt;/a&gt; the oficial site of &lt;a href=&quot;http://video.google.com/videoplay?docid=4939078184096254535&quot;&gt;the documentary&lt;/a&gt;.&lt;/p&gt;</description>
	<pubDate>Sat, 12 Apr 2008 04:42:04 +0000</pubDate>
	<dc:creator>ulisses</dc:creator>
</item>
<item>
	<title>Eric Kow (kowey): darcs 2 at last!</title>
	<guid isPermalink="false">tag:blogger.com,1999:blog-21123659.post-737614930474400956</guid>
	<link>http://koweycode.blogspot.com/2008/04/darcs-2-at-last.html</link>
	<description>I'm sure you've all seen David's &lt;a href=&quot;http://thread.gmane.org/gmane.comp.version-control.darcs.devel/7809&quot;&gt;announcement&lt;/a&gt;: darcs 2.0.0 is out!&lt;br /&gt;&lt;h3&gt;what's good&lt;/h3&gt;In short, darcs 2.0 is safer and faster.&lt;br /&gt;&lt;br /&gt;Particularly, the dreaded exponential-time merge bug has now been largely resolved.  Let me say it more carefully: while it may still be possible to run into exponential time merges, our improvements to conflict-handling should make it considerably less common.  We hope that nobody ever runs into such a situation in practice.&lt;br /&gt;&lt;br /&gt;Other key points are improved the hashed inventory and pristine cache which darcs more robust (you no longer have to worry about third party tools like Eclipse or Unison messing things up by mucking around with darcs internals), the ssh-connection mode which speeds up SSH-issues a lot and kills the typing-your-password-ten-million-times issue dead (at most you'll have to type it in twice).&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;what's bad&lt;/h3&gt;On the one hand, darcs 2.0.0 should be much smoother and faster for most users.  On the other hand, people with large repositories (e.g. GHC-sized) might find certain operations to be somewhat slower.  David does not (yet) have ideas on how to make things better for such users, and is even recommending them to switch to something else.  If you've got a repository of darcs' size (over 5000 patches, 6 years, 131 contributors) or smaller, you should continue using darcs, because we still think it works better: we're still the only ones around to offer &lt;em&gt;deep&lt;/em&gt; cherry picking... something which we think would be hard to do without radically changing the way other VCSes work.  If you would like to prove us wrong, please do so and we would be most grateful!&lt;br /&gt;&lt;br /&gt;Also, taking advantage of darcs 2 will require you to upgrade your repository to the &lt;code&gt;darcs-2&lt;/code&gt; format (see &lt;code&gt;darcs convert&lt;/code&gt;), which unfortunately, is not compatible with older versions of darcs.  People with new repositories should definitely start using this format.  People with old repositories should probably do so at the earliest convenient moment, although this means your users will have to upgrade.  Please switch to the new format.  It will make everybody's lives easier.&lt;br /&gt;&lt;br /&gt;The final piece of bad news: we're going to have to shift to a lighter weight development model,  something which puts less strain on David and the rest of the contributors.  The consequences are that patches might get less review [one maintainer and not two], and that you'll be seeing less of David on the mailing lists.  The good news in the bad news is that our lighter weight development model is now being supported by increased automation of the administrative stuff.  For example, our bug tracker is now integrated with the darcs repository so that it automatically knows when a ticket has been resolved by a patch.  This increased automation gives us extra rigour and more time to think about making darcs better.  The only thing we need is more of us.   If you want a place to hone your Haskell, Perl or C... or if you think you know a thing or two about user interfaces,  please spend some time with us.&lt;br /&gt;&lt;h3&gt;to sum up...&lt;/h3&gt;Have you been hesitating to try darcs out?  Well, now is a good time to do so, as our killer bugs have been fixed as well as the kind of minor nuisances that get most of us.  Or... are you looking for something to work on?  Uncle David needs you!&lt;br /&gt;&lt;br /&gt;[note: Thanks to David Roundy for comments on a draft of this post]</description>
	<pubDate>Fri, 11 Apr 2008 17:56:54 +0000</pubDate>
	<dc:creator>kowey</dc:creator>
</item>
<item>
	<title>Tom Moertel: That looks about right</title>
	<guid isPermalink="false">urn:uuid:8c556b83-dcaa-4044-9f0f-7af434f6f3f7</guid>
	<link>http://blog.moertel.com/articles/2008/04/11/that-looks-about-right</link>
	<description>&lt;p&gt;Via &lt;a href=&quot;http://www.cwinters.com/news/display/3624&quot;&gt;Chris&lt;/a&gt;:&lt;/p&gt;


&lt;pre&gt;$ history | awk '{print $2}' | sort | uniq -c | sort -rn | head
    196 git
    110 l
    102 cd
     70 make
     34 darcs
     30 pushd
     23 ssh
     23 m
     23 ls
     20 rm
&lt;/pre&gt;

	&lt;p&gt;The &lt;em&gt;l&lt;/em&gt; and &lt;em&gt;m&lt;/em&gt; commands are aliases:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;l&lt;/em&gt; = &lt;em&gt;ls &amp;#8211;CF&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;m&lt;/em&gt; = &lt;em&gt;less&lt;/em&gt;&lt;/li&gt;
	&lt;/ul&gt;</description>
	<pubDate>Fri, 11 Apr 2008 16:04:49 +0000</pubDate>
	<dc:creator>Tom Moertel</dc:creator>
</item>
<item>
	<title>Bryan O'Sullivan: Hoisted from someone else&amp;#8217;s comments</title>
	<guid isPermalink="false">http://www.serpentine.com/blog/2008/04/10/hoisted-from-someone-elses-comments/</guid>
	<link>http://www.serpentine.com/blog/2008/04/10/hoisted-from-someone-elses-comments/</link>
	<description>Marc Ambinder comments on the &lt;a href=&quot;http://marcambinder.theatlantic.com/archives/2008/04/advance_praise_for_war_and_dec.php&quot;&gt;peculiar cadence of the jacket blurbs&lt;/a&gt; for Douglas Feith&amp;#8217;s new book, to which some wag responds with a suggestion for a similar endorsement.

&lt;blockquote&gt;Feith&amp;#8217;s book is perfectly rectangular. Its page numbers progress in a pleasing upward sequence. Its evident shortcomings in terms of accuracy are offset by its usefulness in balancing wobbly furniture.&lt;/blockquote&gt;</description>
	<pubDate>Fri, 11 Apr 2008 06:11:47 +0000</pubDate>
	<dc:creator>Bryan O'Sullivan (bos@serpentine.com)</dc:creator>
</item>

</channel>
</rss>
