1 / 49

LING 581: Advanced Computational Linguistics

LING 581: Advanced Computational Linguistics. Lecture Notes March 8th. Today’s Topics. Finish off talking about the grammar we built in class last time Quantifiers: Theory of Generalized Quantifiers Homework : Build a grammar … Due date : present in 2 weeks time (22 nd March) .

abeni
Download Presentation

LING 581: Advanced Computational Linguistics

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. LING 581: Advanced Computational Linguistics Lecture Notes March 8th

  2. Today’s Topics • Finish off talking about the grammar we built in class last time • Quantifiers: Theory of Generalized Quantifiers • Homework: Build a grammar … • Due date: present in 2 weeks time (22nd March)

  3. Grammar: version 3 g3.pl

  4. Grammar: version 3

  5. Grammar Implements Theory • fjpSlides4.pdf • Slide 7

  6. Grammar Implements Theory • fjpSlides4.pdf • Slide 8

  7. Grammar Implements Theory • fjpSlides4.pdf • Slide 9

  8. Grammar: version 3

  9. Grammar: version 3

  10. Evaluation • Check our computer implementation on… • fjpSlides4.pdf • Slide 12

  11. Evaluation

  12. Evaluation

  13. Evaluation • Use cut (!) to commit parser to narrow scope reading (first parse)

  14. Evaluation

  15. Proofs • Examples (on following slides) • Entailment • Contradiction • Valid • Equivalence We can use our propositional engine from last time to solve these

  16. Entailment • fjpSlides4.pdf • Slide 14

  17. Does not entail • fjpSlides4.pdf • Slide 15

  18. Contradiction • fjpSlides4.pdf • Slide 16 • (labeled as 14)

  19. Validity • fjpSlides4.pdf • Slide 17 • (labeled as 15)

  20. Logical Equivalence • fjpSlides4.pdf • Slide 18 • (labeled as 16)

  21. Additional Exercise

  22. Quantifiers • Not all noun phrases (NPs) are (by nature) directly referential like names • Quantifiers: “something to do with indicating the quantity of something” • Examples: • every child • nobody • two dogs • several animals • most people • nobody has seen a unicorn • means roughly (Prolog-style): • ?-setof(X,(person(X), seen(X,Y), unicorn(Y)),Set),cardinality(Set,0).

  23. Quantifiers • Database • nobody has seen a unicorn • means roughly (Prolog-style): • ?-setof(X,(person(X), seen(X,Y), unicorn(Y)),Set),cardinality(Set,0). • setof vs. findall (recall last lecture) Fix:

  24. Quantifiers • Semantic compositionality: • elements of a sentence combine in piecewise fashion to form an overall (propositional) meaning for the sentence • Example: • (4) Every baby cried • WordMeaning • cried cried(X). • baby baby(X). • every ? • every baby cried proposition (True/False) • that can be evaluated for a given situation

  25. Scenario (Possible World): suppose there are three babies... baby(noah). baby(merrill). baby(dani). all three cried cried(noah). cried(merrill). cried(dani). only Dani jumped jumped(dani). Noah and Dani swam swam(noah). swam(dani). think of quantifiers as “properties-of-properties” every_baby(P) is a proposition P: property every_baby(P) true for P=cried every_baby(P) false for P=jumped and P=swam Quantifiers

  26. Quantifiers • think of quantifiers as “properties-of-properties” • every_baby(P) true for P=cried • every_baby(P) false for P=jumped and P=swam • Generalized Quantifiers • the idea that quantified NPs represent sets of sets • this idea is not as wierd as it sounds • we know • every_baby(P) is true for certain properties • view • every_baby(P) = set of all properties P for which this is true • in our scenario • every_baby(P) = {cried} • we know cried can also be view as a set itself • cried = set of individuals who cried • in our scenario • cried = {noah, merrill, dani}

  27. Quantifiers • how do we define the expression every_baby(P)? • (Montague-style) • every_baby(P) is shorthand for • for all individuals X, baby(X) -> P(X) • -> : if-then (implication : logic symbol) • written another way (lambda calculus-style): • λP.[∀X.[baby(X) -> P(X)]] • ∀: for all (universal quantifier: logic symbol) • Example: • every baby walks • for all individuals X, baby(X) -> walks(X) more formally • [NP every baby] [VP walks] • λP.[∀X.[baby(X) -> P(X)]](walks) • ∀X.[baby(X) ->walks(X)]

  28. Quantifiers • how do we define this Prolog-style? • Example: • every baby walks • [NP every baby] [VP walks] • λP.[∀X (baby(X) -> P(X))](walks) • ∀X (baby(X) ->walks(X)) • Possible World (Prolog database): • :- dynamic baby/1. (allows us to modify the baby database online) • baby(a). baby(b). • walks(a). walks(b). walks(c). • individual(a). individual(b). individual(c). • What kind of query would you write? • One Possible Query (every means there are no exceptions): • ?- \+ (baby(X), \+ walks(X)). (NOTE: may need a space between \+ and ( here) • Yes (TRUE) • ?- baby(X), \+ walks(X). • No • ?- assert(baby(d)). • ?- baby(X), \+ walks(X). • X = d ; • Yes Using no exception idea that ∀X P(X) is the same as ¬∃X ¬P(X) ∃= “there exists” (quantifier) (implicitly: all Prolog variables are existentially quantified variables)

  29. Recall: Truth Tables • De Morgan’s Rule • ¬(P∨Q) = ¬P∧¬Q ¬(PvQ)=T only when both P and Q are F Hence, ¬(PvQ) is equivalent to ¬P∧¬Q ¬P∧¬Q=T only when both P and Q are F

  30. Conversion into Prolog Note: \+ (baby(X), \+walks(X)) is Prolog for ∀X (baby(X) -> walks(X)) Steps: • ∀X (baby(X) -> walks(X)) • ∀X (¬baby(X) v walks(X)) • (since P->Q = ¬PvQ, see truth tables from two lectures ago) • ¬∃X ¬ (¬baby(X) v walks(X)) • (since ∀X P(X) = ¬∃X ¬P(X), no exception idea) • ¬∃X (baby(X) ∧¬walks(X)) • (by De Morgan’s rule, see truth table from last slide) • ¬(baby(X) ∧¬walks(X)) • (can drop ∃X since all Prolog variables are basically existentially quantified variables) • \+ (baby(X) ∧ \+walks(X)) • (\+ = Prolog negation symbol) • \+ (baby(X), \+walks(X)) • (, = Prolog conjunction symbol)

  31. Quantifiers • how do we define this Prolog-style? • Example: • every baby walks • [NP every baby] [VP walks] • λP.[∀X.[baby(X) -> P(X)]](walks) • ∀X.[baby(X) ->walks(X)] • Another situation (Prolog database): • :- dynamic baby/1. • :- dynamic walks/1. • Does ?- \+ (baby(X), \+ walks(X)). still work? • Yes because • ?- baby(X), \+ walks(X). • No • cannot be satisfied

  32. Quantifiers • how do we define the expression every_baby(P)? • (Montague-style) • every_baby(P) is shorthand for • λP.[∀X.baby(X) -> P(X)] • (Barwise & Cooper-style) • think directly in terms of sets • leads to another way of expressing the Prolog query • Example: every baby walks • {X: baby(X)} set of all X such that baby(X) is true • {X: walks(X)} set of all X such that walks(X) is true • Subset relation (⊆) • {X: baby(X)} ⊆{X: walks(X)} the “baby” set must be a subset of the “walks” set

  33. Quantifiers (Barwise & Cooper-style) • think directly in terms of sets • leads to another way of expressing the Prolog query • Example: every baby walks • {X: baby(X)} ⊆{X: walks(X)} the “baby” set must be a subset of the “walks” set • How to express this as a Prolog query? • Queries: • ?-setof(X,baby(X),L1). L1 is the set of all babies in the database • ?-setof(X,walks(X),L2). L2 is the set of all individuals who walk Need a Prolog definition of the subset relation. This one, for example: subset([],_). subset([X|L1],L2) :- member(X,L2), subset(L1,L2). member(X,[X|_]). member(X,[_|L]) :- member(X,L).

  34. True for world: • baby(a). baby(b). • walks(a). walks(b). walks(c). L1 = [a,b] L2 = [a,b,c] ?- subset(L1,L2) is true • False for world: • baby(a). baby(b). baby(d). • walks(a). walks(b). walks(c). L1 = [a,b,d] L2 = [a,b,c] ?- subset(L1,L2) is false Quantifiers • Example: every baby walks • {X: baby(X)} ⊆ {X: walks(X)} the “baby” set must be a subset of the “walks” set • Assume the following definitions are part of the database: subset([],_). subset([X|_ ],L) :- member(X,L). member(X,[X|_ ]). member(X,[ _|L]) :- member(X,L). • Prolog Query: • ?-setof(X,baby(X),L1), setof(X,walks(X),L2), subset(L1,L2).

  35. Quantifiers • Example: every baby walks • (Montague-style) ∀X (baby(X) -> walks(X)) • (Barwise & Cooper-style) {X: baby(X)} ⊆ {X: walks(X)} • how do we define every_baby(P)? • (Montague-style)λP.[∀X (baby(X) -> P(X))] • (Barwise & Cooper-style) {X: baby(X)} ⊆ {X: P(X)} • how do we define every? • (Montague-style) λP1.[λP2.[∀X (P1(X) -> P2(X))]] • (Barwise & Cooper-style) {X: P1(X)} ⊆ {X: P2(X)}

  36. Quantifiers • how do we define the expression every? • (Montague-style) λP1.[λP2.[∀X (P1(X) -> P2(X))]] • Let’s look at computation in the lambda calculus... • Example: every man likes John • WordExpression • every λP1.[λP2.[∀X (P1(X) -> P2(X))]] • man man • likes λY.[λX.[ X likes Y]] • John John • Syntax: [S [NP [Q every][N man]][VP [V likes][NP John]]]

  37. Quantifiers • Example: [S [NP [Q every][N man]][VP [V likes][NP John]]] • WordExpression • every λP1.[λP2.[∀X (P1(X) -> P2(X))]] • man man • likes λY.[λX.[ X likes Y]] • John John • Logic steps: • [Q every][N man]] λP1.[λP2.[∀X (P1(X) -> P2(X))]](man) • [Q every][N man]] λP2.[∀X (man(X) -> P2(X))] • [VP [V likes][NP John]] λY.[λX.[ X likes Y]](John) • [VP [V likes][NP John]] λX.[ X likes John] • [S [NP [Q every][N man]][VP [V likes][NP John]]] • λP2.[∀X (man(X) -> P2(X))](λX.[ X likes John]) • ∀X (man(X) -> λX.[ X likes John](X)) • ∀X (man(X) -> [ X likes John])

  38. Quantifiers: Homework Previous slide: • Syntax: [S [NP [Q every][N man]][VP [V likes][NP John]]] • Semantics: ∀X (man(X) -> [ X likes John]) Part 1: Montague-style Implement a Prolog grammar that assembles the equivalent Prolog query for the above sentence • Semantics (Prolog): \+ (man(X), \+likes(X,john)) Present your grammar and working examples of situations for which the Prolog query evaluates to true/false

  39. Quantifiers: Homework Part 2: Barwise-Cooper-style • Syntax: [S [NP [Q every][N man]][VP [V likes][NP John]]] • Semantics: {X: man(X)} ⊆ {X: likes(X,John)} • Prolog : setof(X,man(X),S1), setof(X,likes(X,john),S1), subset(S1,S2). Implement a Barwise-Cooper style grammar and test the Prolog query on relevant situations. • Prolog programming help • Prolog predicate names cannot be variables • P(X). is illegal, p(X). is okay • p(X), X = john. is okay • P(X), P = man. isn’t • P =man, PX =.. [P,X]. is okay. (PX=man(X))

  40. Quantifiers: Homework

  41. Quantifiers: Homework • Example: • λP1.[λP2.[∀X (P1(X) -> P2(X))]] lambda(P1,lambda(P2,(\+ (P1(X), \+ P2(X))))) • Example: • {X: P(X)} • setof(X,P(X),Set)

  42. Quantifiers: Homework • Example: • {X: P(X)} • Illegal: setof(X,P(X),Set) • Alternate: setof(X,call(P,X),Set) Database

  43. Quantifiers: Homework • Example: • λP1.[λP2.[∀X (P1(X) -> P2(X))]] Illegal: lambda(P1,lambda(P2,(\+ (P1(X), \+ P2(X))))) Alternate: lambda(P1,lambda(P2,(\+ (call(P1,X),\+ call(P2,X)))))

  44. Quantifiers: Homework Part 3: Coordination • Extend your two grammars to handle • Every man and every woman likes John

  45. Other Quantifiers • Other quantifiers can also be expressed using set relations between two predicates: Example: no: {X: P1(X)} ∩ {Y: P2(Y)} = ∅ ∩ = set intersection ∅ = empty set no man smokes {X: man(X)} ∩ {Y: smokes(Y)} = ∅ should evaluate to true for all possible worlds where there is no overlap between men and smokers men smokers

  46. Other Quantifiers • Other quantifiers can also be expressed using set relations between two predicates: Example: some: {X: P1(X)} ∩ {Y: P2(Y)} ≠∅ ∩ = set intersection ∅ = empty set some men smoke {X: man(X)} ∩ {Y: smokes(Y)} ≠ ∅ men smokers

  47. we’ve mentioned that names directly refer here is another idea… Conjunction X and Y both X and Y have to be of the same type in particular, semantically... we want them to have the same semantic type what is the semantic type of every baby? Example every baby and John likes ice cream [NP[NP every baby] and [NP John]] likes ice cream every baby likes ice cream {X: baby(X)} ⊆ {Y: likes(Y,ice_cream)} John likes ice cream ??? ⊆ {Y: likes(Y,ice_cream)} John ∈ {Y: likes(Y,ice_cream)} want everything to be a set (to be consistent) i.e. want to state something like ({X: baby(X)} ∪{X: john(X)}) ⊆ {Y: likes(Y,ice_cream)} note: set union (∪) is the translation of “and” Names as Generalized Quantifiers

  48. animal dog Keeshond Downwards and Upwards Entailment (DE & UE) • Quantifier every has semantics • {X: P1(X)} ⊆ {Y: P2(Y)} • e.g. every woman likes ice cream • {X: woman(X)} ⊆ {Y:likes(Y,ice_cream)} • Every is DE for P1 and UE for P2 • Examples: • (25) a. Every dog barks • b. Every Keeshond barks (valid) • c. Every animal barks (invalid) • semantically, “Keeshond” is a sub-property or subset with respect to the set “dog” animal dog Keeshond

  49. make noise barks barks loudly Downwards and Upwards Entailment (DE & UE) • Quantifier every has semantics • {X: P1(X)} ⊆ {Y: P2(Y)} • e.g. every woman likes ice cream • {X: woman(X)} ⊆ {Y:likes(Y,ice_cream)} • Every is DE for P1 and UE for P2 • Examples: • (25) a. Every dog barks • d. Every dog barks loudly (invalid) • c. Every dog makes noise (valid) • semantically, “barks loudly” is a subset with respect to the set “barks”, which (in turn) is a subset of the set “makes noise” make noise barks loud

More Related