Lambda Dependency-Based Compositional Semantics

by   Percy Liang, et al.

This short note presents a new formal language, lambda dependency-based compositional semantics (lambda DCS) for representing logical forms in semantic parsing. By eliminating variables and making existential quantification implicit, lambda DCS logical forms are generally more compact than those in lambda calculus.


page 1

page 2

page 3

page 4


Learning Dependency-Based Compositional Semantics

Suppose we want to build a system that answers a natural language questi...

A CCG-based Compositional Semantics and Inference System for Comparatives

Comparative constructions play an important role in natural language inf...

Natural Hoare Logic: Towards formal verification of programs from logical forms of natural language specifications

Formal verification provides strong guarantees of correctness of softwar...

Logical Semantics and Commonsense Knowledge: Where Did we Go Wrong, and How to Go Forward, Again

We argue that logical semantics might have faltered due to its failure i...

Quantifiers metamorphoses. Generalizations, variations, algorithmic semantics

This article contains ideas and their elaboration for quantifiers, which...

A Logical Semantics for PDDL+

PDDL+ is an extension of PDDL2.1 which incorporates fully-featured auton...

Universal Dependencies to Logical Forms with Negation Scope

Many language technology applications would benefit from the ability to ...

1 Introduction

Semantic parsing is the task of mapping natural language utterances to logical forms in some formal language such as lambda calculus. This short note describes lambda dependency-based compositional semantics (lambda DCS), an alternate formal language which can be notationally simpler than lambda calculus. Here is an example:111This example is based on the Freebase schema, which reifies events (called compound value types in Freebase). Here, denotes that a person was involved in a living event , and denotes that the location of that event is Seattle. Other properties of would include and .

  • Utterance: “people who have lived in Seattle”

  • Logical form (lambda calculus):

  • Logical form (lambda DCS):

As one can see, lambda DCS attempts to remove explicit use of variables. This makes it similar in spirit to dependency-based compositional semantics (DCS) (Liang et al. 2011), but DCS is restricted to tree-structured logical forms, and is therefore not as expressive as lambda calculus. Lambda DCS, on the other hand, borrows the use of variables and lambda abstraction from lambda calculus when necessary to handle phenomena such as anaphora.

Lambda DCS was designed in the context of building a natural language interface into Freebase (Bollacker et al. 2008), a large graph database, where the logical forms are database queries (see Berant et al. (2013) for our companion paper). Therefore, we will focus on representing the semantics of noun phrases or wh-questions. Also, we will discuss only the semantics of the formal language, not the compositional semantics of mapping natural language utterances into lambda DCS. Finally, this document assumes the reader has basic familiarity with lambda calculus in the context of natural language (see Carpenter (1998) for an introduction).

2 Definition

We now present the full definition of lambda DCS. In the background, we have a knowledge base of assertions. Let be a set of entities (e.g., ), be the set of properties (e.g., ). Then

is the knowledge base, which can be visualized as a directed graph where nodes are entities and edges represent assertions in the knowledge graph. Also, let

be a set of variables (e.g., ).

Let denote the truth value of the condition. For example, denotes the function that returns true if and only if its argument is equal to .

We will now walk through each of the constructs in lambda DCS with concrete examples, and also provide a formal definition of their semantics by providing a formal conversion to equivalent lambda calculus forms. Notationally, let be the lambda calculus form corresponding to the lambda DCS form . In the following definitions, let denote fresh variables which are not used anywhere else.

Unary base case

The simplest lambda DCS form is a single entity. For example,

Seattle (1)

denotes the singleton set containing Seattle. The equivalent in lambda calculus is:


In general, for an entity , is a unary logical form representing the indicator function that returns true when its argument is equal to :


Binary base case

The next example is


which denotes the set of pairs of people and where they were born:


In general, for a property , is a binary logical form, which denotes a function mapping two arguments to whether holds:



The most central operation in lambda DCS is join. For example, “people born in Seattle” is represented as


in lambda DCS and as


in lambda calculus. In general, for a binary logical form and unary logical form , we have that is a unary logical form which denotes:


The key feature of a join is the implicit existential quantification over the argument shared by and . From a database perspective, this is simply a join over relations and on the second argument of and the first (and only) argument of and then projecting out the joined variable.

The advantage of lambda DCS is more apparent when binaries are chained. For example, consider “those who had children born in Seattle”:


and its lambda calculus equivalent:


Here, denotes whether has a child and denotes whether was born in Seattle.

A logical form corresponds to a chain-structured graph pattern on the knowledge base which matches any entity (node) which can reach by following edges labeled with the given properties .


The set of scientists born in Seattle in lambda DCS:


and in lambda calculus:


In general, for two unaries and is a unary logical form representing:


In terms of the graph pattern perspective, intersection allows tree-structured graph patterns, where branch points correspond to the intersections.


Whereas intersection corresponds to conjunction, union corresponds to disjunction. The set containing “Oregon, Washington and Canadian provinces” in lambda DCS:


and in lambda calculus:


In general, for two unaries and is a unary logical form representing:



Negation is straightforward. Here is “states not bordering California” in lambda DCS:


and in lambda calculus:


In general, for a unary ,


Higher-order functions

Higher-order functions operate on sets of entities rather than on individual entities. These include aggregation (counting, finding the min/max), superlatives (taking the argmin/argmax), and generalized quantification. In lambda DCS, these are implemented in the natural way.

For example, the number of states and the number largest state by area are represented as follows in lambda DCS:


In lambda calculus:


In general, for an aggregation operator (e.g., count) and a unary , we have:


For a superlative operator (e.g., argmax), unary , and binary :


Lambda abstraction

Up until now, our lambda DCS logical forms have been limited in two ways:

  1. Fundamentally, our logical forms have been tree-structured, since the only way different parts of the logical forms can currently interact is via one implicitly represented overlapping variable. Non-tree-structured logical forms are important for handling bound anaphora, and to capture such phenomena, we will introduce a construct called mu abstraction.

  2. All our composition operations have created unaries. However, higher-order operations such as argmax take in a binary which supply the comparison function, which could be non-atomic. To construct binaries compositionally, we introduce lambda abstraction, which is in general distinct from lambda abstraction in lambda calculus, although the two coincide in some cases.

Let us start with an example of bound anaphora: “those who had a child who influenced them”. In lambda DCS, we use mu abstraction:


Here, the simply adds a constraint that the first argument of Children be bound to the second argument of Influenced. In lambda calculus, this expression is:


Let us consider a superlative with a compositional comparison function: “person who has the most children”. In lambda DCS, we use lambda abstraction to construct a new binary logical form denoting pairs of people and the number of children they have:


where we use the reverse operator switches the arguments of .

The equivalent logical form in lambda calculus:


In general, for a variable and a unary , we define the conversion for variables, mu abstraction, and lambda abstraction as follows:


Note that applied to unaries, lambda abstraction produces binary logical forms, while mu abstraction produces unary logical forms.

2.1 Discussion

A prevailing theme in lambda DCS is that the construction of logical forms centers around sets (of entities or entity pairs), whereas in lambda calculus, construction centers around truth values. Lifting up to sets allows us to eliminate variables, treating them as implicitly existentially quantified. Indeed, looking back to the conversion function , they all have the form . Of course, there are logical forms where lambda DCS would not offer much savings in reducing variables—for example, when many predicates operate on the same variables in a non-tree-structured manner. However, we have found that for logical forms derived from natural language, especially for querying databases, lambda DCS is a good choice.

The development of lambda DCS has been inspired by many other formalisms. As evident by name, lambda DCS is adapted from Dependency-Based Compositional Semantics (DCS) (Liang et al. 2011), which prominently features (i) tree-structured logical forms and (ii) default existential quantification, the latter being imported from Discourse Representation Theory (Kamp and Reyle 1993). There are two major differences between lambda DCS and DCS. First, lambda DCS revolves around unaries and binaries, which we found to be the right level of generality; DCS allowed arbitrary arities, and thus was a little too low-level. Second, we have omitted the mark-execute construct of DCS, which is an orthogonal direction for future exploration. We can think of mark-execute as more in the realm of constructing logical forms compositionally rather than their representation. We have focused on the latter here.

The syntax of lambda DCS and the tree-structured nature (without variables) is derived from the concept constructors in description logic (Baader 2003), but the marriage with variables and higher-order functions is specific to lambda DCS. Of course, description logic is designed for logical inference, which necessitates a simpler logic, whereas lambda DCS is designed for model checking (e.g., querying a database), and can therefore bear the additional complexity.

Given our application to querying graph databases, it is natural that there are some parallels between lambda DCS and graph query languages such as SPARQL (Harris and Seaborne 2011), to which we ultimately convert in order to execute the logical forms (Berant et al. 2013). Working with a graph database leads to thinking about logical forms as graph patterns, although this intuition is less helpful when we add higher-order operations.

In terms of expressivity, lambda DCS is clearly dominated by lambda calculus, as evident by our conversion from the former to the latter. From this perspective, lambda DCS is syntactic sugar. However, we believe that lambda DCS is more closely connected with the compositional structure of natural language and therefore can be quite convenient to work with.

We should also note that lambda calculus in formal semantics is really used for two purposes, which we’d like to dissect: The first purpose is to construct the logical form of a sentence compositionally, where lambda abstraction is merely used as a macro to piece bits of logical form together. The second purpose is to represent the final logical form, where lambda abstraction is needed to denote a function (e.g., the comparison function passed into argmax). Here, we have mainly focused on the latter representation issues. As for construction, we have so far used a very simple construction mechanism Berant et al. (2013), since we targeted the semantic parsing of short questions, which have limited compositional demands. In principle, lambda DCS logical forms could be constructed using lambda calculus (serving as a macro) in a CCG formalism. Analogously, lambda calculus has been used to build logical forms in Discourse Representation Theory (Muskens 1996). Down the road, we hope that working with lambda DCS can lead to new construction mechanisms suitable for complex sentences.


  • Baader [2003] F. Baader. The description logic handbook: theory, implementation, and applications. Cambridge University Press, 2003.
  • Berant et al. [2013] J. Berant, A. Chou, R. Frostig, and P. Liang. Semantic parsing on Freebase from question-answer pairs. In

    Empirical Methods in Natural Language Processing (EMNLP)

    , 2013.
  • Bollacker et al. [2008] K. Bollacker, C. Evans, P. Paritosh, T. Sturge, and J. Taylor. Freebase: a collaboratively created graph database for structuring human knowledge. In International Conference on Management of Data (SIGMOD), pages 1247–1250, 2008.
  • Carpenter [1998] B. Carpenter. Type-Logical Semantics. MIT Press, 1998.
  • Harris and Seaborne [2011] S. Harris and A. Seaborne. SPARQL 1.1 query language. In W3C Working Draft, 12 May, 2011.
  • Kamp and Reyle [1993] H. Kamp and U. Reyle. From Discourse to Logic: An Introduction to the Model-theoretic Semantics of Natural Language, Formal Logic and Discourse Representation Theory. Kluwer, Dordrecht, 1993.
  • Liang et al. [2011] P. Liang, M. I. Jordan, and D. Klein. Learning dependency-based compositional semantics. In Association for Computational Linguistics (ACL), pages 590–599, 2011.
  • Muskens [1996] R. Muskens. Combining montague semantics and discourse representation. Linguistics and Philosophy, 19(2):143–186, 1996.