% Multifile declarations.
:- multifile if/2.

% load phonology and tree output
:- [trale_home(tree_extensions)].

% specify signature file
signature(signature).

% grisu output specifications

hidden_feat(dtrs).         % shown by the tree
%hidden_feat(daughters).    % not shown by the tree

vform <<< aux.
vform <<< inv.

>>>>>> phon.



%====================================================================

% ID Schemata

% ID 1
head_subject_schema ##
(phrase, 
    synsem:local:cat:subcat:e_list,
    daughters:(headcompstruc,
        headdtr:Hdtr,
        compdtrs:[Ndtr]))
===>
cat> Ndtr,
cat> (Hdtr,(synsem:nonlocal:tobind:slash:eset)).

%ID2
head_complement_rule ##
(phrase,
    daughters:(headcompstruc,
        headdtr:(Hdtr,
                 synsem:local:cat:(head:((verb, inv:minus);
                                          non_verb),
                                   subcat:ne_list)),
        compdtrs:[Compdtr]))
===>
cat> Hdtr,
cat> Compdtr.

% ID 3
head_subject_complement_schema ##
(phrase, 
	synsem:local:cat:(head:(verb, inv:plus),
                    subcat:e_list),
	daughters:(headcompstruc, 
	           headdtr:Hdtr,
             compdtrs:CompDtr))
===>
cat> Hdtr,
cat> CompDtr.

% ID 4
head_marker_schema ##
(phrase,
 daughters:(headmarkstruc,
            headdtr:Hdtr,
            markerdtr:Ndtr))
===>
cat> (Ndtr, phon:ne_list,
            synsem:local:cat:head:mod:Mod),
cat> (Hdtr, synsem:(Mod,
                    nonlocal:tobind:slash:eset)).


% ID 5
head_adjunct_schema ##
(phrase,
 daughters:(headadjstruc,
            headdtr:Headdtr,
            adjunctdtr:Adjunctdtr))
   ===>
cat> (Headdtr,
      synsem:(Synsem,
              nonlocal:tobind:slash:eset)),

cat> (Adjunctdtr,
      synsem:local:cat:head:mod:Synsem).

      
% ID 6 (Head-Filler-Schema) not yet implemented
     
%====================================================================
% PRINCIPLES

%head feature principle

(phrase,
 daughters:headstruc) *> (synsem:local:cat:head:Head,
                          daughters:headdtr:synsem:local:cat:head:Head).

%spec principle

(phrase,
	((daughters:(headmarkstruc,markerdtr:Ndtr));
	(daughters:(headcompstruc,compdtrs:[Ndtr])))) *>
	(Ndtr,synsem:local:cat:head:(func,spec:Synsem),
	daughters:headdtr:synsem:Synsem).


%subcat principle, working on binary branching

(phrase, daughters:headstruc) *> (synsem:local:cat:subcat:X,
                                  daughters:(headdtr:(synsem:local:cat:subcat:[DTR|X]),
                                             compdtrs:[synsem:DTR])).


%the subcat principle, original (with append), non-working

%(phrase,
% daughters:headstruc) *> (phrase,
%                          synsem:local:cat:subcat:X,
%                          daughters:(headstruc,
%                                     (headdtr:(synsem:local:cat:subcat:Z),
%                                      compdtrs:Y)))
%goal
%sign_synsem_append(X,Y,Z).

sign_synsem_append(X,Y,Z) if
   when( ( X=(e_list;ne_list)
          ; Y=e_list
          ; Z=(e_list;ne_list)
                 ),
            undelayed_synsem_append(X,Y,Z)).
undelayed_synsem_append([],[],[]) if true.
undelayed_synsem_append([Hd|Tl1],Y,[Hd|Tl2]) if sign_synsem_append(Tl1,Y,Tl2).
undelayed_synsem_append([],[synsem:Hd|Tl1],[Hd|Tl2]) if
  sign_synsem_append([],Tl1,Tl2).

% Semantics Principle
(phrase,
 daughters:headstruc) *> (synsem:local:content:Content,
                          daughters:headdtr:synsem:local:content:Content).


% Marking Principle
(phrase,
 daughters:headstruc) *> (synsem:local:cat:marking:Marking0,
                          daughters:markerdtr:synsem:local:cat:marking:Marking0);

                         (synsem:local:cat:marking:Marking1,
                         daughters:headdtr:synsem:local:cat:marking:Marking1),
                          =\=(daughters:headmarkstruc).

			  

%====================================================================
% LEXICON

% NOUNS ...

peter ~~> (word, synsem:local:((cat:(head:noun,subcat:e_list)),
                        content:index:(ref,
                                    num:sing,
                                    person:third,
                                    gender:masc))).
           

mary ~~> (word, synsem:local:((cat:(head:noun,subcat:e_list)),
                      content:index:(ref,
                                  num:sing,
                                  person:third,
                                  gender:fem))).
          
a ~~> (word, synsem:local:(cat:(head:(det),subcat:[local:cat:head:noun]),
               content:(quant,(det:exists)))).

book ~~> (word, synsem:local:(cat:(head:noun,subcat:[]),
                      content:index:(ref,
                                  num:sing,
                                  person:third,
                                  gender:neut))).

% VERBS ...

likes ~~>  (word, synsem:local:cat:(head:(verb,
                                   vform: fin,
                                   inv:minus,
                                   aux: minus),
			     subcat:[(local:(cat:(head:noun))),
                                     (local:(cat:(head:noun)))])).
				     
walks ~~>  (word, synsem:local:cat:(head:(verb,
                                   vform: fin,
                                   inv:minus,
                                   aux: minus),
			     subcat:[(local:(cat:(head:noun)))])).
			     
gives ~~>  (word, synsem:local:cat:(head:(verb,
                                   vform: fin,
                                   inv:minus,
                                   aux: minus),
			     subcat:[(local:(cat:(head:noun))),
			             (local:(cat:(head:noun))),
                                     (local:(cat:(head:noun)))])).
                                     
can ~~> (word,synsem:local:cat:(head:(verb,
                                vform:fin,
                                inv:minus,
                                aux:plus),
                             subcat:[(local:(cat:(head:noun))),
                                     (local:(cat:(head:(verb,
vform:bse))))])) .

go ~~>  (word, synsem:local:cat:(head:(verb,
                                   vform: bse,
                                   inv: minus,
                                   aux: minus),
                                   subcat:e_list)).

