1 / 51

Uses of Logic in Computational Understanding of English

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. ?.

jerry-henry
Download Presentation

Uses of Logic in Computational Understanding of English

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Uses of Logic in Computational Understanding of English Iddo Lev cs157, Autumn 2006

  2. 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.

  3. The Turing Test

  4. ? A Big A.I. Dream… answer

  5. These Days… I took cs534, cs621, and math443. If I take cs970, do I also need to take cs157? Computer Science Department: Degree Requirements

  6. The Dream… I took cs534, cs621, and math443. If I take cs970, do I also need to take cs157? Computer Science Department: Degree Requirements

  7. 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?

  8. 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? …

  9. 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!

  10. 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…

  11. x.[student(x)…] ? The Programmer Does the Understanding Degree Reqs answer

  12. ? The Computer Does the Understanding Degree Reqs x.[student(x)…] answer

  13. 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.

  14. Example: Logic Puzzles • Vocabulary

  15. 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)  ¬x1x2x3x4x1x2  x1x3  x1x4  x2x3  x2x4  x3x4  sculpture(x1)  …  sculpture(x4)  exhibIn(x1,z)  …  exhibIn(x4,z)]

  16. Example: Logic Puzzles • Implicit content • Types & disjointness • xy [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)]

  17. 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.

  18. Example: Logic Puzzles • World Knowledge and Word Meaning • Commonsense: A sculpture cannot be exhibited in more than one room at the same time. • xyz [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 [yx  sculpture(y)  exhibIn(y,r1)]

  19. 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!

  20. 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?

  21. 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

  22. 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.

  23. 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.

  24. Examples (Thanks to Bill MacCartney)

  25. 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

  26. 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 ?

  27. 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 .

  28. Anaphora • “a” = existential • A man entered the room. He was smiling. • xy [man(x)  room(y)  enter(x,y)] + smile(x) •  xy [man(x)room(y)enter(x,y)smile(x)] • “a” = universal • If a farmer owns a donkey, he feeds it. • [xy [farmer(x)donkey(y)own(x,y)]]  feed(x,y) •  xy [farmer(x)donkey(y)own(x,y)  feed(x,y)] • A candidate is required to complete a program of 45 units.

  29. 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) 

  30. 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. 

  31. 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.

  32. 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?

  33. 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

  34. Syntactic Analysis • If sculptures E and F are exhibited in the same room, no other sculpture may be exhibited in that room.

  35. 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”)

  36. 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]

  37. 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)

  38. 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)] : (et)(et)t • Linear logic (a “resource sensitive” logic) is used to deduce how the semantic pieces may combine based on their types. (cf. “glue semantics”)

  39. Compositional Semantics john: e2 λxλy.saw(x,y): e2  (e3  t1) λy.saw(john,y): e3  t1 mary: e3 saw(john,mary): t1

  40. Compositional Semantics scope ambiguity: every(P,Q)x.[P(x)  Q(x)] some(P,Q)x.[P(x)  Q(x)]

  41. 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!

  42. 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

  43. 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.

  44. 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!

  45. 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)

  46. 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.

  47. Epilogue

  48. 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.

  49. 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.

  50. 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

More Related