def type_check(domain,ast): for atom in apps_ast(ast): arity = len(atom.args) correct_arity = get_correct_arity(domain,atom) if arity != correct_arity and not(atom.rep == '-' and arity == 1): # print "atom: {} : {}".format(atom,type(atom)) raise IvyError(atom, "wrong number of arguments to {}: got {}, expecting {}." .format(atom.rep,arity,correct_arity))
def type_check(domain, ast): for atom in apps_ast(ast): arity = len(atom.args) correct_arity = get_correct_arity(domain, atom) if arity != correct_arity and not (atom.rep == "-" and arity == 1): # print "atom: {} : {}".format(atom,type(atom)) raise IvyError( atom, "wrong number of arguments to {}: got {}, expecting {}.".format(atom.rep, arity, correct_arity) ) for a in atom.args: if isinstance(a.get_sort(), EnumeratedSort): raise IvyError(a, "symbol {} of enumerated type can only appear under equality".format(a.rep)) for atom in eqs_ast(ast): t0, t1 = [x.get_sort() for x in atom.args] if t0 != t1: raise IvyError(atom, "comparison of incompatible types")
def type_check(domain, ast): for atom in apps_ast(ast): arity = len(atom.args) correct_arity = get_correct_arity(domain, atom) if arity != correct_arity and not (atom.rep == '-' and arity == 1): # print "atom: {} : {}".format(atom,type(atom)) raise IvyError( atom, "wrong number of arguments to {}: got {}, expecting {}.". format(atom.rep, arity, correct_arity)) for a in atom.args: if isinstance(a.get_sort(), EnumeratedSort): raise IvyError( a, "symbol {} of enumerated type can only appear under equality" .format(a.rep)) for atom in eqs_ast(ast): t0, t1 = [x.get_sort() for x in atom.args] if t0 != t1: raise IvyError(atom, "comparison of incompatible types")
def create_macro_maps(assumes, asserts, macros): global universally_quantified_variables global macro_var_map global macro_dep_map global macro_map global macro_value_map global strat_map macro_map = dict() for df, lf in macros: macro_map[df.defines()] = (df, lf) macro_dep_map = defaultdict(set) macro_var_map = dict() macro_value_map = dict() def var_map_add(w, vn): if w in macro_var_map: unify(macro_var_map[w], vn) else: macro_var_map[w] = vn for fmla, _ in assumes + asserts + list(reversed(macros)): for app in ilu.apps_ast(fmla): if app.rep in macro_map: mvs = macro_map[app.rep][0].args[0].args for v, w in zip(app.args, mvs): if il.is_variable(w): if il.is_variable(v): if v in universally_quantified_variables: var_map_add(w, strat_map[v]) if v in macro_var_map: var_map_add(w, macro_var_map[v]) if v in macro_dep_map: macro_dep_map[w].update(macro_dep_map[v]) else: for u in ilu.used_variables_ast(v): if u in universally_quantified_variables: macro_dep_map[w].add(strat_map[u]) if u in macro_var_map: macro_dep_map[w].add(macro_var_map[u]) if u in macro_dep_map: macro_dep_map[w].update(macro_var_map[u])