+ All Categories
Home > Documents > Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9....

Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9....

Date post: 09-Oct-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
36
Computational Linguistics CS579: Fall Semester 2020 School of Computing Korea Advanced Institute of Science and Technology Jong C. Park © All rights reserved.
Transcript
Page 1: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Computational LinguisticsCS579: Fall Semester 2020

School of ComputingKorea Advanced Institute of Science and Technology

Jong C. Park

© All rights reserved.

Page 2: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

We reviewed the following aspects of First-Order Logic.• Three extensions: function symbols; equality;

sorted first-order logic We also reviewed three inference tasks,

along with related notions.• Querying; Consistency checking;

Informativity checking• Satisfiability and unsatisfiability; Validity

(invalidity), Valid and invalid arguments

Fall 2020 KAIST CS579: Computational Linguistics 2

Review of the Last Lecture

Page 3: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

First-Order Logic Three Inference Tasks A First-Order Model Checker First-Order Logic and Natural Language

Fall 2020 KAIST CS579: Computational Linguistics 3

First-Order Logic

Page 4: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Goals Today• We review the syntax and semantics of first

order logic as the representation formalism.• We define the three inference tasks: querying,

consistency checking, and informativity checking.

• We present a first-order model checker to carry out querying.

• We see how good first-order logic is as a tool for computing natural language semantics.

Fall 2020 KAIST CS579: Computational Linguistics 4

First-Order Logic

Page 5: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Tasks• We decide how to represent models (in

Prolog).• We decide how to represent first-order

formulas (in Prolog).• We specify how (Prolog representations of)

first-order formulas are to be evaluated in (Prolog representations of) models with respect to (Prolog representations of) variable assignments.

Fall 2020 KAIST CS579: Computational Linguistics 5

A First-Order Model Checker

Page 6: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

A Vocabulary{(LOVE,2), (CUSTOMER,1), (ROBBER,1),(JULES,0), (VINCENT,0), (PUMPKIN,0),(HONEY-BUNNY,0), (YOLANDA,0) }

Fall 2020 KAIST CS579: Computational Linguistics 6

Representing Models in Prolog

Page 7: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

A Model in Prologmodel([d1,d2,d3,d4,d5],

[f(0,jules,d1), f(0,vincent,d2),f(0,pumpkin,d3), f(0,honey_bunny,d4),f(0,yolanda,d5), f(1,customer,[d1,d2]), f(1,robber,[d3,d4]),f(2,love,[(d3,d4)])]).

Fall 2020 KAIST CS579: Computational Linguistics 7

{(LOVE,2), (CUSTOMER,1), (ROBBER,1),(JULES,0), (VINCENT,0), (PUMPKIN,0),(HONEY-BUNNY,0), (YOLANDA,0) }

Page 8: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Another Model in Prologmodel([d1,d2,d3,d4,d5,d6],

[f(0,jules,d1), f(0,vincent,d2),f(0,pumpkin,d3), f(0,honey_bunny,d4),f(0,yolanda,d5), f(1,customer,[d1,d2,d5,d6]), f(1,robber,[d3,d4]),f(2,love,[])]).

Fall 2020 KAIST CS579: Computational Linguistics 8

Page 9: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

First-order variables are represented by Prolog variables.• Use Prolog’s inbuilt unification mechanism to

handle variables.

A first-order constant c is represented by the Prolog atom and a first-order relation symbol R is represented by the Prolog atom .

The special two-place relation symbol = will be represented by the Prolog term .

Fall 2020 KAIST CS579: Computational Linguistics 9

Representing Formulas in Prolog

Page 10: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

The connectives ∧, ∨, →, and ¬ are represented by the Prolog terms ,

, , and , respectively. Suppose is a first-order formula, and

is its representation as a Prolog term. Then will be represented as and as .

Fall 2020 KAIST CS579: Computational Linguistics 10

Page 11: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

The task of evaluating (Prolog representations of) first-order formulas in (Prolog representations of) models with respect to (Prolog representations of) variable assignments is handled by the predicate

, whose four arguments are:1. the formula to be evaluated2. the model3. a list of assignments of members of the model’s

domain to any free variables the formula contains

4. a polarity feature ( or )

Fall 2020 KAIST CS579: Computational Linguistics 11

The Satisfaction Definition (in Prolog)

Page 12: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

We use the Prolog terms of the form to indicate that a

variable has been assigned the element of the model’s domain.

The polarity feature is a flag that records whether we are trying to see if a particular subformula is true or false in a model.

Fall 2020 KAIST CS579: Computational Linguistics 12

Page 13: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

for the boolean connectives• Negation

satisfy(not(Formula),Model,G,pos):-satisfy(Formula,Model,G,neg).

satisfy(not(Formula),Model,G,neg):-satisfy(Formula,Model,G,pos).

Fall 2020 KAIST CS579: Computational Linguistics 13

Page 14: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

• Conjunction satisfy(and(Formula1,Formula2),Model,G,pos)

:-satisfy(Formula1,Model,G,pos),satisfy(Formula2,Model,G,pos).

satisfy(and(Formula1,Formula2),Model,G,neg):-satisfy(Formula1,Model,G,neg);satisfy(Formula2,Model,G,neg).

Fall 2020 KAIST CS579: Computational Linguistics 14

Page 15: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

• Disjunction satisfy(or(Formula1,Formula2),Model,G,pos)

:-satisfy(Formula1,Model,G,pos);satisfy(Formula2,Model,G,pos).

satisfy(or(Formula1,Formula2),Model,G,neg):-satisfy(Formula1,Model,G,neg),satisfy(Formula2,Model,G,neg).

Fall 2020 KAIST CS579: Computational Linguistics 15

Page 16: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

• Implicationsatisfy(imp(Formula1,Formula2),

Model,G,Pol) :-satisfy(or(not(Formula1),Formula2),

Model,G,Pol).

Fall 2020 KAIST CS579: Computational Linguistics 16

Page 17: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

for existential quantificationsatisfy(some(X,Formula),model(D,F),G,pos) :-

memberList(V,D),satisfy(Formula,model(D,F),[g(X,V)|G],pos).

satisfy(some(X,Formula),model(D,F),G,neg) :-setof(V,(memberList(V,D),

satisfy(Formula,model(D,F),[g(X,V)|G],neg)), Dom),

setof(V,memberList(V,D),Dom).

Fall 2020 KAIST CS579: Computational Linguistics 17

model([d1,d2,d3,d4,d5],[f(0,jules,d1), f(0,vincent,d2),

f(0,pumpkin,d3), f(0,honey_bunny,d4),f(0,yolanda,d5), f(1,customer,[d1,d2]), f(1,robber,[d3,d4]), f(2,love,[(d3,d4)])]).

Page 18: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

for universal quantificationsatisfy(all(X,Formula),Model,G,Pol) :-

satisfy(not(some(X,not(Formula))),Model,G,Pol).

Fall 2020 KAIST CS579: Computational Linguistics 18

model([d1,d2,d3,d4,d5],[f(0,jules,d1), f(0,vincent,d2),

f(0,pumpkin,d3), f(0,honey_bunny,d4),f(0,yolanda,d5), f(1,customer,[d1,d2]), f(1,robber,[d3,d4]), f(2,love,[(d3,d4)])]).

Page 19: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

for atomic formulas• One-place predicate symbols

satisfy(Formula,model(D,F),G,pos) :-compose(Formula,Symbol,[Argument]),i(Argument,model(D,F),G,Value),memberList(f(1,Symbol,Values),F),memberList(Value,Values).

Fall 2020 KAIST CS579: Computational Linguistics 19

compose(Term,Symbol,ArgList) :-Term =.. [Symbol|ArgList].

model([d1,d2,d3,d4,d5],[f(0,jules,d1), f(0,vincent,d2),

f(0,pumpkin,d3), f(0,honey_bunny,d4),f(0,yolanda,d5), f(1,customer,[d1,d2]), f(1,robber,[d3,d4]), f(2,love,[(d3,d4)])]).

Page 20: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

satisfy(Formula,model(D,F),G,neg) :-compose(Formula,Symbol,[Argument]),i(Argument,model(D,F),G,Value),memberList(f(1,Symbol,Values),F),\+ memberList(Value,Values).

Fall 2020 KAIST CS579: Computational Linguistics 20

Page 21: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Interpretation function in i(X,model(_,F),G,Value) :-

(var(X),memberList(g(Y,Value),G),Y==X, !

;atom(X),memberList(f(0,X,Value),F)

).

Fall 2020 KAIST CS579: Computational Linguistics 21

Page 22: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

for atomic formulas• Two-place predicate symbols

satisfy(Formula,model(D,F),G,pos) :-compose(Formula,Symbol,[Arg1,Arg2]),i(Arg1,model(D,F),G,Value1),i(Arg2,model(D,F),G,Value2),memberList(f(2,Symbol,Values),F),memberList((Value1,Value2),Values).

Fall 2020 KAIST CS579: Computational Linguistics 22

model([d1,d2,d3,d4,d5],[f(0,jules,d1), f(0,vincent,d2),

f(0,pumpkin,d3), f(0,honey_bunny,d4),f(0,yolanda,d5), f(1,customer,[d1,d2]), f(1,robber,[d3,d4]), f(2,love,[(d3,d4)])]).

Page 23: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

satisfy(Formula,model(D,F),G,neg) :-compose(Formula,Symbol,[Arg1,Arg2]),i(Arg1,model(D,F),G,Value1),i(Arg2,model(D,F),G,Value2),memberList(f(2,Symbol,Values),F),\+ memberList((Value1,Value2),Values).

Fall 2020 KAIST CS579: Computational Linguistics 23

model([d1,d2,d3,d4,d5],[f(0,jules,d1), f(0,vincent,d2),

f(0,pumpkin,d3), f(0,honey_bunny,d4),f(0,yolanda,d5), f(1,customer,[d1,d2]), f(1,robber,[d3,d4]), f(2,love,[(d3,d4)])]).

Page 24: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Equality in satisfy(eq(X,Y),Model,G,pos) :-

i(X,Model,G,Value1),i(Y,Model,G,Value2),Value1=Value2.

satisfy(eq(X,Y),Model,G,neg) :-i(X,Model,G,Value1),i(Y,Model,G,Value2),\+ Value1=Value2.

Fall 2020 KAIST CS579: Computational Linguistics 24

Page 25: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Example modelsexample(3,

model([d1,d2,d3,d4,d5,d6,d7,d8],[f(0,mia,d1), f(0,jody,d2),f(0,jules,d3), f(0,vincent,d4),f(1,woman,[d1,d2]),f(1,man,[d3,d4]), f(1,joke,[d5,d6]),f(1,episode,[d7,d8]),f(2,in,[(d5,d7),(d5,d8)]),f(2,tell,[(d1,d5),(d2,d6)])])).

Fall 2020 KAIST CS579: Computational Linguistics 25

Page 26: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Using the example modelsevaluate(Formula,Example,Assignment) :-

example(Example,Model),satisfy(Formula,Model,Assignment,Result),printStatus(Result).

evaluate(Formula,Example) :-evaluate(Formula,Example,[]).

Fall 2020 KAIST CS579: Computational Linguistics 26

example(3,model([d1,d2,d3,d4,d5,d6,d7,d8],

[f(0,mia,d1), f(0,jody,d2),f(0,jules,d3), f(0,vincent,d4),f(1,woman,[d1,d2]),f(1,man,[d3,d4]), f(1,joke,[d5,d6]),f(1,episode,[d7,d8]),f(2,in,[(d5,d7),(d5,d8)]),f(2,tell,[(d1,d5),(d2,d6)])])).

Page 27: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Test suite file (modelCheckerTestSuite.pl)test(some(X,robber(X)),1,[],pos).test(some(X,some(Y,love(X,Y))),1,[],pos).test(some(X,some(Y,love(X,Y))),2,[],neg).test(all(X,all(Y,love(X,Y))),2,[],neg).test(not(all(X,all(Y,love(X,Y)))),2,[],pos).…

Refer to modelChecker1.pl .

Fall 2020 KAIST CS579: Computational Linguistics 27

Page 28: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

We can use the Model Checker to handle the querying task, but also to find elements in a model’s domain that satisfy certain descriptions. ?- satisfy(robber(X),

model([d1,d2,d3], [f(0,pumpkin,d1), f(o,jules,d2),f(1,customer,[d2]), f(1,robber,[d1,d3])]),[g(X,Value)], pos).

Value = d1 ;Value = d3

Fall 2020 KAIST CS579: Computational Linguistics 28

Refining the Model Checker

Page 29: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Problems • First Problem

?- evaluate(X,1).?- evaluate(imp(X,Y),4).

• Second Problem?- evaluate(mia,3).?- evaluate(all(mia,vincent),2).

Fall 2020 KAIST CS579: Computational Linguistics 29

Page 30: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

• Third Problem?- evaluate(tasty(royale_with_cheese), 1).

• Fourth Problem?- evaluate(customer(X),1). Not satisfied in model.[ Cannot be evaluated.]

Refer to modelChecker2.pl .

Fall 2020 KAIST CS579: Computational Linguistics 30

Page 31: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

First-order logic as a tool for computing natural language semantics• Inferential Capabilities• Resolution and tableau-based theorem provers• Model builders• Background knowledge

• Mia is married. She has a husband.• married mia → hashusband mia• ∀x woman x ∧ married x → hashusband x

Fall 2020 KAIST CS579: Computational Linguistics 31

First-Order Logic and Natural Language

Page 32: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

• Representational Capabilities• Time (intervals, events, necessity and belief)• Higher-order entities

• Butch has every property that a good boxer has.• ∀P∀x goodboxer x → P x → P butch

• Partiality• FOL offers an elegant handle on partiality.

• Generalized quantifiers• Two robbers, most robbers, many robbers

Fall 2020 KAIST CS579: Computational Linguistics 32

First-Order Logic and Natural Language

Page 33: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

SUMMARY

CS579: Computational Linguistics 33Fall 2020 KAIST

Page 34: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

We reviewed a first-order model checker.• Represent models and first-order formulas in Prolog;

Specify the evaluation process in Prolog The Satisfaction Definition in Prolog

• satisfy/4 for boolean connectives (negation, conjunction, disjunction, implication), existential and universal quantification, one-place and two-place predicates, equality

• Interpretation function We discussed the need to refine the Model Checker. We examined the relationship between First-Order

Logic and Natural Language.• Inferential and Representational Capabilities

Fall 2020 KAIST CS579: Computational Linguistics 34

Summary

Page 35: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Make a bidding to the provided list of papers and, when the bidding is resolved, write a review of the assigned paper. • Select at least two “eager to review” papers and at

least five “willing to review” papers so that the final assignment is in your favor and evenly distributed as much as possible. (Bidding due: 29 September, 2020)

• The specific assignments will be announced as soon as the bids are fully resolved.

• Details of what are expected in your review will be provided.

Due: 28 October, 2020 Upload your review at KLMS.

Fall 2020 KAIST CS579: Computational Linguistics 35

Homework #2

Page 36: Computational Linguisticsnlpcl.kaist.ac.kr/~cs579_2020/slides/579-fall-2020-8-hw2.pdf · 2020. 9. 24. · The task of evaluating (Prolog representations of) first-order formulas in

Propose a topic for your term project.• The topic should lead to an implemented system with

documentation.• Give an appropriate scenario for user interaction, i.e.,

expected inputs and outputs, justify why this scenario is interesting; and explain the kind of work that should be done.

• Use a maximum of two A4 pages, single column, with appropriate margins and font sizes.

• Write your proposal in English. • Your proposal will be assessed with the metrics below:

novelty, substance, relevance, and clarity. Due: 14 October, 2020 (before 15 October, 2020) Upload your proposal at KLMS.

Fall 2020 KAIST CS579: Computational Linguistics 36

Term Project: Proposal


Recommended