Wednesday, November 7, 2007

Passivating Thoughts

Before a friend of mine became a brilliant linguist, he was a brilliant Linguistics student. I recall the two of us mulling over some thoughts about active and passive voice then. In English, the subject of an active voice sentence is the actor doing the action. Geoff studies languages. In passive voice, the subject and direct object get swapped. Languages are studied by Geoff. It turns out that most active voice sentences can be rewritten in passive voice and vice versa.

However, there is an interesting class of active voice sentences that cannot be “passivated,” if I may coin that term. He sank the boat to become a hero. If we try to flip that around, it no longer makes any real sense. The boat was sunk to become a hero. It’s no longer correct. Surely the sinker and not the boat itself is the hero.

There are similarly structured sentences that do admit passivation. He sank the boat to collect the insurance. This is nearly identical to the previous example. The boat was sunk to collect the insurance. That works! It’s clear that the boat is not the collector of the insurance. A million other examples flow off the tongue. He drank the Jolt to postpone sleep. We were in college after all. The Jolt was drunk to postpone sleep.

So, what’s so special about the hero example? Why does the passivation transformation sometimes fail?

After kicking this around some, one of us noticed a difference in the sentences. The verb “collect” can be used in passive voice. Insurance was collected. But “become” is special. Without taking poetic license with the language, one cannot passivate become. Hero was become, is not correct. We then conjectured that sentences of the form above could be passivated if and only if their infinitival clause had a valid passive voice form.

Armed with a conjecture, we thought we’d run a few more experiments and see how it bears up. There’s no way to say “was remain”, so we predicted that the following sentence could not be passivated. He shredded the contract to remain a free agent. And sure enough: The contract was shredded to remain a free agent. This sentence would imply that the contract itself was a free agent, but the active voice form does not. The attempt to passivate the verb “to shred” in this example fails because “to remain” admits no passive voice form.

Other experiments also shore up the conjecture. To dance all night, she chose comfortable shoes. That has a clear meaning. She, and not the shoes, is doing the dancing. But attempting to passivate the sentence fails. Comfortable shoes were chosen to dance all night. Even if that might be a grammatically correct sentence, the meaning is warped. The shoes were not selected to dance (among other dancing candidates). It’s the dancer that dances. Our conjecture correctly predicts this because the construction “were danced” doesn’t make sense. (Although I could dance a jig, which is transitive, and a jig could “be danced,” the flavor of dance used above is intransitive, admitting no direct object, and no passive voice form.)

We both celebrated with a Jolt, but here is where the differences in the way Physics students and Linguistics students look at the world came into play. “We’re done,” I exclaimed. “We looked at the data, formed a conjecture, and tested it with more data. Write it up!” That our conjecture was interesting and useful was enough for me.

My friend said something like, “No, we’re not done at all. Now we have to figure out why English obeys the conjecture. What forces could have driven the evolution of the language (or our minds, really) to behave this way? We can‘t just offer the conjecture without justifying it.”

This notion floored me. It would never occur to me to ask why F = GMm/r^2. That’s just a useful law that Newton discovered. That it works is enough. Hypotheses non fingo. So, it seemed incredibly ambitious and speculative to try to explain why the linguistics conjecture worked. I was of no further use.

In summary, most English active voice sentences can be passivated without changing their meaning or rendering the new sentence ungrammatical. Putting on our Physics hat, we might say that they are invariant under the passivation transformation. However, there are a few sentences that are not, namely the ones with infinitival clauses that admit no passive form. This represents an interesting broken symmetry.

When refactoring software, one improves the internal structure without breaking the desired external behavior. In the literature, I perceive a couple of approaches to this. Both are compatible, but have different emphases. Martin Fowler and others emphasize the importance of comprehensive unit tests that pass before and after modifications are made. Bill Opdyke and others champion the idea that source code can be transformed in specific, discrete ways that leave behavior unchanged.

I feel that both approaches are important. The first approach admits the possibility that the unit test suite is not complete enough. A client somewhere might rely on some behavior that’s not checked by a unit test. So the refactoring attempt could fail. The second approach should always work, but it limits the refactoring repertoire to those actions that your tool can do. (Unless you are incredibly meticulous and can confidently edit the code by hand yourself.).

However, I wonder what subtle broken symmetries, analogous to the linguistics example above, might still exist when transforming source code according to our profession's ever growing catalog of refactorings.

2 comments:

markm said...

Starting with this: "He sank the boat" => "The boat was sunk by him."

When I examine "He sank the boat to become a hero" I can see that the "to" is shorthand for "in order to", so we can convert it thusly: "In order to become a hero, the boat was sunk by him".

Or "The boat was sunk by him so that he could become a hero", if you want the motivation after the action.

Morgan Creighton said...

Mark, you are exactly right. It is possible to turn the hero sentence into passive voice. But only by using a different transform.

Imagine writing a computer program to manipulate the sentences. It would have to examine the verb in the infinitival clause to see if it's one of those special, non-passivatable ones (become, remain, et al). If it is, the program would have to execute the special transform that adds the "so that" wordage.

public String transform(String s)
{
  String verb = extractInfinitivalFrom(s);
  if (specialVerbs.contains(verb))
  {
    return specialTransform(s);
  }
  else
  {
    return defaultTransform(s);
  }
}