示例#1
0
文件: ivy_graph.py 项目: asyaf/ivy
 def extra_concepts(self):
     tn = self.text_name()
     X,Y = self.variable('X'),self.variable('Y')
     c = [Literal(1,Atom(tn,[X])),~eq_lit(X,Y),Literal(1,Atom(tn,[Y]))]
     cs = [ProductSpace([NamedSpace(x) for x in c])]
     w = get_witness(self)
     if w:
         cls = [[~lit,eq_lit(X,w)] for lit in self.fmla]
         cs += [ProductSpace([NamedSpace(x) for x in c]) for c in cls]
     return cs
示例#2
0
 def extra_concepts(self):
     tn = self.text_name()
     X, Y = self.variable('X'), self.variable('Y')
     c = [
         Literal(1, Atom(tn, [X])), ~eq_lit(X, Y),
         Literal(1, Atom(tn, [Y]))
     ]
     cs = [ProductSpace([NamedSpace(x) for x in c])]
     w = get_witness(self)
     if w:
         cls = [[~lit, eq_lit(X, w)] for lit in self.fmla]
         cs += [ProductSpace([NamedSpace(x) for x in c]) for c in cls]
     return cs
示例#3
0
 def splatter(self, node, constants=None):
     if constants == None:
         constants = used_constants_clauses(self.constraints)
     eqs = [
         eq_lit(node.variable('X'), Constant(c)) for c in constants
         if c.sort == node.sort
     ]
     #        print "splatter eqs = {}".format(eqs)
     self.split_n_way(node, eqs)
示例#4
0
文件: ivy_graph.py 项目: asyaf/ivy
 def split(self,node,p):
     if isinstance(p,tuple):
         self.split_n_way(node,[eq_lit(p[0],x) for x in p[1]])
         return
     label = make_lit_label(p)
     posname = node.name + "+" + label
     negname = node.name + "-" + label
     self.all_nodes = [n for n in self.all_nodes if n is not node]
     self.all_nodes.append(GraphNode(posname, node.fmla + [p],node.sort))
     neg_p = Literal(1-p.polarity,p.atom)
     self.all_nodes.append(GraphNode(negname, node.fmla + [neg_p],node.sort))
     self.needs_recompute = True
示例#5
0
 def split(self, node, p):
     if isinstance(p, tuple):
         self.split_n_way(node, [eq_lit(p[0], x) for x in p[1]])
         return
     label = make_lit_label(p)
     posname = node.name + "+" + label
     negname = node.name + "-" + label
     self.all_nodes = [n for n in self.all_nodes if n is not node]
     self.all_nodes.append(GraphNode(posname, node.fmla + [p], node.sort))
     neg_p = Literal(1 - p.polarity, p.atom)
     self.all_nodes.append(
         GraphNode(negname, node.fmla + [neg_p], node.sort))
     self.needs_recompute = True
def update_frame_constraint(update, relations):
    """ Return a clause list constraining all updated symbols
    to keep their previous values """
    clauses = []
    for sym in update[0]:
        if sym in relations:
            arity = relations[sym]
            vs = [Variable("V{}".format(i)) for i in range(0, arity)]
            lit1 = Literal(1, Atom(sym, vs))
            lit2 = Literal(1, Atom(new(sym), vs))
            clauses += [[~lit1, lit2], [lit1, ~lit2]]
        else:
            clauses.append([eq_lit(Constant(sym), Constant(new(sym)))])
    return Clauses(clauses)
示例#7
0
文件: ivy_transrel.py 项目: odedp/ivy
def update_frame_constraint(update,relations):
    """ Return a clause list constraining all updated symbols
    to keep their previous values """
    clauses = []
    for sym in update[0]:
        if sym in relations:
            arity = relations[sym]
            vs = [Variable("V{}".format(i)) for i in range(0,arity)]
            lit1 = Literal(1,Atom(sym,vs))
            lit2 = Literal(1,Atom(new(sym),vs))
            clauses += [[~lit1,lit2],[lit1,~lit2]]
        else:
            clauses.append([eq_lit(Constant(sym),Constant(new(sym)))])
    return Clauses(clauses)
示例#8
0
文件: ivy_graph.py 项目: asyaf/ivy
    def witness(self,node):
        g = self
        for lit in node.fmla:
#            print lit
            if is_equality_lit(lit) and isinstance(lit.atom.args[0],Variable):
                self.add_witness_constraint(node,lit.atom.args[1])
                return lit.atom.args[1]
        uc = used_symbols_clauses(g.state)
        fmlas = [n.fmla for n in g.all_nodes]
        for f in fmlas:
            uc.update(used_symbols_clause(f))
        nc = unused_constant(uc,node.sort)
#        print "type(nc) = {}".format(type(nc))
        self.add_witness_constraint(node,nc)
        self.split(node,eq_lit(Variable('X',node.sort),nc))
        return nc 
示例#9
0
 def witness(self, node):
     g = self
     for lit in node.fmla:
         #            print lit
         if is_equality_lit(lit) and isinstance(lit.atom.args[0], Variable):
             self.add_witness_constraint(node, lit.atom.args[1])
             return lit.atom.args[1]
     uc = used_symbols_clauses(g.state)
     fmlas = [n.fmla for n in g.all_nodes]
     for f in fmlas:
         uc.update(used_symbols_clause(f))
     nc = unused_constant(uc, node.sort)
     #        print "type(nc) = {}".format(type(nc))
     self.add_witness_constraint(node, nc)
     self.split(node, eq_lit(Variable('X', node.sort), nc))
     return nc
示例#10
0
文件: ivy_graph.py 项目: asyaf/ivy
    def splatter(self,node,constants = None):
        if constants == None:
            constants = used_constants_clauses(self.constraints)
        eqs = [eq_lit(node.variable('X'),Constant(c)) for c in constants if c.sort == node.sort]
#        print "splatter eqs = {}".format(eqs)
        self.split_n_way(node,eqs)