Negation as failure in Prolog is a procedural behavior?

前端 未结 2 775
一整个雨季
一整个雨季 2021-01-15 05:44

I have a little question about the negation as failure in Prolog language:

This is a question more theoretical than practical because I have clear h

2条回答
  •  Happy的楠姐
    2021-01-15 06:27

    I disagree with 'limitations of the logic'.

    The same would be

    likes(mary,X) :- not(snake(X)) , animal(X).
    

    Because Prolog uses a depth-first-search some things can be expressed in an shorter way that then depends on the depth-first-search backtracking algorithm.

    x :- a, !, b.
    x :- c.
    x :- d.
    

    is the same as

    x :- a, b.
    x :- not(a), c.
    x :- not(a), d.
    

提交回复
热议问题