Using Z3Py online to prove that n^5 <= 5 ^n for n >= 5

后端 未结 1 455
囚心锁ツ
囚心锁ツ 2021-01-25 03:22

Using the following code:

n = Int(\'n\')
s = Solver()
s.add(n >= 5)
s.add(Not( n**5 <= 5**n))
print s
print s.check()

we obtain the follo

相关标签:
1条回答
  • 2021-01-25 04:11

    Z3 has very limited support for nonlinear integer arithmetic. See the following related post for more information:

    • How does Z3 handle non-linear integer arithmetic?

    Z3 has a complete solver (nlsat) for nonlinear real (polynomial) arithmetic. You can simplify your script by writing

    n = Real('n')
    e, f = Reals('e f')
    prove(Implies(And(e >=0, f >= 0), -(5 + f + 1)**5 + ((5 + f)**5 + e)*5 >= 0))
    

    Z3 uses nlsat in the problem above because it contains only real variables. We can also force Z3 to use nlsat even if the problem contains integer variables.

    n = Int('n')
    e, f = Ints('e f')
    s = Tactic('qfnra-nlsat').solver()
    s.add(e >= 0, f >= 0)
    s.add(Not(-(5 + f + 1)**5 + ((5 + f)**5 + e)*5 >= 0))
    print s
    print s.check()
    
    0 讨论(0)
提交回复
热议问题