def solve(t): """Solve the given goal using Z3.""" s = z3.Solver() # First strip foralls from t. while Term.is_all(t): t = t.arg.subst_bound(Var(t.arg.var_name, t.arg.var_T)) s.add(z3.Not(convert(t))) return str(s.check()) == 'unsat'
def strip_all_implies(t, names): """Given a term of the form !x_1 ... x_k. A_1 --> ... --> A_n --> C. Return the triple ([v_1, ..., v_k], [A_1, ... A_n], C), where v_1, ..., v_k are new variables with the given names, and A_1, ..., A_n, C are the body of the input term, with bound variables substituted for v_1, ..., v_k. """ if Term.is_all(t): assert len(names) > 0, "strip_all_implies: not enough names input." assert isinstance(names[0], str), "strip_all_implies: names must be strings." v = Var(names[0], t.arg.var_T) vars, As, C = strip_all_implies(t.arg.subst_bound(v), names[1:]) return ([v] + vars, As, C) else: assert len(names) == 0, "strip_all_implies: too many names input." As, C = t.strip_implies() return ([], As, C)