SNePS: A Logic for Natural Language Understanding and Commonsense Reasoning Stuart C. Shapiro

advertisement

SNePS: A Logic for Natural

Language Understanding and

Commonsense Reasoning

Stuart C. Shapiro

Department of Computer Science and Engineering and Center for Cognitive Science

State University of New York at Buffalo shapiro@cse.buffalo.edu

S. C. Shapiro

Based on

Stuart C. Shapiro, “SNePS: A Logic for Natural

Language Understanding and Commonsense

Reasoning,” in Lucja Iwanska and Stuart C. Shapiro, Eds.,

Natural Language Processing and Knowledge

Representation: Language for Knowledge and

Knowledge for Language ,

AAAI Press/The MIT Press, 2000.

S. C. Shapiro

S. C. Shapiro

Abstract

Design a better logic

Than FOPL

For NLU and CSR

SNePS

Presentation Approach

Problem

Difficulties of FOPL

Solution in SNePS

Use SNePSLOG .

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Twenty Questions

Everything is an animal, a vegetable, or a mineral.

Squash is a vegetable

• Is squash an animal?

• a mineral?

Marble is neither an animal nor a vegetable.

• Is marble a mineral?

S. C. Shapiro

Twenty Questions in FOPL?

 x[Animal(x)

Vegetable(x)

Mineral(x)] but don’t want inclusive or

 x[Animal(x) Vegetable(x) Mineral(x)]

T T

T

F

T

So don’t want exclusive or either

S. C. Shapiro

andor andor(i, j){P i

, ..., P n

}

True iff at least i, and at most j of the P i are True

S. C. Shapiro

Twenty Questions in SNePSLOG

: all(x)(andor(1,1){animal(x), vegetable(x), mineral(x)}).

: vegetable(squash)!

VEGETABLE(SQUASH)

~ANIMAL(SQUASH)

~MINERAL(SQUASH)

S. C. Shapiro

Twenty Questions in SNePSLOG

II

: andor(0,0){animal(marble), vegetable(marble)}!

~ANIMAL(MARBLE)

~VEGETABLE(MARBLE)

MINERAL(MARBLE)

S. C. Shapiro

Equivalent Statements

For every object, the following statements are equivalent:

– It is human. It is a featherless biped.

It is a rational animal.

Socrates is human.

– Is Socrates a featherless biped? A rational animal?

Snoopy is not a featherless biped.

Is Snoopy a rational animal? A human?

S. C. Shapiro

Equivalent Statements in FOPL?

 x[Human(x)

Featherless-Biped(x)

Rational-Animal(x)] wrong:

F

F

T

T

T

S. C. Shapiro

thresh thresh(i, j){P i

, ..., P n

}

True iff either fewer than i, or more than j of the P i are True

Note: thresh(i, j)  ~andor(i, j)

S. C. Shapiro

thresh Abbreviation thresh(i){P i

, ..., P n

} for thresh(i, n-1){P i

, ..., P n

}

S. C. Shapiro

Equivalent Statements in SNePSLOG 1

: all(x)(thresh(1){human(x), featherless-biped(x), rational-animal(x)}).

: human(Socrates)!

HUMAN(SOCRATES)

FEATHERLESS-BIPED(SOCRATES)

RATIONAL-ANIMAL(SOCRATES)

S. C. Shapiro

Equivalent Statements in SNePSLOG 2

: ~featherless-biped(Snoopy)!

~RATIONAL-ANIMAL(SNOOPY)

~FEATHERLESS-BIPED(SNOOPY)

~HUMAN(SNOOPY)

S. C. Shapiro

Putative Inclusive or

If Hilda is in Boston or Kathy is in Las Vegas, then Eve is in Providence.

What if Hilda is in Boston and Kathy is in Las

Vegas?

Rips 1983: ___

___

___

S. C. Shapiro

or-entailment

{P i

, ..., P n

} v=> {Q i

, ..., Q n

}

True iff for all i, j P i

Q j

S. C. Shapiro

Hilda and Kathy in SNePSLOG

: {in(Hilda, Boston), in(Kathy, Las_Vegas)} v=> {in(Eve, Providence)}.

: in(Hilda, Boston)!

Since

{IN(HILDA,BOSTON),IN(KATHY,LAS_VE

GAS)} v=> {IN(EVE,PROVIDENCE)} and IN(HILDA,BOSTON)

I infer IN(EVE,PROVIDENCE)

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Disappointed Voter Problem

“If someone votes for X and someone votes for Y, one of them will be disappointed”

: all(u,v,x,y)(

{votesfor(u,x), votesfor(v,y)}

&=>

{andor(1,1){disappointed(u), disappointed(v)}}).

: all(u,x)({votesfor(u,x),wins(x)}

&=> {~disappointed{u}}).

S. C. Shapiro

Hillary and Elizabeth Vote

: votesfor(Hillary, Bill).

: votesfor(Elizabeth, Bob).

: wins(Bill).

: disappointed(?x)?

DISAPPOINTED(ELIZABETH)

~DISAPPOINTED(HILLARY)

S. C. Shapiro

FOPL Disappointment

{votesfor(Hillary, Bill), votesfor(Hillary, Bill)}

&=>

{andor(1,1)

{disappointed(Hillary), disappointed(Hillary)}}

 disappointed(Hillary)

S. C. Shapiro

Unique Variable Binding Rule

(UVBR)

Two variables in one wff cannot be replaced by the same term.

or

Two terms in an mgu cannot be equal.

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

S. C. Shapiro

Sisters

“Mary, Sue, and Sally are sisters.”

Sisters in FOPL

Sisters(Mary, Sue)

Sisters(Sue, Sally)

(x,y)[Sisters(x,y)

Sisters(y,x)]

(x,z)[x

 z

(

(y)[sisters(x,y)

 sisters(y,z)]

Sisters(x,z))]

S. C. Shapiro

Reduction Inference

P(s

1

,...,s i

,  ,s i+1

,...,s m

),  ’  

P(s

1

,...,s i

,  ’,s i+1

,...,s m

)

P(s

1

,...,s i

,{t

1

,…,t n

},s i+1

,...,s m

)

P(s

1

,...,s i

,t i

,s i+1

,...,s m

)

S. C. Shapiro

Sisters in SNePSLOG

: sisters({Mary, Sue, Sally}).

: all(x,y)(sisters({x,y}) =>

{likes(x,y), likes(y,x)}).

: likes(?x,?y)?

LIKES(SUE,MARY)

LIKES(MARY,SUE)

LIKES(SALLY,SUE)

LIKES(SUE,SALLY)

LIKES(MARY,SALLY)

LIKES(SALLY,MARY)

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Inadequacy of F OPL 1

If R is a transitive relation and R(x, y) and R(y, z) then R(x, z).

S. C. Shapiro

S. C. Shapiro

Term Logic

Every expression in SNePS is a term.

SNePSLOG Transitivity Rule

: all(R)(Transitive(R) => all(x,y,z)({R(x,y), R(y,z)}

&=> {R(x,z)})).

: Transitive(bigger).

: bigger(elephant,lion).

: bigger(lion,mouse).

: bigger(elephant,mouse)?

BIGGER(ELEPHANT,MOUSE)

S. C. Shapiro

Inadequacy of F OPL 2

Everything Bob believes is true.

Bob believes everything Bill believes.

• Bill believes Kevin’s favorite proposition.

• Kevin’s favorite proposition is that John is taller than Mary.

Is John taller than Mary?

S. C. Shapiro

Quantifying Over Propositions

: all(p)(Believes(Bob, p) => p).

: all(p)(Believes(Bill, p)

=> Believes(Bob, p)).

: all(p)

(Favorite-proposition(Kevin, p)

=> Believes(Bill, p)).

: Favorite-proposition(Kevin,

Taller(John, Mary)).

: Taller(John, Mary)?

TALLER(JOHN,MARY)

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Opaque Contexts

“George IV wished to know whether Scott was the author of Waverly

[Russell 1906]

S. C. Shapiro

Intensional Representation

Every SNePS term represents (denotes) an intensional (mental) entity.

S. C. Shapiro

Uniqueness Principle

No two SNePS terms denote the same entity.

S. C. Shapiro

McCarthy’s

Telephone Number Problem

: all(R)(Transparent(R)

=> all(a,x,y)({R(a,x), =({x,y})}

&=> {R(a,y)})).

: Transparent(Dial).

: =({Telephone(Mike),

Telephone(Mary)}).

: Know(Pat, Telephone(Mike)).

: Dial(Pat, Telephone(Mike)).

S. C. Shapiro

Correct Answer to Telephone

Number Problem

: ?what(Pat, ?which)?

DIAL(PAT,TELEPHONE(MARY))

KNOW(PAT,TELEPHONE(MIKE))

DIAL(PAT,TELEPHONE(MIKE))

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Reasoning by Elimination

No one has more than one mother.

Jane is John's mother.

– Is Mary John's mother?

The committee members are Chris, Leslie,

Pat, and Stevie. At least two of them are women.

Leslie and Stevie are men.

Is Pat a man or a woman?

S. C. Shapiro

Numerical Quantifiers nexists(i,j,k)(x)

({P

1

(x),..., P n

(x)}: {Q(x)})}

There are k individuals that satisfy

P

1

(x)

...

P n

(x) and, of them, at least i and at most j also satisfy

Q(x)

S. C. Shapiro

Numerical Quantifier

Rule of Inference 1

• If j individuals are known that satisfy

P

1

(x)

 … 

P n

(x)

Q(x) then every other individual that satisfies

P

1

(x)

...

P n

(x) also satisfies

~Q(x)

S. C. Shapiro

S. C. Shapiro

Numerical Quantifier

Rule of Inference 2

• If k-i individuals are known that satisfy

P

1

(x)

 … 

P n

(x)

~ Q(x) then every other individual that satisfies

P

1

(x)

 … 

P n

(x) also satisfies

Q(x)

S. C. Shapiro

Numerical Quantifier Forms

• nexists(i,j,k)

• nexists(_,j,_)

• nexists(i,_,k)

Reasoning by Elimination in SNePSLOG 1

: all(x)(Person(x) => nexists(_,1,_)(y)({Person(y)}:

{Mother(y,x)})).

: Person({John, Jane, Mary}).

: Mother(Jane, John).

: Mother(Mary, John)?

~MOTHER(MARY,JOHN)

S. C. Shapiro

Reasoning by Elimination in SNePSLOG 2

: Member({Chris, Leslie, Pat,

Stevie}).

: nexists(2,_,4)(x)

({Member(x)}: {Woman(x)}).

: all(x)(Member(x) => andor(1,1){Man(x), Woman(x)}).

S. C. Shapiro

Committee Problem Answer

: Man({Leslie, Stevie}).

: ?What(Pat)?

WOMAN(PAT)

MEMBER(PAT)

~MAN(PAT)

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Contexts

Pegasus is a winged horse in mythology

But a normal horse in the real world.

So Bellerophon travels by air in mythology

• but by ground in the real world.

S. C. Shapiro

Pegasus in the Real and

Mythological Worlds

: set-context real-world ()

: set-default-context real-world

: all(x)({Bird(x), Beast(x)} v=> {Animal(x)}).

: all(x)(Animal(x) => andor(1,1){Bird(x), Beast(x)}).

: all(x)(Horse(x) => Beast(x)).

: Horse(Pegasus).

S. C. Shapiro

Bellerophon in the Real and

Mythological Worlds

: all(x,y)(Rides(x,y) => andor(1,1){Travelsby(x, air),

Travelsby(x, ground)}).

: all(x,y)(Rides(x,y) => thresh(1,1){Winged(y),

Travelsby(x, air)}).

: Rides(Bellerophon, Pegasus).

S. C. Shapiro

Initialize Mythology

: describe-context

((ASSERTIONS

(WFF1 WFF2 WFF3 WFF4 WFF5 WFF6

WFF7))

(RESTRICTION NIL)

(NAMED (REAL-WORLD)))

: set-context mythology

(WFF1 WFF2 WFF3 WFF4 WFF5 WFF6

WFF7)

S. C. Shapiro

Riding in the Real World

: all(x)(Winged(x) <=> Bird(x)).

: Travelsby(Bellerophon,?what)?

TRAVELSBY(BELLEROPHON,GROUND)

~TRAVELSBY(BELLEROPHON,AIR)

S. C. Shapiro

Riding in Mythology

: set-default-context mythology

: Winged(Pegasus).

: Travelsby(Bellerophon,?what)?

~TRAVELSBY(BELLEROPHON,GROUND)

TRAVELSBY(BELLEROPHON,AIR)

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Relevance Logic:

A Paraconsistent Logic

A contradiction should not imply anything whatsoever.

S. C. Shapiro

Opus Flies and Doesn’t

: all(x)(Flies(x)=>Feathered(x)).

: all(x)(~Flies(x) => Swims(x)).

: Flies(Opus).

: ~Flies(Opus).

A contradiction was detected within context DEFAULT-DEFAULTCT.

...

~FLIES(OPUS)

S. C. Shapiro

Opus is Feathered and Swims, but the Earth isn’t Flat

: Feathered(Opus)?

FEATHERED(OPUS)

: Swims(Opus)?

SWIMS(OPUS)

: Flat(Earth)?

:

S. C. Shapiro

The Inconsistent Belief Space

: list-asserted-wffs all(X)(FLIES(X) => FEATHERED(X)) all(X)((~FLIES(X)) => SWIMS(X))

FLIES(OPUS)

~FLIES(OPUS)

FEATHERED(OPUS)

SWIMS(OPUS) but the earth isn’t flat.

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Information Provided by Real

People

• is circular

• and left- and right-recursive

S. C. Shapiro

Circular Definitions

: all(x,y)(thresh(1,1)

{North-of(x,y), Southof(y,x)}).

: North-of(Seattle, Portland).

: South-of(San_Francisco,

Portland).

: North-of(San_Francisco,

Los_Angeles).

: South-of(San_Diego,

Los_Angeles).

S. C. Shapiro

Using a Circular Definition

: North-of(?x, ?y)?

NORTH-OF(SEATTLE,PORTLAND)

NORTH-OF

(SAN_FRANCISCO,LOS_ANGELES)

NORTH-OF(LOS_ANGELES,SAN_DIEGO)

NORTH-OF(PORTLAND,SAN_FRANCISCO)

S. C. Shapiro

Recursive Rules

: all(x,y)(parent(x,y) => ancestor(x,y)).

: all(x,y,z)({ancestor(x,y), ancestor(y,z)}

&=> {ancestor(x,z)}).

: parent(John, Mary).

: ancestor(Mary, George).

: ancestor(George, Sally).

: parent(Sally, Jimmy).

S. C. Shapiro

Using a Recursive Rule

: ancestor(John, ?y)?

ANCESTOR(JOHN,JIMMY)

ANCESTOR(JOHN,MARY)

ANCESTOR(JOHN,GEORGE)

ANCESTOR(JOHN,SALLY)

S. C. Shapiro

In the Other Direction

: ancestor(?x, Jimmy)?

ANCESTOR(SALLY,JIMMY)

ANCESTOR(JOHN,JIMMY)

ANCESTOR(GEORGE,JIMMY)

ANCESTOR(MARY,JIMMY)

S. C. Shapiro

Outline

Set-Oriented Logical Connectives

The Unique Variable Binding Rule

Set Arguments

• “Higher-Order” Logic

Intensional Representation

The Numerical Quantifiers

Contexts

Relevance Logic

Circular and Recursive Rules

Practical Donkey Sentences

S. C. Shapiro

Practical Donkey Sentences

• Donkey Sentence:

– Every farmer who owns a donkey beats it.

• Practical Donkey Sentence:

– If you have a quarter in your pocket, put it in the meter.

[Lenhart Schubert]

S. C. Shapiro

FOPL Practical Sentence

• 

(x)[Quarter(x)

In(x, pocket)

PutIn(x, meter)]

– puts all quarters in pocket in the meter

• 

(x) )[Quarter(x)

In(x, pocket)]

PutIn(x, meter)

– last x unbound

• 

(x) )[Quarter(x)

In(x, pocket)]



(x) )[Quarter(x)

In(x, pocket)

PutIn(x, meter)]

– Finds one, may put in another

S. C. Shapiro

Withsome withsome(var, suchthat, do,[else])

Term denoting an act: if there is some a satisfying suchthat{a/x} perform do{a/x} else perform else.

S. C. Shapiro

Practical Sentence in SNePSLOG

(define-primaction Putin

(object place)

(format t

"~&I am putting ~{~A~}~ in the ~{~A~}.~%” object place))

S. C. Shapiro

Practical Sentence in SNePSLOG 2

: Nickel(N1).

: Nickel(N2).

: Quarter(Q1).

: Quarter(Q2).

: Quarter(Q3).

: In(N1, pocket).

: In(Q1, pocket).

: In(Q2, pocket).

S. C. Shapiro

Practical Sentence in SNePSLOG 3

: perform withsome(?x,

Quarter(?x) and In(?x, pocket),

Putin(?x, meter))

I am putting Q1 in the METER.

S. C. Shapiro

Summary

SNePS Logic has been designed specifically to support Natural Language Understanding and CommonSense Reasoning.

The aspects of that design fall under several categories:

S. C. Shapiro

Basic SNePS Principles

Term Logic:

Every expression in SNePS is a term.

Intensional Representation:

Every SNePS term represents (denotes) an intensional (mental) entity.

Uniqueness Principle:

No two SNePS terms denote the same entity.

S. C. Shapiro

Specialized Syntax

Term Logic

Set Arguments

Set-Oriented Logical Connectives

Numerical Quantifiers

• “Higher-Order” Logic

Acts

S. C. Shapiro

Specialized Inference Rules

The Unique Variable Binding Rule

Relevance Logic

S. C. Shapiro

Specialized Semantics

Intensional Representation

Uniqueness Principle

S. C. Shapiro

Specialized Inference Mechanism

Contexts

Belief Revision

Use of circular and recursive rules

Integrated reasoning and acting

S. C. Shapiro

For More Information

Personnel

Manual

Tutorial

Bibliography

• ftp’able SNePS source code

• etc.

http://www.cse.buffalo.edu/sneps/

S. C. Shapiro

Download