I have implemented the above implication in Python but it does not return the expected results:
True True None
True False None
False True True
False False None
My python code is:
def implies(a,b):
if a:
return b
else:True
return
for p in (True, False):
for q in (True, False):
print("%10s %10s %s" %(p,q,implies((p or q) and (not p), q)))
I don't understand the contradiction here. None implies False doesn't it? And why not print True like it should?
else: True
should beelse: return True
. As is it doesn't do anything.implies
with the valueTrue
, if every result is expected to beT
.return not a or b
will do the trick as well.