Algorithm Search⌘K

Modeladvanced

Combinatory categorial grammar

Also called CCG.

A lexicalized grammar whose words have functor categories such as (S\NP)/NP, combined by application, composition and type raising.

Combinatory categorial grammar (CCG) puts almost all of the grammar in the lexicon: each word gets a category such as (S\NP)/NP(S\backslash NP)/NP, which says "give me a noun phrase on the right, then a noun phrase on the left, and I make a sentence". A small fixed set of rules then combines neighboring categories by function application, function composition and type raising. The rules are the combinators B, T and S of combinatory logic, and each rule builds a term of the lambda calculus for the meaning in step with the syntax: the lambda calculus is the language of the meanings, while CCG is the grammar that decides which terms to build and in what order, without variables of its own. CCG is the formalism behind many supertagging parsers and semantic parsers, and it is weakly equivalent to tree-adjoining grammar.

The machine

Categories. Fix a finite set NN of atomic categories, such as SS, NPNP, NN and PPPP. Every atomic category is a category, and if XX and YY are categories then so are X/YX/Y and X\YX\backslash Y. The category X/YX/Y is a function that takes an argument YY on its right and gives XX; X\YX\backslash Y takes YY on its left. Slashes associate to the left, so (S\NP)/NP(S\backslash NP)/NP is a transitive verb: it takes the object on the right first, then the subject on the left.

Grammar. We write the grammar as G=(N,Σ,R,S)G = (N, \Sigma, R, S), where Σ\Sigma is the set of words, RR is the lexicon, a finite set of pairs of a word and a category, together with the rule schemata the grammar allows, and S∈NS \in N is the start category. The size gg is the total length of the lexical entries. Each lexical entry also carries a lambda term for its meaning.

Rules. The common schemata, with the meaning each one builds:

rule name syntax meaning
>> forward application X/YY⇒XX/Y \quad Y \Rightarrow X f af\,a
<< backward application YX\Y⇒XY \quad X\backslash Y \Rightarrow X f af\,a
>B>\mathbf{B} forward composition X/YY/Z⇒X/ZX/Y \quad Y/Z \Rightarrow X/Z λz. f (g z)\lambda z.\, f\,(g\,z)
<B<\mathbf{B} backward composition Y\ZX\Y⇒X\ZY\backslash Z \quad X\backslash Y \Rightarrow X\backslash Z λz. f (g z)\lambda z.\, f\,(g\,z)
>B×>\mathbf{B}_\times forward crossed composition X/YY\Z⇒X\ZX/Y \quad Y\backslash Z \Rightarrow X\backslash Z λz. f (g z)\lambda z.\, f\,(g\,z)
>T>\mathbf{T} forward type raising X⇒T/(T\X)X \Rightarrow T/(T\backslash X) λf. f a\lambda f.\, f\,a
<T<\mathbf{T} backward type raising X⇒T\(T/X)X \Rightarrow T\backslash(T/X) λf. f a\lambda f.\, f\,a
>S>\mathbf{S} forward substitution (X/Y)/ZY/Z⇒X/Z(X/Y)/Z \quad Y/Z \Rightarrow X/Z λz. f z (g z)\lambda z.\, f\,z\,(g\,z)

Generalized composition >Bk>\mathbf{B}^k lets the second category have kk arguments, X/Y(…(Y/Z1)…)/Zk⇒(…(X/Z1)…)/ZkX/Y \quad (\ldots(Y/Z_1)\ldots)/Z_k \Rightarrow (\ldots(X/Z_1)\ldots)/Z_k, for kk up to a fixed bound. Coordination uses the category (X\X)/X(X\backslash X)/X for "and", with the meaning of a conjunction at the type of XX. Composition is Curry's combinator B\mathbf{B}, type raising is T\mathbf{T} and substitution is S\mathbf{S}, which gives the grammar its name. A string of words is in the language if some choice of lexical categories, combined by the rules, gives SS.

An example. Take the lexicon Kim, Sandy, broccoli ⊢NP\vdash NP, likes ⊢(S\NP)/NP:λx.λy. like(y,x)\vdash (S\backslash NP)/NP : \lambda x.\lambda y.\,\mathit{like}(y, x), hates the same with hate\mathit{hate}, and and ⊢(X\X)/X\vdash (X\backslash X)/X. The sentence "Kim likes and Sandy hates broccoli" coordinates two strings that are not constituents in a context-free grammar:

  1. Kim ⇒S/(S\NP):λf. f kim\Rightarrow S/(S\backslash NP) : \lambda f.\, f\,\mathit{kim} by >T>\mathbf{T}.
  2. Kim likes ⇒S/NP:λx. like(kim,x)\Rightarrow S/NP : \lambda x.\,\mathit{like}(\mathit{kim}, x) by >B>\mathbf{B}.
  3. Sandy hates ⇒S/NP:λx. hate(sandy,x)\Rightarrow S/NP : \lambda x.\,\mathit{hate}(\mathit{sandy}, x) in the same way.
  4. and Sandy hates ⇒(S/NP)\(S/NP)\Rightarrow (S/NP)\backslash(S/NP) by >>, and then Kim likes and Sandy hates ⇒S/NP:λx. like(kim,x)∧hate(sandy,x)\Rightarrow S/NP : \lambda x.\,\mathit{like}(\mathit{kim}, x) \wedge \mathit{hate}(\mathit{sandy}, x) by <<.
  5. Adding broccoli by >> gives S:like(kim,broccoli)∧hate(sandy,broccoli)S : \mathit{like}(\mathit{kim}, \mathit{broccoli}) \wedge \mathit{hate}(\mathit{sandy}, \mathit{broccoli}).

The meaning comes out by beta reduction of the terms the rules build. The same rules give extraction, as in "the broccoli that Kim likes", where Kim likes is again S/NPS/NP.

What it counts

Recognition and parsing time. A chart parser fills items (X,i,j)(X, i, j), which say that the category XX derives the words of the span (i,j)(i, j). Spans are fenceposts: (i,j)(i, j) covers the words i+1i + 1 to jj of a sentence of nn words. If the categories that can appear in a derivation form a finite set, which holds when composition and type raising are bounded so that no category grows with nn, the grammar is context-free in effect and the CKY algorithm recognizes it in O(n3)O(n^3) time for a fixed grammar (theorem). With generalized composition the categories in a derivation can grow with nn, and Vijay-Shanker and Weir (1993) gave a polynomial algorithm that shares the stack-like tails of categories, with the same O(n6)O(n^6) time as for tree-adjoining grammar (theorem).

Grammar size. When the grammar is part of the input, the problem is much harder. Kuhlmann, Satta and Jonsson (2018) showed that universal recognition for CCG in the Vijay-Shanker and Weir style is EXPTIME-complete, and NP-complete when lexical entries for the empty string are not allowed (theorem). So the polynomial bounds above hide a factor that is exponential in gg.

Spurious ambiguity. One reading can have many derivations. "Kim likes broccoli" can be derived by >> then <<, or by >T>\mathbf{T}, >B>\mathbf{B} and >>; composition is associative, so both give the same term (theorem). A parser that does not restrict derivations spends time on these copies. Eisner (1996) gave a normal form that keeps one derivation for each reading in a restricted CCG, by forbidding the output of a composition to be the function of a later composition or application (theorem).

Ambiguity in practice. With a wide-coverage lexicon each word has many categories; in Clark and Curran's tag dictionary the word "is" has 45. The number of lexical choices is the main cost of parsing, which is why parsers first prune the categories with a supertagger (heuristic, with the measurements below).

Relation to other models

  • Context-free grammar. Categorial grammar with only application, the AB grammar of Ajdukiewicz and Bar-Hillel, is weakly equivalent to context-free grammar (theorem, Bar-Hillel, Gaifman and Shamir 1960). Composition and type raising are what take CCG beyond it.
  • Tree-adjoining grammar. CCG, tree-adjoining grammar, linear indexed grammar and head grammar generate the same class of string languages (theorem, Vijay-Shanker and Weir 1994). All four are mildly context-sensitive: they generate {ambmcmdm}\{a^m b^m c^m d^m\} and cross-serial dependencies, yet parse in polynomial time. The structures they assign differ: TAG builds trees by adjunction, CCG builds derivations of categories.
  • Lambda calculus and combinatory logic. Each rule is a combinator, and a derivation builds a term of the simply typed lambda calculus whose types follow the categories, for example NP↦eNP \mapsto e and S\NP↦e→tS\backslash NP \mapsto e \to t. The lambda calculus has variables and abstraction; CCG has neither in its syntax, and builds the same terms by combinators.
  • Dependency grammar. The function-argument pairs of a derivation give word-to-word dependencies, which is how CCG parsers are often evaluated.
  • Feature structures. Atomic categories often carry features such as S[dcl]S[\mathit{dcl}] or NP[nb]NP[\mathit{nb}], which match by a light form of feature structure unification.

Known results in the model

  • CCGbank. Hockenmaier and Steedman converted the Penn Treebank into CCG derivations, which gave a corpus for training wide-coverage CCG parsers.
  • Wide-coverage parsing (measurement). Clark and Curran (2007) kept the 425 categories that occur at least 10 times in sections 02 to 21 of CCGbank. Their log-linear supertagger reached 92.6% per-word accuracy on section 00 with gold part-of-speech tags, and 91.5% with automatic tags. Their CKY parser over the pruned categories reached more than 81% F-score on the DepBank evaluation.
  • Semantic parsing (measurement and method). Zettlemoyer and Collins (2005) learned a CCG lexicon with lambda-calculus meanings from sentences labeled only with logical forms, and trained a log-linear model over derivations. Many later semantic parsers use CCG in the same way.
  • A* parsing. Because a supertag-factored model scores a derivation by its lexical categories, A* parsing with an estimate built from the supertag scores finds the best derivation while building few chart items (heuristic, with measurements in the work of Lewis and Steedman).

References

  1. Mark Steedman, The Syntactic Process, MIT Press, 2000, the combinatory rules of application, composition, type raising and substitution, and their use for coordination and extraction
  2. K. Vijay-Shanker and David J. Weir, The equivalence of four extensions of context-free grammars, the weak equivalence of CCG, tree-adjoining grammar, linear indexed grammar and head grammar
  3. K. Vijay-Shanker and David J. Weir, Parsing some constrained grammar formalisms, the polynomial recognition algorithm for CCG
  4. Marco Kuhlmann, Giorgio Satta and Peter Jonsson, On the complexity of CCG parsing, Computational Linguistics 44(3), 447-482, 2018, the universal recognition problem for CCG: EXPTIME-complete in general and NP-complete without empty categories
  5. Stephen Clark and James R. Curran, Wide-coverage efficient statistical parsing with CCG and log-linear models, Section 8 (the supertagger and its 425 categories), Section 9 (adaptive supertagging and CKY parsing) and the evaluation on DepBank
  6. Luke S. Zettlemoyer and Michael Collins, Learning to map sentences to logical form, the CCG lexicon with lambda-calculus semantics and the log-linear model over derivations

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/BT4KA7/text.yaml