Re: All Quantifier
- From: michael.igler@xxxxxx (Michael Igler)
- Date: Wed, 16 Jul 2008 11:20:34 +0200
Michael Igler <michael.igler@xxxxxx> wrote:
Geoffrey Summerhayes <sumrnot@xxxxxxxxx> wrote:
On Jun 23, 2:28 am, michael.ig...@xxxxxx (Michael Igler) wrote:
Hi Geoff,
yes, that's it. Many thanxs.
The working code:
:- dynamic done/1.
% black_edge and so black_conn connecting two processes
black_conn(X,Y) :- black_edge(X,Z), black_conn(Z,Y).
black_conn(X,Y) :- black_edge(X,Y).
% red_conn connecting two processes
red_conn(X,Y) :- red_edge(X,Y).
% Now A shall also be required in order to execute C:
% A -black-> B -red-> C ==implies==> A -red-> C
red_conn(X,Z) :- black_conn(X,Y), red_conn(Y,Z).
% Is a process executable?
executable(X) :- black_conn(X,_).
executable(Y) :- black_conn(_,Y).
executable(X) :- red_conn(X,_).
% A process that is connected through a red edge
% shall only be executable if all preceding processes
% have been executed
executable(Y) :- \+ (red_conn(X,Y),\+ done(X)).
% MODEL FLOW
% A -black-> B -black-> C -black-> D -red-> E
black_edge(a,b).
black_edge(b,c).
black_edge(c,d).
red_edge(d,e).
% QUERIES
% executable(e). --> NO
% assert(done(a)).
% assert(done(b)).
% assert(done(c)).
% assert(done(d)).
% executable(e). --> YES
Try removing the other executable declarations.
:- dynamic done/1.
black_conn(X,Y) :- black_edge(X,Z), black_conn(Z,Y).
black_conn(X,Y) :- black_edge(X,Y).
red_conn(X,Y) :- red_edge(X,Y).
red_conn(X,Z) :- black_conn(X,Y), red_conn(Y,Z).
executable(Y) :- \+ (red_conn(X,Y),\+ done(X)).
black_edge(a,b).
black_edge(b,c).
black_edge(c,d).
red_edge(d,e).
And make sure that executable/1 does what you
want it to, it allows more than you might think.
Try executable(f).
----
Geoff
Yes it is still working.
I wonder for 2 days now what the meaning of \+ is.
Sicstus Manual says:
\+ P : Fails if the goal P has a solution, and succeeds otherwise.
This is not real negation ("P is false"), but a kind of pseudo-negation
meaning "P is not provable".
But I have no idea how it is applicable to my case.
Michael
I have modified my program and added a statement that gives me a set of
processes that I can execute :
:- dynamic done/1.
% black_edge and so black_conn connecting two processes
black_conn(X,Y) :- black_edge(X,Z), black_conn(Z,Y).
black_conn(X,Y) :- black_edge(X,Y).
% red_conn connecting two processes
red_conn(X,Y) :- red_edge(X,Y).
% Now A shall also be required in order to execute C:
% A -black-> B -red-> C ==implies==> A -red-> C
red_conn(X,Z) :- black_conn(X,Y), red_conn(Y,Z).
% Is a process executable?
executable(X) :- black_conn(X,_).
executable(Y) :- black_conn(_,Y).
executable(X) :- red_conn(X,_).
% Now I need that executable(c) is only possible if done(a) AND done(b)
holds
executable(X) :- \+ (red_conn(W,X),\+ done(W)).
% Give a list of processes that are excutable
canDo :- setof(X, executable(X), Ausfuehrbar), write('You can do = '),
write(Ausfuehrbar),nl.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INSTANCE
% MODEL FLOW
% A -black-> B -red-> C
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
black_edge(a,b).
red_edge(b,c).
The following prolog session illustrates my problem:
?- canDo.
You can do = [a, b]
true.
?- assert(done(a)).
true.
?- assert(done(b)).
true.
?- canDo.
You can do = [_G327, a, b]
true.
Why is there a _G327 and not 'c', and how can I resolve this problem?
Thanks for tips,
Michael
.
- Follow-Ups:
- Re: All Quantifier
- From: Geoffrey Summerhayes
- Re: All Quantifier
- Prev by Date: Re: canonical alternative to assert and retract
- Next by Date: Re: All Quantifier
- Previous by thread: canonical alternative to assert and retract
- Next by thread: Re: All Quantifier
- Index(es):
Relevant Pages
|