Пример #1
0
def remove_vars_match(mat, fmla):
    """ Remove the variables bindings from a match. This is used to
    prevent variable capture when applying the match to premises. Make sure free variables
    are not captured by fmla """
    res = dict((s, v) for s, v in mat.iteritems() if il.is_ui_sort(s))
    sympairs = [(s, v) for s, v in mat.iteritems() if il.is_constant(s)]
    symfmlas = il.rename_vars_no_clash([v for s, v in sympairs], [fmla])
    res.update((s, w) for (s, v), w in zip(sympairs, symfmlas))
    return res
Пример #2
0
def remove_vars_match(mat,fmla):
    """ Remove the variables bindings from a match. This is used to
    prevent variable capture when applying the match to premises. Make sure free variables
    are not captured by fmla """
    res = dict((s,v) for s,v in mat.iteritems() if il.is_ui_sort(s))
    sympairs = [(s,v) for s,v in mat.iteritems() if il.is_constant(s)]
    symfmlas = il.rename_vars_no_clash([v for s,v in sympairs],[fmla])
    res.update((s,w) for (s,v),w in zip(sympairs,symfmlas))
#    show_match(res)
    return res
Пример #3
0
def strip_action(ast, strip_map, strip_binding):
    if isinstance(ast, ia.CallAction):
        name = canon_act(ast.args[0].rep)
        args = [
            strip_action(arg, strip_map, strip_binding)
            for arg in ast.args[0].args
        ]
        strip_params = get_strip_params(name, ast.args[0].args, strip_map,
                                        strip_binding, ast)
        call = ast.args[0].clone(args[len(strip_params):])
        return ast.clone([call] + [
            strip_action(arg, strip_map, strip_binding) for arg in ast.args[1:]
        ])
    if isinstance(ast, ia.AssignAction):
        if ast.args[0].rep.name in ivy_logic.sig.symbols:
            lhs_params = strip_map_lookup(ast.args[0].rep.name, strip_map)
            if len(lhs_params) != num_isolate_params:
                raise iu.IvyError(ast, "assignment may be interfering")
    if (ivy_logic.is_constant(ast)
            or ivy_logic.is_variable(ast)) and ast in strip_binding:
        sname = strip_binding[ast]
        if sname not in ivy_logic.sig.symbols:
            ivy_logic.add_symbol(sname, ast.sort)
            strip_added_symbols.append(ivy_logic.Symbol(sname, ast.sort))
        return ivy_logic.Symbol(sname, ast.sort)
    args = [strip_action(arg, strip_map, strip_binding) for arg in ast.args]
    if ivy_logic.is_app(ast):
        name = ast.rep.name
        strip_params = get_strip_params(name, ast.args, strip_map,
                                        strip_binding, ast)
        if strip_params:
            new_sort = strip_sort(ast.rep.sort, strip_params)
            new_args = args[len(strip_params):]
            new_symbol = ivy_logic.Symbol(name, new_sort)
            return new_symbol(*new_args)
    if isinstance(ast, ivy_ast.Atom):
        name = ast.rep
        strip_params = get_strip_params(name, ast.args, strip_map,
                                        strip_binding, ast)
        if strip_params:
            new_args = args[len(strip_params):]
            return ast.clone(new_args)
    return ast.clone(args)
Пример #4
0
def strip_action(ast,strip_map,strip_binding):
    if isinstance(ast,ia.CallAction):
        name = ast.args[0].rep
        args = [strip_action(arg,strip_map,strip_binding) for arg in ast.args[0].args]
        strip_params = get_strip_params(name,ast.args[0].args,strip_map,strip_binding,ast)
        call = ast.args[0].clone(args[len(strip_params):])
        return ast.clone([call]+[strip_action(arg,strip_map,strip_binding) for arg in ast.args[1:]])
    if (ivy_logic.is_constant(ast) or ivy_logic.is_variable(ast)) and ast in strip_binding:
        sname = strip_binding[ast]
        if sname not in ivy_logic.sig.symbols:
            ivy_logic.add_symbol(sname,ast.sort)
        return ivy_logic.Symbol(sname,ast.sort)
    args = [strip_action(arg,strip_map,strip_binding) for arg in ast.args]
    if ivy_logic.is_app(ast):
        name = ast.rep.name
        strip_params = get_strip_params(name,ast.args,strip_map,strip_binding,ast)
        if strip_params:
            new_sort = strip_sort(ast.rep.sort,strip_params)
            new_args = args[len(strip_params):]
            new_symbol = ivy_logic.Symbol(name,new_sort)
            return new_symbol(*new_args)
    return ast.clone(args)
Пример #5
0
 def unlikely(fmla):
     # remove if possible the =constant predicates
     return ivy_logic.is_eq(fmla) and ivy_logic.is_constant(fmla.args[0])
Пример #6
0
 def unlikely(fmla):
     # remove if possible the =constant predicates
     return ivy_logic.is_eq(fmla) and ivy_logic.is_constant(
         fmla.args[0])