First of all,I wish a happy new year for everyone.I searched more and worked a lot but I could not solve this question.I am quite a new in prolog and I must do this homework.
In my homework,the question is like this:
Write a prolog program that determines a valid order for the tasks to be carried out in a company. The prolog program will consist of a set of "before" predicates which denotes the order between task pairs. Here is an example;
before(a,b).
before(a,e).
before(d,c).
before(b,c).
before(c,e).
Here, task a should be carried before tasks b and e, d before c and so on. Hence a valid ordering of the tasks would be [a, b, d, c, e]. The order predicate in your program will be queried as follows.
?- order([a,b,c,d,e],X).
X = [a, b, d, c, e] ;
X = [a, d, b, c, e] ;
X = [d, a, b, c, e] ;
false.
Hint: Try to generate different orders for the tasks (permutation) and then check if the order is consistent with the "before" relationships given. Even if you can generate a single valid order, you will get reasonable partial credits.