finding all paths satisfying expressions
From: Willem Hajenius (willem.hajenius_at_scarlet.be)
Date: 03/07/05
- Next message: Brian Hulley: "Re: finding all paths satisfying expressions"
- Previous message: Fabien Todescato: "Re: swi prolog and odbc connectivity"
- Next in thread: Brian Hulley: "Re: finding all paths satisfying expressions"
- Reply: Brian Hulley: "Re: finding all paths satisfying expressions"
- Reply: Willem Hajenius: "Thanks!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 7 Mar 2005 21:08:34 +0100
Perhaps someone can help me with this. I'm trying to construct a
program to
help me with some rigorous software testing. The objective is to find
all
possible test paths, given a set of decision tables. Some test cases
refer
to test cases in other tables, which in turn may refer to other
tables.
Currently the approach is to follow all paths by hand and write them
down,
which gets quite confusing and error-prone for deeply linked tables,
besides being a dull job.
I was thinking of using Prolog to automate this procedure, to have
something to verify my results against. The meaning of the tables
could be
expressed as links from a node to an expression yielding new nodes:
main ==> (a1 or a2) and g1
a1 ==> b1 or b2 or b3
a2 ==> b3 and (e1 or e2)
b2 ==> f1
'or' means 'fork path here' and 'and' means 'follow the first path,
return,
and then continue with the second path'.
So for the above example, the required output would be something like
this:
[main, a1, b1, g1]
[main, a1, b2, f1, g1]
[main, a1, b3, g1]
[main, a2, b3, e1, g1]
[main, a2, b3, e2, g1]
I've been trying to construct something along the line below, but so
far I haven't been
able to get it correct. (Prolog sometimes doesn't choose the intended
rule). Since I couldn't get any decent algorithm for the past two
weeks (and believe me, I have really tried!), I seek help from a more
knowledgeable Prologician.
Thanks for your time,
Willem Hajenius.
% add links of the form 'link(x, y).'
:- op(600, yfx, and).
:- op(550, yfx, or).
path(A, B and C, [A, PathB | PathC]) :-
path(A, B, PathB),
path(A, C, PathC).
path(A, B or _, [PathB]) :-
path(A, B, PathB).
path(A, _ or C, [PathC]) :-
path(A, C, PathC).
path(A, A, [A]).
path(A, B, [A | RestPath]) :-
link(A, Int),
path(Int, B, RestPath).
- Next message: Brian Hulley: "Re: finding all paths satisfying expressions"
- Previous message: Fabien Todescato: "Re: swi prolog and odbc connectivity"
- Next in thread: Brian Hulley: "Re: finding all paths satisfying expressions"
- Reply: Brian Hulley: "Re: finding all paths satisfying expressions"
- Reply: Willem Hajenius: "Thanks!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|