LING 581: Advanced Computational Linguistics Lecture Notes March 8th.

Slides:



Advertisements
Similar presentations
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Advertisements

LING 364: Introduction to Formal Semantics Lecture 24 April 13th.
CSA4050: Advanced Topics in NLP Semantics IV Partial Execution Proper Noun Adjective.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Predicates and Quantifiers
L41 Lecture 2: Predicates and Quantifiers.. L42 Agenda Predicates and Quantifiers –Existential Quantifier  –Universal Quantifier 
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
LING 581: Advanced Computational Linguistics Lecture Notes April 23rd.
CPSC 322, Lecture 21Slide 1 Bottom Up: Soundness and Completeness Computer Science cpsc322, Lecture 21 (Textbook Chpt 5.2) February, 27, 2009.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 3 Syntax of Propositional Logic Parse trees revised Construction of parse trees Semantics of propositional.
LING 364: Introduction to Formal Semantics Lecture 23 April 11th.
1 Problem Solving CS 331 Dr M M Awais Representational Methods Formal Methods Propositional Logic Predicate Logic.
2/17/2008Sultan Almuhammadi1 ICS Logic & Sets (An Overview) Week 1.
LING 364: Introduction to Formal Semantics Lecture 22 April 6th.
LING 364: Introduction to Formal Semantics Lecture 19 March 20th.
CPSC 322, Lecture 21Slide 1 Bottom Up: Soundness and Completeness Computer Science cpsc322, Lecture 21 (Textbook Chpt 5.2) March, 5, 2010.
1 Math 306 Foundations of Mathematics I Math 306 Foundations of Mathematics I Goals of this class Introduction to important mathematical concepts Development.
Formal Logic Mathematical Structures for Computer Science Chapter 1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFormal Logic.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
LING 364: Introduction to Formal Semantics Lecture 25 April 18th.
Survey of Mathematical Ideas Math 100 Chapter 3, Logic
Predicates and Quantifiers
Lecture 8 Introduction to Logic CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Course Outline Book: Discrete Mathematics by K. P. Bogart Topics:
LING 581: Advanced Computational Linguistics Lecture Notes April 16th.
Formal Logic Mathematical Structures for Computer Science Chapter Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFormal Logic.
October 2004CSA4050 Advanced Techniques in NLP 1 CSA4050: Advanced Topics in NLP Semantics 6 Semantics of Questions and Assertions involving Quantification.
1 Knowledge Based Systems (CM0377) Lecture 4 (Last modified 5th February 2001)
Fall 2002CMSC Discrete Structures1 Let’s get started with... Logic !
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
First Order Logic Lecture 2: Sep 9. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Quantifiers Not all noun phrases (NPs) are (by nature) directly referential like names Quantifiers: “something to do with indicating the quantity of something”
Albert Gatt LIN3021 Formal Semantics Lecture 4. In this lecture Compositionality in Natural Langauge revisited: The role of types The typed lambda calculus.
January 30, 2002Applied Discrete Mathematics Week 1: Logic and Sets 1 Let’s Talk About Logic Logic is a system based on propositions.Logic is a system.
CompSci 102 Discrete Math for Computer Science
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Logical Operations – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Logical Operations Reading: Kolman, Section 2.1.
Computer Science CPSC 322 Lecture 22 Logical Consequences, Proof Procedures (Ch 5.2.2)
TRUTH TABLES. Introduction The truth value of a statement is the classification as true or false which denoted by T or F. A truth table is a listing of.
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
1 First Order Logic CS 171/271 (Chapter 8) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
LING 364: Introduction to Formal Semantics Lecture 21 April 4th.
1 Chapter 2.1 Chapter 2.2 Chapter 2.3 Chapter 2.4 All images are copyrighted to their respective copyright holders and reproduced here for academic purposes.
PREDICATES AND QUANTIFIERS COSC-1321 Discrete Structures 1.
Lecture 041 Predicate Calculus Learning outcomes Students are able to: 1. Evaluate predicate 2. Translate predicate into human language and vice versa.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Metalogic Soundness and Completeness. Two Notions of Logical Consequence Validity: If the premises are true, then the conclusion must be true. Provability:
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Logics for Data and Knowledge Representation ClassL (part 1): syntax and semantics.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Chapter 1 Logic and proofs
LING 581: Advanced Computational Linguistics Lecture Notes May 4th.
Introduction to Logic for Artificial Intelligence Lecture 2
LING 581: Advanced Computational Linguistics
Lecture 1 – Formal Logic.
Logics for Data and Knowledge Representation
LING 581: Advanced Computational Linguistics
LING 581: Advanced Computational Linguistics
Logics for Data and Knowledge Representation
LING 581: Advanced Computational Linguistics
LING 581: Advanced Computational Linguistics
Logics for Data and Knowledge Representation
Predicates and Quantifiers
Presentation transcript:

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)

Grammar: version 3 g3.pl

Grammar: version 3

Grammar Implements Theory fjpSlides4.pdf Slide 7

Grammar Implements Theory fjpSlides4.pdf Slide 8

Grammar Implements Theory fjpSlides4.pdf Slide 9

Grammar: version 3

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

Evaluation

Use cut (!) to commit parser to narrow scope reading (first parse)

Evaluation

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

Entailment fjpSlides4.pdf Slide 14

Does not entail fjpSlides4.pdf Slide 15

Contradiction fjpSlides4.pdf Slide 16 (labeled as 14)

Validity fjpSlides4.pdf Slide 17 (labeled as 15)

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

Additional Exercise

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). nobody has seen a unicorn means roughly (Prolog-style): ?- setof(X,(person(X), seen(X,Y), unicorn(Y)),Set),cardinality(Set,0).

Quantifiers Database nobody has seen a unicorn means roughly (Prolog-style): ?- setof(X,(person(X), seen(X,Y), unicorn(Y)),Set),cardinality(Set,0). 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:

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 – criedcried(X). – babybaby(X). – every? – every baby criedproposition (True/False) – that can be evaluated for a given situation

(6)every baby exactly one baby most babies cried ✓✓ jumped ✓ swam ✓ Quantifiers 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 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}

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)]

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

Recall: Truth Tables De Morgan’s Rule ¬(P ∨ Q) = ¬P ∧ ¬Q PvQ TTT FTT FFF TTT ¬(PvQ) F F T F ¬P ∧ ¬Q FTF TFFFT TFT FTF ¬(PvQ)=T only when both P and Q are F ¬P ∧ ¬Q=T only when both P and Q are F Hence, ¬(PvQ) is equivalent to ¬P ∧ ¬Q

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)

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

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

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

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). 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 (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) λP 1.[λP 2.[ ∀ X (P 1 (X) -> P 2 (X))]] (Barwise & Cooper-style) {X: P 1 (X)} ⊆ {X: P 2 (X)}

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

Quantifiers Example: [ S [ NP [ Q every][ N man]][ VP [ V likes][ NP John]]] – WordExpression – everyλP 1.[λP 2.[ ∀ X (P 1 (X) -> P 2 (X))]] – manman – likesλY.[λX.[ X likes Y]] – John John Logic steps: [ Q every][ N man]]λP 1.[λP 2.[ ∀ X (P 1 (X) -> P 2 (X))]](man) [ Q every][ N man]]λP 2.[ ∀ X (man(X) -> P 2 (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]]] λP 2.[ ∀ X (man(X) -> P 2 (X))](λX.[ X likes John]) ∀ X (man(X) -> λX.[ X likes John](X)) ∀ X (man(X) -> [ X likes John])

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

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

Quantifiers: Homework

Example: – λP 1.[λP 2.[ ∀ X (P 1 (X) -> P 2 (X))]] lambda(P1,lambda(P2,(\+ (P1(X), \+ P2(X))))) Example: – {X: P(X)} – setof(X,P(X),Set)

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

Quantifiers: Homework Example: – λP 1.[λP 2.[ ∀ X (P 1 (X) -> P 2 (X))]] Illegal: lambda(P1,lambda(P2,(\+ (P1(X), \+ P2(X))))) Alternate: lambda(P1,lambda(P2,(\+ (call(P1,X),\+ call(P2,X)))))

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

Other Quantifiers Other quantifiers can also be expressed using set relations between two predicates: Example: no: {X: P 1 (X)} ∩ {Y: P 2 (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

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

Names as Generalized Quantifiers 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”

Downwards and Upwards Entailment (DE & UE) Quantifier every has semantics – {X: P 1 (X)} ⊆ {Y: P 2 (Y)} – e.g. every woman likes ice cream – {X: woman(X)} ⊆ {Y:likes(Y,ice_cream)} Every is DE for P 1 and UE for P 2 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 animal dog Keeshond

Downwards and Upwards Entailment (DE & UE) Quantifier every has semantics – {X: P 1 (X)} ⊆ {Y: P 2 (Y)} – e.g. every woman likes ice cream – {X: woman(X)} ⊆ {Y:likes(Y,ice_cream)} Every is DE for P 1 and UE for P 2 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 barks loudly make noise barks loud