[Haskell-cafe] and  = True; or  = False
miguelimo38 at yandex.ru
Mon Apr 26 08:24:29 EDT 2010
Well, what's the sum of an empty list? Seems naturally that it's 0, but why?
Let's say that sum  = x.
If we take two lists, say, l1 = [1,2,3] and l2 = [4,5], then
sum l1 + sum l2 = 6 + 9 = 15 = sum [1,2,3,4,5] = sum (l1 ++ l2)
We expect it to be the case even if one of the lists is empty, so
x + 9 = sum  + sum l2 = <to be expected> = sum ( ++ l2) = sum l2 = 9
Therefore, x = 0.
With "and" we have the same thing:
and  = x
Let l1 = [True, True], l2 = [True, False]
and l1 && and l2 = True && False = False = and [True, True, True, False] = and (l1 ++ l2)
x && True = and  && and l1 = <to be expected> = and ( ++ l1) = and l1 = True
Therefore, x = True.
Bjorn Buckwalter wrote:
> Dear all,
> Does it make good sense that 'and ' returns 'True' and 'or '
> returns 'False'? The Haskell Road to Logic, Maths and Programming says
> "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?
> What got me thinking about this was the apparently incorrect intuition
> that 'and xs' would imply 'or xs'.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe