From NL to FOL From NL to Logic Semantics and the NLTK Scott - - PowerPoint PPT Presentation

from nl to fol
SMART_READER_LITE
LIVE PREVIEW

From NL to FOL From NL to Logic Semantics and the NLTK Scott - - PowerPoint PPT Presentation

From NL to FOL Scott Farrar CLMA, University of Washington far- rar@u.washington.edu Review From NL to FOL From NL to Logic Semantics and the NLTK Scott Farrar CLMA, University of Washington farrar@u.washington.edu February 17, 2010


slide-1
SLIDE 1

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

From NL to FOL

Scott Farrar CLMA, University of Washington farrar@u.washington.edu February 17, 2010

1/27

slide-2
SLIDE 2

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Today’s lecture

1

Review

2

From NL to Logic

3

Semantics and the NLTK

2/27

slide-3
SLIDE 3

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

3/27

slide-4
SLIDE 4

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

the three main problems associated with computational semantics?

3/27

slide-5
SLIDE 5

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

the three main problems associated with computational semantics? a logic?

3/27

slide-6
SLIDE 6

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

the three main problems associated with computational semantics? a logic? some logics we’ve talked about ?

3/27

slide-7
SLIDE 7

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

the three main problems associated with computational semantics? a logic? some logics we’ve talked about ? a logical sentence?

3/27

slide-8
SLIDE 8

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

the three main problems associated with computational semantics? a logic? some logics we’ve talked about ? a logical sentence? the logical connectives of sentential logical?

3/27

slide-9
SLIDE 9

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

the three main problems associated with computational semantics? a logic? some logics we’ve talked about ? a logical sentence? the logical connectives of sentential logical? a logical argument?

3/27

slide-10
SLIDE 10

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

ForAllX

What is/are:

the three main problems associated with computational semantics? a logic? some logics we’ve talked about ? a logical sentence? the logical connectives of sentential logical? a logical argument? a tautology?

3/27

slide-11
SLIDE 11

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

What is meaning, really?

An example:

4/27

slide-12
SLIDE 12

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

What is meaning, really?

An example:

1 English: Horatio bakes me a cake or Horatio bakes you

a cake.

4/27

slide-13
SLIDE 13

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

What is meaning, really?

An example:

1 English: Horatio bakes me a cake or Horatio bakes you

a cake.

2 Sentential Logic: P ∨ Q (just a symbolic translation) 4/27

slide-14
SLIDE 14

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

What is meaning, really?

An example:

1 English: Horatio bakes me a cake or Horatio bakes you

a cake.

2 Sentential Logic: P ∨ Q (just a symbolic translation)

Intuitive approach to meaning

4/27

slide-15
SLIDE 15

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

What is meaning, really?

An example:

1 English: Horatio bakes me a cake or Horatio bakes you

a cake.

2 Sentential Logic: P ∨ Q (just a symbolic translation)

Intuitive approach to meaning

Intuitively we say that (1)’s meaning depends on whether Horatio bakes a cake, and whether it’s for you

  • r me.

4/27

slide-16
SLIDE 16

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

What is meaning, really?

An example:

1 English: Horatio bakes me a cake or Horatio bakes you

a cake.

2 Sentential Logic: P ∨ Q (just a symbolic translation)

Intuitive approach to meaning

Intuitively we say that (1)’s meaning depends on whether Horatio bakes a cake, and whether it’s for you

  • r me.

That is, depending on the state of the world.

4/27

slide-17
SLIDE 17

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

What is meaning, really?

An example:

1 English: Horatio bakes me a cake or Horatio bakes you

a cake.

2 Sentential Logic: P ∨ Q (just a symbolic translation)

Intuitive approach to meaning

Intuitively we say that (1)’s meaning depends on whether Horatio bakes a cake, and whether it’s for you

  • r me.

That is, depending on the state of the world. Not very satisfying!

4/27

slide-18
SLIDE 18

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Slightly more formal account

What about assigning a value to meaning?

Something like the meaning of Horatio bakes me a cake. is:

5/27

slide-19
SLIDE 19

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Slightly more formal account

What about assigning a value to meaning?

Something like the meaning of Horatio bakes me a cake. is: True

5/27

slide-20
SLIDE 20

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Slightly more formal account

What about assigning a value to meaning?

Something like the meaning of Horatio bakes me a cake. is: True 0.43

5/27

slide-21
SLIDE 21

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Slightly more formal account

What about assigning a value to meaning?

Something like the meaning of Horatio bakes me a cake. is: True 0.43

Truth values

In fact, we can say that the atomic sentences of our logic P, Q, ..., X can either be True or False depending on the state

  • f the world. This is called a truth functional logic.

5/27

slide-22
SLIDE 22

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Slightly more formal account

What about assigning a value to meaning?

Something like the meaning of Horatio bakes me a cake. is: True 0.43

Truth values

In fact, we can say that the atomic sentences of our logic P, Q, ..., X can either be True or False depending on the state

  • f the world. This is called a truth functional logic.

Complex sentences

What about P ∨ Q? When is it True or False?

5/27

slide-23
SLIDE 23

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Truth table for ‘inclusive or’, ∨

P Q P ∨ Q T T T T F T F T T F F F

6/27

slide-24
SLIDE 24

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Truth table for ‘exclusive or’, ⊕

P Q P ⊕ Q T T F T F T F T T F F F

7/27

slide-25
SLIDE 25

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Today’s lecture

1

Review

2

From NL to Logic

3

Semantics and the NLTK

8/27

slide-26
SLIDE 26

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Methodology

Semantic analysis is the mapping of NL utterances onto some logic. In traditional logic classes, the mapping is usually done from logic to NL:

9/27

slide-27
SLIDE 27

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Methodology

Semantic analysis is the mapping of NL utterances onto some logic. In traditional logic classes, the mapping is usually done from logic to NL:

Example

∃x (dog(x) ∧ disappear(x)) At least one entity is a dog and disappeared. Some dog disappeared. A dog disappeared.

9/27

slide-28
SLIDE 28

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Methodology

Semantic analysis is the mapping of NL utterances onto some logic. In traditional logic classes, the mapping is usually done from logic to NL:

Example

∃x (dog(x) ∧ disappear(x)) At least one entity is a dog and disappeared. Some dog disappeared. A dog disappeared. Our methodology: start with structures in NL and find appropriate logical formulas. This makes the logic work for NL, not the other way around.

9/27

slide-29
SLIDE 29

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Nouns

What do nouns usually denote?

10/27

slide-30
SLIDE 30

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Nouns

What do nouns usually denote? physical objects, ones that exist in time and space fish, dogs, hat, leg

10/27

slide-31
SLIDE 31

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Nouns

What do nouns usually denote? physical objects, ones that exist in time and space abstract objects, ones that may persist in time, but not space fish, dogs, hat, leg value, politics, mathematics, scorn

10/27

slide-32
SLIDE 32

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Nouns

What do nouns usually denote? physical objects, ones that exist in time and space abstract objects, ones that may persist in time, but not space events, ones that exist in time and space, but not as long as objects fish, dogs, hat, leg value, politics, mathematics, scorn destruction, creation, movement

10/27

slide-33
SLIDE 33

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Nouns

Unary predicates, those with a single argument, are often used to represent the semantics of nouns. fish(FLIPPER), dog(FRITZ), hat(HAT234) value(V 1), politics(P1), scorn(S1) destroyingEvent(D1), movementEvent(M1) In fact the unary predicate is naming the type of whatever the argument may be. There can be many, many types wrt the semantics of natural language.

11/27

slide-34
SLIDE 34

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

NL semantics and ontology

Definition

Our FOL approach requires a rich ontology, or a theory of existence and how the elements of the world relate.

12/27

slide-35
SLIDE 35

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

NL semantics and ontology

Definition

Our FOL approach requires a rich ontology, or a theory of existence and how the elements of the world relate. Modeling NL meaning is an exercise in ‘natural language’ metaphysics.

12/27

slide-36
SLIDE 36

DOLCE upper categories

slide-37
SLIDE 37

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: PNs

Constants are used to represent the semantics of proper nouns. Queen Elizabeth II, ELIZII Barack Obama, BARACK John, JOHN432

14/27

slide-38
SLIDE 38

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: NPs

A modified NP is an NP of the form: NP → X NN, where X can be one of a number of syntactic categories: determiner, quantity, adjective, etc. a dog, some dog all cats 3 fish several elephants a bunch of rats

15/27

slide-39
SLIDE 39

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

Quantificational modifiers of the type a or some are modeled using the existential quantifier, ∃. a dog, ∃x dog(x) some person, ∃x person(x)

16/27

slide-40
SLIDE 40

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

And the quantificational modifier of the type all, every, etc. can be modeled using the universal ∀:

17/27

slide-41
SLIDE 41

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

And the quantificational modifier of the type all, every, etc. can be modeled using the universal ∀: all fish, ∀f fish(f )

17/27

slide-42
SLIDE 42

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

And the quantificational modifier of the type all, every, etc. can be modeled using the universal ∀: all fish, ∀f fish(f ) every man, ∀m man(m)

17/27

slide-43
SLIDE 43

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

And the quantificational modifier of the type all, every, etc. can be modeled using the universal ∀: all fish, ∀f fish(f ) every man, ∀m man(m) each and every member, ∀m member(m)

17/27

slide-44
SLIDE 44

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

In reality quantification in languages is often difficult to describe given the standard logical machinery of FOL: ∃ and ∀.

18/27

slide-45
SLIDE 45

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

In reality quantification in languages is often difficult to describe given the standard logical machinery of FOL: ∃ and ∀. Semanticists are often forced to come up with new logical quantifiers to discuss natural language quantification.

18/27

slide-46
SLIDE 46

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

In reality quantification in languages is often difficult to describe given the standard logical machinery of FOL: ∃ and ∀. Semanticists are often forced to come up with new logical quantifiers to discuss natural language quantification.

18/27

slide-47
SLIDE 47

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

In reality quantification in languages is often difficult to describe given the standard logical machinery of FOL: ∃ and ∀. Semanticists are often forced to come up with new logical quantifiers to discuss natural language quantification. Just a few biscuits please, with a lot of gravy!

18/27

slide-48
SLIDE 48

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

In reality quantification in languages is often difficult to describe given the standard logical machinery of FOL: ∃ and ∀. Semanticists are often forced to come up with new logical quantifiers to discuss natural language quantification. Just a few biscuits please, with a lot of gravy! He’ll take several doses to be cured.

18/27

slide-49
SLIDE 49

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

In reality quantification in languages is often difficult to describe given the standard logical machinery of FOL: ∃ and ∀. Semanticists are often forced to come up with new logical quantifiers to discuss natural language quantification. Just a few biscuits please, with a lot of gravy! He’ll take several doses to be cured. A couple of slices.

18/27

slide-50
SLIDE 50

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Quantificational modifiers

In reality quantification in languages is often difficult to describe given the standard logical machinery of FOL: ∃ and ∀. Semanticists are often forced to come up with new logical quantifiers to discuss natural language quantification. Just a few biscuits please, with a lot of gravy! He’ll take several doses to be cured. A couple of slices. Simply scads of weapons of mass destruction.

18/27

slide-51
SLIDE 51

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Adjectives

Just as with nouns, adjectives say something about the type

  • f entity being referred to; accordingly, they can be modeled

as unary predicates at the semantic level.

19/27

slide-52
SLIDE 52

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Adjectives

Just as with nouns, adjectives say something about the type

  • f entity being referred to; accordingly, they can be modeled

as unary predicates at the semantic level.

19/27

slide-53
SLIDE 53

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Adjectives

Just as with nouns, adjectives say something about the type

  • f entity being referred to; accordingly, they can be modeled

as unary predicates at the semantic level. broken leg, broken(x) ∧ leg(x)

19/27

slide-54
SLIDE 54

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Adjectives

Just as with nouns, adjectives say something about the type

  • f entity being referred to; accordingly, they can be modeled

as unary predicates at the semantic level. broken leg, broken(x) ∧ leg(x) red rooster, red(y) ∧ rooster(y)

19/27

slide-55
SLIDE 55

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Adjectives

Just as with nouns, adjectives say something about the type

  • f entity being referred to; accordingly, they can be modeled

as unary predicates at the semantic level. broken leg, broken(x) ∧ leg(x) red rooster, red(y) ∧ rooster(y) jagged white pill, jagged(z) ∧ white(z) ∧ pill(z)

19/27

slide-56
SLIDE 56

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Adjectives

Just as with nouns, adjectives say something about the type

  • f entity being referred to; accordingly, they can be modeled

as unary predicates at the semantic level. broken leg, broken(x) ∧ leg(x) red rooster, red(y) ∧ rooster(y) jagged white pill, jagged(z) ∧ white(z) ∧ pill(z) Some adjectives are more problematic and require more elaborate semantic machinery: small solar system, large mouse, grande latte

19/27

slide-57
SLIDE 57

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Conjunctions

Conjunctions such as and, as well as, or, either...or... are mapped to logical connectives.

20/27

slide-58
SLIDE 58

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Conjunctions

Conjunctions such as and, as well as, or, either...or... are mapped to logical connectives. fish and chips, fish(f ) ∧ chip(c)

20/27

slide-59
SLIDE 59

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Conjunctions

Conjunctions such as and, as well as, or, either...or... are mapped to logical connectives. fish and chips, fish(f ) ∧ chip(c) ham as well as eggs, ham(h) ∧ egg(e)

20/27

slide-60
SLIDE 60

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Conjunctions

Conjunctions such as and, as well as, or, either...or... are mapped to logical connectives. fish and chips, fish(f ) ∧ chip(c) ham as well as eggs, ham(h) ∧ egg(e) coffee or tea, coffee(c) ∨ tea(t)

20/27

slide-61
SLIDE 61

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Conjunctions

Conjunctions such as and, as well as, or, either...or... are mapped to logical connectives. fish and chips, fish(f ) ∧ chip(c) ham as well as eggs, ham(h) ∧ egg(e) coffee or tea, coffee(c) ∨ tea(t) either red or green, red(x) ⊕ green(x) (XOR)

20/27

slide-62
SLIDE 62

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: misc

Negative markers are mapped to formulas with the negation symbol. not pumpkin, ¬pumpkin(p)

21/27

slide-63
SLIDE 63

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: misc

Negative markers are mapped to formulas with the negation symbol. not pumpkin, ¬pumpkin(p) Some prepositions are mapped to binary predicates. Joe is in Seattle, in(JOE, SEATTLE)

21/27

slide-64
SLIDE 64

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: misc

Negative markers are mapped to formulas with the negation symbol. not pumpkin, ¬pumpkin(p) Some prepositions are mapped to binary predicates. Joe is in Seattle, in(JOE, SEATTLE) Copulas (certain occurrences of be) are mapped to equality. Fred is the killer, FRED = KILLER123

21/27

slide-65
SLIDE 65

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Verbs

The main verb is mapped to an n-ary predicate in FOL. It indicates a property or relation.

22/27

slide-66
SLIDE 66

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Verbs

The main verb is mapped to an n-ary predicate in FOL. It indicates a property or relation. Intransitives can be represented as unary predicates. swim(x)

22/27

slide-67
SLIDE 67

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Verbs

The main verb is mapped to an n-ary predicate in FOL. It indicates a property or relation. Intransitives can be represented as unary predicates. swim(x) Transitives can be represented as binary predicates. steal(x, y)

22/27

slide-68
SLIDE 68

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Verbs

The main verb is mapped to an n-ary predicate in FOL. It indicates a property or relation. Intransitives can be represented as unary predicates. swim(x) Transitives can be represented as binary predicates. steal(x, y) Ditransitives can be represented as ternary predicates. give(x, y, z)

22/27

slide-69
SLIDE 69

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Mapping NL to FOL: Verbs

The main verb is mapped to an n-ary predicate in FOL. It indicates a property or relation. Intransitives can be represented as unary predicates. swim(x) Transitives can be represented as binary predicates. steal(x, y) Ditransitives can be represented as ternary predicates. give(x, y, z) But there’s a problem.

22/27

slide-70
SLIDE 70

Mapping NL to FOL: VPs

John buttered the toast. Butter(JOHN, TOAST)

slide-71
SLIDE 71

Mapping NL to FOL: VPs

John buttered the toast. Butter(JOHN, TOAST) John buttered the toast at midnight. Butter(JOHN, TOAST, MIDNIGHT)

slide-72
SLIDE 72

Mapping NL to FOL: VPs

John buttered the toast. Butter(JOHN, TOAST) John buttered the toast at midnight. Butter(JOHN, TOAST, MIDNIGHT) John buttered the toast at midnight with a knife. Butter(JOHN, TOAST, MIDNIGHT, KNIFE)

slide-73
SLIDE 73

Mapping NL to FOL: VPs

John buttered the toast. Butter(JOHN, TOAST) John buttered the toast at midnight. Butter(JOHN, TOAST, MIDNIGHT) John buttered the toast at midnight with a knife. Butter(JOHN, TOAST, MIDNIGHT, KNIFE) John buttered the toast at midnight with a knife before he went to bed. Butter(JOHN, TOAST, MIDNIGHT, KNIFE, ...)

slide-74
SLIDE 74

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Today’s lecture

1

Review

2

From NL to Logic

3

Semantics and the NLTK

24/27

slide-75
SLIDE 75

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

Packages

nltk.sem.logic: A version of first order logic, built on top of the untyped lambda calculus. nltk.sem.logic.Expression is the base class for all kinds of logical formulas. nltk.sem.LogicParser: A parser that reads semantic representations and creates logic objects. nltk.sem.util: Utility functions for batch-processing sentences: parsing and extraction of the semantic representation of the root node of the the syntax tree, followed by evaluation of the semantic representation in a first-order model. Prover9: a supplemental theorem prover callable from the NLTK

25/27

slide-76
SLIDE 76

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

FOL in the NLTK

The nltk.sem.logic package contains the tools necessary for representing FOL. Boolean operators: negation

  • (the hyphen)

conjunction & disjunction | implication

  • >

equivalence <->

26/27

slide-77
SLIDE 77

From NL to FOL Scott Farrar CLMA, University

  • f Washington far-

rar@u.washington.edu Review From NL to Logic Semantics and the NLTK

FOL in the NLTK

Equality predicates: equality = inequality != Quantifiers: existential exists universal all lambda \

27/27