% Grammar 4c
% ==========


% signature file
signature(signature).


:- [lexicon].


% phrase structure rules
subject_head_rule rule
(phrase,
 phon:MotherPhon,
 synsem:category:subcat:[],
 dtr1:Subj, dtr2:Head)
   ===>
cat> (Subj, phon:SubjPhon),
cat> (Head, phon:HeadPhon),
goal> phon_append(SubjPhon,HeadPhon,MotherPhon).

head_complement_rule rule
(phrase,
 phon:MotherPhon,
 synsem:category:subcat:ne_list,
 dtr1:Comp, dtr2:Head)
   ===>
cat> (Head, phon:HeadPhon),
cat> (Comp, phon:CompPhon),
goal> phon_append(HeadPhon,CompPhon,MotherPhon).


% Principles

% Semantics Principle
phrase *> (synsem:content:C,
	   dtr2:synsem:content:C).

% Head Feature Principle
phrase *> (synsem:category:head:H,
	   dtr2:synsem:category:head:H).

% Subcategorization Principle (alternate version)
phrase *> (%Phrase,
	   synsem:category:subcat:PhrSubcat,
           dtr1:synsem:Synsem,
           dtr2:synsem:category:subcat:HeadSubcat)
goal
   append(PhrSubcat,[Synsem],HeadSubcat).



% Goal definitions

phon_append([],[],[]) if !, true.
phon_append([],[H|T1],[H|T2]) if phon_append([],T1,T2).
phon_append([H|T1],L,[H|T2]) if phon_append(T1,L,T2).


append(X,Y,Z) if
   when(  ( X=(e_list;ne_list)
                ),
            undelayed_append(X,Y,Z)).

undelayed_append(L,[],L) if true.
undelayed_append([],(L,ne_list),L) if true.
undelayed_append([H|T1],(L,ne_list),[H|T2]) if
  append(T1,L,T2).








%==============================================================


% definite relation for alternative version of the
% Subcategorization Principle

app(L,[],L) if true.
app([],(L,ne_list),L) if true.
app([H|T1],(L,ne_list),[H|T2]) if
  app(T1,L,T2).




%==============================================================

% Subcategorization Principle

% more efficient version:
% delay full application of Subcategorization Principle until
% the values of the dtr features are unified into the mother
%
%goal when( (Phrase=(dtr1:synsem:category:head:(noun;verb),
%		    dtr2:synsem:category:head:(noun;verb)) ),
%   app(PhrSubcat,[Synsem],HeadSubcat)).
