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
Mathieu Roger a7e3a9df5a Create socrates.py
Classical syllogism in Z3.
Many samples talks about integer, reals. Not much sample available on non integer things.
2016-09-14 19:10:49 +02:00

34 lines
782 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

############################################
# 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