def make_skolems(fmla, ast, pol, univs): global macro_dep_map global strat_map if isinstance(fmla, il.Not): make_skolems(fmla.args[0], ast, not pol, univs) if isinstance(fmla, il.Implies): make_skolems(fmla.args[0], ast, not pol, univs) make_skolems(fmla.args[1], ast, pol, univs) is_e = il.is_exists(fmla) is_a = il.is_forall(fmla) if is_e and pol or is_a and not pol: fvs = set(il.free_variables(fmla)) for u in univs: if u in fvs: for e in il.quantifier_vars(fmla): macro_dep_map[e].add(strat_map[u]) if is_e and not pol or is_a and pol: make_skolems(fmla.args[0], ast, pol, univs + list(il.quantifier_vars(fmla))) for arg in fmla.args: make_skolems(arg, ast, pol, univs) if isinstance(fmla, il.Ite): make_skolems(fmla.args[0], ast, not pol, univs) if isinstance(fmla, il.Iff) or (il.is_eq(fmla) and il.is_boolean(fmla.args[0])): make_skolems(fmla.args[0], ast, not pol, univs) make_skolems(fmla.args[1], ast, not pol, univs)
def get_qa_arcs(fmla,ast,pol,univs,strat_map): if isinstance(fmla,il.Not): for a in get_qa_arcs(fmla.args[0],ast,not pol,univs,strat_map): yield a return if isinstance(fmla,il.Implies): for a in get_qa_arcs(fmla.args[0],ast,not pol,univs,strat_map): yield a for a in get_qa_arcs(fmla.args[1],ast,pol,univs,strat_map): yield a return is_e = il.is_exists(fmla) is_a = il.is_forall(fmla) if is_e and pol or is_a and not pol: fvs = set(il.free_variables(fmla)) for u in univs: if u in fvs: for e in il.quantifier_vars(fmla): yield (find(strat_map[u]),find(strat_map[e]),ast) if is_e and not pol or is_a and pol: for a in get_qa_arcs(fmla.args[0],ast,pol,univs+list(il.quantifier_vars(fmla)),strat_map): yield a for arg in fmla.args: for a in get_qa_arcs(arg,ast,pol,univs,strat_map): yield a if isinstance(fmla,il.Ite): for a in get_qa_arcs(fmla.args[0],ast,not pol,univs,strat_map): yield a if isinstance(fmla,il.Iff) or (il.is_eq(fmla) and il.is_boolean(fmla.args[0])): for a in get_qa_arcs(fmla.args[0],ast,not pol,univs,strat_map): yield a for a in get_qa_arcs(fmla.args[1],ast,not pol,univs,strat_map): yield a
def get_qa_arcs(fmla,ast,pol,univs): if isinstance(fmla,il.Not): for a in get_qa_arcs(fmla.args[0],ast,not pol,univs): yield a return is_e = il.is_exists(fmla) is_a = il.is_forall(fmla) if is_e and pol or is_a and not pol: for u in univs: for e in il.quantifier_vars(fmla): yield (u.sort,e.sort,ast) if is_e and not pol or is_a and pol: for a in get_qa_arcs(fmla.args[0],ast,pol,univs+list(il.quantifier_vars(fmla))): yield a for arg in fmla.args: for a in get_qa_arcs(arg,ast,pol,univs): yield a
def get_qa_arcs(fmla, ast, pol, univs): if isinstance(fmla, il.Not): for a in get_qa_arcs(fmla.args[0], ast, not pol, univs): yield a return is_e = il.is_exists(fmla) is_a = il.is_forall(fmla) if is_e and pol or is_a and not pol: for u in univs: for e in il.quantifier_vars(fmla): yield (u.sort, e.sort, ast) if is_e and not pol or is_a and pol: for a in get_qa_arcs(fmla.args[0], ast, pol, univs + list(il.quantifier_vars(fmla))): yield a for arg in fmla.args: for a in get_qa_arcs(arg, ast, pol, univs): yield a
def property_tactic(self, decls, proof): cut = proof.args[0] goal = decls[0] subgoal = goal_subst(goal, cut, cut.lineno) lhs = proof.args[1] if not isinstance(lhs, ia.NoneAST): fmla = il.drop_universals(cut.formula) if not il.is_exists(fmla) or len(fmla.variables) != 1: raise IvyError(proof, 'property is not existential') evar = list(fmla.variables)[0] rng = evar.sort vmap = dict((x.name, x) for x in lu.variables_ast(fmla)) used = set() args = lhs.args targs = [] for a in args: if a.name in used: raise IvyError(lhs, 'repeat parameter: {}'.format(a.name)) used.add(a.name) if a.name in vmap: v = vmap[a.name] targs.append(v) if not (il.is_topsort(a.sort) or a.sort != v.sort): raise IvyError(lhs, 'bad sort for {}'.format(a.name)) else: if il.is_topsort(a.sort): raise IvyError( lhs, 'cannot infer sort for {}'.format(a.name)) targs.append(a) for x in vmap: if x not in used: raise IvyError( lhs, '{} must be a parameter of {}'.format(x, lhs.rep)) dom = [x.sort for x in targs] sym = il.Symbol(lhs.rep, il.FuncConstSort(*(dom + [rng]))) if sym in self.stale or sym in goal_defns(goal): raise iu.IvyError(lhs, '{} is not fresh'.format(sym)) term = sym(*targs) if targs else sym fmla = lu.substitute_ast(fmla.body, {evar.name: term}) cut = clone_goal(cut, [], fmla) goal = goal_add_prem(goal, ia.ConstantDecl(sym), goal.lineno) return [goal_add_prem(goal, cut, cut.lineno)] + decls[1:] + [subgoal]