Boolean operators and programming lessons for babies

r31mrA couple of days ago I was aimlessly clicking around looking at interesting stuff on the Internet when I stumbled across something very rare indeed: a news item that I am qualified to have an opinion on by virtue of having a PhD on the subject. (For those of you just tuning in: I model the mechanisms of natural language interpretation using concepts from logic and set theory.)

I’d be a fool to waste such a unique opportunity.

The article in question reported on a project by computer programmer Eric Redmond, who is using Kickstarter to fund a book that teaches Boolean operators to babies in order to better prepare them for a future in the 21st century. A Boolean algebra is a mathematical structure whose elements are related to each other by three different operations: AND, OR, and NOT, the properties of which are defined by a shortish list of axioms. (What these axioms express, more or less, is that the elements of the algebra are ordered from smallest to greatest in some systematic way.) Many of the mathematical formalisms used in both formal linguistics and computer science are Boolean in nature, such as propositional logic and set theory. We’ll be using the latter here because it gets the basic notions of Boolean algebra across in the most intuitive way. In set-theoretical terms, AND is defined as set intersection, OR as set union, and NOT as the complement:

boolean or-and-not

From left to right: union, intersection, and complement

It is, of course, no coincidence that the names given to the three Boolean operators correspond to the familiar English words andor and not, because intuitively, they seem to mean just that:

From left to right: natural language expressions behaving like Boolean operations

From left to right: natural language expressions behaving like Boolean operations. (If you balk at the first picture – something that’s both fluffy and orange is not ‘fluffy or orange’! – just keep reading.)

Considering this, using ordinary English to teach children the various properties of Boolean algebras (and, in this way, increasing their chances of finding favour in the eyes of our future robot overlords, something any responsible parent should strive for!) seems like a pretty great idea.

But if there’s anything that being a linguist teaches you, it’s that human language is a messy and complex thing. When you look more closely at the behaviour of and and or in natural language, it often doesn’t look all that Boolean. Judging by the various examples from the programming-for-babies book, Eric Redmond did not realise this, since the sentences that are supposed to be teaching Boolean AND and OR to babies actually display several of the finest examples of non-Boolean behaviour. The worst offender is the sentence “The panda is black and white”- entire research papers with “non-Boolean and in the title have been written about sentences just like that, so it is rather unfortunate that it ended up in a book supposedly all about Boolean logic.

Some pictures from Redmond's book (via Daily Dot). See if you can already spot how the first instance of 'and' is quite different from the second one!

Some pictures from Redmond’s book (via Daily Dot). See if you can already spot how the first instance of ‘and’ is quite different from the second one.

But the examples for or are problematic too – in natural conversation, those sentences trigger various non-Boolean inferences, which is not a sign that humans are stupid and incapable of logical thinking, but a process that forms an important part of our linguistic competence and our everyday understanding of how language works. Unless the parent/reader is very careful when it comes to intonation patterns, the book’s text is incompatible with those inferences, potentially interfering with the child’s acquisition of the rules of ordinary English.

So, how are natural language and and or different from their well-behaved mathematical counterparts?

Non-Boolean behaviour of natural language and
Looking at the pictures above, it is easy to see that the following holds for Boolean AND:

  1. If X is A AND B, then the following must also be true (and vice versa):
    – X is A;
    – X is B.

In the case of the fluffy orange cat, this is the case: the book tells us that the cat is “orange and fluffy”, and the baby can easily verify that the pictured cat is orange, and that he is fluffy.

But what about “The panda is black and white”? The pictured panda, in fact, isn’t black, nor is it white: the equivalence in (1) does not apply to the sentence. What “The panda is black and white” expresses is that the panda is part black, part white – but we cannot obtain this property by intersecting the set of things that are black and the set of things that are white. In fact, cases like this are referred to as instances of ‘non-Boolean conjunction’, and they are a big challenge for semantic theories that treat and as the natural language equivalent of Boolean AND.

“The panda is black and white”, in short, is a terrible example of Boolean logic. Or rather, it’s not an example of Boolean logic at all.

(What should we do with non-Boolean and? Perhaps people permit non-Boolean interpretations of conjunctions like “black and white” because these two concepts are mutually exclusive, which means their intersection is necessarily empty, which means that an expression like “black and white” could never be used to express anything true and informative. This is a waste of good language, so we’ve figured out a way to make conjunctions like this meaningful: enter the part this, part that interpretation. That this account is probably on the right track is suggested by a couple of really interesting studies by my colleague Eva Poortman, who shows that non-Boolean uses of and become increasingly acceptable to people the more they perceive the conjoined concepts as mutually exclusive.)

Non-Boolean behaviour of natural language or
Just as and sometimes behaves in a non-logical way that shows that we cannot just treat it as merely the natural language equivalent of set intersection, or has properties that set it apart from its associated Boolean operator. As you can see in the pictures above, the set union operation takes two sets A and B and throws all their members together into one big new set C; this means that any member of set C is also a member of set A OR set B. I’m writing ‘OR’ here rather than or precisely because one of the main differences between natural and logical disjunction: if a certain element is a member of both set A and set B, the union operation will by definition include it in set C, while most language users would say that the natural language statement “X is A or B” is false if X is both A and B. If I tell you that “John or Mary will come to my party”, you will likely be very surprised if you arrive at my party and find both John and Mary there. In technical terms, Boolean OR is inclusive (compatible with AND) while natural language or is often exclusive (incompatible with AND).

Why should this be so? The standard account of the exclusive behaviour of or is that or actually does have an inclusive meaning, but gets strengthened to ‘or… but not both’ in much of everyday communication because we reason that if it had been both, the speaker would have used and rather than or. One of the predictions of such an account is that or will not be interpreted exclusively if the hearer knows that the speaker lacks the knowledge to decide whether or or and would be more appropriate – for example, in a question. If someone asks me “Will Mary or John come to your party?”, it is clear that I’m not supposed to answer ‘no’ if I’m expecting both Mary and John – here, or is interpreted with its logical meaning of ‘or… and possibly both’. (The field of linguistics that studies this sort of non-logical inferences and the mechanisms that cause them to arise (or not arise) in certain communicative contexts is called pragmatics.) 

So, at first glance, the question-answer format of the baby programming book seems a good way to teach babies the properties of Boolean OR, since the behaviour of or in questions is often more ‘logical’ than its behaviour in assertions. However, the ‘…but not both’ inference is not the only non-logical inference that arises with natural language or. Another one is an inference called exhaustivity – for example, if you’re making me breakfast and ask me what I want to drink, and I tell you “coffee or orange juice”, you would probably conclude that I don’t want tea or a kale smoothie, even though from a logical perspective I have claimed no such thing – in fact, the logical properties of OR guarantee that if it is true that I want coffee it must also be true that I want coffee or juice or tea or a kale smoothie.

Intonation often determines whether certain pragmatic inferences arise or not, which is especially true for exhaustivity. Consider the following sentence from the baby programming book:

  1.  Is the penguin hot or cold?
Two pictures from Redmond's book (image via Daily Dot)

Two pictures from Redmond’s book (image via Daily Dot)

If we pronounce this with question intonation – a briefly falling and then rising pitch – on cold (“Is the penguin hot or COLD?”), there is no exhaustivity inference: the speaker considers it possible that the penguin is neither hot nor cold, so it would be informative and non-weird to answer this question with ‘yes’ or ‘no’ (as the programming book teaches babies to do). This is a valid exercise in Boolean logic (although it would have been even better if hot and cold hadn’t been mutually exclusive, which would’ve enabled the use of the disjunction in a context that makes both disjuncts true – see, for example, the rabbit and guinea pig picture below).

But this is, in my opinion, not the most natural intonation for sentence (2). If I had to pronounce (2) without realising I was supposed to be teaching Boolean algebra to a baby, I would pronounce it with a rising pitch on both hot and cold (“Is the penguin HOT or COLD?”), which conveys the expectation that the correct answer should be either the one or the other – not some third, unmentioned option. A major factor in this is the fact that hot and cold are antonyms, which makes it quite natural to assume a binary worldview in which anything that’s not hot is cold and anything that’s not cold is hot. In other words, the most natural way to read the question in (2) assumes that ‘hot or cold’ is an exhaustive disjunction. This makes the book’s scripted answer – ‘yes’ or ‘no’ – profoundly strange: if the mentioned options exhaust the possibilities, of course the answer will be yes. (In natural conversation, then, such questions aren’t interpreted as yes/no questions, but as ‘which one is it?’)

In short, the most natural way to interpret and read a question like “Is the penguin hot or cold?” treats the disjunction as exhaustive, but for this kind of question-answer exchange to be an exercise in Boolean logic (and for the intended yes/no answer to make sense) it crucially needs a non-exhaustive meaning and a somewhat less natural intonation pattern. This problem is not as serious as the non-Boolean and discussed above – parents just need to learn to ignore their own preference for an exhaustive intonation (and the additional confusion caused by the book’s capitalisation and underlining of or, which implies that it should be stressed) – but it does require quite a bit of semantic and pragmatic awareness on the reader’s part. None of which is actually necessary, since it is incredibly easy to come up with contexts in which the required non-exhaustive interpretation and corresponding intonation are more natural than the exhaustive one. Using non-antonymic words (for example, colour terms) and making the unmentioned option(s) prominent in the accompanying picture are two simple ways to make both parent and baby aware of the existence of more possibilities than the ones mentioned in the sentence. (Again, this is something the baby needs to be aware of if we want her to grasp the truth conditions of Boolean disjunction, instead of just messing up her understanding of how natural language works.)

Some alternative possibilities that make the required non-exhaustive reading more natural and teach that Boolean OR is inclusive.

Using non-antonymic words makes the required non-exhaustive reading more natural and prominent, and (if we want a really clever baby) enables us to teach her that Boolean OR is inclusive.

Let’s sum up (before this post becomes a book in itself). If we want to teach a baby logical concepts like AND and OR by using natural language, we have to keep in mind that English and and or do not always behave in a logical, Boolean way. If Eric Redmond wants his programming-for-babies book to work, he needs to pick his sentences and pictures more carefully to avoid unwanted non-Boolean behaviour – otherwise, instead of cultivating your child’s inner math nerd, the book may just end up messing with her acquisition of essential natural language concepts.

Fortunately, until there’s a better version of Boolean Logic for Babies for me to fund on Kickstarter, I’m pretty sure the ten-month-old terrorising our household will be perfectly happy if I just read her her favourite Miffy book once again. And again. And again….

About hannadevries

University lecturer (in linguistics/artificial intelligence) with occasional opinions on religion & social justice-related stuff.
This entry was posted in Language & linguistics and tagged , . Bookmark the permalink.

3 Responses to Boolean operators and programming lessons for babies

  1. Eric Redmond says:

    This is a fantastic writeup! I wish I would have seen this earlier. You’re absolutely right about the panda. Believe it or not, someone else brought this up. But we decided to go ahead because it, presents conjunction in a conversational way that even parents can understand. A “panda is black and white” is a sentence than comes to mind to many parents when talking about animals and conjunctions, a sort of base-state, like “A is for apple,” (which we’re all aware, A isn’t for apple, it’s just the first letter and for a great many things).

    This may surprise you to know, but babies won’t learn Boolean logic from this book (shocker! ;)). The purpose of this book is to introduce the primitives, inexact as they may be, in the same way that ABC or 123 books introduce writing primitives. The idea isn’t to be precise or exhaustive, but get babies to pay attention to the conjunctions they hear. My daughter actually uses the word “and” quite a bit now (“mama and dada and nana…”) rather than running them together, which is common for babies (“mama dada nana…”).

    • hannadevries says:

      Thank you for your gracious reply to a post that perhaps wasn’t very nice about your project! I guess nuance often gets lost in websites’ reporting on these projects, so instead of “this book playfully introduces connectives like ‘and’ and ‘or'” you get headlines like “this book teaches Boolean logic to babies!” and I’m left spluttering “but… but… what about all the intricacies and complications of ‘or’ and ‘and’ in natural language and why does no one ever pay attention to all the beautiful research that is done in linguistics?” I’m still not enthusiastic about the panda or about the somewhat unnatural-sounding question-answer patterns in the disjunction examples that I saw, but I’m glad to know more about the project, and to learn that you know your subject better than I’m afraid I have given you credit for. Anyway, here’s to babies learning stuff! My daughter is starting to talk now and it’s the most beautiful thing in the world.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s