Ejemplo n.º 1
0
 def get_instance(self, params, to_clauses=True):
     defn = self.defn
     if len(params) != len(defn.args[0].args):
         raise IndexError
     subst = dict((x.rep, y.rep) for x, y in zip(defn.args[0].args, params))
     ast = ivy_ast.ast_rewrite(defn.args[1], ivy_ast.AstRewriteSubstPrefix(subst, None))
     #        print "get_instance ast = {}".format(ast)
     fmla = ast.compile_with_sort_inference()
     #        print "get_instance fmla = {}".format(fmla)
     return formula_to_clauses(fmla) if to_clauses else fmla
Ejemplo n.º 2
0
    def get_instance(self,params,to_clauses=True):
        defn = self.defn
        if len(params) != len(defn.args[0].args):
            raise IndexError
        subst = dict((x.rep,y.rep) for x,y in zip(defn.args[0].args,params))
        ast = ivy_ast.ast_rewrite(defn.args[1],ivy_ast.AstRewriteSubstPrefix(subst,None))
#        print "get_instance ast = {}".format(ast)
        fmla = ast.compile_with_sort_inference()
#        print "get_instance fmla = {}".format(fmla)
        return formula_to_clauses(fmla) if to_clauses else fmla
Ejemplo n.º 3
0
def instantiate_macro(inst,defns):
    if inst.relname in defns:
        defn = defns[inst.relname]
        aparams = inst.args
        fparams = defn.args[0].args
        if len(aparams) != len(fparams):
            raise IvyError(inst,"wrong number of parameters");
        subst = dict((x.rep,y) for x,y in zip(fparams,aparams))
#        print "subst: {!r}".format(subst)
        psubst = dict((x.rep,y.rep) for x,y in zip(fparams,aparams)
                      if (isinstance(y,ivy_ast.App) or isinstance(y,ivy_ast.Atom)) and
                      len(y.args) == 0)
        return ivy_ast.ast_rewrite(defn.args[1],ivy_ast.AstRewriteSubstConstantsParams(subst,psubst))
    return None
Ejemplo n.º 4
0
def instantiate_macro(inst,defns):
    if inst.relname in defns:
        defn = defns[inst.relname]
        aparams = inst.args
        fparams = defn.args[0].args
        if len(aparams) != len(fparams):
            raise IvyError(inst,"wrong number of parameters");
        subst = dict((x.rep,y) for x,y in zip(fparams,aparams))
#        print "subst: {!r}".format(subst)
        psubst = dict((x.rep,y.rep) for x,y in zip(fparams,aparams)
                      if (isinstance(y,ivy_ast.App) or isinstance(y,ivy_ast.Atom)) and
                      len(y.args) == 0)
        return ivy_ast.ast_rewrite(defn.args[1],ivy_ast.AstRewriteSubstConstantsParams(subst,psubst))
    return None