TEACH LERNGRAM                                  Chris Mellish February 1983

LERNGRAM is a very simple program for learning concepts involving English
sentences. The program assumes to start that every sentence that it will ever
encounter is grammatical according to the following grammar (expressed in
Prolog grammar rules):

    s(s(NP,VP)) --> np(NP), vp(VP).

    np(np(D,A,N)) --> det(D), adjs(A), noun(N).

    adjs(adjs(As)) --> noadjs(As).
    adjs(adjs(As)) --> someadjs(As).

    noadjs(noadjs) --> [].

    someadjs(someadjs(A,As)) --> adj(A), adjs(As).

    adj(adj(A)) --> sizeadj(A).
    adj(adj(A)) --> colouradj(A).

    sizeadj(sizeadj(big)) --> [big].
    sizeadj(sizeadj(small)) --> [small].

    colouradj(colouradj(red)) --> [red].
    colouradj(colouradj(blue)) --> [blue].

    det(det(a)) --> [a].
    det(det(the)) --> [the].

    noun(noun(man)) --> [man].
    noun(noun(block)) --> [block].

    vp(vp(VP)) --> transvp(VP).
    vp(vp(VP)) --> verb(VP).

    transvp(transvp(V,NP)) --> verb(V), np(NP).

    verb(verb(sees)) --> [sees].
    verb(verb(hates)) --> [hates].

Given this grammar, the task of the program is to learn a concept that the
user has thought up. Example concepts that it can learn are:

    A sentence with a transitive verb phrase
    A sentence whose subject has at least two adjectives
    A sentence whose subject and object both have the noun "block"

It learns these concepts by being given examples and non-examples of
sentences which fit the concept, in the same style as Winston's program.

The program is in the Prolog library, and so to load it, run Prolog and type:

    ?- library(lerngram).

To actually run it, use the predicate 'talk' (with no arguments).

The program uses the methods of concept learning outlined in * PARPAR, and
prints messages indicating its progress in isolating the concept. Its
representation of "partial parse trees" is as Prolog terms, with the first
element of a tree providing the functor, and "=" entries represented by
Prolog uninstantiated variables. Thus, for instance, the tree

       [world
          [object block]
          [object =]
          [relations
             [touchrel [touchingrel =]]
             [displacementrel above]
          ]
       ]

would be represented by the term:

       world(
          object(block),
          object(X),
          relations(
             touchrel(touchingrel(Y)),
             displacementrel(above)
                   )
             )

Note that Prolog uninstantiated variables are printed out as _1, _2, _3, etc.
