def empty_edge(self, rel_lit, head, tail): g = self fmla = [~lit for lit in head.fmla] + [ ~substitute_lit(lit, {'X': Variable('Y')}) for lit in tail.fmla ] + [~rel_lit] # print "adding clause: %s" % fmla self.add_constraints([fmla])
def get_lit_facts(h, lit, res): vs, rows = h.check(lit) ## print "rows = {}".format(rows) for r in rows: ## print "r = {}".format(r) subst = dict(zip([v.rep for v in vs], r)) ## print "subst = {}".format(subst) res += [substitute_lit(lit, subst)]
def get_definite_facts(self, names, tvals): edges = self.get_edges() return [[ substitute_lit( Literal(1 if status == 'true' else 0, self.rel_lit.atom), {'X': get_witness(p1)}) ] for (p1, ), status in edges if status != 'undef' and status in tvals and p1.name in names]
def check_edge(self,f1,solver): x = var_to_skolem('__',Variable('X',self.sorts[0])).suffix(str(self.sorts[0])) solver.push() s_add(solver,cube_to_z3(substitute_clause(f1,{'X':x}))) # print "xsort: {}, ysort: {}".format(x.get_sort(),y.get_sort()) # print "rel_lit: {}, subs: {}".format(self.rel_lit,substitute_lit(self.rel_lit,{'X':x,'Y':y})) res = s_check_cube(solver,[substitute_lit(self.rel_lit,{'X':x})]) solver.pop() return res
def check_edge(self, f1, solver): x = var_to_skolem('__', Variable('X', self.sorts[0])).suffix(str(self.sorts[0])) solver.push() s_add(solver, cube_to_z3(substitute_clause(f1, {'X': x}))) # print "xsort: {}, ysort: {}".format(x.get_sort(),y.get_sort()) # print "rel_lit: {}, subs: {}".format(self.rel_lit,substitute_lit(self.rel_lit,{'X':x,'Y':y})) res = s_check_cube(solver, [substitute_lit(self.rel_lit, {'X': x})]) solver.pop() return res
def make_lit_label(lit): # pred = lit.atom.relname # if pred != "=": # label = pred # else: # terms = lit.atom.args # arg = 1 if isinstance(terms[0],Variable) else 0 # label = "=" + lit.atom.args[arg].rep for v in used_variables_ast(lit): return repr(substitute_lit(lit,{v.rep:Variable('',v.sort)})).replace(' ','').replace('()','') label = str(lit.atom) return label if lit.polarity == 1 else "~" + label
def make_lit_label(lit): # pred = lit.atom.relname # if pred != "=": # label = pred # else: # terms = lit.atom.args # arg = 1 if isinstance(terms[0],Variable) else 0 # label = "=" + lit.atom.args[arg].rep for v in used_variables_ast(lit): return repr(substitute_lit(lit, {v.rep: Variable('', v.sort)})).replace( ' ', '').replace('()', '') label = str(lit.atom) return label if lit.polarity == 1 else "~" + label
def empty_edge(self,rel_lit,head,tail): g = self fmla = [~lit for lit in head.fmla] + [~substitute_lit(lit,{'X':Variable('Y')}) for lit in tail.fmla] + [~rel_lit] # print "adding clause: %s" % fmla self.add_constraints([fmla])
def apply_edge_rel(rel_lit,arg1,arg2): return substitute_lit(rel_lit,{'X':arg1,'Y':arg2})
def test_lit(self,param,status): return substitute_lit(self.status_lit(status),{'X':param})
def get_definite_facts(self,names,tvals): edges = self.get_edges() return [[substitute_lit(Literal(1 if status =='true' else 0,self.rel_lit.atom), {'X':get_witness(p1)})] for (p1,),status in edges if status != 'undef' and status in tvals and p1.name in names]
def apply_edge_rel(rel_lit, arg1, arg2): return substitute_lit(rel_lit, {'X': arg1, 'Y': arg2})
def test_lit(self, param, status): return substitute_lit(self.status_lit(status), {'X': param})