[Haskell-cafe] and [] = True; or [] = False
Daniel Fischer
daniel.is.fischer at web.de
Mon Apr 26 08:26:40 EDT 2010
Am Montag 26 April 2010 14:15:40 schrieb Bjorn Buckwalter:
> Dear all,
>
> Does it make good sense that 'and []' returns 'True' and 'or []'
> returns 'False'? The Haskell Road to Logic, Maths and Programming says
> so:
>
> "The function or takes a list of truth values and returns True if at
> least one member of the list equals True, while and takes a list of
> truth values and returns True if all members of the list equal True."
>
> "Should the conjunction of all elements of [] count as true or false?
> As true, for it is indeed (trivially) the case that all elements of []
> are true. So the identity element for conjunction is True. Should the
> disjunction of all elements of [] count as true or false? As false,
> for it is false that [] contains an element which is true. Therefore,
> the identity element for disjunction is False."
>
> While the above reasoning is fine, and allows straight-forward
> implementations, it isn't extremely convincing. In particular, it
> isn't clear that, while simple, the definitions of the first paragraph
> are the most sensible. Perhaps one of the more mathematically versed
> readers on the Cafe could enlighten me?
It's necessary for
and (xs ++ ys) == and xs && and ys
and
or (xs ++ ys) == or xs || or ys
It's the same reason why sum [] == 0 and product [] == 1.
>
> What got me thinking about this was the apparently incorrect intuition
> that 'and xs' would imply 'or xs'.
Unless xs is empty
>
> Thanks,
> Bjorn
More information about the Haskell-Cafe
mailing list