Here's what I am trying to do. I have a Prop
class defined as this:
class Prop:
def __init__(self, val, name=None):
self.val=val
self.name=name
def getVal(self):
return self.val
def giveName(self, newname):
self.name=newname
def getName(self, name):
return self.name
def changeVal(self, newval):
if type(newval)!=bool:
raise ValueError("You are trying to assign non-boolean value to the proposition")
else:
self.val=newval
As you can understand, Prop
objects should be regarded as propositions with boolean value ascribed to each one of them. Also I have defined a standard boolean function, implication:
def impl(p, q):
if p.getVal()==True and q.getVal()==False:
return Prop(False)
else:
return Prop(True)
Now what I want to do is to define a function which will take some expression like this impl(impl(p,q), r)
as the first of its arguments and a list of Prop
objects ([p,q,r]
) as the second one and check if this expression is true in regard with the propositions in the list. One important thing: if there's no proposition in the list which was mentioned in the expression, our program should regard this proposition as a false one. How can I do that?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…