Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of...

71
Computational Semantics: More λ Calculus Scott Farrar CLMA, University of Washington far- [email protected] λ-calculus Recap NLTK semantics λ operations Type theory Computational Semantics: More λ Calculus Scott Farrar CLMA, University of Washington [email protected] March 1, 2010 1/23

Transcript of Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of...

Page 1: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Computational Semantics: More λ Calculus

Scott FarrarCLMA, University of Washington

[email protected]

March 1, 2010

1/23

Page 2: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Today’s lecture

1 λ-calculus Recap

2 NLTK semantics

3 λ operations

4 Type theory

2/23

Page 3: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Key points from last time

The λ-calculus can be considered an axiomatic theoryof functions.

It is a calculus of functions and function application(F A), where F is some function and A is someargument.

F is in the form of λvar .expr such that var is bound bythe λ operator.

λx .red(x) is an example of a λ-expression.

The function λx .red(x) is anonymous; it has no name.

The λ-calculus can be used with FOL to functions toaid in the compositionality process.

3/23

Page 4: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Key points from last time

The λ-calculus can be considered an axiomatic theoryof functions.

It is a calculus of functions and function application(F A), where F is some function and A is someargument.

F is in the form of λvar .expr such that var is bound bythe λ operator.

λx .red(x) is an example of a λ-expression.

The function λx .red(x) is anonymous; it has no name.

The λ-calculus can be used with FOL to functions toaid in the compositionality process.

3/23

Page 5: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Key points from last time

The λ-calculus can be considered an axiomatic theoryof functions.

It is a calculus of functions and function application(F A), where F is some function and A is someargument.

F is in the form of λvar .expr such that var is bound bythe λ operator.

λx .red(x) is an example of a λ-expression.

The function λx .red(x) is anonymous; it has no name.

The λ-calculus can be used with FOL to functions toaid in the compositionality process.

3/23

Page 6: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Key points from last time

The λ-calculus can be considered an axiomatic theoryof functions.

It is a calculus of functions and function application(F A), where F is some function and A is someargument.

F is in the form of λvar .expr such that var is bound bythe λ operator.

λx .red(x) is an example of a λ-expression.

The function λx .red(x) is anonymous; it has no name.

The λ-calculus can be used with FOL to functions toaid in the compositionality process.

3/23

Page 7: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Key points from last time

The λ-calculus can be considered an axiomatic theoryof functions.

It is a calculus of functions and function application(F A), where F is some function and A is someargument.

F is in the form of λvar .expr such that var is bound bythe λ operator.

λx .red(x) is an example of a λ-expression.

The function λx .red(x) is anonymous; it has no name.

The λ-calculus can be used with FOL to functions toaid in the compositionality process.

3/23

Page 8: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Key points from last time

The λ-calculus can be considered an axiomatic theoryof functions.

It is a calculus of functions and function application(F A), where F is some function and A is someargument.

F is in the form of λvar .expr such that var is bound bythe λ operator.

λx .red(x) is an example of a λ-expression.

The function λx .red(x) is anonymous; it has no name.

The λ-calculus can be used with FOL to functions toaid in the compositionality process.

3/23

Page 9: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Today’s lecture

1 λ-calculus Recap

2 NLTK semantics

3 λ operations

4 Type theory

4/23

Page 10: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Variables

The NLTK implements FOL and λ-calculus starting with abasic functional calculus and then adding elements of FOL.Furthermore, variables in the NLTK’s implementation aretyped:

IndividualVariableExpression: the value has to bea, b, c, ..., w,x,y,z (but not e), plus 0 or morenumerals, e.g., x, y, x1, y23.

EventVariableExpression: has to be e or e1, e2,...

FunctionVariableExpression: has to be a singlecapital letter and can be followed by a numeral, e.g., A,B, A1, E1

5/23

Page 11: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Variables

The NLTK implements FOL and λ-calculus starting with abasic functional calculus and then adding elements of FOL.Furthermore, variables in the NLTK’s implementation aretyped:

IndividualVariableExpression: the value has to bea, b, c, ..., w,x,y,z (but not e), plus 0 or morenumerals, e.g., x, y, x1, y23.

EventVariableExpression: has to be e or e1, e2,...

FunctionVariableExpression: has to be a singlecapital letter and can be followed by a numeral, e.g., A,B, A1, E1

5/23

Page 12: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Variables

The NLTK implements FOL and λ-calculus starting with abasic functional calculus and then adding elements of FOL.Furthermore, variables in the NLTK’s implementation aretyped:

IndividualVariableExpression: the value has to bea, b, c, ..., w,x,y,z (but not e), plus 0 or morenumerals, e.g., x, y, x1, y23.

EventVariableExpression: has to be e or e1, e2,...

FunctionVariableExpression: has to be a singlecapital letter and can be followed by a numeral, e.g., A,B, A1, E1

5/23

Page 13: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Variables

The NLTK implements FOL and λ-calculus starting with abasic functional calculus and then adding elements of FOL.Furthermore, variables in the NLTK’s implementation aretyped:

IndividualVariableExpression: the value has to bea, b, c, ..., w,x,y,z (but not e), plus 0 or morenumerals, e.g., x, y, x1, y23.

EventVariableExpression: has to be e or e1, e2,...

FunctionVariableExpression: has to be a singlecapital letter and can be followed by a numeral, e.g., A,B, A1, E1

5/23

Page 14: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Constants

ConstantExpression: an expression consisting of aconstant, e.g., BILL, BB, bill

6/23

Page 15: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Binder expressions

VariableBinderExpression: an abstract class, anexpression with at least one bound variable and abinding operator (\, all, exists)

LambdaExpression: an expression with at least onevariable bound by the λ operator (\)ExistsExpression: an expression with at least onevariable bound by the exists operator

AllExpression: an expression with at least onevariable bound by the all operator

ApplicationExpression: an expression with a functorand an argument

7/23

Page 16: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Binder expressions

VariableBinderExpression: an abstract class, anexpression with at least one bound variable and abinding operator (\, all, exists)

LambdaExpression: an expression with at least onevariable bound by the λ operator (\)ExistsExpression: an expression with at least onevariable bound by the exists operator

AllExpression: an expression with at least onevariable bound by the all operator

ApplicationExpression: an expression with a functorand an argument

7/23

Page 17: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Binder expressions

VariableBinderExpression: an abstract class, anexpression with at least one bound variable and abinding operator (\, all, exists)

LambdaExpression: an expression with at least onevariable bound by the λ operator (\)

ExistsExpression: an expression with at least onevariable bound by the exists operator

AllExpression: an expression with at least onevariable bound by the all operator

ApplicationExpression: an expression with a functorand an argument

7/23

Page 18: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Binder expressions

VariableBinderExpression: an abstract class, anexpression with at least one bound variable and abinding operator (\, all, exists)

LambdaExpression: an expression with at least onevariable bound by the λ operator (\)ExistsExpression: an expression with at least onevariable bound by the exists operator

AllExpression: an expression with at least onevariable bound by the all operator

ApplicationExpression: an expression with a functorand an argument

7/23

Page 19: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Binder expressions

VariableBinderExpression: an abstract class, anexpression with at least one bound variable and abinding operator (\, all, exists)

LambdaExpression: an expression with at least onevariable bound by the λ operator (\)ExistsExpression: an expression with at least onevariable bound by the exists operator

AllExpression: an expression with at least onevariable bound by the all operator

ApplicationExpression: an expression with a functorand an argument

7/23

Page 20: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK semantics

Binder expressions

VariableBinderExpression: an abstract class, anexpression with at least one bound variable and abinding operator (\, all, exists)

LambdaExpression: an expression with at least onevariable bound by the λ operator (\)ExistsExpression: an expression with at least onevariable bound by the exists operator

AllExpression: an expression with at least onevariable bound by the all operator

ApplicationExpression: an expression with a functorand an argument

7/23

Page 21: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

Summary of λ-expressions

syn. category example FOL λ expressioncommon noun dog dog(x) \ x.dog(x)proper noun Bill BILL \ P.P(BILL)intransitive verb runs run(x) \ x.run(x)transitive verb loves love(x , y) \ X y.X(\ x.love(y,x))copula is eq(x , y) \ X y.X(\ x.eq(y,x))negative copula isn’t ¬eq(x , y) \ X y.X(\ x.-eq(y,x))auxiliary verb did go go(x) \ K z.K(z) (\ x.go(x))neg. auxiliary verb didn’t go ¬go(x) \ K z.-K(z) (\ x.go(x))

Page 22: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Abstractions

We say that:\ x.red(x) is a λ abstraction

Definition

The term λ-abstraction refers to a function, possiblyconstructed from an expression which was not originally afunction, e.g., a predicate logic formula.

9/23

Page 23: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Abstractions

We say that:\ x.red(x) is a λ abstraction

Definition

The term λ-abstraction refers to a function, possiblyconstructed from an expression which was not originally afunction, e.g., a predicate logic formula.

9/23

Page 24: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Applications

We say that:\ x. red(x) (BOAT)

is an application expression.

Definition

An application expression is a formula with a function andan argument.

10/23

Page 25: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Applications

We say that:\ x. red(x) (BOAT)is an application expression.

Definition

An application expression is a formula with a function andan argument.

10/23

Page 26: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Applications

We say that:\ x. red(x) (BOAT)is an application expression.

Definition

An application expression is a formula with a function andan argument.

10/23

Page 27: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Today’s lecture

1 λ-calculus Recap

2 NLTK semantics

3 λ operations

4 Type theory

11/23

Page 28: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Reducing

We say that:\x .red(x)(BOAT )β-reduces to:red(BOAT)

Definition

β-reduction is the process of substituting an argument forvariables (in the function) bound by the λ operator.

12/23

Page 29: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

α-conversion

Definition

Alpha conversion allows bound variable names to bechanged. For example, an alpha conversion of \ x.x wouldbe \ y.y . Frequently in uses of λ calculus, terms that differonly by alpha conversion are considered to be equivalent.

\ x.x ≡ \ y.y ≡ \ t.t

Given \ x. \ x.x, which of the following would be a validα-conversion?

1 \ y. \ x.x

2 \ y.\ x.y

(invalid conversion)

13/23

Page 30: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

α-conversion

Definition

Alpha conversion allows bound variable names to bechanged. For example, an alpha conversion of \ x.x wouldbe \ y.y . Frequently in uses of λ calculus, terms that differonly by alpha conversion are considered to be equivalent.

\ x.x ≡ \ y.y ≡ \ t.t

Given \ x. \ x.x, which of the following would be a validα-conversion?

1 \ y. \ x.x

2 \ y.\ x.y (invalid conversion)

13/23

Page 31: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Today’s lecture

1 λ-calculus Recap

2 NLTK semantics

3 λ operations

4 Type theory

14/23

Page 32: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Adjectives

Adjectives are relatively simple unary predicates, but with anadded conjunction.

For example, the target semantics for a noun modified by anadjective would be red ball, would translate to:\ x.red(x) & ball(x)The result is obtained using this lambda expression for red :\ P y. (red(y) & P(y))

red ball

\ P y. (red(y) & P(y)) (\ x.ball(x))

\ y. (red(y) & \ x.ball(x)(y))

\ y.(red(y) & ball(y))

15/23

Page 33: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Adjectives

Adjectives are relatively simple unary predicates, but with anadded conjunction.

For example, the target semantics for a noun modified by anadjective would be red ball, would translate to:\ x.red(x) & ball(x)The result is obtained using this lambda expression for red :\ P y. (red(y) & P(y))

red ball

\ P y. (red(y) & P(y)) (\ x.ball(x))

\ y. (red(y) & \ x.ball(x)(y))

\ y.(red(y) & ball(y))

15/23

Page 34: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Adjectives

Adjectives are relatively simple unary predicates, but with anadded conjunction.

For example, the target semantics for a noun modified by anadjective would be red ball, would translate to:\ x.red(x) & ball(x)The result is obtained using this lambda expression for red :\ P y. (red(y) & P(y))

red ball

\ P y. (red(y) & P(y)) (\ x.ball(x))

\ y. (red(y) & \ x.ball(x)(y))

\ y.(red(y) & ball(y))

15/23

Page 35: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Adjectives

Adjectives are relatively simple unary predicates, but with anadded conjunction.

For example, the target semantics for a noun modified by anadjective would be red ball, would translate to:\ x.red(x) & ball(x)The result is obtained using this lambda expression for red :\ P y. (red(y) & P(y))

red ball

\ P y. (red(y) & P(y)) (\ x.ball(x))

\ y. (red(y) & \ x.ball(x)(y))

\ y.(red(y) & ball(y))

15/23

Page 36: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Adjectives

Adjectives are relatively simple unary predicates, but with anadded conjunction.

For example, the target semantics for a noun modified by anadjective would be red ball, would translate to:\ x.red(x) & ball(x)The result is obtained using this lambda expression for red :\ P y. (red(y) & P(y))

red ball

\ P y. (red(y) & P(y)) (\ x.ball(x))

\ y. (red(y) & \ x.ball(x)(y))

\ y.(red(y) & ball(y))

15/23

Page 37: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Adjectives

Adjectives are relatively simple unary predicates, but with anadded conjunction.

For example, the target semantics for a noun modified by anadjective would be red ball, would translate to:\ x.red(x) & ball(x)The result is obtained using this lambda expression for red :\ P y. (red(y) & P(y))

red ball

\ P y. (red(y) & P(y)) (\ x.ball(x))

\ y. (red(y) & \ x.ball(x)(y))

\ y.(red(y) & ball(y))

15/23

Page 38: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Basic types

Syntactically speaking, expressions in the FOL+λ languagecome in 2 basic types: e and t

e is the type for entities

t is the type for formulas, i.e., expressions which havetruth values (True or False).

e type

The ‘e’ stands for entity in the UD. Constants and variables(terms) map to entities in the UD:

BILL is of type e

x is of type e

16/23

Page 39: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Basic types

Syntactically speaking, expressions in the FOL+λ languagecome in 2 basic types: e and t

e is the type for entities

t is the type for formulas, i.e., expressions which havetruth values (True or False).

e type

The ‘e’ stands for entity in the UD. Constants and variables(terms) map to entities in the UD:

BILL is of type e

x is of type e

16/23

Page 40: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Basic types

Syntactically speaking, expressions in the FOL+λ languagecome in 2 basic types: e and t

e is the type for entities

t is the type for formulas, i.e., expressions which havetruth values (True or False).

e type

The ‘e’ stands for entity in the UD. Constants and variables(terms) map to entities in the UD:

BILL is of type e

x is of type e

16/23

Page 41: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Basic types

Syntactically speaking, expressions in the FOL+λ languagecome in 2 basic types: e and t

e is the type for entities

t is the type for formulas, i.e., expressions which havetruth values (True or False).

e type

The ‘e’ stands for entity in the UD. Constants and variables(terms) map to entities in the UD:

BILL is of type e

x is of type e

16/23

Page 42: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Basic types

Syntactically speaking, expressions in the FOL+λ languagecome in 2 basic types: e and t

e is the type for entities

t is the type for formulas, i.e., expressions which havetruth values (True or False).

e type

The ‘e’ stands for entity in the UD. Constants and variables(terms) map to entities in the UD:

BILL is of type e

x is of type e

16/23

Page 43: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Basic types

Syntactically speaking, expressions in the FOL+λ languagecome in 2 basic types: e and t

e is the type for entities

t is the type for formulas, i.e., expressions which havetruth values (True or False).

e type

The ‘e’ stands for entity in the UD. Constants and variables(terms) map to entities in the UD:

BILL is of type e

x is of type e

16/23

Page 44: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

t type

type for formulas, i.e., expressions which have truth values(True or False):

boy(x)

∀x .smokes(x)

∃y .knows(y ,BILL)

17/23

Page 45: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

t type

type for formulas, i.e., expressions which have truth values(True or False):

boy(x)

∀x .smokes(x)

∃y .knows(y ,BILL)

17/23

Page 46: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

t type

type for formulas, i.e., expressions which have truth values(True or False):

boy(x)

∀x .smokes(x)

∃y .knows(y ,BILL)

17/23

Page 47: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

t type

type for formulas, i.e., expressions which have truth values(True or False):

boy(x)

∀x .smokes(x)

∃y .knows(y ,BILL)

17/23

Page 48: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Definition

Now, lets assume that expressions in our FOL can be eitherfunctions and arguments, as the λ calculus does. Functionshave signatures which define (1) what kinds of argumentsthe function takes and (2) the return type.

Complex types

There are arbitrarily many complex types expressed by theirsignatures. The set of types is defined as follows:

e is a (basic) type

t is a (basic) type

If a and b are types, then so is 〈a, b〉.Nothing except the basic types, and what can beconstructed from them by means of the previous clauseare types.

18/23

Page 49: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Definition

Now, lets assume that expressions in our FOL can be eitherfunctions and arguments, as the λ calculus does. Functionshave signatures which define (1) what kinds of argumentsthe function takes and (2) the return type.

Complex types

There are arbitrarily many complex types expressed by theirsignatures. The set of types is defined as follows:

e is a (basic) type

t is a (basic) type

If a and b are types, then so is 〈a, b〉.Nothing except the basic types, and what can beconstructed from them by means of the previous clauseare types.

18/23

Page 50: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Definition

Now, lets assume that expressions in our FOL can be eitherfunctions and arguments, as the λ calculus does. Functionshave signatures which define (1) what kinds of argumentsthe function takes and (2) the return type.

Complex types

There are arbitrarily many complex types expressed by theirsignatures. The set of types is defined as follows:

e is a (basic) type

t is a (basic) type

If a and b are types, then so is 〈a, b〉.Nothing except the basic types, and what can beconstructed from them by means of the previous clauseare types.

18/23

Page 51: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Definition

Now, lets assume that expressions in our FOL can be eitherfunctions and arguments, as the λ calculus does. Functionshave signatures which define (1) what kinds of argumentsthe function takes and (2) the return type.

Complex types

There are arbitrarily many complex types expressed by theirsignatures. The set of types is defined as follows:

e is a (basic) type

t is a (basic) type

If a and b are types, then so is 〈a, b〉.Nothing except the basic types, and what can beconstructed from them by means of the previous clauseare types.

18/23

Page 52: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Definition

Now, lets assume that expressions in our FOL can be eitherfunctions and arguments, as the λ calculus does. Functionshave signatures which define (1) what kinds of argumentsthe function takes and (2) the return type.

Complex types

There are arbitrarily many complex types expressed by theirsignatures. The set of types is defined as follows:

e is a (basic) type

t is a (basic) type

If a and b are types, then so is 〈a, b〉.

Nothing except the basic types, and what can beconstructed from them by means of the previous clauseare types.

18/23

Page 53: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Definition

Now, lets assume that expressions in our FOL can be eitherfunctions and arguments, as the λ calculus does. Functionshave signatures which define (1) what kinds of argumentsthe function takes and (2) the return type.

Complex types

There are arbitrarily many complex types expressed by theirsignatures. The set of types is defined as follows:

e is a (basic) type

t is a (basic) type

If a and b are types, then so is 〈a, b〉.Nothing except the basic types, and what can beconstructed from them by means of the previous clauseare types.

18/23

Page 54: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Complex types

1 < e, t >: signature for unary predicates, ie sets in UD

2 < e, < e, t >>: signature for binary predicates, ierelations among sets in UD

3 < e, < e, < e, t >>>: signature for a more complexfunction

4 ...

< e, t >

< e, t > means that some function takes something of typee and returns something of type t. For instance, a unarypredicate is one such example.

19/23

Page 55: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Complex types

1 < e, t >: signature for unary predicates, ie sets in UD

2 < e, < e, t >>: signature for binary predicates, ierelations among sets in UD

3 < e, < e, < e, t >>>: signature for a more complexfunction

4 ...

< e, t >

< e, t > means that some function takes something of typee and returns something of type t. For instance, a unarypredicate is one such example.

19/23

Page 56: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Complex types

1 < e, t >: signature for unary predicates, ie sets in UD

2 < e, < e, t >>: signature for binary predicates, ierelations among sets in UD

3 < e, < e, < e, t >>>: signature for a more complexfunction

4 ...

< e, t >

< e, t > means that some function takes something of typee and returns something of type t. For instance, a unarypredicate is one such example.

19/23

Page 57: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Complex types

1 < e, t >: signature for unary predicates, ie sets in UD

2 < e, < e, t >>: signature for binary predicates, ierelations among sets in UD

3 < e, < e, < e, t >>>: signature for a more complexfunction

4 ...

< e, t >

< e, t > means that some function takes something of typee and returns something of type t. For instance, a unarypredicate is one such example.

19/23

Page 58: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Complex types

1 < e, t >: signature for unary predicates, ie sets in UD

2 < e, < e, t >>: signature for binary predicates, ierelations among sets in UD

3 < e, < e, < e, t >>>: signature for a more complexfunction

4 ...

< e, t >

< e, t > means that some function takes something of typee and returns something of type t. For instance, a unarypredicate is one such example.

19/23

Page 59: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Expression types

Complex types

1 < e, t >: signature for unary predicates, ie sets in UD

2 < e, < e, t >>: signature for binary predicates, ierelations among sets in UD

3 < e, < e, < e, t >>>: signature for a more complexfunction

4 ...

< e, t >

< e, t > means that some function takes something of typee and returns something of type t. For instance, a unarypredicate is one such example.

19/23

Page 60: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Complex Types

< e, < e, t >>

< e, < e, t >> means that some expression takes somethingof type e and returns something of type ¡e,t¿. For instance,a binary predicate is one example.

< e, e >

What about this one?

Consider the named function father(x).fatherJOHN results in TED

20/23

Page 61: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Complex Types

< e, < e, t >>

< e, < e, t >> means that some expression takes somethingof type e and returns something of type ¡e,t¿. For instance,a binary predicate is one example.

< e, e >

What about this one?Consider the named function father(x).

fatherJOHN results in TED

20/23

Page 62: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Complex Types

< e, < e, t >>

< e, < e, t >> means that some expression takes somethingof type e and returns something of type ¡e,t¿. For instance,a binary predicate is one example.

< e, e >

What about this one?Consider the named function father(x).fatherJOHN results in TED

20/23

Page 63: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier

The quantifier words every and all translate to the universalquantifier ∀, plus a conditional, e.g., All CEOs smoke.

∀x(CEO(x)→ smoke(x))

We need to ensure that the structure of this quantifierphrase gets preserved. The attachment for all is:\ P Q. all x. (P (x) -> Q (x))

21/23

Page 64: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier example

All boys smoke.

1 \ P Q. all x. (P (x) -> Q (x)) (\ z.boy(z))(\ s.smoke(s))

2 \ Q. all x. ((\ z. boy(z)) (x) -> Q (x))

3 \ Q. all x. (boy(x) -> Q (x))

4 \ Q. all x. (boy(x) -> Q (x))(\ s.smoke(s))

5 all x. (boy(x) -> \ s.smoke(s) (x))

6 all x. (boy(x) -> smoke(x))

22/23

Page 65: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier example

All boys smoke.

1 \ P Q. all x. (P (x) -> Q (x)) (\ z.boy(z))(\ s.smoke(s))

2 \ Q. all x. ((\ z. boy(z)) (x) -> Q (x))

3 \ Q. all x. (boy(x) -> Q (x))

4 \ Q. all x. (boy(x) -> Q (x))(\ s.smoke(s))

5 all x. (boy(x) -> \ s.smoke(s) (x))

6 all x. (boy(x) -> smoke(x))

22/23

Page 66: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier example

All boys smoke.

1 \ P Q. all x. (P (x) -> Q (x)) (\ z.boy(z))(\ s.smoke(s))

2 \ Q. all x. ((\ z. boy(z)) (x) -> Q (x))

3 \ Q. all x. (boy(x) -> Q (x))

4 \ Q. all x. (boy(x) -> Q (x))(\ s.smoke(s))

5 all x. (boy(x) -> \ s.smoke(s) (x))

6 all x. (boy(x) -> smoke(x))

22/23

Page 67: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier example

All boys smoke.

1 \ P Q. all x. (P (x) -> Q (x)) (\ z.boy(z))(\ s.smoke(s))

2 \ Q. all x. ((\ z. boy(z)) (x) -> Q (x))

3 \ Q. all x. (boy(x) -> Q (x))

4 \ Q. all x. (boy(x) -> Q (x))(\ s.smoke(s))

5 all x. (boy(x) -> \ s.smoke(s) (x))

6 all x. (boy(x) -> smoke(x))

22/23

Page 68: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier example

All boys smoke.

1 \ P Q. all x. (P (x) -> Q (x)) (\ z.boy(z))(\ s.smoke(s))

2 \ Q. all x. ((\ z. boy(z)) (x) -> Q (x))

3 \ Q. all x. (boy(x) -> Q (x))

4 \ Q. all x. (boy(x) -> Q (x))(\ s.smoke(s))

5 all x. (boy(x) -> \ s.smoke(s) (x))

6 all x. (boy(x) -> smoke(x))

22/23

Page 69: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier example

All boys smoke.

1 \ P Q. all x. (P (x) -> Q (x)) (\ z.boy(z))(\ s.smoke(s))

2 \ Q. all x. ((\ z. boy(z)) (x) -> Q (x))

3 \ Q. all x. (boy(x) -> Q (x))

4 \ Q. all x. (boy(x) -> Q (x))(\ s.smoke(s))

5 all x. (boy(x) -> \ s.smoke(s) (x))

6 all x. (boy(x) -> smoke(x))

22/23

Page 70: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

Universal quantifier example

All boys smoke.

1 \ P Q. all x. (P (x) -> Q (x)) (\ z.boy(z))(\ s.smoke(s))

2 \ Q. all x. ((\ z. boy(z)) (x) -> Q (x))

3 \ Q. all x. (boy(x) -> Q (x))

4 \ Q. all x. (boy(x) -> Q (x))(\ s.smoke(s))

5 all x. (boy(x) -> \ s.smoke(s) (x))

6 all x. (boy(x) -> smoke(x))

22/23

Page 71: Computational Semantics: More CalculusSemantics: More Calculus Scott Farrar CLMA, University of Washington far-rar@u.washington.edu -calculus Recap NLTK semantics operations Type theory

ComputationalSemantics: More

λ Calculus

Scott FarrarCLMA, Universityof Washington [email protected]

λ-calculus Recap

NLTK semantics

λ operations

Type theory

NLTK notes for hw6

For hw6 use a feature context free grammar to parse thesimple sentences. Notice how the func-arg relation isrepresented here:

% start S

S[sem = <?subj(?vp)>] -> NP[sem=?subj] VP[sem=?vp]...IV[sem=<\x.run(x)>] -> ’runs’...

Just use simple semantic attachments, no m/s featuresrequired. Try event semantics if you want.

23/23