Using logic throughout implies minimal need for interfaces
Logic term rewriting formalism
Applications:
- A conversation system in French on social and kin relationships
- A Spanish, French and English front end to the first database system written in Prolog (compared favourably in efficiency to that of the Lunar System by Woods)
Interesting mutual feedback: formal linguistics, computational linguistics
and L.P.
sent(P) :- name(X), verb_phrase(X,P).
% Verb Phrases
verb_phrase(X,P):- verb(X,P,L), comps(L).
comps([]).
comps([H|T]) :- comp(H), comps(T).
comp([P,X]) :- P, name(X).
prep_phrase(W,Z) :- W, name(Z).
% Intransitive verbs
verb(X,smiles(X),[]) :- #smiles.
% Transitive verbs
verb(X,likes(X,Y),[[prep(dir),Y]]) :- #likes.
verb(X,P,L) :- #is, adj(X,P,L).
% Bitransitive verbs
verb(X,gives(X,Y,Z),[[prep(dir),Y],[prep(to),Z]]) :- #gives.
prep(to) :- #to.
prep(dir).
name(anne) :- #anne.
name(rover) :- #rover.
name(peter) :- #peter.
name(X) :- #who.
% Unary adjectives
adj(X,intelligent(X),[]) :- #intelligent.
adj(X,kind(X),[]) :- #kind.
% Binary adjectives
adj(X,angry_with(X,Y),[[prep(with),Y]]) :- #angry.
Retrieving the argument questioned on (sentences with "who")
% A question is a sentence in which some % name has been replaced by "who" % (assumed as "answer" in the name rule, % to be consumed by the question rule) question(X,P) :- sent(P), -answer(X). sent(P) :- noun_phrase(X), verb_phrase(X,P). % Noun Phrases noun_phrase(X) :- name(X). % Verb Phrases verb_phrase(X,P):- verb(X,P,L), comps(L). comps([]). comps([H|T]) :- comp(H), comps(T). comp([P,X]) :- P, name(X). prep_phrase(W,Z) :- W, name(Z). % Intransitive verbs verb(X,smiles(X),[]) :- #smiles. % Transitive verbs verb(X,likes(X,Y),[[prep(dir),Y]]) :- #likes. verb(X,P,L) :- #is, adj(X,P,L). % Bitransitive verbs verb(X,gives(X,Y,Z),[[prep(dir),Y],[prep(to),Z]]) :- #gives. prep(to) :- #to. prep(dir). name(anne) :- #anne. name(rover) :- #rover. name(peter) :- #peter. name(X) :- #who, +answer(X). % Unary adjectives adj(X,intelligent(X),[]) :- #intelligent. adj(X,kind(X),[]) :- #kind. % Binary adjectives adj(X,angry_with(X,Y),[[prep(with),Y]]) :- #angry. % Adjective Phrases adj_phrase(X,P) :- adj(X,P,L), comps(L).
% N.B. Not yet embedded inside noun phrases % (i.e., complements are built around proper % names, not quantified noun phrases) % Only relevant rules are shown, more complete % grammar next sent(S) :- noun_phrase(X,P,S), verb_phrase(X,P). % Noun Phrases noun_phrase(X,P,P) :- name(X). noun_phrase(X,Predicate,Formula):- quant(X,Subject,Predicate,Formula), noun(X,Subject,L), comps(L). quant(X,S,P,the(X,S,P)) :- #the. quant(X,S,P,a(X,S,P)) :- #a; #some. quant(X,S,P,no(X,S,P)) :- #no. quant(X,S,P,all(X,S,P)) :- #all; #every. noun(X,dinosaur(X),[]):- #dinosaur. noun(X,chair(X),[]):- #chair. noun(X,mother_of(X,Y),[[prep(of),Y]]). noun(X,father_of(X,Y),[[prep(of),Y]]).
% WARNING: WORKS FOR ANALYSIS ONLY % Sentences question(X,Q) :- sent(Q), -answer(X). sent(S) :- noun_phrase(X,P,S), verb_phrase(X,P). % Noun Phrases noun_phrase(X,P,P) :- name(X). noun_phrase(X,Predicate,Formula):- quant(X,Subject,Predicate,Formula), noun(X,S,L), comps(L,S,Subject). quant(X,S,P,the(X,S,P)) :- #the. quant(X,S,P,a(X,S,P)) :- #a; #some. quant(X,S,P,no(X,S,P)) :- #no. quant(X,S,P,all(X,S,P)) :- #all; #every. noun(X,dinosaur(X),[]):- #dinosaur. noun(X,zoo(X),[]):- #zoo. % noun(X,chair(X),[]):- #chair. noun(X,mother_of(X,Y),[[of,Y]]):- #mother. noun(X,father_of(X,Y),[[of,Y]]):- #father. % Verb Phrases % The verb phrase's representation is now obtained % incrementally: each complement contributes % some more structure to the skeleton P verb_phrase(X,P1):- verb(X,P,L), comps(L,P,P1). comps([],P,P). comps([[P,X]|L],S1,S) :- prep(P), noun_phrase(X,S1,S2), comps(L,S2,S). % Intransitive verbs verb(X,smiles(X),[]) :- #smiles. % Transitive verbs verb(X,likes(X,Y),[[dir,Y]]) :- #likes. verb(X,P,L) :- #is, adj(X,P,L). % Bitransitive verbs verb(X,gives(X,Y,Z),[[dir,Y],[to,Z]]) :- #gives. prep(of) :- #of. prep(to) :- #to. prep(with):- #with. prep(dir). name(anne) :- #anne. name(rover) :- #rover. name(peter) :- #peter. name(X) :- #who, +answer(X). % Unary adjectives adj(X,intelligent(X),[]) :- #intelligent. adj(X,kind(X),[]) :- #kind. % Binary adjectives adj(X,angry_with(X,Y),[[with,Y]]) :- #angry. % Adjective Phrases adj_phrase(X,P) :- adj(X,P1,L), comps(L,P1,P).
The Parsing Problem: Given a grammar and a presumed sentence in the language defined by that grammar, obtain some representative structure(s) if the sentence is indeed in the language.
"Logic, we love" "Logic, I know we love" "Logic, I suspected he knew we love"
sentence --> s(complete). s(E) --> noun_phrase(complete), verb_phrase(E). noun_phrase(complete) --> determiner, noun, relative. noun_phrase(complete) --> name. noun_phrase(missing_np) --> []. verb_phrase (complete) --> verb. verb_phrase (E) --> verb, noun_phrase(E). relative --> pronoun, s(missing_np). relative --> pronoun, vp(complete).
e.g. subject-verb inversion, as occurs in interrogative sentences in some romance languages, can be described by MG rules such as:
marker, noun_phrase, verb --> verb, noun_phrase.where ``marker'' has been introduced by rules such as:
sentence(interrogative) --> marker, s, [?]. sentence (affirmative) --> s.e.g. relativization can be expressed in XGs through:
relative --> rel_marker, sentence. np --> trace(_). rel_marker(I), skip(X), trace(I) --> rel_pronoun(I), skip(X).
S --> NP VP [num:X, [num:X] case:nom] NP --> name VP --> V [num:X, [num:X, [num:X] [num:X, case:Y] case:Y] subcat:1] NP --> Pronoun VP --> V NP [num:X, [num:X, [num:X] [num:X, [case:acc] case:Y] case:Y] subcat:2] Name --> Maria V --> laughs [num:sing] [num:sing, subcat:1]
E. g. the relativization rule in lambda-Prolog:
relative (that::L1) L2 :- (np Z Z) => s L1 L2.prevents empty noun phrases from being generated outside relative clauses.
HPSG treats long-distance dependencies through transmitting a non overt category's feature specifications from arbitrary daughters (not just head daughters) to their mothers, until they can be unified with the appropriate dislocated constituent.
HPSG-inspired approaches: Constraint Logic Grammars, The Comprehensive Unification Formalism, CU-Prolog, Typed Unification Grammars
Government-Binding: three rule systems and a set of modules which define well-formedness conditions on each of four levels of representation
np(X,VP,VP):- proper_name(X), *(specifier(X)). np(X,VP,R):- det(X,NP,VP,R), noun(X-F,NP), *(specifier(X-F)). pronoun(X-[masc,sing]):- #he. pronoun(X-[fem,sing]):- #her. anaphora(X):- pronoun(X). noun(X-[fem,sing],woman(X)):- #woman.
np(X,VP,VP):- anaphora(X), -(specifier(X)).
Backwards anaphora:
Near her, Alice saw a Bread-and-Butterfly.
Tweedledum proposed, and Tweedledee agreed to, a battle.
% The assumption being made was expected % by a previous consumption =X :- -wait(X), !. % if no previous expectation, assume it linearly =X :- +X. % uses an assumption, and deletes it if linear =-X :- -X, !. % if assumption not yet made, % adds its expectation =-X :- +wait(X).
sent(and(S1,S2)):- s(S1), +and, s(S2).
% conjunction of two sentences assumes that
% there will be an ``and'' between them.
s(S):- name(K), verb(K,P,S), np(P).
np(P):- det(X,P1,P), noun(X,P1),
=ref_np(P).
% keep it as potential
%referent for a missing np
np(P):- #and, -and,
=-ref_np(P).
det(X,P,the(X,P)):- #the.
noun(X,cupboard(X)):- #cupboard.
name(tim):- #tim.
name(anne):- #anne.
verb(X,Y,built(X,Y)):- #built.
verb(X,Y,painted(X,Y)):- #painted.
test(In,Out):- dcg_def(In), sent(Out),
dcg_val([]).
go:-example(X),test(X,Out),write(Out),nl,fail;
write('end'), nl.
example([tim,built,and,
anne,painted,the,cupboard]).
we obtain the semantic representation:
and(built(tim,the(X,cupboard(X)),
painted(ann,the(X,cupboard(X)))
==BEGIN COMMAND RESULTS== you are in the lobby SUCCEEDING(go(lobby)) user(veronica,none,'http://localhost'). user(paul,none,'http://localhost'). login(paul). online(veronica). online(paul). place(lobby). place(office). contains(lobby,veronica). contains(lobby,paul). SUCCEEDING(look)
==END COMMAND RESULTS==
TEST: Craft a cat. Where is the cat? Who has it? WORDS: [craft,a,cat,.,where,is,the,cat,?,who,has,it,?] SENTENCES: [craft,a,cat] [where,is,the,cat] [who,has,it]
==BEGIN COMMAND RESULTS== SUCCEEDING(craft(cat)) cat is in lobby SUCCEEDING(where(cat)) joe has cat SUCCEEDING(who(has,cat))
==END COMMAND RESULTS==
TEST: Dig the bedroom. Go there. Dig a kitchen, open a port south to the kitchen, go there, open a port north to the bedroom. Go there. Craft a song-au. Give it to the Wizard.
==BEGIN COMMAND RESULTS== SUCCEEDING(dig(bedroom)) you are in the bedroom SUCCEEDING(go(bedroom)) SUCCEEDING(dig(kitchen)) SUCCEEDING(open_port(south,kitchen)) you are in the kitchen SUCCEEDING(go(kitchen)) SUCCEEDING(open_port(north,bedroom)) you are in the bedroom SUCCEEDING(go(bedroom)) SUCCEEDING(craft(song.au)) logimoo:<joe># 'wizard:I give you song.au' SUCCEEDING(give(wizard,song.au))
==END COMMAND RESULTS==
TEST: Craft a Gnu. Who has it? Where is it? Where am I? WORDS: [craft,a,gnu,.,who,has,it,?,where,is,it,?,where,am,i,?] SENTENCES: [craft,a,gnu] [who,has,it] [where,is,it] [where,am,i]
==BEGIN COMMAND RESULTS== SUCCEEDING(craft(gnu)) joe has gnu SUCCEEDING(who(has,gnu)) gnu is in bedroom SUCCEEDING(where(gnu)) you are in the bedroom SUCCEEDING(whereami)
==END COMMAND RESULTS==
TEST: Give to the Wizard the Gnu that I crafted. Who has it? WORDS: [give,to,the,wizard,the,gnu,that,i,crafted,.,who,has,it,?] SENTENCES: [give,to,the,wizard,the,gnu,that,i,crafted] [who,has,it]
==BEGIN COMMAND RESULTS== logimoo:<joe># 'wizard:I give you gnu' SUCCEEDING(give(wizard,gnu)) wizard has gnu SUCCEEDING(who(has,gnu))
==END COMMAND RESULTS==
TEST: construya un gato. donde esta el gato? quien tiene lo? WORDS: [construya,un,gato,.,donde,esta,el,gato,?,quien,tiene,lo,?] SENTENCES: [construya,un,gato] [donde,esta,el,gato] [quien,tiene,lo]
==BEGIN COMMAND RESULTS== SUCCEEDING(craft(gato)) gato is in lobby SUCCEEDING(where(gato)) veronica has gato SUCCEEDING(who(has,gato))
==END COMMAND RESULTS==
e.g. for "Alan Robinson discovered the resolution principle in the sixties", the following two rules may be tried in order:
vp --> v, np. vp --> v, np, pp.
This document was generated using the LaTeX2HTML translator Version 95.1 (Fri Jan 20 1995) Copyright © 1993, 1994, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html -split 0 -link 0 html.tex.
The translation was initiated by Veronica Dahl on Sat Dec 27 18:27:30
PST 1997