How to negate in Prolog

后端 未结 2 2033
南方客
南方客 2021-02-20 12:14

I\'m new to PROLOG and am at the very beginning of the exercises on this page. Given the rules parent(X, Y) and male(X), I\'m trying to define a rule mother(X, Y) as

         


        
相关标签:
2条回答
  • 2021-02-20 12:41

    \+/1 is the ISO Prolog predicate to "negate". Note that "negate" means here not provable at that point.

    You can refer to this excellent answer by @false for more on the subject

    0 讨论(0)
  • 2021-02-20 13:00

    The solution is actually in the exercise file on that page:

    female(X) :- \+ male(X).
    

    As @Mog said, negation is the unary \+ operator.

    0 讨论(0)
提交回复
热议问题