Skip to content

Instantly share code, notes, and snippets.

@rntz
Last active October 28, 2020 20:46
Show Gist options
  • Save rntz/d2592274d242e9175ad3dda2da5d0575 to your computer and use it in GitHub Desktop.
Save rntz/d2592274d242e9175ad3dda2da5d0575 to your computer and use it in GitHub Desktop.
# two folks have different preferences if one likes a beer the other doesn't.
differ(a, b) :- person(b), likes(beer, a), !likes(beer, b).
differ(a, b) :- person(a), !likes(beer, a), likes(beer, b).
# what you want to write
unique(a) :- ∀b. (a = b or differ(a,b)).
# how you have to write it.
unique(a) :- not exists_same(a).
exists_same(a) :- person(a), person(b), !differ(a,b), a != b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment