It is interesting for me if there is any built-in tool, in Prolog, that would work for the following example:
parentRole(X,Y,Z):- parent(X,Y), male(X), !, Z=='father', !.
parentRole(X,Y,Z):- parent(X,Y), Z=='mother'.
I want the rule parent(X,Y)
to stop the program (+return false) if parent(X,Y)
failed, in rule #1, else go on as usually.
This way I'd be able to write:
parentRole(X,Y,Z):- parent(X,Y), male(X), !, Z=='father', !.
parentRole(X,Y,Z):- Z=='mother'.
Suppose facts are:
parent(myMom, i)
male(i)
I expect for the scope:
parentRole(notMyMom, i, 'mother')
the program to stop and return false, but in the real, it fails at parent(X,Y)
in the 1st rule, and tries to satisfy the 2nd, and it return true as Z=='mother'
Thanks.
parentRole(notMyFather, me, 'mother')
, I expect the first rule to stop the program, but actually it tries the 2nd one and it returns true. - Postica Ðenis\+ parent(a,b),!.
Means if your database does not contain anyspecific a,b
then simply stop it. - Luai Ghunim