No-argument (and) returns t
Asked Answered
T

3

7

Both CL and Scheme define (and) to return t (or #t) with no arguments.

I'm trying to understand the rationale for this. My naive assumption is that an empty set is false, and passing in zero arguments feels like passing in nothing that can be true.

Edit: clojure follows the same convention. I must be missing some basic Lisp assumption.

Trivium answered 26/5, 2015 at 19:55 Comment(0)
I
17

The empty product is 1. The reason is that 1 is a neutral element for *.

If you have the product of 2 and 3 and then multiply by the product of nothing, you will get 2*3*1 = 6. We can write

  (product (product 2 3) (product)) 
= (product 6 1) 
= 6

The same computation with and:

  (and (and #t #t) (and)) 
= (and #t ?) 
= #t

We want the empty (and) to give a value ? that doesn't affect the result. The answer is #t since #t is a neutral element.

(and x #t) = x   for all boolean x
Idealize answered 26/5, 2015 at 20:11 Comment(6)
And similarly, an empty or should be false. In general, if you're generalizing a binary operator to be n-ary, it's useful to make the 0-ary case return the identify element of the operator.Cesena
The term for this is the "identity". Zero is the additive identity, one is the multiplicative identity. For logical and, the identity is true, and for logical or, the identity is false.Stratification
There is some background in the Empty product Wikipedia articleScurry
This makes sense. Thank you for explaining a more general concept to me.Trivium
I guess another way of saying this is to say that conjunction is like multiplication, it is the intersection of all arguments with the universal set. Universal set is 1 for multiplication and #t for conjunction.Trivium
The posh name for a neutral element of an operation is an identity. I'm sure you're aware of this, but your readers may not be.Michikomichon
U
7

Here's a more intuitive answer: an "and" is like a checklist: you're "done" (that is, true) when all of the things on the list are true. Suppose someone gave you an empty checklist; in that case, you have nothing to check off, and you're trivially done.

Ungainly answered 27/5, 2015 at 16:49 Comment(0)
C
4

Here's my attempt to put it as simple as possible: An and expression is false if and only at least one of its arguments is false, otherwise it is true. So it is trivially true if there are no arguments.

Corral answered 27/5, 2015 at 17:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.