What does \+ mean in Prolog?
I've seen some answers here that u开发者_如何学Pythonse 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 :)
It's the 'not provable' operator. It succeeds if its argument is not provable (and fails if its argument is provable).
It's do with negation. \+ Goal
will succeed if Goal
cannot be proven.
The way I memorize it is through the following logical rule:
\+
= 'ifunsure
orfalse
, assumefalse
'
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
精彩评论