If you intend to use membero , there is no general solution to this problem. Calling membero with fresh vars will cause it to generate all (read, endless) possible lists for which q is a member. Of course, lists that are larger than 3 are not applicable, but since you used run* , it will continue to blindly try lists that exceed score 3, although each of them will fail.
You can write a better version of membero in new versions of core.logic using the framework of restrictions, but the details of how to do this are likely to change in the coming months. Until you have a reliable public api for defining restrictions, you are stuck with such subtle problems with ordering and without interruption that Prolog is worried about.
source share