reperiendi

Dew

Posted in Uncategorized by Mike Stay on 2010 March 30

Monads for functional JavaScript programming

Posted in Uncategorized by Mike Stay on 2010 March 26

Introduction

Philip Wadler’s excellent paper “Monads for Functional Programming” is about how to achieve some of the benefits of using side-effecting languages using a purely functional language. Wadler uses Haskell to illustrate his examples. To me, that has the effect of preaching to the choir—you can’t do anything in a purely functional language without a monad, so anyone proficient in Haskell will already have had to understand the point he’s trying to make.

“It’s easier to port programmers than to port programs”, so I’ll take a different tack: purely functional programs are far easier to test. If you are concerned about the reliability of your code, programming in a functional style is something to consider seriously. So in my opinion, the examples should be given in the impure language; I’m going to use JavaScript.

In one example, Wadler assumes that computing 1/0 throws an error. Since JavaScript says 1/0 === Infinity instead, I’m going to use silentmatt’s BigInteger library, which does throw an error.

In what follows, I simply give a direct translation from Wadler’s Haskell code in section 2 of his paper.

(more…)

A Pietà for the modern age

Posted in Uncategorized by Mike Stay on 2010 March 26

Crochet your own action figures

Posted in Uncategorized by Mike Stay on 2010 March 23


She’s selling the patterns for $3.50 each on her Etsy page. See also this collection of Lord of the Rings characters.

Artificial photosynthesis

Posted in Uncategorized by Mike Stay on 2010 March 19

96% efficiency at turning CO2 and H20 into sugar.

PTSD in Haiti

Posted in Uncategorized by Mike Stay on 2010 March 17

Lucas Williams writes:

[This was written as a response to close friend of mine who is a social worker in the greater Hartford area. She asked me if I had any anecdotes from Haiti that she could share at an upcoming conference on mental health and trauma. I tried to jot down just a few thoughts, but found that I couldn’t stop typing. This is a letter to a friend, not an essay or paper, but I want to share it. I hope that it can be of help to someone else, either to a returning aid worker, or someone who hasn’t been to Haiti yet wants to understand, to feel a little bit of what it is like.]

Dear *****

I’m in Miami right now, I landed last night. I’ve been in Haiti, working as an Emergency Department technician in a field hospital for almost 6 weeks, and it’s more than a little weird to be lying on a friends couch watching TV. I head back to Port-au-Prince on Saturday for another 5 weeks. I tried to write you a short reply about post-trauma and it turned into a novel. By the second paragraph I realized I was really writing it for me, but it just kept on going. I don’t know if this is going to be much help, but I’m sending it anyways, because each time I try and clean it up it just gets messier, and longer.

I think about post-traumatic stress disorder a lot. Before I left for Haiti I thought of it as a Western illness. It wasn’t that I thought it wasn’t real — I just believed that you had to be emotionally “fragile” before the trauma in order to be severely affected by it afterwards. We had a psychologist on the plane with us, and my first thought when I heard she was coming was “what the hell is she going to do?” Haiti is the poorest country in this hemisphere. These people are tough as nails, they won’t need a shrink, and besides, there’s no way she could be effective dealing with such a monstrous language barrier. Less than 48 hours from the time we landed I would feel very differently.

(more…)

Burninatin’ the countryside

Posted in Uncategorized by Mike Stay on 2010 March 15


With consummate Vs!

Pretty jewelry

Posted in Uncategorized by Mike Stay on 2010 March 9

The artist says the bands of color are due to a diffraction grating; the base is recycled titanium. Is it etched, or ground, or what? The page only says “a multistep process”.

Life imitates Art

Posted in Borges by Mike Stay on 2010 March 8

In “Tlön, Uqbar, Orbis Tertius“, Borges describes a group of dedicated people who describe a world, Tlön, in such detail and produce enough forged artifacts that the whole world adopts their vision and begins to convert itself into Tlön. I attributed a farcical version of Borges’ story “Death and the Compass” to a pseudonymous Umberto Eco in the last post; in that story, the detective’s supposition that there is a pattern induces his prey to begin using the pattern in order to entrap him. In fact, Eco borrowed that idea for his own detective story, The Name of the Rose. The Bible formed the basis for the production of thousands of fraudulent relics, and the Book of Mormon inspired Mark Hoffmann to create forgeries of letters from the early Mormon community (though his were designed to destroy the community instead of build it). Cellphones look like Star Trek communicators, and Bluetooth headsets look like Uhura’s earpiece. Of course, there’s all the merchandising from Star Wars and Lord of the Rings. And my brother David just gave my brother Doug a set of the six signs from Susan Cooper’s The Dark is Rising sequence.

What story has motivated you to create your own artifacts?

Creative ways to ask a girl on a date

Posted in Borges by Mike Stay on 2010 March 8

In Utah, it is expected that high-school students and undergraduates will come up with extravagant ways, often including horrible puns, to ask a girl out on a date and to reply to such an invitation. My cousin’s family, having just moved there, asked on the family list for ideas. My response:

My date read the “police beat” religiously, so I got Umberto Eco to write a story about a detective on the BYU campus police force who believes that two crimes (involving the vandalism of FARMS researchers’ webpages with screeds linking kabbalah to quantum field theory) are related even though, in fact, they are not. The detective was responsible for a student’s conviction of violating the Honor Code and eventual expulsion. The student learns of the detective’s interest and begins to commit crimes that fit the imagined pattern; the detective predicts where the final crime will be committed and stakes out the place, but because the student was expecting him, he is captured by the student and his friends and forced to wear U of U paraphernalia.

I had it published pseudonymously in the Daily Herald, and then used my network of friends to commit 137 minor crimes across campus for the next six months prior to the dance that spelled out “[Name], will you go to the dance with me?” I waited at the place where the point of the question mark would be, but she never showed up.

She did, however, wire my brakes to my horn and leave a sheet with a big “YES” painted on it under the hood. This would have been amusing had the new wiring not caused electrical arcing. The sheet caught fire, which caught other things on fire, which eventually burned out the interior of the car. It wasn’t too much of a loss, though, because it was a 1973 Honda Civic that I’d bought from a graduating senior for $200.

Anyway, neither of us wanted to dance all that much in the first place, so we went down to the underground laser lab where my roommate worked and then explored the steam tunnels.

Birdfeeders in UK are splitting Blackcaps into two species

Posted in Uncategorized by Mike Stay on 2010 March 5

There’s a mutation that sends blackcaps in the wrong direction when migrating for the winter, and they end up in Britain. Before humans started putting out bird feeders, they would merely die. But now, they’re surviving and living to reproduce. They spend part of their time in Europe, but they overlap less with the birds that migrate over the alps; the two groups are now more genetically distinct between groups than within them. This gap arose in around 50 years; if it holds up, the groups may cease to interbreed entirely and will become two different species.

The Murder of Asher Ben-Judah

Posted in Borges by Mike Stay on 2010 March 4

Here’s a story I wrote; it’s inspired by Borges’ collection of stories “A Universal History of Infamy.”

The Murder of Asher Ben-Judah

In the fourth year of the reign of Nebuchadnezzar II, Egypt successfully repelled the invasion by Babylon. Believing Babylon to be weakened, Jehoiakim of Jerusalem stopped paying tribute to Babylon, took a pro-Egyptian position, and promptly died. His son Jeconiah chose to continue the policy; one hundred days later, he was deposed by Nebuchadnezzar II for rebellion. The Babylonian king sacked the temple, took captive all the nobility and craftsmen who had not fled the city—some ten thousand people—and carried them off to Babylon; the prophet Ezekiel was among them. Before leaving, perhaps mockingly, Nebuchadnezzar annointed Jeconiah’s uncle Mattaniah, clothed him in the robes of kingship, and gave him the new name “Righteousness of the LORD.”

Despite the destruction, the harvest that year was a good one for farmers, and the sale of the excess bought capital for rebuilding the city. Those wise and wealthy enough to have fled Jerusalem with their property in anticipation of the inevitable response to Jehoiakim’s stupidity returned; among them was the ward boss Asher Ben-Judah. Asher was a master at organizing labor; he was often and fruitfully compared to Father Jacob’s father-in-law for having the cunning to convince a man to work fourteen years in the hope of being paid someday. However, when cunning failed, Asher was not above resorting to other motivators: he was also a master at organizing crime. If one were to speak to a particular man in the bazaar, he would recite a list of Asher’s prices:

  • Punching – 2 shekels,
  • Both Eyes Blackened – 4 shekels,
  • Nose & Jaw Broken – 10 shekels,
  • Ear Chawed Off – 15 shekels,
  • Leg Or Arm Broken – 19 shekels,
  • Stab – 25 shekels,
  • Doing the Job – 100 shekels and up.

As the armies of Babylon flooded the country, Asher came to rest in the mountains of Ararat. A generation before, the Arartian king Rusa II had built more cities than Solomon, Ramses, Semiramis and Sargon put together; the blind arches of Rusahinili and Teishebaini rivaled the fortifications of Ninevah. Asher knew there would be plenty of work for masons in rebuilding Jerusalem after Babylon was through with it.

Another household returning to Jerusalem that year was that of Asher’s second cousin “Jawbone” Ben-Samson, a merchant dealing in precious metals and a smith in his own right, having received the secrets of metallurgy from his fathers. Ben-Samson had chosen to find refuge in Egypt, where Babylon could not follow, and returned with artifacts of gold, silver, brass, and steel.

Though Asher cared nothing for working metal, he was the firstborn and had inherited the sword forged by their great-grandfather; the iron was cast down from heaven and laid waste to a forest near Damascus. Such iron was very rare and very valuable, since it was pure enough to be strengthened by forging in charcoal; iron extracted from ore already had too much of the black ash in it, and would become brittle.

It’s unclear what happened to spark Ben-Samson’s madness. He began to accuse the king of plotting against Babylon; the king, who owed his throne to Nebuchadnezzar’s grace, ordered his death, but Ben-Samson escaped to the desert. He began to forget key metallurgical processes; he sent his sons to Asher to coerce him into giving them their great-grandfather’s records. Asher turned them away, but they returned and attempted to buy the records; insulted at the prospect of selling his birthright, Asher told his men to kill the intruders. “Jawbone” Ben-Samson was not so named because he was a weakling, and his sons lived up to their name: they fought off the thugs and escaped, but in the scuffle they dropped the keys to their family’s treasury. Since neither Ben-Samson nor his sons could reenter the city to claim their property, Asher became the second-richest man in Jerusalem.

Asher, dressed in his finest, went out on the town to celebrate. He bought everyone drinks at the ward tavern and used his favorite prostitute; near the end of the third watch he stumbled out the door towards home. Asher Ben-Judah was found stripped and decapitated the next day; his sword and his great grandfather’s records were missing. Neither Ben-Samson nor his sons ever returned to Jerusalem.

Theories and models

Posted in Category theory, Math, Programming by Mike Stay on 2010 March 4

The simplest kind of theory is just a set T, thought of as a set of concepts or Platonic ideals. We typically have some other set S, thought of as the set of real things that are described by concepts. Then a model is a function f:T \to S. For example, we could let T = {0, 1}; this is the theory of the number “two”, since it has two elements. Whatever set we choose for S, the models of the theory are going to be pairs of elements of S. So if S = the set of people, models of T in S are going to be pairs of people (where choosing the same person twice is allowed).

Concepts, however, are usually related to each other, whereas in a set, you can only ask if elements are the same or not. So the way a theory is usually presented is as a category T. For example let T be the category with two objects E, V and two parallel nontrivial morphisms \sigma, \tau:E\to V, and let S be the category Set of sets and functions. A model is a structure-preserving map from the category T to Set, i.e. a functor. Each object of T gets mapped to a set; here we think of the image of V as a set of vertices and the image of E as a set of edges. Each morphism of T gets mapped to a function; \sigma and \tau take an edge and produce the source vertex or target vertex, respectively. The category T = Th(Graph) is the theory of a graph, and its models are all graphs.

Usually, our theories have extra structure. Consider the first example of a model, a function between sets. We can add structure to the theory; for example, we can take the set T to be the ring of integers \mathbb{Z}. Then a model is a structure-preserving function, a homomorphism between T and S. Of course, this means that S has to have at least as much structure as T. We could, for instance, take S to be the real numbers under multiplication. Since this ring homomorphism is entirely determined by where we map 1, and we can choose any real number for its image, there would be one model for each real number; each integer x would map to a^x for some a. Another option is to take S = \mathbb{Z}_4, the integers modulo 4. There are three nonisomorphic models of \mathbb{Z} in \mathbb{Z}_4. If we map 1 to 0, we get the trivial ring; if we map 1 to 1 or 3, we get integers modulo 4; and if we map 1 to 2, we get integers modulo 2.

Similarly, we can add structure to a category. If we take monoidal categories T, S, then we can tensor objects together to get new ones. A model of such a theory is a tensor-product-preserving functor from T to S. See my paper “Physics, Topology, Computation, and Logic: a Rosetta Stone” with John Baez for a thorough exploration of theories that are braided monoidal closed categories and models of these.

An element of the set \mathbb{Z}_4 is a number, while an object of the category Th(Graph) is a set. A theory is a mathematical gadget in which we can talk about theories of one dimension lower. In Java, we say “interface” instead of “theory” and “class” instead of “model”. With Java interfaces we can describe sets of values and functions between them; it is a cartesian closed category whose objects are datatypes and whose morphisms are (roughly) programs. Models of an interface are different classes that implement that interface.

And there’s no reason to stop at categories; we can consider bicategories with structure and structure-preserving functors between these; these higher theories should let us talk about different models of computation. One model would be Turing machines, another lambda calculus, a third would be the Java Virtual Machine, a fourth Pi calculus.

Digital compositing

Posted in Uncategorized by Mike Stay on 2010 March 3

Stargate studios shows off: