10
$\begingroup$

I originaly asked a question on Programmers.SE to know why $0$ was consider $\text{false}$ and all the other [integral] values were considered $\text{true}$. That was a huge debate and many said it was a legacy from Boolean algebra where $0$ is indeed $\text{false}$ and $1$ is $\text{true}$.

Somebody suggested I go further and ask here why this is actually the case in Boolean algebra. So here is the question: what is the rationale for $0$ to be $\text{false}$ and $1$ to be $\text{true}$ and not the other way around in Boolean algebra?

| cite | improve this question | | | | |
$\endgroup$
  • 1
    $\begingroup$ This isn't really a universal property, it's a property of C and all C-like languages. I suspect that the reason is the instruction set of the first machines C was implemented on could only do conditional jumps based on whether a value is zero or non-zero... Mathematically, $0$ isn't the only choice, though it certainly isn't a bad choice as Nick Kidman has pointed out in his answer. $\endgroup$ – fgp May 16 '13 at 12:53
  • $\begingroup$ @fgp After having read all the answers and comments on my original question on Programmers.SE, I agree with you, but could please keep the programming languages talk on the other topic and only talk about the Boolean algebra choices on this one? :) $\endgroup$ – Morwenn May 16 '13 at 13:44
9
$\begingroup$

The numbers you use essentially don't matter. But if you want to represent your $2^4$ truth functions (see Wikipedia) using arithmetic, then $0,1$ come in handy. This is because their properties of being the additive and multiplicative neutral element simplifies some computations.

You can represent the functions using any numbers, really. If $a$ can be a number representing $\text{true}$ or another number representing $\text{false}$, then

$$\text{NOT}(a):=\text{true}+\text{false}-a$$

works out for defining the negation. For example

$$\text{NOT}(\text{true}):=\text{true}+\text{false}-\text{true}=\text{false}.$$

Here follows a nice graphic showing all the general constructions. As examples, the use of $\{0,1\}$ and also $\{-1,1\}$ is demonstated. Notice how using $0$ "for $\text{false}$" eliminates all the terms involving the number $s_0$, making the $\{0,1\}$ column specifically short and simple for computations.

enter image description here

| cite | improve this answer | | | | |
$\endgroup$
  • $\begingroup$ The guy that told me to ask the question there was right: that is both simple and comprehensive. I also note that using $1,0$ instead of $0,1$ seems as simple to compute. Thanks :) $\endgroup$ – Morwenn May 16 '13 at 12:55
  • $\begingroup$ @Morwenn: Switching $\{s_0,s_1\}$ amounts to switching all resulting truth values. So to find any truth function with these switched representations, concatenate the it with the (old) negation function. For $\{0,1\}$ the negation is $NOT(a):=1-a$ and e.g. $A>B$ is $A>B\ (a,b):=a-ab$. Now $NOT(A>B\ (a,b))=1-(a-ab)=1-a+ab$ and if you check the board you see that this is exactly the function $A\leq B$. So in general, if you consider a representation $\{s_0,s_1\}$ and you have a truth function $f(a,b)$, then the associated switched function, according to the table, is given by $(s_0+s_1)-f(a,b)$. $\endgroup$ – Nikolaj-K May 16 '13 at 13:42
  • $\begingroup$ I now see that more generally, if you got truth representations $\{s_0,s_1\}$ and you change them to $\{s_0+x,s_1+y\}$, the you just have to change all truth functions $f$ to $f+(x (s_1-f)-y (s_0-f))/(s_1-s_0)$. You get the switch $\{s_0,s_1\}\mapsto \{s_1,s_0\}$ via $x=s_1-s_0,y=-x$, in which case the function becomes $(s_0+s_1)-f$ as I noted above. $\endgroup$ – Nikolaj-K May 19 '13 at 16:34
  • $\begingroup$ @Morwenn: The fact is that it is undoubtedly natural to use the value 0 as the neutral element for (Boolean) “addition” (and absorbing element for multiplication), resp. 1 as the neutral element for “multiplication”. But one could also have said that AND corresponds to addition, resp. OR to multiplication: that might actually have been nicer, since in everyday language addition is referred by the word “and” indeed! $\endgroup$ – Rémi Peyre Mar 24 '18 at 0:34
4
$\begingroup$

I wouldn't be surprised if a version of this convention goes back to Boole himself, in his algebra of classes. I believe he used $0$ for the empty class and $1$ for the class of "everything". (This was before the set-theoretic paradoxes made people queasy about the class of everything.) Under the natural correspondence between classes and functions to "true" and "false" (where a class $C$ corresponds to the function sending elements of $C$ to "true" and "everything" else to "false"), these would be the constant "false" function for $0$ and the constant "true" function for $1$. So it was natural and convenient to identify the truth values with these numbers.

| cite | improve this answer | | | | |
$\endgroup$
  • $\begingroup$ Indeed, actually you can see this convention as requiring that the indicator function $\mathbf{1}_{A}$ (which is $1$ if $A$ is true, resp. $0$ if $A$ is false) corresponds to identity. It would be absurd to define the indicator function the other way, since, for instance, you want that the expectation $\mathbb{E}(\mathbf{1}_A)$ for the indicator of $A$ is the probability $\mathbb{P}(A)$ of $A$ itself, not of its complement… $\endgroup$ – Rémi Peyre Mar 26 '18 at 16:06
  • $\begingroup$ In the other way, if you want to interpret a number as a boolean, that is, to define a canonical map $\mathbb{N}\to\{\mathit{true},\mathit{false}\}$, it seems more natural to say that $0$ is true and everything else is false, since there is only one way to be true and many to be false. Then addition is compatible with the AND operator (quite pleasant that addition is AND!), resp. multiplication with the OR operator. And the indicator becomes the map $n\mapsto0^n$… So, this explains the shell convention when $0$ is false and everything else true, which may be more convenient for programming. $\endgroup$ – Rémi Peyre Mar 26 '18 at 16:15
  • $\begingroup$ But obviously, it would not be nice that the convention to convert numbers into booleans would not be compatible with the convention to convert booleans into numbers… So, at some point a choice has to be done, the most relevant one depending on the context: do you want to test if something is true—then better to take $\mathit{true} = 0$—or to count the number of time something occurs—then better to take $\mathit{true} = 1$—?… $\endgroup$ – Rémi Peyre Mar 26 '18 at 16:19
0
$\begingroup$

I believe this has to do with boolean algebra where or is considered as plus operation and and is considered to be multiplication. If we assign false to 0 and true to 1 then the usual arithmetic works.

| cite | improve this answer | | | | |
$\endgroup$
  • 2
    $\begingroup$ The operations in a boolean algebra are usually called conjunction ($\cap$ or $\land$), disjunktion ($\cup$ or $\lor$) and negation ($.^C$, $\overline{.}$ or $\lnot$). Calling them addition and multiplication is missleading, because in a boolean algebra both conjunction and disjunktion are distributive to each other, i.e. $(a \land b) \lor c = (a\lor c) \land (b\lor c)$ and $(a \lor b) \land c = (a\land c) \lor (b\land c)$, while you don't usually have that $(a\cdot b) + c = (a + c)\cdot(b+c)$ $\endgroup$ – fgp May 16 '13 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.