3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-10 19:27:06 +00:00

Merge pull request #736 from MathieuRoger/patch-1

Create socrates.py
This commit is contained in:
Nikolaj Bjorner 2016-09-14 10:29:21 -07:00 committed by GitHub
commit 01eafdf68e

View file

@ -0,0 +1,33 @@
############################################
# 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