home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / pdprolog / grrules.pro < prev    next >
Text File  |  1986-05-05  |  1KB  |  39 lines

  1. /* 
  2. Except for the PD version, A.D.A. supports the grammar rule syntax. 
  3. If the syntax is supported, one could ask the question:
  4. sentence( X, [every, man, loves, a, woman], [] ).
  5. and see the result translated into a formula of the predicate calculus.
  6. If you want to compile this under the PD version, add the declaration:
  7.   op( 150, xfy, '-->' ). However, the program won't run under type PD
  8. unless you write a grammar rule expander (definitely feasible). 
  9. */
  10.  
  11.  
  12. ?-op( 100, xfx, '$' ).
  13. ?-op( 150, xfy, '->' ).
  14.  
  15. sentence( P ) --> noun_phrase(X,P1,P), verb_phrase(X,P1).
  16.  
  17. noun_phrase(X, P1, P ) -->
  18.    determiner(X,P2,P1,P), noun( X, P3 ),
  19.    rel_clause( X, P3, P2 ).
  20. noun_phrase( X, P, P ) --> proper_noun( X ).
  21.  
  22. verb_phrase( X, P ) --> trans_verb(X,Y, P1), noun_phrase(Y, P1, P ).
  23. verb_phrase( X, P ) --> intrans_verb(X, P ).
  24.  
  25. rel_clause(X,P1,(P1$P2)) --> [that], verb_phrase(X, P2).
  26. rel_clause(_, P, P) --> [].
  27.  
  28. determiner(X, P1, P2, all(X, (P1->P2))) --> [every].
  29. determiner(X, P1, P2, exists(X,(P1$P2))) --> [a].
  30.  
  31. noun(X, man(X) ) --> [man].
  32. noun(X, woman(X)) --> [woman].
  33.  
  34. proper_noun(john) --> [john].
  35.  
  36. trans_verb(X, Y, loves(X,Y)) --> [loves].
  37.  
  38. intrans_verb(X, lives(X) ) --> [lives].
  39.