def _check(expression): """method performing check""" if background_knowledge: e = AndExpression(expression.fol(), background_knowledge) if verbose: print "performing check on: %s" % e t = Theorem(NegatedExpression(e), e) else: if verbose: print "performing check on: %s" % expression.fol() t = Theorem(NegatedExpression(expression), expression) result, output = t.check() if verbose: if output: print "\nMace4 returns:\n%s\n" % output else: print "\nProver9 returns: %s\n" % (not result) return result
def theorem_proving(prove_fun, premises, conclusion, predicates, lst): res = prove_fun(premises, conclusion, predicates, lst) if res: prediction = 'yes' else: negated_conclusion = NegatedExpression(conclusion) res = prove_fun(premises, negated_conclusion, predicates, lst) if res: prediction = 'no' else: prediction = 'unknown' return prediction
def theorem_proving(prove_fun, premises, conclusion, predicates, lst, axioms, mode, data): res = prove_fun(premises, conclusion, predicates, lst, axioms, mode) if res: prediction = 'yes' else: if data not in datasets: negated_conclusion = NegatedExpression(conclusion) res = prove_fun(premises, negated_conclusion, predicates, lst, axioms, mode) if res: prediction = 'no' else: prediction = 'unknown' else: prediction = 'unknown' return prediction
def assumptions(self): assumptions = self._command.assumptions() predicates = self._make_predicate_dict(assumptions) new_assumptions = [] for p in predicates: predHolder = predicates[p] new_sig = self._make_unique_signature(predHolder) new_sig_exs = [VariableExpression(v) for v in new_sig] disjuncts = [] # Turn the signatures into disjuncts for sig in predHolder.signatures: equality_exs = [] for v1, v2 in zip(new_sig_exs, sig): equality_exs.append(EqualityExpression(v1, v2)) disjuncts.append(reduce(lambda x, y: x & y, equality_exs)) # Turn the properties into disjuncts for prop in predHolder.properties: # replace variables from the signature with new sig variables bindings = {} for v1, v2 in zip(new_sig_exs, prop[0]): bindings[v2] = v1 disjuncts.append(prop[1].substitute_bindings(bindings)) # make the assumption if disjuncts: # disjuncts exist, so make an implication antecedent = self._make_antecedent(p, new_sig) consequent = reduce(lambda x, y: x | y, disjuncts) accum = ImpExpression(antecedent, consequent) else: # nothing has property 'p' accum = NegatedExpression(self._make_antecedent(p, new_sig)) # quantify the implication for new_sig_var in new_sig[::-1]: accum = AllExpression(new_sig_var, accum) new_assumptions.append(accum) return assumptions + new_assumptions
def clone(self): new_agenda = Agenda() set_list = [s.copy() for s in self.sets] new_allExs = set() for allEx,_ in set_list[Categories.ALL]: new_allEx = AllExpression(allEx.variable, allEx.term) try: new_allEx._used_vars = set(used for used in allEx._used_vars) except AttributeError: new_allEx._used_vars = set() new_allExs.add((new_allEx,None)) set_list[Categories.ALL] = new_allExs set_list[Categories.N_EQ] = set((NegatedExpression(n_eq.term),ctx) for (n_eq,ctx) in set_list[Categories.N_EQ]) new_agenda.sets = tuple(set_list) return new_agenda
def fol(self): return NegatedExpression(self.term.fol())
def prove_negative(queue): negated_conclusion = NegatedExpression(conclusion) res = prove_fun(premises, negated_conclusion, predicates, lst, axioms, mode) is_prover = False queue.put((is_prover, res))