I have the following rules set up.
pokemonOfType(charmander, fire).
pokemonOfType(staryu, water).
typeWins(water, fire). % this should not affect the outcome,
% but who knows
pokemonWins(Winner, Loser) :-
pokemonOfType(Winner, TypeWinner),
pokemonOfType(Loser, TypeLoser),
typeWins(TypeWinner, TypeLoser).
If I run ?-pokemonWins(charmander, staryu).
I get the following output (false). If I run ?-not(pokemonWins(charmander, staryu)).
I also get false!
What is going on?
I have the following rules set up.
pokemonOfType(charmander, fire).
pokemonOfType(staryu, water).
typeWins(water, fire). % this should not affect the outcome,
% but who knows
pokemonWins(Winner, Loser) :-
pokemonOfType(Winner, TypeWinner),
pokemonOfType(Loser, TypeLoser),
typeWins(TypeWinner, TypeLoser).
If I run ?-pokemonWins(charmander, staryu).
I get the following output (false). If I run ?-not(pokemonWins(charmander, staryu)).
I also get false!
What is going on?
Share Improve this question edited Nov 18, 2024 at 20:36 TessellatingHeckler 29.1k4 gold badges54 silver badges93 bronze badges asked Nov 18, 2024 at 17:28 ChuweeChuwee 11 bronze badge 2 |1 Answer
Reset to default 0?- pokemonWins(charmander, staryu)
false
?- not(pokemonWins(charmander, staryu))
true
should work. So, it's likely something else.
But, in Prolog, not
is implemented as "negation as failure". not(X)
succeeds if X
fails, and fails if X
succeeds. not doesn't mean "logical not" in the classical sense.
And it's considered deprecated due to such confusion and should not be used in a new code according to the SWI prolog. https://www.swi-prolog./pldoc/man?predicate=not/1
not(pokemonWins(charmander, staryu)).
succeeds, i.e. showstrue
, in swi-prolog 9.2.8. – brebs Commented Nov 18, 2024 at 18:09not(pokemonWins...)
write:\+ pokemonWins(...)
– TA_intern Commented Nov 19, 2024 at 7:22