%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  File:  grammar3.pl
%
%  Course:  HPSG Grammars in ALE
%
%  Purpose:  1. Introduces macros
%            2. Implements the head-complement schema
%            3. Adds lexical entries for "likes", "gives",
%               "kim", and "books"
%
%  Parses:    kim likes sandy
%             kim gives sandy books
%             *snored likes sandy
%             *likes likes sandy (two parses)
%
% No parses:  same as before
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%**********************  Type Hierarchy

bot sub [sign,list,cat,head].

sign sub []
   intro [cat:cat].

cat sub []
   intro [head:head,
          subj:list,
          comps:list].       % new feature
                                
head sub [noun,verb].

noun sub [].
verb sub [].

list sub [e_list,ne_list].

ne_list sub []
   intro [hd:bot,
          tl:list].

e_list sub [].

%%%**********************  Macros

np macro
  cat:(head:noun,                 %  Define "np" as a macro
       subj:[],
       comps:[]).              %  NPs don't take complements

%%%**********************  Lexical Entries

sandy ---> @np.        %  Macro definitions used in lexical entries.
kim   ---> @np.          %  New entries for "kim", "books", etc
books ---> @np.

snored ---> cat:(head:verb,
                 subj:[@np],
                 comps:[]).       % "comps" specification required

likes ---> cat:(head:verb,
                subj:[@np],
                comps:[@np]).

gives ---> cat:(head:verb,
                subj:[@np],
                comps:[@np,@np]).

%%%**********************  Grammmar Rules

subject_head rule
(cat:subj:[])
===>
cat> (cat:head:Head),  
cat> (cat:(subj:[cat:head:Head],
                 comps:[])).          % "comps" feature added

head_complement rule            % head-complement rule added
(cat:comps:[])
===>
cat> (cat:comps:Comps),
cats> (Comps,ne_list).           % Note "cats>" matches a list
