Prolog uses First Order logic. Fact and rules, in the way they are defined expresses only positive claims.
Is is possibile to define also negative claims in First Order logic ? If yes, why use facts and rules ? And advantages they offer ?
Prolog uses First Order logic. Fact and rules, in the way they are defined expresses only positive claims.
Is is possibile to define also negative claims in First Order logic ? If yes, why use facts and rules ? And advantages they offer ?
Copyright © 2021 JogjaFile Inc.
There sort of are negations in Prolog, as Mauro says in the comments ... although the use of $!$ in something like $P :- !Q$ really means "if we can't show that $Q$ then we can say $P$", and something being unprovable is not the same as it being false. And note that there is no such thing as $!P :- Q$ ... and thus we cannot represent a claim like 'If $Q$ is true then $P$ is false'. Indeed, in the end, in Prolog we can only show things to be true, not that they are false.
Something else you can't capture in Prolog is a claim like $P \rightarrow (Q \lor R)$ ... or even just that $P \lor Q$; you can use disjunctions in the antecedent, but not in the consequent or as a plain 'fact'.
OK, so yes, you are right: Prolog is not as expressive as first-order logic. So why not add some expressivity and make it just as expressive. Well, the thing is that by restricting all the claims in Prolog to be the way they are, its backtracking mechanism to try and prove something can be as efficient as it is. If you add the full expressivity of FOL, your algorithm would be far less efficient. In fact, once you get full FOL, then the problem of figuring out whether something is provable becomes undecidable; there simply does not exist an algorithm that is able to decide logical consequence in general!