generating quantifiers and negation to explain homework ...tetreaul/bea5/08-perry-shan.pdf · an...

57

Upload: others

Post on 05-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Generating Quanti�ers and Negation to Explain

Homework Testing

Jason Perry and Chung-chieh Shan

Rutgers University

June 5, 2010

Slides available athttp://paul.rutgers.edu/~jasperry/gqn_bea.pdf

Page 2: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Automated Programming Assignment Checking

Professor teaching Programming 101 types requirement:\Every source �le compiles and `Readme.txt` mentions every source

�le."

Computer understands this requirement and automatically checksstudents' �les.

Student automatically receives feedback:\Credit was lost because `foo.c' doesn't compile and `Readme.txt'

doesn't mention `bar.c'."

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 2 / 23

Page 3: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Automated Programming Assignment Checking

Professor teaching Programming 101 types requirement:\Every source �le compiles and `Readme.txt` mentions every source

�le."

Computer understands this requirement and automatically checksstudents' �les.

Student automatically receives feedback:\Credit was lost because `foo.c' doesn't compile and `Readme.txt'

doesn't mention `bar.c'."

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 2 / 23

Page 4: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Automated Programming Assignment Checking

Professor teaching Programming 101 types requirement:\Every source �le compiles and `Readme.txt` mentions every source

�le."

Computer understands this requirement and automatically checksstudents' �les.

Student automatically receives feedback:\Credit was lost because `foo.c' doesn't compile and `Readme.txt'

doesn't mention `bar.c'."

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 2 / 23

Page 5: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Goals

Workable automated checking of basic programming assignmentrequirements with a natural language interface.

A study of quanti�ers and negation in NL generation, within anend-to-end NLP framework.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 3 / 23

Page 6: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Prograder NLP System Architecture Overview

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 4 / 23

Page 7: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Semantics of a Requirements Statement

Each requirement speci�cation is a sentence, whose truth value isdetermined by checking a single student's programming assignment.

Use the types of Montague grammar, which are the base type ofentities e, the base type of propositions t, and function types notatedby !.

A domain-speci�c �rst-order language, executable in Python

and (everysourcefile (lambda x : compiles (x)) ,

everysourcefile (lambda z : mentions (z, ("Readme.txt"))))

Checking of quanti�ed statements is done through iteration over thedomain (submitted �les).

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 5 / 23

Page 8: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Semantics of a Requirements Statement

Each requirement speci�cation is a sentence, whose truth value isdetermined by checking a single student's programming assignment.

Use the types of Montague grammar, which are the base type ofentities e, the base type of propositions t, and function types notatedby !.

A domain-speci�c �rst-order language, executable in Python

and (everysourcefile (lambda x : compiles (x)) ,

everysourcefile (lambda z : mentions (z, ("Readme.txt"))))

Checking of quanti�ed statements is done through iteration over thedomain (submitted �les).

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 5 / 23

Page 9: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Semantics of a Requirements Statement

Each requirement speci�cation is a sentence, whose truth value isdetermined by checking a single student's programming assignment.

Use the types of Montague grammar, which are the base type ofentities e, the base type of propositions t, and function types notatedby !.

A domain-speci�c �rst-order language, executable in Python

and (everysourcefile (lambda x : compiles (x)) ,

everysourcefile (lambda z : mentions (z, ("Readme.txt"))))

Checking of quanti�ed statements is done through iteration over thedomain (submitted �les).

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 5 / 23

Page 10: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Semantics of a Requirements Statement

Each requirement speci�cation is a sentence, whose truth value isdetermined by checking a single student's programming assignment.

Use the types of Montague grammar, which are the base type ofentities e, the base type of propositions t, and function types notatedby !.

A domain-speci�c �rst-order language, executable in Python

and (everysourcefile (lambda x : compiles (x)) ,

everysourcefile (lambda z : mentions (z, ("Readme.txt"))))

Checking of quanti�ed statements is done through iteration over thedomain (submitted �les).

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 5 / 23

Page 11: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Explaining Truth Values

The checking code should produce not only a truth value but also anexplanation of that value.

An explanation of a truth value may be viewed as a conjunction of asu�cient number of evidence statements, one for each failed check, inthe same logical language:

not(compiles('foo.c'))

not(mentions('bar.c')('Readme.txt'))

Expand the type de�nition of truth value: instead of just a boolean,use a (boolean, explanation) pair.

Summarization by grouping/quantifying over evidence statements

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 6 / 23

Page 12: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Explaining Truth Values

The checking code should produce not only a truth value but also anexplanation of that value.

An explanation of a truth value may be viewed as a conjunction of asu�cient number of evidence statements, one for each failed check, inthe same logical language:

not(compiles('foo.c'))

not(mentions('bar.c')('Readme.txt'))

Expand the type de�nition of truth value: instead of just a boolean,use a (boolean, explanation) pair.

Summarization by grouping/quantifying over evidence statements

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 6 / 23

Page 13: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Explaining Truth Values

The checking code should produce not only a truth value but also anexplanation of that value.

An explanation of a truth value may be viewed as a conjunction of asu�cient number of evidence statements, one for each failed check, inthe same logical language:

not(compiles('foo.c'))

not(mentions('bar.c')('Readme.txt'))

Expand the type de�nition of truth value: instead of just a boolean,use a (boolean, explanation) pair.

Summarization by grouping/quantifying over evidence statements

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 6 / 23

Page 14: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Explaining Truth Values

The checking code should produce not only a truth value but also anexplanation of that value.

An explanation of a truth value may be viewed as a conjunction of asu�cient number of evidence statements, one for each failed check, inthe same logical language:

not(compiles('foo.c'))

not(mentions('bar.c')('Readme.txt'))

Expand the type de�nition of truth value: instead of just a boolean,use a (boolean, explanation) pair.

Summarization by grouping/quantifying over evidence statements

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 6 / 23

Page 15: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Explaining Truth Values

The checking code should produce not only a truth value but also anexplanation of that value.

An explanation of a truth value may be viewed as a conjunction of asu�cient number of evidence statements, one for each failed check, inthe same logical language:

not(compiles('foo.c'))

not(mentions('bar.c')('Readme.txt'))

Expand the type de�nition of truth value: instead of just a boolean,use a (boolean, explanation) pair.

Summarization by grouping/quantifying over evidence statements

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 6 / 23

Page 16: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Prograder NLP System Architecture

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 7 / 23

Page 17: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Prograder Architecture - the Hard Part

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 8 / 23

Page 18: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Aarne Ranta's Grammatical Framework

http://www.grammaticalframework.org/

A type-theoretical framework for symmetric parsing and linearization

Supports translation through separation into an abstract grammarand concrete grammar

Common abstract grammar, separate concrete grammar for eachlanguageParse using one concrete grammar, generate using the other, andvice-versa

Abstract grammar is functional, concrete grammar uses stringconcatenation with record structures for e�ciency (context-free+)

Prograder uses one concrete grammar for parsing/generatingEnglish, another for the Python logical form.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 9 / 23

Page 19: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Aarne Ranta's Grammatical Framework

http://www.grammaticalframework.org/

A type-theoretical framework for symmetric parsing and linearization

Supports translation through separation into an abstract grammarand concrete grammar

Common abstract grammar, separate concrete grammar for eachlanguageParse using one concrete grammar, generate using the other, andvice-versa

Abstract grammar is functional, concrete grammar uses stringconcatenation with record structures for e�ciency (context-free+)

Prograder uses one concrete grammar for parsing/generatingEnglish, another for the Python logical form.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 9 / 23

Page 20: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Aarne Ranta's Grammatical Framework

http://www.grammaticalframework.org/

A type-theoretical framework for symmetric parsing and linearization

Supports translation through separation into an abstract grammarand concrete grammar

Common abstract grammar, separate concrete grammar for eachlanguageParse using one concrete grammar, generate using the other, andvice-versa

Abstract grammar is functional, concrete grammar uses stringconcatenation with record structures for e�ciency (context-free+)

Prograder uses one concrete grammar for parsing/generatingEnglish, another for the Python logical form.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 9 / 23

Page 21: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Aarne Ranta's Grammatical Framework

http://www.grammaticalframework.org/

A type-theoretical framework for symmetric parsing and linearization

Supports translation through separation into an abstract grammarand concrete grammar

Common abstract grammar, separate concrete grammar for eachlanguageParse using one concrete grammar, generate using the other, andvice-versa

Abstract grammar is functional, concrete grammar uses stringconcatenation with record structures for e�ciency (context-free+)

Prograder uses one concrete grammar for parsing/generatingEnglish, another for the Python logical form.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 9 / 23

Page 22: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Aarne Ranta's Grammatical Framework

http://www.grammaticalframework.org/

A type-theoretical framework for symmetric parsing and linearization

Supports translation through separation into an abstract grammarand concrete grammar

Common abstract grammar, separate concrete grammar for eachlanguageParse using one concrete grammar, generate using the other, andvice-versa

Abstract grammar is functional, concrete grammar uses stringconcatenation with record structures for e�ciency (context-free+)

Prograder uses one concrete grammar for parsing/generatingEnglish, another for the Python logical form.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 9 / 23

Page 23: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Parsing Requirements to Abstract Syntax

Non-phrase-structure aspects such such as agreement are handled inthe (English) concrete grammar.

Quanti�ed NPs are not distinguished from syntactic NPs in theabstract syntax.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 10 / 23

Page 24: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Prograder NLP Architecture Revisited

Produce a logical semantic representation from the syntax tree using GF's

generation capability.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 11 / 23

Page 25: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Quanti�er Scoping Overview

\A �le mentions every source �le": How to implement semantics ofquanti�er scoping?

Semantic attachments to the syntax tree, in the form of lambdaexpressions representing the denotation of categoriesExpressions are combined with a composition rule and beta-reducedComposition rules can be speci�ed by a functional/categorial grammar

What kind of expressions/application rules implement scoping?

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 12 / 23

Page 26: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Quanti�er Scoping Overview

\A �le mentions every source �le": How to implement semantics ofquanti�er scoping?

Semantic attachments to the syntax tree, in the form of lambdaexpressions representing the denotation of categoriesExpressions are combined with a composition rule and beta-reducedComposition rules can be speci�ed by a functional/categorial grammar

What kind of expressions/application rules implement scoping?

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 12 / 23

Page 27: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Quanti�er Scoping Overview

\A �le mentions every source �le": How to implement semantics ofquanti�er scoping?

Semantic attachments to the syntax tree, in the form of lambdaexpressions representing the denotation of categoriesExpressions are combined with a composition rule and beta-reducedComposition rules can be speci�ed by a functional/categorial grammar

What kind of expressions/application rules implement scoping?

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 12 / 23

Page 28: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Surface Scope with Continuation Grammar Rules

Express scoping preferences directly in the grammar by means ofcontinuized denotations and combination rules.

Model the ability of constituents to take scope over others.

NP's have this structure in Montague Grammar: type ((e ! t)! t)instead of e.

Continuation grammars [Barker & Shan] generalize the use ofhigher-order functions in grammar rules to provide access tocontinuation for all constituents.

Treat each constituent, quanti�ed or non-quanti�ed, as having accessto its own continuation.

fun ApplyS NP VP

= NP(lambda n: VP(lambda v: v(n)))

Represents surface scope: NP can take scope over VP

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 13 / 23

Page 29: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Surface Scope with Continuation Grammar Rules

Express scoping preferences directly in the grammar by means ofcontinuized denotations and combination rules.

Model the ability of constituents to take scope over others.

NP's have this structure in Montague Grammar: type ((e ! t)! t)instead of e.

Continuation grammars [Barker & Shan] generalize the use ofhigher-order functions in grammar rules to provide access tocontinuation for all constituents.

Treat each constituent, quanti�ed or non-quanti�ed, as having accessto its own continuation.

fun ApplyS NP VP

= NP(lambda n: VP(lambda v: v(n)))

Represents surface scope: NP can take scope over VP

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 13 / 23

Page 30: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Surface Scope with Continuation Grammar Rules

Express scoping preferences directly in the grammar by means ofcontinuized denotations and combination rules.

Model the ability of constituents to take scope over others.

NP's have this structure in Montague Grammar: type ((e ! t)! t)instead of e.

Continuation grammars [Barker & Shan] generalize the use ofhigher-order functions in grammar rules to provide access tocontinuation for all constituents.

Treat each constituent, quanti�ed or non-quanti�ed, as having accessto its own continuation.

fun ApplyS NP VP

= NP(lambda n: VP(lambda v: v(n)))

Represents surface scope: NP can take scope over VP

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 13 / 23

Page 31: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Surface Scope with Continuation Grammar Rules

Express scoping preferences directly in the grammar by means ofcontinuized denotations and combination rules.

Model the ability of constituents to take scope over others.

NP's have this structure in Montague Grammar: type ((e ! t)! t)instead of e.

Continuation grammars [Barker & Shan] generalize the use ofhigher-order functions in grammar rules to provide access tocontinuation for all constituents.

Treat each constituent, quanti�ed or non-quanti�ed, as having accessto its own continuation.

fun ApplyS NP VP

= NP(lambda n: VP(lambda v: v(n)))

Represents surface scope: NP can take scope over VP

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 13 / 23

Page 32: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Surface Scope with Continuation Grammar Rules

Express scoping preferences directly in the grammar by means ofcontinuized denotations and combination rules.

Model the ability of constituents to take scope over others.

NP's have this structure in Montague Grammar: type ((e ! t)! t)instead of e.

Continuation grammars [Barker & Shan] generalize the use ofhigher-order functions in grammar rules to provide access tocontinuation for all constituents.

Treat each constituent, quanti�ed or non-quanti�ed, as having accessto its own continuation.

fun ApplyS NP VP

= NP(lambda n: VP(lambda v: v(n)))

Represents surface scope: NP can take scope over VP

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 13 / 23

Page 33: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Surface Scope with Continuation Grammar Rules

Express scoping preferences directly in the grammar by means ofcontinuized denotations and combination rules.

Model the ability of constituents to take scope over others.

NP's have this structure in Montague Grammar: type ((e ! t)! t)instead of e.

Continuation grammars [Barker & Shan] generalize the use ofhigher-order functions in grammar rules to provide access tocontinuation for all constituents.

Treat each constituent, quanti�ed or non-quanti�ed, as having accessto its own continuation.

fun ApplyS NP VP

= NP(lambda n: VP(lambda v: v(n)))

Represents surface scope: NP can take scope over VP

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 13 / 23

Page 34: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Surface Scope with Continuation Grammar Rules

Express scoping preferences directly in the grammar by means ofcontinuized denotations and combination rules.

Model the ability of constituents to take scope over others.

NP's have this structure in Montague Grammar: type ((e ! t)! t)instead of e.

Continuation grammars [Barker & Shan] generalize the use ofhigher-order functions in grammar rules to provide access tocontinuation for all constituents.

Treat each constituent, quanti�ed or non-quanti�ed, as having accessto its own continuation.

fun ApplyS NP VP

= NP(lambda n: VP(lambda v: v(n)))

Represents surface scope: NP can take scope over VP

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 13 / 23

Page 35: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Abstract Syntax Tree with Semantic Attachments

Can we generate/combine such representations using GF?

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 14 / 23

Page 36: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Abstract Syntax Tree with Semantic Attachments

Can we generate/combine such representations using GF?Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 14 / 23

Page 37: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Simulating Bounded-depth Continuations with String

Concatenation

We want to generate the logical form in GF using a concretegrammar.

... then we get parsing for free

But GF's linearization is limited to string concatenation - nohigher-order functions allowed.

Solution: simulate higher-order functions with interleaved record �elds.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 15 / 23

Page 38: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Simulating Bounded-depth Continuations with String

Concatenation

We want to generate the logical form in GF using a concretegrammar.... then we get parsing for free

But GF's linearization is limited to string concatenation - nohigher-order functions allowed.

Solution: simulate higher-order functions with interleaved record �elds.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 15 / 23

Page 39: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Simulating Bounded-depth Continuations with String

Concatenation

We want to generate the logical form in GF using a concretegrammar.... then we get parsing for free

But GF's linearization is limited to string concatenation - nohigher-order functions allowed.

Solution: simulate higher-order functions with interleaved record �elds.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 15 / 23

Page 40: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Simulating Bounded-depth Continuations with String

Concatenation

We want to generate the logical form in GF using a concretegrammar.... then we get parsing for free

But GF's linearization is limited to string concatenation - nohigher-order functions allowed.

Solution: simulate higher-order functions with interleaved record �elds.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 15 / 23

Page 41: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Simulating Bounded-depth Continuations with String

Concatenation

lin foosource =

{ "", "'foo.c'", "" }

lin everysourcefile =

{ "everysourcefile(lambda x:", "x", ")" }

lin compiles =

{ "", "compiles", "" }

`Apply' functions simply interleave and concatenate the record �elds.

"compiles('foo.c')"

"everysourcefile(lambda x: compiles(x))"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 16 / 23

Page 42: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Simulating Bounded-depth Continuations with String

Concatenation

lin foosource =

{ "", "'foo.c'", "" }

lin everysourcefile =

{ "everysourcefile(lambda x:", "x", ")" }

lin compiles =

{ "", "compiles", "" }

`Apply' functions simply interleave and concatenate the record �elds.

"compiles('foo.c')"

"everysourcefile(lambda x: compiles(x))"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 16 / 23

Page 43: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Simulating Bounded-depth Continuations with String

Concatenation

lin foosource =

{ "", "'foo.c'", "" }

lin everysourcefile =

{ "everysourcefile(lambda x:", "x", ")" }

lin compiles =

{ "", "compiles", "" }

`Apply' functions simply interleave and concatenate the record �elds.

"compiles('foo.c')"

"everysourcefile(lambda x: compiles(x))"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 16 / 23

Page 44: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

GF Generations as Semantic Attachments

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 17 / 23

Page 45: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Negatives as Quanti�ers

Negatives have scope too: \Every source �le doesn't compile" versus\Not Every source �le compiles"

Important to handle negatives tastefully in the explanation to thestudent

\It is not the case that not every source �le doesn't compile"

Claim: More natural-sounding sentences are generated when negationis pushed all the way in using De Morgan's rule.\No source �le compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 18 / 23

Page 46: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Negatives as Quanti�ers

Negatives have scope too: \Every source �le doesn't compile" versus\Not Every source �le compiles"

Important to handle negatives tastefully in the explanation to thestudent\It is not the case that not every source �le doesn't compile"

Claim: More natural-sounding sentences are generated when negationis pushed all the way in using De Morgan's rule.\No source �le compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 18 / 23

Page 47: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Negatives as Quanti�ers

Negatives have scope too: \Every source �le doesn't compile" versus\Not Every source �le compiles"

Important to handle negatives tastefully in the explanation to thestudent\It is not the case that not every source �le doesn't compile"

Claim: More natural-sounding sentences are generated when negationis pushed all the way in using De Morgan's rule.

\No source �le compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 18 / 23

Page 48: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Negatives as Quanti�ers

Negatives have scope too: \Every source �le doesn't compile" versus\Not Every source �le compiles"

Important to handle negatives tastefully in the explanation to thestudent\It is not the case that not every source �le doesn't compile"

Claim: More natural-sounding sentences are generated when negationis pushed all the way in using De Morgan's rule.\No source �le compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 18 / 23

Page 49: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

\Generating" De Morgan's Rule in GF

Every statement in the logical grammar should be parsed into anabstract tree with negation all the way in.

A grammar doesn't `know' De Morgan's rule such that it can preservesemantics of negation (move negatives inside and ip quanti�ers)

But we can simulate it by storing two versions of each record, one forthe original quanti�ers and one with the dual, with a `switched' ag.

noteverysourcefile (not (not (compiles)))

"not every source file compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 19 / 23

Page 50: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

\Generating" De Morgan's Rule in GF

Every statement in the logical grammar should be parsed into anabstract tree with negation all the way in.

A grammar doesn't `know' De Morgan's rule such that it can preservesemantics of negation (move negatives inside and ip quanti�ers)

But we can simulate it by storing two versions of each record, one forthe original quanti�ers and one with the dual, with a `switched' ag.

noteverysourcefile (not (not (compiles)))

"not every source file compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 19 / 23

Page 51: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

\Generating" De Morgan's Rule in GF

Every statement in the logical grammar should be parsed into anabstract tree with negation all the way in.

A grammar doesn't `know' De Morgan's rule such that it can preservesemantics of negation (move negatives inside and ip quanti�ers)

But we can simulate it by storing two versions of each record, one forthe original quanti�ers and one with the dual, with a `switched' ag.

noteverysourcefile (not (not (compiles)))

"not every source file compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 19 / 23

Page 52: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

\Generating" De Morgan's Rule in GF

Every statement in the logical grammar should be parsed into anabstract tree with negation all the way in.

A grammar doesn't `know' De Morgan's rule such that it can preservesemantics of negation (move negatives inside and ip quanti�ers)

But we can simulate it by storing two versions of each record, one forthe original quanti�ers and one with the dual, with a `switched' ag.

noteverysourcefile (not (not (compiles)))

"not every source file compiles"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 19 / 23

Page 53: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Sample Output

$ ./runPrograder.py assn 'every source file compiles and

"README" mentions every source file'

******************************

RESULT: False, because:

a source file doesn't compile and "README" doesn't mention

every source file

"nowork2.c" doesn't compile

"nowork.c" doesn't compile

"README" doesn't mention "nowork2.c"

"README" doesn't mention "hello.c"

"README" doesn't mention "work1.c"

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 20 / 23

Page 54: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Conclusion

Simulating continuized grammar rules with records is a workable wayto generate logical forms of quanti�ed and negated statements forNLP applications, while keeping parsing and generation tractable.

Grad students don't have to write as many scripts, professors don'thave to learn a new system.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 21 / 23

Page 55: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Conclusion

Simulating continuized grammar rules with records is a workable wayto generate logical forms of quanti�ed and negated statements forNLP applications, while keeping parsing and generation tractable.

Grad students don't have to write as many scripts, professors don'thave to learn a new system.

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 21 / 23

Page 56: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

Continuing Work

Testing with actual professors and students, expanding the vocabulary

Finish the general formulation of the continuation-rule-to-recordmapping, including higher-order quanti�ers e.g. `some'

Further investigation of summarization within the type-theoreticframework

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 22 / 23

Page 57: Generating Quantifiers and Negation to Explain Homework ...tetreaul/BEA5/08-perry-shan.pdf · An explanation of a truth value may be viewed as a conjunction of a su cient number of

The End

Thank you!

Perry and Shan (Rutgers) Q & N for Homework Testing June 5, 2010 23 / 23