def conclude(self, assumptions): ''' Try to automatically conclude this bi-directional implication by reducing its operands to true/false. ''' from . import iff_t_t, iff_t_f, iff_f_t, iff_f_f, true_iff_true, false_iff_false if self in {true_iff_true, false_iff_false}: # should be proven via one of the imported theorems as a simple # special case try: self.evaluation(assumptions) except BaseException: return self.prove() try: # try to prove the bi-directional implication via evaluation reduction. # if that is possible, it is a relatively straightforward thing to # do. return Operation.conclude(assumptions) except BaseException: pass try: # Use a breadth-first search approach to find the shortest # path to get from one end-point to the other. return TransitiveRelation.conclude(self, assumptions) except BaseException: pass # the last attempt is to introduce the Iff via implications each way, an # essentially direct consequence of the definition. return self.conclude_by_definition(assumptions)
def conclude(self, assumptions): from proveit.logic import FALSE if is_irreducible_value(self.lhs) and is_irreducible_value(self.rhs): # prove that two irreducible values are not equal return self.lhs.not_equal(self.rhs, assumptions) if self.lhs == FALSE or self.rhs == FALSE: try: # prove something is not false by proving it to be true return self.conclude_via_double_negation(assumptions) except BaseException: pass if hasattr(self.lhs, 'not_equal') and is_irreducible_value(self.rhs): try: return self.lhs.not_equal(self.rhs, assumptions) except BaseException: pass if hasattr(self.lhs, 'deduce_not_equal'): # If there is a 'deduce_not_equal' method, use that. # The responsibility then shifts to that method for # determining what strategies should be attempted # (with the recommendation that it should not attempt # multiple non-trivial automation strategies). eq = self.lhs.deduce_not_equal(self, assumptions) if eq.expr != self: raise ValueError("'deduce_not_equal' not implemented " "correctly; must deduce the 'inequality' " "that it is given if it can: " "'%s' != '%s'" % (eq.expr, self)) return eq try: return self.conclude_as_folded(assumptions) except BaseException: # try the default (reduction) return Operation.conclude(assumptions)
def conclude(self, assumptions): from proveit.logic import FALSE if isIrreducibleValue(self.lhs) and isIrreducibleValue(self.rhs): # prove that two irreducible values are not equal return self.lhs.notEqual(self.rhs) if self.lhs == FALSE or self.rhs == FALSE: try: # prove something is not false by proving it to be true return self.concludeViaDoubleNegation(assumptions) except: pass if hasattr(self.lhs, 'notEquals') and isIrreducibleValue(self.rhs): try: return self.lhs.notEqual(self.rhs, assumptions) except: pass try: return self.concludeAsFolded(assumptions) except: return Operation.conclude(assumptions) # try the default (reduction)