Reply content:
List().forall(f)
I think the other answers mentioned in the vacuous truth
has already answered this question very simply,
True&&x -- => xx&&True -- => x
"All elements are odd" at the price of "no element is not an odd number."
There is no element in an empty set, and naturally there is no "element of the Singularity". Therefore, there is no element in an empty set that is not an odd number, that is, all the elements of the void are odd numbers.
If the elements of a set are all odd, then the elements of his subset should all be odd.
{1} is obviously a "singular set", so its subset {} should also be a "singular set".
First See vacuous truth
This concept tends to be irrational and difficult to understand. But if you take a closer examination, you will find that this is the only logical explanation. @ zu and the account of the "unit of the Yuan" in the words.
Wikipedia on empty product
This one is also very well explained. Set X1 x2 to two arrays,
According to common sense there should be odd (x1:::x2) =odd (x1) &odd (x2)
Take x1=[] x2 non-empty Get odd ([]) =true from a program implementation point of view, meet all the simplest logic is that there is a non-satisfied demand to return to the not (circular judgment), and finally the default is true, similar to the rapid failure of the policy, so the result of the empty collection is true. The pseudo code is as follows
for x in xs if x is not odd return falsereturn true
If you use recursive writing to determine whether an array is a singular method
Head (x) x removes the last element
The last element of Tail (x) x
Odd (x) =odd (Head (x)) && (tail (x)%2==1) "I'm sorry grammar is a little forgotten.
So when x has only one element, it is
Odd (empty set) && (tail (x)%2==1)
At this point the odd (empty set) can only be expressed in the semantics of the Trueall F xs:
All elements in XS satisfy the condition F
Also namely:
There is no element in XS that does not meet the condition F
Therefore, [] does not exist in ... The element, of course, is true
The semantic reason for this, @Geek. CS has made it very clear that the implementation of the details @ ancestor and occupy also has been said very clearly,
So if you design a standard library and design a generic all function, it's basically not the other way.
Of course, if you need special handling of the empty set in your specific application scenario, you can wrap a special all of your own, for example, you can return nothing when you accept [], of course, the return value type is maybe. The implementation of the standard library, in the case of not returning to maybe, can also do logical self-consistency, it is naturally not to choose to achieve the use of such a troublesome thing. Short ver: What do you think you should return? False? Error? Maybe Bool? Mathematically called vacuous truth:vacuous truth
A long time ago, the topology class was often used
This is very intuitive, why the Lord will feel anti-human. Like the example in a wiki, if one asks, "are all the phones in this room turned off?" "If everyone in the room doesn't have a cell phone, the normal person won't answer No."
Perhaps better understood by the inverse of the proposition: there are no even numbers in the array