from z3 import * # lecture 15 slide 5 # simple logic, substitutions, simplifications T = BoolVal(True) F = BoolVal(False) x = Bool('x') y = Bool('y') z = Bool('z') w = Bool('w') f = And(Not(x), Not(y)) g = substitute(f, (x, z)) h = substitute(f, (x, T)) j = simplify(h) k = simplify(substitute(f, (y, F))) l = simplify(substitute(f, (x, Not(w)), (y, F))) # lecture 15 slide 11 # existential quantifier elimination exists_y_f = Exists([y], f) quant_elim = Tactic('qe') qe_exists_y_f = quant_elim(exists_y_f)[0][0] # why double nested list? # could use multiple tactics and then get a list of results # e.g. could do this, but not needed here: Tactic('qe', 'reduce')