Created
October 19, 2020 19:53
-
-
Save evanthebouncy/fc322b2a45474680bee695cb2853c9e8 to your computer and use it in GitHub Desktop.
simple ancestor relation encoding in z3 smt solver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare-sort Person) | |
(declare-fun ancestor (Person Person) Bool) | |
;; anti symmetry | |
(assert (forall ((x Person) (y Person)) | |
(=> (ancestor x y) (not (ancestor y x))))) | |
;; transitivity | |
(assert (forall ((x Person) (y Person) (z Person)) | |
(=> (and (ancestor x y) (ancestor y z)) | |
(ancestor x z) | |
) | |
)) | |
(declare-var bob Person) | |
(declare-var joe Person) | |
(declare-var tim Person) | |
(assert (ancestor bob joe)) | |
(assert (ancestor joe tim)) | |
(declare-var flip Bool) | |
(assert (= flip (ancestor joe bob))) | |
(declare-var transitive Bool) | |
(assert (= transitive (ancestor bob tim))) | |
(check-sat) | |
(get-model) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment