Re: Newbie question...simple rule question...
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 11 Aug 2005 14:13:01 GMT
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
.
- Follow-Ups:
- References:
- Newbie question...simple rule question...
- From: mans
- Re: Newbie question...simple rule question...
- From: Jan Wielemaker
- Re: Newbie question...simple rule question...
- From: mans
- Newbie question...simple rule question...
- Prev by Date: newbie question: how to measure run-time with Sicstus under linux?
- Next by Date: Re: Newbie question...simple rule question...
- Previous by thread: Re: Newbie question...simple rule question...
- Next by thread: Re: Newbie question...simple rule question...
- Index(es):
Relevant Pages
|
|