Esempio n. 1
0
def equiv_alpha(x, y):
    """check if two closed terms are equivalent module alpha
    conversion. for now, we assume the terms are closed
    """
    if x == y:
        return True
    if il.is_lambda(x) and il.is_lambda(y):
        return x.body == il.substitute(y.body, zip(x.variables, y.variables))
    return False
    pass
Esempio n. 2
0
 def recur(expr):
     for e in expr.args:
         recur(e)
     for trig,ax in triggers:
         mp = dict()
         if match(trig,expr,mp):
             fmla = normalize(il.substitute(ax.formula,mp))
             if fmla not in insts:
                 insts.add(fmla)
                 inst_list.append(fmla)
Esempio n. 3
0
def equiv_alpha(x,y):
    """check if two closed terms are equivalent module alpha
    conversion. for now, we assume the terms are closed
    """
    if x == y:
        return True
    if il.is_lambda(x) and il.is_lambda(y):
        return x.body == il.substitute(y.body,zip(x.variables,y.variables))
    return False
    pass
Esempio n. 4
0
    def qe(self,expr,sort_constants):
        if il.is_quantifier(expr):
            old = self.syms.get(expr,None)
            if old is not None:
                return old
            res = self.fresh(expr)
            consts = [sort_constants[x.sort] for x in expr.variables]
            values = itertools.product(*consts)
            maps = [dict(zip(expr.variables,v)) for v in values]
            insts = [normalize(il.substitute(expr.body,m)) for m in maps]
#            for i in insts:
#                print '    {}'.format(i)
            for inst in insts:
                c = il.Implies(res,inst) if il.is_forall(expr) else il.Implies(inst,res)
                self.fmlas.append(c)
            return res
        return clone_normal(expr,[self.qe(e,sort_constants) for e in expr.args])