1

I'm totally new to Prolog. So please excuse this possibly extermely simple qiuestion: I have a few facts like

likes(peter,cars).
likes(maria,bikes).
likes(walter,bikes).
likes(paul,bikes).
likes(paul,cars).

in a file likes.pl. Now I'm trying to check whether paul likes cars and bikes, so I tried on GNU Prolog's REPL:

| ? - [likes].
| ? - likes(paul,bikes) #\/ likes(paul,cars).

but I get "uncaught exception:...". Obviously I'm doing something wrong. - How can I combine two facts with an AND in GNU Prolog?

halloleo
  • 9,216
  • 13
  • 64
  • 122

1 Answers1

2

The operator you are using #\/ is a Boolean Finite Domain operator used in constraint programming clp(b).

If you just want a conjunction of two facts A and B, use A, B. If you want a disjunction of them use A; B.

In your case you can just type likes(paul, bikes), likes(paul, cars)..

rajashekar
  • 3,460
  • 11
  • 27
  • Thanks @rajashekar, works perfectly! I guess I have to read up on _Finite Domain operators_ and _constraint programming_... – halloleo Jun 11 '21 at 01:28
  • 1
    @halloleo : The inputs to the boolean fd operators must be evaluable to `0` or `1`. So if you give it `X #/\ Y` it returns `X = 1, Y = 1`. It works with any propositional formula. CLP is powerful, but I suggest you go there after becoming more familiar with core prolog itself. – rajashekar Jun 11 '21 at 01:32