Esempio n. 1
0
 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])
Esempio n. 2
0
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)]
Esempio n. 3
0
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)]
Esempio n. 4
0
 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]
Esempio n. 5
0
    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
Esempio n. 6
0
 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
Esempio n. 7
0
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
Esempio n. 8
0
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
Esempio n. 9
0
    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])
Esempio n. 10
0
def apply_edge_rel(rel_lit,arg1,arg2):
    return substitute_lit(rel_lit,{'X':arg1,'Y':arg2})
Esempio n. 11
0
 def test_lit(self,param,status):
     return substitute_lit(self.status_lit(status),{'X':param})
Esempio n. 12
0
 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]
Esempio n. 13
0
def apply_edge_rel(rel_lit, arg1, arg2):
    return substitute_lit(rel_lit, {'X': arg1, 'Y': arg2})
Esempio n. 14
0
 def test_lit(self, param, status):
     return substitute_lit(self.status_lit(status), {'X': param})