Exemple #1
0
 def get_facts(self, rels, definite=True):
     clauses = []
     if not definite:
         clauses += [[~lit for lit in n.fmla] for n in self.all_nodes
                     if n.status == "false"]
         clauses += [
             rela_fact(1, equals, n, n) for n in self.all_nodes
             if (n.status != "false" and not n.summary and not any(
                 is_equality_lit(lit) for lit in n.fmla))
         ]
     for n in self.all_nodes:
         if n.status == 'true':
             wit = get_witness(n)
             if wit != None:
                 fmla = substitute_clause(n.fmla, {'X': (wit)})
                 clauses += [[lit] for lit in fmla
                             if not is_taut_equality_lit(lit)]
     names = set(
         n.name for n in self.all_nodes
         if (n.status == "true" if definite else n.status != "false"))
     for (r, tvals) in rels:
         if tvals:
             clauses += r.get_definite_facts(
                 names, tvals) if definite else r.get_facts(names, tvals)
     return clauses
Exemple #2
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 
Exemple #3
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
Exemple #4
0
 def get_facts(self,rels,definite=True):
     clauses = []
     if not definite:
         clauses += [[~lit for lit in n.fmla] for n in self.all_nodes if n.status == "false"]
         clauses += [rela_fact(1,equals,n,n)
                     for n in self.all_nodes
                     if (n.status != "false" and not n.summary and not any(is_equality_lit(lit) for lit in n.fmla))]
     for n in self.all_nodes:
         if n.status == 'true':
             wit = get_witness(n)
             if wit != None:
                 fmla = substitute_clause(n.fmla,{'X':(wit)})
                 clauses += [[lit] for lit in fmla if not is_taut_equality_lit(lit)]
     names = set(n.name for n in self.all_nodes if (n.status == "true" if definite else n.status != "false"))
     for (r,tvals) in rels:
         if tvals:
             clauses += r.get_definite_facts(names,tvals) if definite else r.get_facts(names,tvals)
     return clauses
Exemple #5
0
def get_witness(n):
    for lit in n.fmla:
#        print "get_witness: lit = {}, iseq = {}, type(lit) = {}, type(lit.atom) = {}, lit.atom.rep = {}, lit.atom.rep == equals = {}".format(lit,is_equality_lit(lit),type(lit), type(lit.atom), lit.atom.rep, lit.atom.rep == equals)
        if is_equality_lit(lit) and isinstance(lit.atom.args[0],Variable):
            return lit.atom.args[1]
    return None
Exemple #6
0
def get_witness(n):
    for lit in n.fmla:
        #        print "get_witness: lit = {}, iseq = {}, type(lit) = {}, type(lit.atom) = {}, lit.atom.rep = {}, lit.atom.rep == equals = {}".format(lit,is_equality_lit(lit),type(lit), type(lit.atom), lit.atom.rep, lit.atom.rep == equals)
        if is_equality_lit(lit) and isinstance(lit.atom.args[0], Variable):
            return lit.atom.args[1]
    return None