1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2%%                                                                           %%
    3%%      Version:  1.00   Date: 30/01/95   File: merge2.pl                    %%
    4%% Last Version:                          File:                              %%
    5%% Changes:                                                                  %%
    6%% 30/01/95 Created                                                          %%
    7%%                                                                           %%
    8%% Purpose:                                                                  %%
    9%%                                                                           %%
   10%% Author:  Zoltan Rigo                                                      %%
   11%%                                                                           %%
   12%% Usage:   prolog merge2.pl                                                 %%
   13%%                                                                           %%
   14%%                                                                           %%
   15%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   16
   17:- op(1100, xfy, 'implies'),
   18   op(1000, xfy, 'and'),
   19   op(1050, xfy, 'or'),
   20   op( 400,  fy, 'not').   21
   22:- op( 600,  fy, 'forall'),
   23   op( 600,  fy, 'exists').   24
   25:- op( 600,  fy, 'box'),
   26   op( 600,  fy, 'diamond').   27
   28merge([],_,[]).
   29merge([X | Xs],Ys,PXYs0):-
   30	merge(Ys,X,PXYs0,PXYs1),
   31	merge(Xs,Ys,PXYs1).
   32
   33merge([],_) --> [].
   34merge([X|Xs],Y) -->
   35	{ merge_to_formula(X,Y,PXY) },
   36	[PXY],
   37	merge(Xs,Y).
   38
   39merge_to_formula(L1, L2, Clause):-
   40	( L1 =.. [implies, Prem1, Conc1] ->
   41	    ( L2 =.. [implies, Prem2, Conc2] ->
   42	         Clause =.. [implies, Prem1