% Semantics Principle

% Clause a

(phrase,
 daughters:headed_struc) *>
(qstore:Qstore,
 retr:Retr,
 daughters:Const_struc)
goal (collect_dtrs_qstores(Const_struc,CollectedQstore),
      app(Head,Qstore,CollectedQstore),
      permute(Head,Retr)).

app(X,Y,Z) if
   when(  ( Z=(e_list;ne_list)
                ),
            undel_app(X,Y,Z)).

undel_app([],(L,ne_list),L) if true.
undel_app([H|T1],(L,ne_list),[H|T2]) if
  app(T1,L,T2).
undel_app(L,[],L) if true.

permute(L1,L2) if
        when( (L1=(e_list;ne_list)
	     ),
	undel_permute(L1,L2)).

undel_permute([],[]) if true.
undel_permute([Ele|List],NewList) if (permute(List,List1),
				      insert(Ele,List1,NewList)).

insert(Ele,List,NewList) if (append(X,Y,List),
			     append(X,[Ele|Y],NewList)).