Would a Prolog SAT solver have an advantage in solving this riddle:
When Alice entered the forest of forgetfulness, she did not forget everything, only certain things. She often forgot her name, and the most likely thing for her to forget was the day of the week. Now, the lion and the unicorn were frequent visitors to this forest. These two are strange creatures. The lion lies on Mondays, Tuesdays, and Wednesdays and tells the truth on the other days of the week. The unicorn, on the other hand, lies on Thursdays, Fridays, and Saturdays, but tells the truth on the other days of the week.
One day Alice met the lion and the unicorn resting under a tree. They made the following statements:
Lion: Yesterday was one of my lying days.
Unicorn: Yesterday was one of my lying days.From these statements, Alice, who was a bright girl, was able to deduce the day of the week. What was it?
Performance advantage over a solution like here (Free Access):
The lion and the unicorn met PROLOG
Bruce Ramsey - 1986
https://dl.acm.org/doi/10.1145/382278.382395
Ok, I was using a SAT solver in a little unorthodox way.
Used it as a compiler for a formula, so that I got:
Works fine and is fast with
optimise=true
:Edit 14.11.2023
So how to use a SAT solver as a compiler. First model
the problem with
library(clpb)
as Boolean formulas.Then look at the normalform:
Take the normalform, reorder the equations a little bit, fewer
variables first, and rewrite them into ISO core standard bitwise
operations, and then take profit.