Wednesday, July 21, 2021

Revisiting Jerry's famous Mary had a little lamb heuristic

 Let me propose a hypothesis "Anything written/expressed in natural language is inherently ambiguous".  As one of hallmarks of civilization and evolution - language evolved as a tool for communication. Language connected people, got embedded in culture, grown into world of literature and finally technologists (being human) started using natural languages to represent and communicate "technological content".  This is where the hypothesis I mentioned in the beginning of this post comes into being. 

For technological or any formal purposes such as finance, legal transactions -  absolute clarity on intent and meaning of constructs of the language - words and sentences is a mandatory requirement. As we can see sentences in natural language can be interpreted in many different ways. Each reader/consumer of such language constructs makes his/her own meaning based on context that is assumed. Also there are differences in spoken and written versions of same text. So we have a problem in use of natural language in formal cases like software development and other areas. In addition to fundamental ambiguity as part and parcel of natural language - transmission of content from person to person add's its own elements of complicating meanings.

Jerry Weinberg, father of testers - recognized and wrote about this long ago. In a book "Exploring Requirements - Quality before design" with Donald Gause - he introduces a tool/technique or heuristic with a catchy name "Mary had a little lamb" - to find out how ambiguous simple line from popular nursery rhyme can become. "Nursery rhymes are infamous examples of ambiguity because of some of them have been transmitted from child to child over hundreds of years, and the original meanings of the rhyme might have been lost of transformed" writes Jerry when introducing the technique.

"Is it possible that a line from Rhyme "Mary had a little lamb" have hidden meanings ?" asks Jerry. In order to bring out such hidden meanings - he proposes following trick.

"If we emphasis each word in a line, one by one and then in combinations we can easily identify 6 or with some additional effort up to 30 meanings of just one line of the rhyme"


Mary had a little lamb

(Its Mary's Lamb - Not Sophie or John)

Mary had a little lamb

(She no longer holds the lamb now)

Mary had a little lamb

(she had only one lamb not many)

Mary had a little lamb

(Its really surprisingly small)

Mary hand a little lamb

(she did not have a dog or a rabbit - it was a lamb)

With all emphasis

Mary had a little lamb

(As contrasted with Pallas who still has four turtles)

So you have one way to subject a sentence to a sharp scrutiny for ambiguities.  Jerry in same book provide yet another corollary to MHALL (Marry had a little Lamb) technique.

This is called MCTT  - Mary Conned the Trader. In this technique - we substitute synonyms for each word in the sentence. Once we have listed down probable synonyms for each word - we can create new sentences as probable interpretation of original sentence taken in another context. By changing context's we would try to identify hidden meanings and possible interpretations.

How does this work? First - take the help of dictionary and elaborate meanings and synonyms of words and list them down.

Let us take words "had" and "lamb"

Had - Past Tense of Have

Have - to hold possession, to acquire ownership, accept, to marked or characterized by, to build a position of disadvantage, beget, bear (have child), bribe, eat

Lamb - young sheep one year old or without permanent teeth, young of various other animals (antelope), person as gentle or as weak as lamb, dear or pet, a person easily cheated, flesh of lamb as food.

With these different meanings - let us get some more meanings of MHALL

- Mary owned a young antelope

-  Mary is (or was) mother of particular small, gentle person

- Mary bribed a small person trading securities who was easily cheated

- Mary ate a little of flesh of a lamb

- Mary held a little sheep under one year of age or without permanent teeth in a position of disadvantage or certain defeat

- Mary acquired a little sheep under one year of age or without permanent teeth.

Well - what if Mary is not a human  but another animal or tree or a group of people.

Mary (Sheep) had given birth to a little lamb last month.

Jerry concludes the section in the book with following comments -

"The commonly held view that the poem is about an innocent young lady with a loyal pet is naive in the extreme - not as naive, though as sophisticated adults who pick some line out of requirements document and without giving a second thought, proceed to develop a product based on single, wrong interpretation."

For testers - its important to look at requirements from multiple angles and perspectives. Application of these two techniques - MHALL and MCTT as heuristic (thumb rule) helps them to see ambiguities in natural language constructs.

Some additional resources about natural language and ambiguity

Before I end this post - a question. Why communication in natural language had to be fundamentally ambiguous?

When are you trying to use these in your projects? Do let me know.

No comments: