Skip to content

Instantly share code, notes, and snippets.

@evanthebouncy
Created October 19, 2020 19:53
Show Gist options
  • Save evanthebouncy/fc322b2a45474680bee695cb2853c9e8 to your computer and use it in GitHub Desktop.
Save evanthebouncy/fc322b2a45474680bee695cb2853c9e8 to your computer and use it in GitHub Desktop.
simple ancestor relation encoding in z3 smt solver
(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