510 likes | 692 Views
Uses of Logic in Computational Understanding of English. Iddo Lev. cs157, Autumn 2006. This Talk. Motivation and Goal English is more complicated than Logic in many ways. Logic is at the core of computational understanding of English and is useful on many levels. The Turing Test. ?.
E N D
Uses of Logic in Computational Understanding of English Iddo Lev cs157, Autumn 2006
This Talk • Motivation and Goal • English is more complicated than Logic in many ways. • Logic is at the core of computational understanding of English • and is useful on many levels.
? A Big A.I. Dream… answer
These Days… I took cs534, cs621, and math443. If I take cs970, do I also need to take cs157? Computer Science Department: Degree Requirements
The Dream… I took cs534, cs621, and math443. If I take cs970, do I also need to take cs157? Computer Science Department: Degree Requirements
These Days… I want to tour Europe for 3 weeks and I need to be in Paris for a conference. Can you help me plan a trip?
The Dream… I want to tour Europe for 3 weeks and I need to be in Paris for a conference. Can you help me plan a trip? Sure! When would you like to leave? …
Motivations • Practical: Extremely useful to have computers that understand English. • Scientific: If a computer can understand English, seeing how it does it might shed light on how we humans understand language and on our thoughts, cognition, and mind!
How Can Computers Understand English? Computer Science Department: MSCS Degree Requirements A candidate is required to complete a program of 45 units. At least 36 of these must be graded units, passed with an average 3.0 (B) grade point average (GPA) or better. The 45 units may include no more than 21 units of courses from those listed below in Requirements 1 and 2. etc. etc…
x.[student(x)…] ? The Programmer Does the Understanding Degree Reqs answer
? The Computer Does the Understanding Degree Reqs x.[student(x)…] answer
Example: Logic Puzzles Sixsculptures—C, D, E, F, G, and H—are to be exhibited inrooms1, 2, and 3 of an art gallery. Sculptures C and Emaynot be exhibited in the same room. Sculptures D and Gmust be exhibited in the same room. If sculptures E and F are exhibited in the same room, no other sculpturemaybe exhibited in that room. At least onesculpture mustbe exhibited in eachroom, and no more than threesculptures maybe exhibited inanyroom. 4. If sculpture D is exhibited in room 3 and sculptures E and F are exhibited in room 1, which of the following may be true? (A) Sculpture C is exhibited in room 1. (B) No more than 2 sculptures are exhibited in room 3. (C) Sculptures F and H are exhibited in the same room. (D) Three sculptures are exhibited in room 2. (E) Sculpture G is exhibited in room 2.
Example: Logic Puzzles • Vocabulary
Example: Logic Puzzles • Explicit content • Sculptures C and Emaynot be exhibited in the same room. ¬y [room(y) exhibIn(c,y) exhibIn(e,y)] • If sculptures E and F are exhibited in the same room, no other sculpturemaybe exhibited in that room. y [room(y) exhibIn(e,y) exhibIn(f, y) ¬x [sculpture(x) x e x f exhibIn(x,y)]] • No more than threesculptures maybe exhibited inanyroom. z [room(z) ¬x1x2x3x4x1x2 x1x3 x1x4 x2x3 x2x4 x3x4 sculpture(x1) … sculpture(x4) exhibIn(x1,z) … exhibIn(x4,z)]
Example: Logic Puzzles • Implicit content • Types & disjointness • xy [exhibIn(x,y) sculpture(x) room(y)] • x [sculpture(x) ¬ room(x)] • sculpture(c) … sculpture(h) room(r1) … • Unique Names Assumption • c d c e … • Domain Closure Assumptions • x [sculpture(x) x=c … x=h]] • x [room(x) x=r1 x=r2 x=r3]] • x [sculpture(x) room(x)]
Example: Logic Puzzles Sixsculptures—C, D, E, F, G, and H—are to be exhibited inrooms1, 2, and 3 of an art gallery. Sculptures C and Emaynot be exhibited in the same room. Sculptures D and Gmust be exhibited in the same room. If sculptures E and F are exhibited in the same room, no other sculpturemaybe exhibited in that room. At least onesculpture mustbe exhibited in eachroom, and no more than threesculptures maybe exhibited inanyroom. 4. If sculpture D is exhibited in room 3 and sculptures E and F are exhibited in room 1, which of the following may be true? (A) Sculpture C is exhibited in room 1. (B) No more than 2 sculptures are exhibited in room 3. (C) Sculptures F and H are exhibited in the same room. (D) Three sculptures are exhibited in room 2. (E) Sculpture G is exhibited in room 2.
Example: Logic Puzzles • World Knowledge and Word Meaning • Commonsense: A sculpture cannot be exhibited in more than one room at the same time. • xyz [sculpture(x) room(y) room(z) exhibIn(x,y) exhibIn(x,z) y=z] • Lexical: “Which of the following is a complete list of the sculptures exhibited in room 1?” • The property of being such a list: • list(x) y [yx sculpture(y) exhibIn(y,r1)]
What Do We Need? • Translate the English text and query to a representation in a logical language • Representation of text’s literal meaning • Check for logical consistency and coherence of the representation • To catch errors in translation • Combine with a representation of general world knowledge • Runautomated reasoning tools to get an answer!
How to Translate from English to Logic? • How to capture the meaning of English texts in a logical language? • How to compute the representation from the English text?
Capturing English Meaning in Logic Important differences between English and logic: • English has many devices not found in relatioal logic: • general quantifiers, plurals, modals, tense, anaphora, ellipsis, reciprocals, … • English has ambiguities • English text (discourse) is not just a list of independent statements. • Context-dependent, in contrast to logical database
Natural Language • Comparison to logic: • Logic is formal and designed to be unambiguous. • Logic was developed for formalizing mathematics, where all truths are necessary and eternal. No notion of context-dependence. • This is a challenge – how to represent something like English in something like logic.
Scope Ambiguity • Imagine a sentence in a formal language that looks like this: • [xp(x)] r(x,y) [yq(y)] • r( [xp(x)] , [yq(y)] ) • Does this sentence mean: • x [p(x) y [q(y) r(x,y)]] • y [q(y) x [p(x) r(x,y)]] • But this is how NL is: • Some minister visited each chapel.
Examples (Thanks to Bill MacCartney)
Plurality Ambiguity • John and Mary weigh 150 lb. • Each? • Together? • Four boys lifted five boxes. • How many readings? • 10 companies own 40 computers. • Weak / under-determined
Dealing with Ambiguities • Special formal languages • USRs represent under-specified information • representations can be gradually made more specified given more information • Open question • When does usr1 |= usr2 ? • maybe if for all j,k reading1j |= reading2k ?
Anaphora • A man entered the room. He was smiling. • x,y [man(x) room(y) enter(x,y)] • smile(x) • x is a free variable! We don’t want to say “every man was smiling”! • Want to somehow extend the scope of .
Anaphora • “a” = existential • A man entered the room. He was smiling. • xy [man(x) room(y) enter(x,y)] + smile(x) • xy [man(x)room(y)enter(x,y)smile(x)] • “a” = universal • If a farmer owns a donkey, he feeds it. • [xy [farmer(x)donkey(y)own(x,y)]] feed(x,y) • xy [farmer(x)donkey(y)own(x,y) feed(x,y)] • A candidate is required to complete a program of 45 units.
Solution • Discourse Representation Structures • Same expressive power as Relational Logic • but different shape of formulas, more amenable to computation from English input. • Variations / related approaches • Dynamic predicate logic, dynamic semantics, situation semantics, context logics, … x y z w farmer(x) donkey(y)own(x,y) z = xw = yfeed(z,w)
English Text • In logic, ; is the same as ; . • NL text is not just a set of assertions: • Example 1 (anaphora) • A man entered the room. He was smiling. • He was smiling. A man entered the room.
English Text • Example 2 (discourse relations, coherence) • Original version • Cats are very versatile. For example, they can jump on the furniture and knock over glass items, but they can also cuddle and purr. Therefore, many people like them. • Garbled • Therefore, many people like cats. For example, cats can knock over glass items and jump on the furniture. They are very versatile. But they can also cuddle and purr.
How to Translate from English to Logic? • How to capture the meaning of English texts in a logical language? • How to compute the representation from the English text?
Computing the Representations • Morphological analysis • booked book[verb] +ed [past] • books book[verb] +s [3rdperson,singular,present] book[noun] +s [plural] • Syntactic analysis • Compositional construction of semantic representations
Syntactic Analysis • If sculptures E and F are exhibited in the same room, no other sculpture may be exhibited in that room.
Syntactic Analysis • The use of logic in Parsing: • Syntax rules can be seen as Horn clauses(“Definite clause grammar”) • sentnc(p1,p2,agr) np(p1,p3,agr) vp (p3,p2,agr) • vp(p1,p2,agr) v(p1,p3,agr) np (p3,p2,_) • Parsing can be seen as logical inference with a particular search strategy • One of the earliest uses of Prolog (parsing comes “for free”)
Syntactic Analysis s vp np v np 0 John 1 likes 2 Cats 3 . • np(0,1,sng) • v(1,2,sng) • np(2,3,plur) • vp(p1,p2,agr) v(p1,p3,agr) np (p3,p2,_) • vp(1,3,sng) [2,3,4] • sentnc(p1,p2,agr) np(p1,p3,agr) vp (p3,p2,agr) • sentnc(0,3,sng) [1,5,6]
Compositional Semantics every dog barks (S) x. [dog(x) bark(x)] every dog (NP) λR. x. [dog(x) R(x)] barks (VP) λz. bark(z) every (Det) λP.λR. x. [P(x) R(x)] dog (Noun) λy.dog(y)
Compositional Semantics • The use of logic: • “Pieces” of semantic representation are associated with type expressions • john:e • barks :e t saw:e e t • “everyone” - λR.x.[person(x) R(x)] : (e t) t • “every” - λP.λR.x.[P(x) R(x)] : (et)(et)t • Linear logic (a “resource sensitive” logic) is used to deduce how the semantic pieces may combine based on their types. (cf. “glue semantics”)
Compositional Semantics john: e2 λxλy.saw(x,y): e2 (e3 t1) λy.saw(john,y): e3 t1 mary: e3 saw(john,mary): t1
Compositional Semantics scope ambiguity: every(P,Q)x.[P(x) Q(x)] some(P,Q)x.[P(x) Q(x)]
What Do We Need? • Translate the English text and query to a representation in a logical language • Representation of text’s literal meaning • Check for logical consistency and coherence of the representation • To catch errors in translation • Combine with a representation of general world knowledge • Runautomated reasoning tools to get an answer!
Using AR for Sanity Check • Informativity • If KB, sentence1, …, sentencen |= sentencen+1then sentencen+1 is not informative, so probably the computer didn’t understand it correctly. • Consistency • If KB {sentence1, …, sentencen}is consistent (has a model) butKB {sentence1, …, sentencen , sentencen+1}is inconsistent (equivalently: KB , sentence1, …, sentencen |= ¬ sentencen+1 )then probably computer didn’t understand correctly. • Can help reduce ambiguities in NL by disqualifying incompatible readings
Using AR to Calculate Answer • “Which of the following must be true?” • If TP says KB |= then “yes” • If MB says KB {¬} is consistent then “no” (MB found a counterexample) • “Which of the following could be true?” • If TP says KB |= ¬ then “no” • If MB says KB {} is consistent then “yes” • And we’ve seen in class how to use a “goal” predicate with Relational Resolution to extract an answer.
What Do We Need? • Translate the English text and query to a representation in a logical language • Representation of text’s literal meaning • Check for logical consistency and coherence of the representation • To catch errors in translation • Combine with a representation of general world knowledge • Runautomated reasoning tools to get an answer!
State of the Art • Very challenging and fascinating research areas • Formal and Computational Semantics, Computational Linguistics, Natural Language Processing (NLP) • Computers can already do precise inferences from NL in simple cases completely automatically • Example of Frontier: Logic puzzles (can solve simple ones from the NL text; but many interesting issues still remain open)
Summary • Natural Language is more complicated than Logic in many ways. • Representing a text’s meaning and reasoning with it is at the core of computational understanding of NL. • Logic is useful for NL understanding on many levels.
From Logic to English • The other direction is called “generation”. • Has many additional complications • NL has many ways of saying the same thing. • So NLU often involves reduction of information – from many to few • In NLG, given impoverished representations, need to create rich NL.
Logic vs. Statistics? • The picture here is not what you might encounter in some NLP courses (e.g. cs224N) that emphasize statistical approaches. • But the two approaches are not antagonistic; their advantages should be combined. • To improve the quality of current probabilistic models, need research in meaning representation and reasoning.
The PULC Project • Precise Understanding of Language by Computers • Deep understanding of particular domain texts (rather than arbitrary texts) • Paying real attention to NL phenomena • Representing text meaning and making inference based on it • Applications: understanding logic puzzles and math questions, law texts, technical texts • We are looking for people! • Website: http://www.stanford.edu/~iddolev/pulc