Some proofs of validity using Z3Py online and a strategy proposed by Nikolaj Bjorner

限于喜欢 提交于 2019-12-11 10:06:41

问题


Lemma: forall x : R, x <> 0 -> (x / x) = 1.

Proof:

  x = Real('x')

  s = Solver()

  s.add(Or(x >0, x < 0), Not(x/x ==1))

  print s.check()

and the output is :

  unsat

Qed.

Lemma: forall x y : R, x <> 0, y <> 0 -> (x / x + y / y) = 2.

Proof:

x, y = Reals('x y')
s = Solver()
s.add(Or(x >0, x < 0), Or(y >0, y < 0), Not(x/x + y/y ==2))
print s.check()

and the output is:

unsat

Qed.

Lemma: forall x y : R, x <> 0, y <> 0 -> (x / x + x / y) = ((x + y) / y).

Proof:

x, y = Reals('x y')
s = Solver()
s.add(Or(x >0, x < 0), Or(y >0, y < 0), Not(x/x + x/y == (x+y)/y))
print s.check()

and the output is:

unsat

Qed.

These lemmas were proved using Coq + Maple at

http://coq.inria.fr/V8.2pl1/contribs/MapleMode.Examples.html

Please let me know if my proofs with Z3Py are correct and if you know a more direct form to prove them using Z3Py. Many thanks.


回答1:


There is a slightly more compact way by using the "prove" command instead of the solver object. For example:

x, y = Reals('x y')
prove(Implies(And(Or(x >0, x < 0), Or(y >0, y < 0)), (x/x + x/y == (x+y)/y)))


来源:https://stackoverflow.com/questions/16267658/some-proofs-of-validity-using-z3py-online-and-a-strategy-proposed-by-nikolaj-bjo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!