# Newbie: Truth values (three-valued logic)

mgutierrez at dss.es mgutierrez at dss.es
Fri Jun 18 05:30:53 EDT 1999

```In article <000201beb946\$b9c99e00\$969e2299 at tim>,
"Tim Peters" <tim_one at email.msn.com> wrote:
> > ...
> > It came to my mind, though, that redefining negation alone will not
> > help. Next time I'll want to redefine 'and' and 'or'. So, unless
> > python 2 implements three-valued logic <hint, hint :)>, I'll have
> > to come up with a routine for myself to handle these truth values
> > consistently.
>
> Well, "and" and "or" do short-ciruit evaluation (i.e., they don't
evaluate
> their right-hand operand at all if the value of their left-hand
operand
> suffices to determine the result).  For that reason, they're more
properly
> viewed as control structures than operators, and so unlikely to get
"opened
> up" to user intervention.
>
> "&" and "|" instead of "and" and "or".  Then you can do whatever you
want.
> If I were you I'd consider not overloading anything, and using ~ & |
> directly with a naming trick, like so:
>
> f, t, m = 0, -1, 42
> name = {0: 'false', -1: 'true', 42: 'maybe', ~42: 'maybe'}

"Not maybe" equals to "not".
Imagine this case:
Maybe, I'll go to the cinema tomorrow.
If you say, not "maybe, I'll go to the cinema tomorrow", then you are
saying not to go the cinema. Imagine:
Johan: Maybe, we could go to the cinema tomorrow.
Anthony: No
Johan : ok, let's go to the zoo, to see that python.

I'd propose another solution, if we currently have:

class a:
def __init__():
pass
pass

e=a(); f=a()
h = e + f

why not :
class a:
....
def __or__(c,d):
pass
def __and__(e,f):
pass

you could even include three logic behaviour in the operator,
so if c = true d= true then __or__ returns true if it has certain
probability.
if c = true d= false returns true if a random value is greater than
0.34 ,...
...

Regards
Manolo

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

```