Thank you for your solution!
I got the puzzle from a discussion here,
which was about Prolog versus Theorem Proving:
The lion and the unicorn met PROLOG
Bruce D. Ramsey, 1986 - Free Access
The lion and the unicorn met PROLOG | ACM SIGPLAN Notices