%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  File:  grammar10.pl
%
%  Course:  HPSG Grammars in ALE
%
%  Purpose: This grammar is a copy of one written by Suresh
%           Manandhar and Claire Grover which implements most of
%           the important aspects of chapter 9 of the HPSG book.
%           It adds a number of central analyses to grammar9.pl,
%           including lexical entries which cover the following:
%
%           1.  Expletive `it' and `there'
%           2.  Infinitive `to'
%           3.  Various versions of `be' (copula, etc)
%           4.  Prepositions
%           5.  Subject raising
%           6.  Object raising
%           7.  Equi and subject control
%           8.  Equi and object control
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

bot cons bot.
bot sub [list,set,sign,mod_synsem,loc,cat,head,cont,marking,ind,qfpsoa,sem_det,
         gend,num,per,vform,case,boolean,manner,nonloc,nonloc1].

list sub [ne_list,list_sign,list_synsem,list_quant].

set sub [ne_set,set_psoa,set_loc].

e_list sub [].

e_set sub [].

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

ne_set sub [ne_set_psoa, ne_set_loc]
       intro [elt:bot,
              elts:set].

list_sign sub [e_list,ne_list_sign].

list_synsem sub [e_list,ne_list_synsem].

list_quant sub [e_list,ne_list_quant].

set_psoa sub [e_set,ne_set_psoa].

set_loc sub [e_set,ne_set_loc].

ne_list_sign sub []
       intro [hd:sign,
              tl:list_sign].

ne_list_synsem sub []
       intro [hd:synsem,
              tl:list_synsem].

ne_list_quant sub []
       intro [hd:quant,
              tl:list_quant].

ne_set_psoa sub []
       intro [elt:psoa,
              elts:set_psoa].

ne_set_loc sub []
           intro [elt:loc,
                  elts:set_loc].

sign sub [phrase,word]
     intro [synsem:synsem].
  phrase sub [].
  word sub [].

mod_synsem sub [synsem,none].
  synsem sub [pre_mod_synsem, post_mod_synsem]
         intro [loc:loc,
                nonloc:nonloc].
     pre_mod_synsem sub [].
     post_mod_synsem sub [].
  none sub [].
  
loc sub []
     intro [cat:cat,
            cont:cont].

cat sub []
     intro [head:head,
            spr: list_synsem,
            subj:list_synsem,
            comps:list_synsem,
            marking:marking].

cont sub [nom_obj, quant, psoa].

% ----------------------- nom_obj -------------------------------------

nom_obj sub []
        intro [index:ind,
               restr:set_psoa].

% ----------------------- quant -------------------------------------

quant sub []
       intro [det:sem_det,
              restind:nom_obj].

sem_det sub [forall,exists,the].
    forall sub [].
    exists sub [].
    the sub [].

%  ----------------------- ind   ------------------------------------
  ind sub [it, there, ref]
      intro [gen:gend, 
             num:num, 
             per:per].
    it sub [].
    there sub [].
    ref sub [].


gend sub [masc,fem,neut].
   masc sub [].
   fem sub [].
   neut sub [].

num sub [sg,pl].
   sg sub [].
   pl sub [].

per sub [first,second,third].
    first sub [].
    second sub [].
    third sub [].

% ----------------------- psoa -------------------------------------

psoa sub []
     intro [quants:list_quant, nucleus: qfpsoa].


%----------- qfpsoa def taken from hpsg.pl in ALE ------------------

  qfpsoa sub [property,un_relation, bin_relation, tri_relation,
              control_qfpsoa].
    property sub [book,red,happy,human,bus,table]
        intro [instance:ref].
      book sub [].
      red sub [].
      happy sub [].
      human sub [].
      bus sub [].
      table sub [].

    un_relation sub [walk,run,snore].
      walk sub [] intro [walker:ref].
      run sub [] intro [runner:ref].
      snore sub [] intro [snorer:ref].

    bin_relation sub [see,hit,like,sem_on].
      see sub [] 
          intro [seer:ref, seen:ref].
      hit sub [] 
          intro [hitter:ref, hittee:ref].
      like sub [] 
          intro [liker:ref, likee:ref].
      sem_on sub []
          intro [obj_above:ref, obj_below:ref].

    tri_relation sub [sell,give].
      sell sub []
         intro [seller:ref, buyer:ref, sold:ref].
      give sub [] 
         intro [giver:ref, given:ref, gift:ref].

    control_qfpsoa sub [obviously, consider, count,
                        trying, tending, believing,
                        expecting, persuading, promising,bothering,
                        appearance, getting, seeming]
                   intro [soa_arg:psoa].
     obviously sub [] intro [manner:obvious].
     consider sub [] intro [considerer:ref,
                            consideree:ref].
     count sub [] intro [counter:ref,
                         countee:ref].
      trying sub []
           intro [tryer:ref].
      persuading sub []
           intro [persuader:ref, persuadee:ref].
      promising sub []
           intro [promiser:ref, promisee:ref].
      tending sub [].
      seeming sub [].
      believing sub []
           intro [believer:ref].
      expecting sub []
           intro [expector:ref].
      bothering sub []
           intro [bothered:ref].
      appearance sub []
           intro [thing: ref].
      getting sub []
           intro [getter: ref].

manner sub [slow,quick,obvious].
   slow sub [].
   quick sub [].
   obvious sub [].


% -------------------------------------------------------------------

head sub [subst,func].

subst sub [noun,verb,adj,prep,reltvz]
         intro [prd:boolean,
                mod:mod_synsem].
    noun sub []
       intro [case:case].
    verb sub []
       intro [vform:vform,
              inv:boolean,
              aux:boolean].
    adj sub [].
    prep sub [on].
        on sub [].
    reltvz sub [].

case sub [nom,acc].
   nom sub [].
   acc sub [].

vform sub [bse, fin, ger, inf, pas, prp, psp].
    bse sub [].
    fin sub [].
    ger sub [].
    inf sub [].
    pas sub [].
    prp sub [].
    psp sub [].

boolean sub [plus,minus].
   plus sub [].
   minus sub [].

func sub [mark, det]
        intro [spec: synsem].
   mark sub [].
   det sub [].


marking sub [marked, unmarked].
   marked sub [comp,conj].
       comp sub [that,for].
            that sub [].
            for  sub [].
       conj sub [and,or].
            and sub [].
            or sub [].
   unmarked sub [].


% ----------------------- nonloc -------------------------------------

nonloc sub []
       intro [inherited:nonloc1,
              to_bind:nonloc1].
nonloc1 sub [] 
        intro [slash:set_loc].



/**********************  Macros  ******************************/
np(Ind)  macro
   loc:((cat):(head:noun, spr:[], subj:[], comps:[], marking:unmarked),
         cont:(index:Ind)).

head(Head)  macro
   loc:(cat):head:Head.

nbar(Ind) macro
   loc:((cat):(head:noun, spr:[_], subj:[], comps:[], marking:unmarked),
         cont:index:(Ind)).

restr(Restr) macro
   loc:cont:restr:Restr.

spr(Spr) macro
   loc:((cat):spr:Spr).

detp(Cont) macro
   loc:((cat):(head:det, spr:[], subj:[], comps:[], marking:unmarked),
         cont:Cont).

cont(Cont) macro
   loc:cont:Cont.

vp(Prop)  macro
    loc:((cat):(head:verb, comps:[]),
         cont:Prop).

subj(Subj) macro
    loc:((cat):(subj:[Subj])).


case(Case) macro
    loc:(cat):head:case:Case.

cat(Cat) macro
    loc:(cat):Cat.

s(Proposition) macro
  loc:(cat:(head:verb,
            subj:[],
            comps:[]),
       cont:Proposition).

comp macro
   loc:(cat):marking:comp.

marking(Marking) macro
   loc:(cat):marking:Marking.

mod(Mod) macro
   loc:(cat):head:mod:Mod.

head(Head) macro
   loc:(cat):head:Head.

prd(Prd) macro
   loc:(cat):head:prd:Prd.

no_slash macro
   nonloc:(inherited:slash:e_set,
             to_bind:slash:e_set).

/**********************Lexical Entries******************************/
%----------------------- Expletive It --------------------------------
it ---> 
   word,
   synsem:((@ np((per:third,num:sg,gen:neut)),@ mod(none)),
            loc:cont:(index:it ,
                      restr:e_set)).  

%----------------------- Expletive there -----------------------------
there ---> 
   word,
   synsem:((@ np((per:third)),@ mod(none)),
            loc:cont:(index:there ,
                      restr:e_set)).  

kim ---> 
   word,
   synsem:((@ np((per:third,num:sg,gen:masc)),@ mod(none)),
            loc:cont:(index:ref,
                      restr:e_set),
            @ no_slash).  

sandy ---> 
   word,
   synsem:((@ np((per:third,num:sg,gen:fem)),@ mod(none)),
           loc:cont:(index:ref,
                     restr:e_set),
           @ no_slash).  


like ---> 
   word, 
   synsem:(@ mod(none),
           loc:((cat):(head:(verb,
                            vform:bse,
                            aux:minus,
                            inv:minus),
                      spr:[(@ comp)],
                      subj:[(@ np(Ind1),@ case(nom))], 
                      comps:[(@ np(Ind2),@ case(acc))],
                      marking:unmarked),
               cont:(nucleus:(like,
                              liker:Ind1,
                              likee:Ind2),
                     quants:[])),
            @ no_slash).

give ---> 
   word, 
   synsem:(@ mod(none),
           loc:((cat):(head:(verb,
                            vform:bse,
                            aux:minus,
                            inv:minus),
                      spr:[(@ comp)],
                      subj:[(@ np(Ind1),@ case(nom))], 
                      comps:[(@ np(Ind2),@ case(acc)),(@ np(Ind3),@ case(acc))],
                      marking:unmarked),
               cont:(nucleus:(give,
                              giver:Ind1,
                              given:Ind2,
                              gift:Ind3),
                     quants:[])),
            @ no_slash).

snore ---> 
   word, 
   synsem:(@ mod(none),
           loc:((cat):(head:(verb,
                            vform:bse,
                            aux:minus,
                            inv:minus),
                      spr:[(@ comp)],
                      subj:[(@ np(Ind),@ case(nom))], 
                      comps:[],
                      marking:unmarked),
               cont:(nucleus:(snore,
                              snorer:Ind),
                     quants:[])),
            @ no_slash).


%----------------------- Auxiliaries --------------------------------
can --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:fin,
                           aux:plus),
                   spr:Spr,
                   subj:[X],
                   comps:[(@ vp(Prop),@ subj(X),@ spr(Spr),
                               loc:cat:(head:vform:bse))],
                   marking:unmarked),
              cont:Prop),
          @ no_slash).

to --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:inf,
                           aux:plus,
                           inv:minus),
                     subj:[X], 
                     comps:[(@ vp(Prop),   
                              loc:cat:(head:vform:bse,
                                       subj:[X]))],
                     marking:unmarked),
              cont:Prop),
            @ no_slash).

be --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           aux:plus),
                     spr:[(@ comp)],
                     subj:[X], 
                     comps:[(@ prd(plus),@ cont(Cont),
                             @ subj(X),@ marking(unmarked))],
                     marking:unmarked),
              cont:Cont),
            @ no_slash).

is --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:fin,
                           aux:plus),
                     spr:[(@ comp)],
                     subj:[X], 
                     comps:[(@ prd(plus),@ cont(Cont),
                             @ subj(X),@ marking(unmarked))],
                     marking:unmarked),
              cont:Cont),
            @ no_slash).
is --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:psp,
                           aux:plus),
                     spr:[(@ comp)],
                     subj:[X], 
                     comps:[(@ prd(plus),@ cont(Cont),
                             @ subj(X),@ marking(unmarked))],
                     marking:unmarked),
              cont:Cont),
            @ no_slash).

%------------------------------ Expletive subject 'is' ------------
is --->
  word,
  synsem:loc:(cat:(head:(verb,
                           mod:none,
                           vform:fin,
                           aux:plus),
                     spr:[(@ comp)],
                     subj:[(@ np(it))], 
                     comps:[X,
                            (@ prd(plus),@ cont(Cont),
                             @ subj(X),
			     @ marking(unmarked))],
                     marking:unmarked),
              cont:Cont).
%------------------------------ Expletive subject 'be' ------------
be --->
  word,
  synsem:loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           aux:plus),
                     spr:[(@ comp)],
                     subj:[(@ np(there))], 
                     comps:[X,
                            (@ prd(plus),@ cont(Cont),
                             @ subj(X),
			     @ marking(unmarked))],
                     marking:unmarked),
              cont:Cont).
%------------------------------ Determiners (Simplified) ------------

every --->
   word,
   synsem:(loc:((cat):(head:(det,
                            spec:((@ cont(Cont),@ nbar((num:sg))))),
                      spr:[],
                      subj:[], 
                      comps:[],
                      marking:unmarked),
               cont:(det: forall,
                     restind: Cont)),
            @ no_slash).

a --->
   word,
   synsem:(loc:((cat):(head:(det,
                            spec:((@ cont(Cont),@ nbar((num:sg))))),
                      spr:[],
                      subj:[], 
                      comps:[],
                      marking:unmarked),
               cont:(det: exists,
                     restind: Cont)),
            @ no_slash).

the --->
   word,
   synsem:(loc:((cat):(head:(det,
                            spec:((@ cont(Cont),@ nbar(_)))),
                      spr:[],
                      subj:[], 
                      comps:[],
                      marking:unmarked),
               cont:(det: exists,
                     restind: Cont)),
            @ no_slash).

%------------------ Complementisers  --------------------------

that --->
  word,
  synsem:(loc:(cat:(head:(mark,
                           spec:(@ s(_),
                                 loc:cat:(head:vform:( fin 
                                                       ; bse),
                                            marking:unmarked))),
                   spr:[],
                   subj:[],
                   comps:[],
                   marking:that)),
            @ no_slash).

for --->
  word,
  synsem:(loc:(cat:(head:(mark,
                           spec:(@ s(_),
                                 loc:cat:(head:vform:(inf),
                                            marking:unmarked))),
                   spr:[],
                   subj:[],
                   comps:[],
                   marking:for)),
            @ no_slash).

%-------------------------- Common Nouns ----------------------
book --->
    word,
    synsem:((@ mod(none),
             @ nbar((per:third,num:sg,gen:neut)),
             @ spr([(@ detp(_))]),
             @ cont((index:Ind,
                     restr:(elt:(nucleus:(book,
                                          instance:Ind),
                                 quants:[]),
                            elts:e_set))),
             @ no_slash)).  

    

bus --->
    word,
    synsem:((@ mod(none),
             @ nbar((per:third,num:sg,gen:neut)),
             @ spr([(@ detp(_))]),
             @ cont((index:Ind,
                     restr:(elt:(nucleus:(bus,
                                          instance:Ind),
                                 quants:[]),
                            elts:e_set))),
             @ no_slash)).  

    

table --->
    word,
    synsem:((@ mod(none),
             @ nbar((per:third,num:sg,gen:neut)),
             @ spr([(@ detp(_))]),
             @ cont((index:Ind,
                     restr:(elt:(nucleus:(table,
                                          instance:Ind),
                                 quants:[]),
                            elts:e_set))),
            @ no_slash)).  

    


person --->
    word,
    synsem:((@ mod(none),
             @ nbar((per:third,num:sg)),
             @ spr([(@ detp(_))]),
             @ cont((index:Ind,
                     restr:(elt:(nucleus:(human,
                                          instance:Ind),
                                 quants:[]),
                            elts:e_set))),
            @ no_slash)).  

    

%--------------------- Non-predicative Adjectives -------------------

red --->
  word,
  synsem:(loc:(cat:(head:(adj,
                         prd:minus,
                         mod:(pre_mod_synsem,
                              @ nbar(Ind),
                              @ restr(Restrs))),
                   spr:[],          % Not quite right. degree sprs.
                   subj:[],
                   comps:[],
                   marking:unmarked),
              cont:(index:Ind,
                    restr:(elt:(nucleus:(red,
                                         instance:Ind),
                                quants:[]),
                           elts:Restrs))),
            @ no_slash).



happy --->
  word,
  synsem:(loc:(cat:(head:(adj,
                         prd:minus,
                         mod:(pre_mod_synsem,
                              @ nbar(Ind),
                              @ restr(Restrs))),
                   spr:[],          % Not quite right. degree sprs.
                   subj:[],
                   comps:[],
                   marking:unmarked),
              cont:(index:Ind,
                    restr:(elt:(nucleus:(happy,
                                         instance:Ind),
                                quants:[]),
                           elts:Restrs))),
            @ no_slash).



obviously --->
  word,
  synsem:(loc:(cat:(head:(adj,
                         prd:minus,
                         mod:((@ vp(Prop),@ marking(unmarked)))),
                   spr:[],        % Not quite right. degree sprs.          
                   subj:[],
                   comps:[],
                   marking:unmarked),
              cont:(nucleus:(obviously,
                             soa_arg:Prop),
                    quants:[])),
            @ no_slash).



% -------------- Non-predicative prepositions (pp. 347)  ---------

on --->
  word,
  synsem:(loc:(cat:(head:(on,
                         prd:minus,
                         mod:none),
                   spr:[],
                   subj:[],
                   comps:[(@ np(Ind),@ restr(Restr))],
                   marking:unmarked),
              cont:(index:Ind, restr:Restr)),
            @ no_slash).


% -------------- Predicative prepositions  ---------------------------

on --->
  word,
  synsem:(loc:(cat:(head:(on,
                         prd:plus,
                         mod:none),
                   spr:[],
                   subj:[(@ np(Ind1))],
                   comps:[(@ np(Ind2))],
                   marking:unmarked),
              cont:(quants:[],
                    nucleus:(sem_on,
                             obj_above:Ind1,
                             obj_below:Ind2))),
            @ no_slash).



%--------------------- Predicative Adjectives -------------------

happy --->
  word,
  synsem:(loc:(cat:(head:(adj,
                         prd:plus,
                         mod:none),
                   spr:[],          % Not quite right. degree sprs.
                   subj:[(@ np(Ind))],
                   comps:[],
                   marking:unmarked),
              cont:(nucleus:(happy,
                             instance:Ind),
                    quants:[])),
            @ no_slash).



%----------------------- Subject raising -------------------
% -- seem[subj:[X],comps:[VP[inf, subj:[X]]]]
seem --->
  word,
  synsem:loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[X],
                   comps:[(@ vp(Prop),@ subj(X),
                           @ head((vform:inf)), @ marking(unmarked))],
                   marking:unmarked),
               cont:(nucleus:(seeming,
                              soa_arg:Prop),
                     quants:[])).  



%----------------------- Object raising -------------------


% -- believe[comps:[X,VP[inf, subj:[X]]]]
% CG -- restricted the X to np to prevent spurious interactions
% with nonlocal stuff.
believe --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[(X, @ np(_)),
                          (@ vp(Prop),@ subj(X),
                           @ head((vform:inf)), @ marking(unmarked))],
                   marking:unmarked),
               cont:(nucleus:(believing,
                              believer:Ind1,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  


% -- expect[comps:[X,VP[inf, subj:[X]]]]
expect --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[X,
                          (@ vp(Prop),@ subj(X),
                           @ head((vform:inf)), @ marking(unmarked))],
                   marking:unmarked),
               cont:(nucleus:(expecting,
                              expector:Ind1,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  


% --------------------- Equi & Subject Control  -----------------------


% -- try[subj:[np(I)],comps:[VP[inf, subj:[np(I)]]]]
try --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[(@ vp(Prop),@ subj(@ np(Ind1)),
                           @ head((vform:inf)), @ marking(unmarked))],
                   marking:unmarked),
               cont:(nucleus:(trying,
                              tryer:Ind1,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  


% -- look[subj:[np(I)],comps:[AP[prd+, subj:[np(I)]]]]
look --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[(loc:(cat:(head:adj), 
                                cont:Prop),
                            @ subj(@ np(Ind1)),@ prd(plus))],
                   marking:unmarked),
               cont:(nucleus:(appearance,
                              thing: Ind1,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  


% -- get[subj:[np(I)],comps:[PP[prd+, subj:[np(I)]]]]
get --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[(loc:(cat:head:prep, 
                                cont:Prop),
                            @ subj(@ np(Ind1)),@ prd(plus))],
                   marking:unmarked),
               cont:(nucleus:(getting,
                              getter: Ind1,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  




% -- promise[subj:[np(I)],comps:[NP2, VP[inf, subj:[np(I)]]]]
promise --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[(@ np(Ind2),@ case(acc)),
		          (@ vp(Prop),@ subj(@ np(Ind1)),
                             @ head((vform:inf)), @ marking(unmarked))],
                   marking:unmarked),
               cont:(nucleus:(promising,
                              promiser:Ind1,
			      promisee:Ind2,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  



% --------------------- Equi & Object control -----------------------


% -- persuade[subj:[NP1],comps:[np(I), VP[inf, subj:[np(I)]]]]
persuade --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
                   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[(@ np(Ind2)),
		          (@ vp(Prop),@ subj(@ np(Ind2)),
                             @ head((vform:inf)), @ marking(unmarked))],
                   marking:unmarked),
               cont:(nucleus:(persuading,
                              persuader:Ind1,
			      persuadee:Ind2,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  



% ---------------------- sbar arguments ------------------------------

% CG -- removed the @ marking(marked) restriction on the s complement
% to allow [kim,believes,sandy,likes,books].
believe --->
  word,
  synsem:(loc:(cat:(head:(verb,
                           mod:none,
                           vform:bse,
                           inv:minus,
                           aux:minus),
                   spr:[(@ comp)],
		   subj:[(@ np(Ind1),@ case(nom))],
                   comps:[(@ s(Prop),
                           @ head((vform:fin)))],
                   marking:unmarked),
               cont:(nucleus:(believing,
                              believer:Ind1,
                              soa_arg:Prop),
                     quants:[])),
            @ no_slash).  




/********************** Lexical Rules ****************************/



% Finite Verb Formation
% ----------------------------------------------------------------------------

% regulars: lexical rule
pres_3s lex_rule
  (word,
   synsem:(loc:((cat):(head:(verb,
                             vform:bse,
                             aux:minus,
                             mod:Mod,
                             inv:Inv
                           ),
                       spr:Spr,
                       subj:[Subj],
                       comps:Comps,   
                       marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))
  **>
  (word,
   synsem:(loc:((cat):(head:(verb,
                             vform:fin,
                             aux:minus,
                             mod:Mod,
                             inv:Inv
                           ),
                       spr:Spr,
                       subj:[NewSubj],
                       comps:Comps,
                       marking:Marking),
                 cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))
  if  pres_3s_act(Subj,NewSubj)
  morphs
    (X,y) becomes (X,i,e,s),
    X becomes (X,s).

pres_3s_act((NP,@ np(_)),(NP,@ np((per:third,num:sg)),@ case(nom))) if
  !,true.
pres_3s_act(X,X) if
  true.




pres_non3s lex_rule
  (word,
   synsem:(loc:((cat):(head:(verb,
                             vform:bse,
                             aux:minus,
                             mod:Mod,
                             inv:Inv),
                       spr:Spr,
                       subj:[Subj],
                       comps:Comps,
                       marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))
  **>
  (word,
   synsem:(loc:((cat):(head:(verb,
                             vform:fin,
                             aux:minus,
                             mod:Mod,
                             inv:Inv),
                       spr:Spr,
                       subj:[NewSubj],
                       comps:Comps,
                       marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))
  if pres_non3s_act(Subj,NewSubj)
  morphs
    X becomes X.

pres_non3s_act((NP,@ np(_)),(NP,@ np((per:(first;second);num:pl)),
                             @ case(nom))) if
  true.




% Passive Formation
% ----------------------------------------------------------------------------
% adapted from hpsg.pl in ALE

passive lex_rule
  (word,
   synsem:(loc:(cat:(head:(verb,
                             vform:bse,
                             aux:minus,
                             inv:Inv,
                             prd:Prd,
                             mod:Mod),
                     comps:([loc:(cat:(head:(noun,
                                            prd:SubPrd,
                                            mod:SubMod), % ignore case
                                      subj:[],
                                      comps:[],
                                      marking:SubMarking),
                                  cont:SubCont)|SubRest]),
                       marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))
  **>
  (word,
   synsem:(loc:(cat:(head:(verb,
                             vform:pas,
                             aux:minus,
                             inv:Inv,
                             prd:Prd,
                             mod:Mod),
                     subj:[(loc:(cat:(head:(noun,
                                            prd:SubPrd,  % no case since
                                            mod:SubMod), %  not fin form
                                      subj:[],
                                      comps:[],
                                      marking:SubMarking),
                                  cont:SubCont))],
                     comps:SubRest,
                     marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))

  morphs
    give becomes given,
    see becomes seen,
    (X,y) becomes (X,ied),
    (X,e) becomes (X,ed),
    X becomes (X,ed).



% Complement Extraction Lexical Rule
% ----------------------------------------------------------------------------


celr lex_rule
(word,
   synsem:(loc:(cat:(head:Head,
                     spr:Spr,
                     subj:Subj,
                     comps:Compsin,
                     marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))
  **>
  (word,
   synsem:(loc:(cat:(head:Head,
                     spr:Spr,
                     subj:Subj,
                     comps:Compsout,
                     marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:(elt:Loc,
                                    elts:e_set),
                   to_bind:slash:e_set)))
  if 
    select((loc:Loc),Compsin,Compsout)
  morphs
    X becomes X.


select(X,(hd:X,tl:Z),Z) if true.
select(X,[Hd|Y],[Hd|Z]) if select(X,Y,Z).


% Subject Extraction Lexical Rule
% ----------------------------------------------------------------------------


selr lex_rule
(word,
   synsem:(loc:(cat:(head:Head,
                     spr:Spr,
                     subj:Subj,
                     comps:Compsin,
                     marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:e_set,
                   to_bind:slash:e_set)))
  **>
  (word,
   synsem:(loc:(cat:(head:Head,
                     spr:Spr,
                     subj:Subj,
                     comps:Compsout,
                     marking:Marking),
                cont:Cont),
           nonloc:(inherited:slash:(elt:Loc,
                                    elts:e_set),
                   to_bind:slash:e_set)))
  if 
    subst((loc:(cat:(head:vform:fin,
                     subj:e_list,
                     comps:e_list),
                cont:SCont)),
          (loc:(cat:(head:vform:fin,
                     subj:[(@ np(_),@ case(nom),loc:Loc)],
                     comps:e_list),
                cont:SCont)),
          Compsin,
          Compsout)
  morphs
    X becomes X.

subst(X,Y,(hd:X,tl:Z),(hd:Y,tl:Z)) if true.
subst(X,Y,[Hd|Tl1],[Hd|Tl2]) if subst(X,Y,Tl1,Tl2).


/********************** Grammmar Rules ****************************/

subject_head rule              % Schema 1               
(phrase,Mother,synsem:loc:(cat):(spr:Spr,subj:[], comps:[]))
===>
cat> (SubjDtr),  
goal> (sign_to_synsem(SubjDtr,SubjSynsem)),
cat> (HeadDtr,synsem:loc:(cat):(spr:Spr,subj:[SubjSynsem],comps:[])),
goal> (head_feature_principle(Mother,HeadDtr),
       semantics_principle(Mother,HeadDtr),
       marking_principle(Mother,HeadDtr),
       nonlocal_feature_principle(Mother,HeadDtr,[SubjDtr])).


head_complement rule            % Schema 2
(phrase,Mother,synsem:loc:(cat):(spr:Spr,subj:Subjs,comps:[]))
===>
cat> (word,HeadDtr,synsem:loc:(cat):(spr:Spr,subj:Subjs, comps:CompSynsems)),
goal> (list_sign_to_synsem(CompDtrs,CompSynsems)),
cats> (CompDtrs,ne_list),
goal> (head_feature_principle(Mother,HeadDtr),
       semantics_principle(Mother,HeadDtr),
       marking_principle(Mother,HeadDtr),
       nonlocal_feature_principle(Mother,HeadDtr,CompDtrs)).


head_subject_complement rule    % Schema 3
(phrase,Mother,synsem:loc:(cat):(spr:[],subj:[],comps:[]))
===>
cat> (word,HeadDtr,synsem:loc:(cat):(head:inv:plus,
%                                     spr:Spr,
                                     subj:[SubjSynsem], 
                                     comps:CompSynsems)),
goal> (list_sign_to_synsem(CompDtrs,CompSynsems)),
cat> (SubjDtr),
goal> (sign_to_synsem(SubjDtr,SubjSynsem)),
cats> (CompDtrs,ne_list),
goal> (head_feature_principle(Mother,HeadDtr),
       semantics_principle(Mother,HeadDtr),
       marking_principle(Mother,HeadDtr),
       nonlocal_feature_principle(Mother,HeadDtr,[SubjDtr|CompDtrs])).


specifier_head rule              % Schema 4
(phrase,Mother,synsem:loc:(cat):(spr:[],subj:[],comps:[]))
===>
cat> (SpecDtr,synsem:loc:(cat):(spr:[],subj:[], comps:[])),
goal> (sign_to_synsem(SpecDtr,SpecSynsem)),
cat> (HeadDtr,synsem:loc:(cat):(spr:[SpecSynsem],subj:[], comps:[])),
goal> (head_feature_principle(Mother,HeadDtr),
       semantics_principle(Mother,HeadDtr),
       marking_principle(Mother,SpecDtr),
       spec_principle(SpecDtr,HeadDtr),
       nonlocal_feature_principle(Mother,HeadDtr,[SpecDtr])).


adjunct_head rule                % Schema 5a
(Mother,phrase,synsem:loc:cat:(spr:Spr, subj:Subj, comps:[]))
===>
cat> (AdjDtr,synsem:loc:cat:(head:mod:(pre_mod_synsem,Mod),
                             spr:[],
                             subj:[],
                             comps:[])),
cat> (HeadDtr,synsem:(Mod,loc:cat:(spr:Spr, subj:Subj, comps:[]))),
goal> (head_feature_principle(Mother,HeadDtr),
       marking_principle(Mother,HeadDtr),
       semantics_principle(Mother,AdjDtr),
       nonlocal_feature_principle(Mother,HeadDtr,[AdjDtr])).


head_adjunct rule                % Schema 5b
(Mother,phrase,synsem:loc:cat:(spr:Spr, subj:Subj, comps:[]))
===>
cat> (HeadDtr,synsem:(Mod,loc:cat:(spr:Spr, subj:Subj, comps:[]))),
cat> (AdjDtr,synsem:loc:cat:(head:mod:(post_mod_synsem,Mod),
                             spr:[],
                             subj:[],
                             comps:[])),
goal> (head_feature_principle(Mother,HeadDtr),
       marking_principle(Mother,HeadDtr),
       semantics_principle(Mother,AdjDtr),
       nonlocal_feature_principle(Mother,HeadDtr,[AdjDtr])).



filler_head rule              % Schema 6
(Mother,phrase,synsem:loc:cat:(head:(verb,vform:fin),
                               spr:Spr,subj:[],comps:[]))
===>
cat> (FillerDtr, synsem:loc:Slashloc),  
cat> (HeadDtr,synsem:(loc:cat:(spr:Spr,subj:[],comps:[]),
                      nonloc:(inherited:slash:(elt:Slashloc,elts:e_set),
                                to_bind:slash:(elt:Slashloc,elts:e_set)))),
goal> (head_feature_principle(Mother,HeadDtr),
       semantics_principle(Mother,HeadDtr),
       marking_principle(Mother,HeadDtr),
       nonlocal_feature_principle(Mother,HeadDtr,[FillerDtr])).


/********************** Universal Principles **********************/

% subcat_principle(Mother,Head-Daughter,Comp-Dtr-Signs)
%--------------------------------------------------------------
%subcat_principle((synsem:loc:(cat):subcat:MSub),(synsem:loc:(cat):subcat:HSub),
%                 CompSigns) if
%  append(MSub,CompSigns,HSub).


% head_feature_principle(Mother,Head-Daughter)
%-------------------------------------------
head_feature_principle(synsem:loc:(cat):head:X,synsem:loc:(cat):head:X) if
  true.



% semantics_principle(Mother, SemHead)
%-------------------------------------------
semantics_principle(synsem:loc:cont:X,synsem:loc:cont:X) if
  true.



% spec_principle(Spec-Dtr,Head-Dtr)
%--------------------------------------------------------
%  Spec-Dtr is either mark-dtr or first comp-dtr
spec_principle((synsem:loc:cat:head:Head),synsem:HeadSynsem) if
  specp_act(Head,HeadSynsem).

specp_act(subst,_) if      % substantive head
  true.
specp_act(spec:X,X) if     % functional head
  true.


% marking_principle(Mother,Head-Daughter)
%-------------------------------------------
marking_principle(synsem:loc:(cat):marking:X,synsem:loc:(cat):marking:X) if
  true.


% nonlocal_feature_principle(Mother,Head-Daughter,Other-Dtrs)
%--------------------------------------------------------------
% adapted from hpsg4.pl

nonlocal_feature_principle(
            (synsem:nonloc:inherited:slash:MISlash),
            (HDtr, synsem:nonloc:to_bind:slash:HTSlash),
            ODtrs) if
   islashes_of([HDtr|ODtrs],e_set,DISlash),
   set_diff(HTSlash,DISlash,MISlash).


/********************** Definite Constraints **********************/
equals(X, X) if true.

append([],Xs,Xs) if
  true.
append([H|T1],L2,[H|T2]) if
  append(T1,L2,T2).


sign_to_synsem(synsem:Synsem,Synsem) if
     true.

list_sign_to_synsem([],[]) if
     true.

list_sign_to_synsem([H|T],[S|R]) if
     sign_to_synsem(H,S),
     list_sign_to_synsem(T,R). 



%% from hpsg.pl

islashes_of([],ISlash,ISlash) if
  true.
islashes_of([(synsem:nonloc:inherited:slash:e_set)|Dtrs],Accum,ISlash) if
  islashes_of(Dtrs,Accum,ISlash),
  !.
islashes_of([(synsem:nonloc:inherited:slash:DISlash)|Dtrs],Accum,ISlash) if
  union(Accum,DISlash,NewAccum),
  islashes_of(Dtrs,NewAccum,ISlash).

% union(?set1,+set2,?union)
union(e_set,Xs,Xs) if       
  true.
union((elt:X,elts:Xs),Ys,Zs) if
  set_member_eq(X,Ys),
  !,union(Xs,Ys,Zs).
union((elt:X,elts:Xs),Ys,(elt:X,elts:Zs)) if
  set_select(X,Ys,YsRest),
  union(Xs,YsRest,Zs).
union((elt:X,elts:Xs),Ys,(elt:X,elts:Zs)) if
  union(Xs,Ys,Zs).

set_diff(e_set,Set,Set) if   %first arg should be instantiated, so cut
  !,true.                    % in case it isn't, and it should also be subset
                             % of the second
set_diff((elt:X,elts:Xs),Set,Diff) if
  set_select_eq(X,Set,Rest),
  set_diff(Xs,Rest,Diff).

set_select(X,(elt:X,elts:Xs),Xs) if
  true.
set_select(Member,(elt:X,elts:Xs),(elt:X,elts:Rest)) if
  set_select(Member,Xs,Rest).

% set_select_eq(+member,+set,?rest)
set_select_eq(X,(elt:Y,elts:Xs),Xs) if    
  (X =@ Y).
set_select_eq(Member,(elt:X,elts:Xs),(elt:X,elts:Rest)) if
  set_select_eq(Member,Xs,Rest).

