Re: Newbie question...simple rule question...



On 2005-08-11, mans <mshapshak@xxxxxxxxx> wrote:
> Dear Jan,
>
> Thanks for you quick reply.
>
> I am trying to make my prolog as similar to the natural language as
> possible and hence deal with the way the actual user is
> thinking...which in this case may be the reverse of the way prolog
> thinks??.
>
> But in any case how about this if I stick withe same input
> declarations:
>
> notok(X) :- \+ok(X).
> everybodyok_new :- not((people(X),notok(X))).
>
> Which seems to work..although I am not sure what the meta call means:
>
> [trace] 125 ?- everybodyok_new.
> Call: (7) everybodyok_new ? creep
> ^ Call: (8) not((people(_G506), notok(_G506))) ? creep
> Call: (10) people(_G506) ? creep
> Exit: (10) people(a) ? creep
> Call: (10) notok(a) ? creep
> Call: (11) ok(a) ? creep
> Exit: (11) ok(a) ? creep
> Fail: (10) notok(a) ? creep
> Redo: (10) people(_G506) ? creep
> Exit: (10) people(c) ? creep
> Call: (10) notok(c) ? creep
> Call: (11) ok(c) ? creep
> Fail: (11) ok(c) ? creep
> Exit: (10) notok(c) ? creep
> Exit: (9) '<meta-call>'((people(c), notok(c))) ? creep

This is an artifact introduced by SWI-Prolog to deal with complex
goals (i.e. goals with control structures) given to call/1, once/1,
etc.

> ^ Fail: (8) not((people(_G506), notok(_G506))) ? creep
> Fail: (7) everybodyok_new ? creep

Now that you understand this, you are ready for the more
readable form:

everybodyok :- forall(people(X), ok(X)).

And for the definition of forall/2 (a built-in):

forall(Cond, Action) :-
\+ (Cond, \+ Action).

Enjoy --- Jan
.



Relevant Pages

  • Re: Newbie question...simple rule question...
    ... I am trying to make my prolog as similar to the natural language as ... Exit: people? ... Fail: notok? ...
    (comp.lang.prolog)
  • Simple question
    ... Using SWI-Prolog, ... problem can be seen from the following debug trace: ... Exit: basicpart? ...
    (comp.lang.prolog)
  • Validating user input?
    ... For a valid input anything is okay, but when a user enters a invalid value I thought, the second goal checkwill fail and backtracking would bring me back to input. ... ?- trace. ...
    (comp.lang.prolog)