3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00
z3/examples/python/socrates.py
Nikolaj Bjorner e7f36a2d35 remove special characters
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2016-09-14 10:32:17 -07:00

36 lines
843 B
Python

############################################
# Copyright (c) Microsoft Corporation. All Rights Reserved.
#
# all humans are mortal
# Socrates is a human
# so Socrates mortal
############################################
from z3 import *
set_param(proof=True)
Object = DeclareSort('Object')
Human = Function('Human', Object, BoolSort())
Mortal = Function('Mortal', Object, BoolSort())
# a well known philosopher
socrates = Const('socrates', Object)
# free variables used in forall must be declared Const in python
x = Const('x', Object)
axioms = [ForAll([x], Implies(Human(x), Mortal(x))),
Human(socrates) == True]
s = Solver()
s.add(axioms)
# classical refutation
s.add(Mortal(socrates) == False)
print(s.check()) # prints unsat so socrates is Mortal
# print(s.proof()) # prints a low level (not readable) proof object.