<br><br><div><span class="gmail_quote">On 7/10/07, <b class="gmail_sendername">Gael Varoquaux</b> <<a href="mailto:gael.varoquaux@normalesup.org">gael.varoquaux@normalesup.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, Jul 10, 2007 at 02:39:28PM +0200, Sebastian Haase wrote:<br>> When you talk about algebra - one might have to restrict one self to '|' and '&'<br>> -- not use '+'  and '-'
<br>> E.g.:<br>> True - True = False   # right !?<br>> # but if:<br>> True+True         = True.<br>> # then<br>> True+True   -False      = True -False   # ????<br>> # here I'm already lost ... I don't think this can be done in a consistent way.
<br><br>It can, its called the Bool algebra, and it is a consistent algebra, in a<br>mathematical sense of algebra<br>(<a href="http://en.wikipedia.org/wiki/Boolean_algebra">http://en.wikipedia.org/wiki/Boolean_algebra</a>
), actually what we are<br>talking about is the two element bool algebra<br>(<a href="http://en.wikipedia.org/wiki/Two-element_Boolean_algebra">http://en.wikipedia.org/wiki/Two-element_Boolean_algebra</a>), and the<br>mathematical structure we are taling about is a ring, the wikipedia
<br>article is quite comprehensible<br>(<a href="http://en.wikipedia.org/wiki/Ring_(mathematics)">http://en.wikipedia.org/wiki/Ring_(mathematics)</a>)<br><br>> In other words:  a "+" operator  would also need a corresponding "-"
<br><br>Yes. In other words (the ensemble theory words) each element needs to<br>have an opposite concerning the '+' law. To understand this you need a<br>bit of algebra theory.<br><br>* An algebra has 2 laws, lets call them "+" and "*".
<br><br>* Each law has a neutral element for this law, ie an element a for which<br>  "a + b = b" for all b in the algebra, lets write these "n+", and "n*".<br><br>* Each element a is required to have an inverse for the "+", ie an element
<br>  b for wich b + a = n+, lets write the opposite of b "-b".<br><br>For integer, n+ = 0, n* = 1.<br><br>For Booleans, n+ = False, and n+ = True, therefore, as Matthieu points out,<br>-True = True, as True + True = n+ = True,
<br>and -False = True, as True + False = n+ = True.<br><br>So you have a consistent algebra.<br><br>Now there is a law for which every element does not have an inverse, it<br>the "*" law. You can check the out for integers. It is also true for
<br>booleans. In fact, you can proove that in an ring, n+ cannot have an<br>inverse for the * law (it the famous divide by zero error !).<br><br>In conclusion, I would like to stress that, yes, +, - and * are well<br>defined on booleans, the definition is universal, and please don't try to
<br>change it.</blockquote><div><br>The proper additive operation to make boolean algebra a ring is 'xor', so that 1 becomes its own inverse. Same thing in sigma rings, where folks used to use exclusive union just to make the algebra to work. But plain 'or' and 'union' work fine and are more intuitive even if they don't give the ring structure.
<br></div><br>Chuck<br></div><br>