# Logical functions with no arguments

I am trying to understand how logical functions are evaluated if no arguments are passed to them.

{Or[], Nor[], And[], Nand[], Xor[], Xnor[]}


{False, True, True, False, False, True}

I tried Trace but it didn't offer many clues. Mathematica (12.2.0 on Win7-x64) evaluates these expressions without any messages.

• If you have a look in the Properties and relations section you will see that it zero-argument evaluates to False. reference.wolfram.com/language/ref/Or.html
– kcr
Feb 28, 2022 at 8:39
• Similar situation in Java developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
– kcr
Feb 28, 2022 at 8:39
• Perhaps this is the way they are supposed to be constructed based on theoretical coding principles? Sorry for the triple comment...I am horrible
– kcr
Feb 28, 2022 at 8:40
• These are simply the trivial cases for these functions. And, for example, is True unless one of it's arguments is False. The zero-argument case is just an extension of that. Feb 28, 2022 at 11:05
• One sees similar behavior with Plus and Times (where it might be more obviously plausible). Symbols with the OneIdentity attribute will, when given an empty argument list, evaluate to their respective identity elements. Feb 28, 2022 at 15:57

I am pretty sure that Syed figured out the question by now, but for future visitors I thought it a good idea to write something.

1. Why does Or[] return False?

From the docs we read

It evaluates its arguments in order, giving True immediately if any of them are True, and False if they are all False.

which is another way of saying that it returns True if any or all of its arguments is true and False otherwise.

1. Why does Nor[] return True?

The easiest way to realize this -I think- is again to have a look at the documentation where we find that it is equivalent to Not[Or[]]. So, Not[False] is True.

1. Why does And[] return True?

Well, again this can be seen directly from the docs and also from the comment by @Sjoerd Smit.

It evaluates to False if any of its arguments are false, and to True otherwise.

1. Why does Nand[] return False?

Similar to the explanation of Nor in this case. Nand[] is equivalent to Not[And[]] and hence Not[True] which is False.

1. Why does Xor[] return False?

Well, it has to evaluate all of its argument and yields True if an odd number of them is True and False otherwise. Since, we do not have an odd number of True statements, it returns False

1. Why does Xnor[] return True?

Xnor[] is equivalent to Not[Xor[]]

• Thanks for the write up.
– Syed
Jan 14 at 12:56
• @Syed if you want to add more to it, let me know and I will turn it into a wiki :-)
– bmf
Jan 14 at 12:58
• It seems that in your description of Nor True and False should be reversed. Jan 14 at 19:26
• @yarchik yes, of course you are right. thanks for spotting this :-)
– bmf
Jan 15 at 1:38

The answer of @bmf is perfect, but I would like to bring some arguments that allow us to better remember the results. It also shows a connection to other MA functions.

The Xor function can be seen as Sum modulo 2. In fact

Sum[1, {i, 0}]
(* 0 *)


which explains why Xor[] == False.

The And function can be regarded as the Product modulo 2. In fact

Product[1, {i, 0}]
(* 1 *)


which explains why And[] == True.

See also a comment of @DanielLichtblau above, which argues in terms of Plus and Times.

• (+1) that's a very neat description!!!
– bmf
Jan 15 at 1:39