Juanjo Conti
Juanjo Conti

Reputation: 30023

What does \+ mean in Prolog?

I've seen some answers here that use it and I don't know what it means or how to use it. I's also hard to look for it via a search engine :)

Upvotes: 38

Views: 59350

Answers (3)

G_V
G_V

Reputation: 2434

The way I memorize it is through the following logical rule:

  • \+ = 'if unsure or false, assume false'

This is different from standard boolean logic in that if your goal is uncertain instead of outright true or false, it assumes false when it can't prove true. The most obvious example of this is being unable to see whether a stream is still open or not. If you can't prove it is open, it's the same as being closed to the program.

https://en.wikipedia.org/wiki/Negation_as_failure

Upvotes: 0

Trevor Tippins
Trevor Tippins

Reputation: 2847

It's do with negation. \+ Goal will succeed if Goal cannot be proven.

Upvotes: 11

Carl Norum
Carl Norum

Reputation: 224944

It's the 'not provable' operator. It succeeds if its argument is not provable (and fails if its argument is provable).

Upvotes: 39

Related Questions