[comp.lang.prolog] A meta puzzle

arun@cwruecmp.UUCP (Arun Lakhotia) (05/09/87)

While the subject of meta-interpreters is still on, let me give
an interesting coffee time puzzle. 

  solve(true,true).
  solve((GoalA,GoalB),(GoalC,GoalD)):-
      solve(GoalA,GoalC),
      solve(GoalB,GoalD).
  solve(GoalA,GoalB) :-
      sys(GoalA),
      sys(GoalB),
      call(GoalA),
      call(GoalB).
  solve(HeadA,HeadB) :-
      clause(HeadA,BodyA),
      clause(HeadB,BodyB),
      solve(BodyA,BodyB).


Q? For what class of programs would solve(GoalA,GoalB)
   be equivalent to solve(GoalA), solve(GoalB).

Q? If solve(GoalA,GoalB) is true then can one make any comment about
   the relation between the proof-tree, search tree for the two goals.
   with (or without :-)) respect to solve(GoalA) and solve(GoalB).

Q? Can any comment be made about the relation between the clauses that
   are used for asserting GoalA and GoalB for solve(GoalA,GoalB) to be
   true. 

   where solve(Goal) is as follows.

solve(true).
solve((GoalA,GoalB)) :-
     solve(GoalA),
     solve(GoalB).
solve(Goal) :-
     sys(Goal),
     call(Goal).
solve(Head) :-
     clause(Head,Body),
     solve(Body).


BACKGROUND

For people who may be interested in the source of this program. 
The program is the result of composition of  meta-interpreters. 

I took the clause

    solve(GoalA,GoalB) :- solve(GoalA), solve(GoalB).

and applied some simple fold/unfold transformation on it, with a
strategy to unfold the same clause for both the goals simultaneously.
With a little more story i got the program solve(GoalA,GoalB).

The complete semantics of the program is still a puzzle to me.

One statement that i could make is 

   solve(GoalA,GoalB) implies (solve(GoalA), solve(GoalB))

=
   Have Fun

Arun Lakhotia

UUCP  : ..!cbatt!cwruecmp!arun
Csnet : arun@case
Arpanet: arun%case@csnet-relay