Many programming environments have a mechanism for querying if every item in a collection of items satisfies some predicate. It is common for such a query to always evaluate as true for an empty collection. For example: • In
JavaScript, the
array method every executes a provided callback function once for each element present in the array, only stopping (if and when) it finds an element where the callback function returns false. Notably, calling the every method on an empty array will return true for any condition. • In
Python, the built-in all() function returns True only when all of the elements of an iterable (in this example, a list) are True or the iterable is empty: all([1,1])==True; all([1,1,0])==False; all([])==True. A less ambiguous way to express this is to say all() returns True when none of the elements are False. • In
Rust, the Iterator::all function accepts an iterator and a predicate and returns true only when the predicate returns true for all items produced by the iterator, or if the iterator produces no items. • In SQL, the function, the function ANY_VALUE can differ depending on the RDBMS's behaviour relating
NULLs to vacuous truth. Some RDBMS might return null even if there are non-null values. Some DBMS might not allow for its use in filter(...) or over(.. ) clauses. • In
Kotlin, the collection method all returns true when the collection is empty. • In
C#, the Linq method All returns true when the collection is empty. • In
C++, the std::all_of function template returns true for an empty collection. • In
Agda, an empty type (for example, ⊥, which is defined with no constructors) is 'false' at the type level, following the
Curry–Howard correspondence. A parameter of such a type can be matched against an 'absurd' pattern and an equation containing such a pattern has no right hand side. The principle of
ex falso quodlibet can be defined this way as a function efq : ∀ {n} {a : Set n} → ⊥ → a. The function efq is then a proof of the vacuously true proposition ⊥ → a for every proposition (i.e. type) a. For example, it is a proof of ⊥ → ⊥. == Examples ==