def test_mrs_robinson(self): f1 = Function("f", [Variable("X")]) f2 = Function("f", [Variable("Y")]) sigma = u.mrs_robinson(f1, f2) f1 = u.substitute(f1, sigma) f2 = u.substitute(f2, sigma) self.assertTrue(f1 == f2)
def test_mrs_robinson(self): f1 = Function("f",[Variable("X")]) f2 = Function("f",[Variable("Y")]) sigma = u.mrs_robinson(f1,f2) f1 = u.substitute(f1,sigma) f2 = u.substitute(f2,sigma) self.assertTrue(f1==f2)
def resolute(disj_a, disj_b): result_set = set([]) temp = deepcopy(disj_a), deepcopy(disj_b) if temp in memo: return memo[temp] for formula in disj_a: for other_formula in disj_b: if type(other_formula) == f.UnaryOperator and type( formula) == f.Relation: # if repr(formula) == "q(v1)": # pdb.set_trace() sigma = u.mrs_robinson(other_formula.term, formula) list_disj_a = [] list_disj_b = [] # simple case resolution possible if other_formula.term == formula: list_disj_a = list(disj_a) list_disj_b = list(disj_b) list_disj_a.remove(formula) list_disj_b.remove(other_formula) # difficult case resolution with unification possible elif sigma: list_disj_a = [ s_wrapper(x, sigma) for x in disj_a if not x is formula ] list_disj_b = [ s_wrapper(x, sigma) for x in disj_b if not x is other_formula ] else: print("Can not resolute", disj_a, "with", disj_b) continue resolvente = Disjunction(list_disj_a + list_disj_b) free_vars = disj_a.free_vars.union(disj_b.free_vars) #sig = {} #for var in free_vars: # sig[var] =next(gen_free()) #resolvente = Disjunction([ s_wrapper(x, sig) for x in resolvente ]) #resolvente.free_vars = set(sig.values()) #if repr(list_disj_a) == "[~r(v4)]": # pdb.set_trace() if not is_tautology(resolvente): print("sigma is ", sigma) print("Resoluting", disj_a, "with", disj_b, "to", resolvente) result_set.add(resolvente) else: print("Result is tautology (", disj_a, disj_a, ")", resolvente) memo[temp] = result_set return result_set