Re: All Quantifier



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











.



Relevant Pages

  • Re: All Quantifier
    ... The working code: ... :- dynamic done/1. ... % black_edge and so black_conn connecting two processes ... % Now A shall also be required in order to execute C: ...
    (comp.lang.prolog)
  • Re: All Quantifier
    ... The working code: ... :- dynamic done/1. ... % black_edge and so black_conn connecting two processes ... % Now A shall also be required in order to execute C: ...
    (comp.lang.prolog)
  • Re: Asynchronous Threading Issue
    ... callbacks is that if I use a callback function it will execute on a ... if I use a callback function ... I want to call BeginConnect so that I try to connect without holding up ... but if there's an error connecting I want to ...
    (microsoft.public.dotnet.general)
  • Re: All Quantifier
    ... The working code: ... :- dynamic done/1. ... % black_edge and so black_conn connecting two processes ... % Now A shall also be required in order to execute C: ...
    (comp.lang.prolog)
  • Re: No results from query in some contexts
    ... maybe even read permission on that table as well. ... ensure you are connecting and executing that proc as you expect. ... > If I execute this sproc from SQL Server Management studio connected to the ... > If I open up the table in visual studio 2005 I see the records. ...
    (microsoft.public.sqlserver.security)