def testFD(self): rules = [Negation(),Commutativity(),Identity(),Domination(),Idempotence(),Associativity(),Exportation(),Distributivity(),Absorption(),DoubleNegation(),DeMorgans(),ImplicationLaw()] s = '(p implies q) & (q -> p)' g = '(~p & ~q) v (q & p)' steps = findDerivation(s,g,rules) for s in steps: print s.cost, "\t", s.action,"\t\t", s.state
def testBug(self): print "buggy test" start = "p" goal = "p" steps = findDerivation(start, goal, rules) print "\nDemonstrate that", start, "is logically equivalent to", goal print "\nCost:\tEst%Complete\tRule:\t\t\t\tStatement:" if steps: for s in steps: print s.cost, "\t", distance(str(s.state), str(goal)), "\t\t", s.action, "\t\t", s.state print "\nTherefore, ", start, " = ", goal, "."
def testSearch3H(self): print "\n\n******Prove 3H******" start = "~(p -> q)" goal = "p & ~q" steps = findDerivation(start, goal, rules) print "\nDemonstrate that", start, "is logically equivalent to", goal print "\nCost:\tRule:\t\t\t\tStatement:" for s in steps: print s.cost, "\t", round( float(s.cost) / (s.cost + distance(str(s.state), str(logicParse(goal)))), 2 ), "\t\t", s.action, "\t\t", s.state print "\nTherefore, ", start, " = ", goal, "."
def testSearchHW1(self): print "\n\n******Hard Problem******" # (p -> q) & (q -> p) start # (~p v q) & (~q v p) implication # ((~p v q) & ~q)&((~p v q) & p) distribution # ((~p & ~q) v (q & ~q)) v ((p & ~p) v (q&p)) distribution # (~p & ~q) v (q&p) ??? start = "(p -> q) & (q -> p)" goal = "(~p & ~q) v (q &p)" steps = findDerivation(start, goal, rules) print "\nDemonstrate that", start, "is logically equivalent to", goal print "\nCost:\tEst%Complete\tRule:\t\t\t\tStatement:" for s in steps: print s.cost, "\t", distance(str(s.state), str(goal)), "\t\t", s.action, "\t\t", s.state print "\nTherefore, ", start, " = ", goal, "."
def searchProfile(): rules = [Negation(),Commutativity(),Identity(),Domination(),Idempotence(),Associativity(),Exportation(),Distributivity(),Absorption(),DoubleNegation(),DeMorgans(),ImplicationLaw()] s = '(p implies q) & (q -> p)' g = '(~p & ~q) v (q & p)' for i in range(20): steps = findDerivation(s,g,rules,cache=False)