Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 49 ยท Syntax

Phrase-structure rules and ambiguity

See how a handful of rewrite rules generate endless sentences, why recursion matters, and how one string of words can have two different trees.

In the last lesson you learned to spot constituents. Now we ask the reverse question: what rules would produce exactly the trees that English allows? A phrase-structure grammar answers with a short list of rewrite rules. The result is small, precise and surprisingly powerful, and it explains a puzzle you meet every day: sentences that mean two things at once.

Two syntax trees for I saw the man with a telescope
The same words, two trees: the prepositional phrase attaches to the verb phrase or to the noun phrase.

What you will learn

  • How to read and write rewrite rules such as S โ†’ NP VP
  • Why recursion gives a finite grammar an infinite output
  • How structural ambiguity arises from attachment choices
  • How fast the number of possible structures grows

Key terms

Rewrite rule: a statement A โ†’ B C meaning "an A can consist of a B followed by a C".

Recursion: a category that can contain itself, directly or indirectly.

Structural ambiguity: one string of words with more than one tree.

Attachment: the choice of which node a phrase joins.

Lexicon: the list of words with their categories.

A small grammar

Here is a grammar fragment for English. Parentheses mean "optional" and the asterisk means "any number of".

TEXT
S  โ†’ NP VP
NP โ†’ (Det) (Adj*) N (PP)
VP โ†’ V (NP) (PP)
PP โ†’ P NP

Plus a lexicon: Det: the, a, my, Adj: young, tiny, N: cat, dog, man, telescope, V: saw, chased, P: with, on. To derive a sentence, start with S and keep replacing a symbol by the right-hand side of one of its rules until only words remain:

S โ†’ NP VP โ†’ Det N VP โ†’ the N VP โ†’ the cat VP โ†’ the cat V NP โ†’ the cat chased NP โ†’ ... โ†’ the cat chased a mouse

Every derivation corresponds to exactly one tree, and the grammar licenses precisely the trees it can derive. A string is grammatical relative to the grammar if some derivation produces it.

Recursion: finite rules, infinite language

Look at the rules for NP and PP together: an NP may contain a PP, and a PP contains an NP. So we can nest forever: the cat on the mat in the house by the river near the bridge. Another source of recursion is the relative clause, as in the nursery rhyme This is the house that Jack built, which grows by adding the malt that lay in the house that Jack built, and so on. No rule limits the length. Most linguists see this as a defining property of human language, a point Chomsky stressed from the 1950s on. (A related claim by Hauser, Chomsky and Fitch in 2002, that recursion is the only uniquely human part of language, is still disputed.)

Real speakers do not nest endlessly. Memory limits stop us after two or three levels of centre-embedding (the rat the cat the dog chased bit ate the malt is nearly unreadable). Linguists separate this performance limit from the competence of the grammar, which has no such limit.

Structural ambiguity

Now return to the telescope. The grammar has two ways to attach the PP with a telescope:

  • VP attachment (VP โ†’ V NP PP): the PP is a sister of the object NP. I used the telescope to see him.
  • NP attachment (NP โ†’ NP PP): the PP belongs inside the object NP. The man I saw was holding a telescope.

Both trees have the same words. Ambiguity at this level is not about two meanings of a word; it comes from two structures. Other classic examples:

  • Flying planes can be dangerous. Either the activity of flying them or planes that fly.
  • Old men and women. [old [men and women]] or [[old men] and women].
  • Visiting relatives can be boring. Same pattern as flying planes.

Psycholinguistic experiments suggest readers often favour the simpler structure first (Frazier's minimal attachment idea), which gives rise to garden-path sentences such as Thomas Bever's The horse raced past the barn fell. Readers commit to raced as the main verb, then must reanalyse. Later work shows that meaning, context and the verb's typical frames also guide the first guess, so structure is not the only force.

How fast do structures multiply?

With k prepositional phrases in a row, each can attach in more places. The number of binary bracketings of a string with n+1 items is the Catalan number C(n): 1, 1, 2, 5, 14, 42, 132... A sentence like I saw the man on the hill with a telescope in the park already has many readings. Parsers need clever algorithms (you will meet one in the computing chapter) to avoid listing them all.

Common misconceptions

"Ambiguity is a flaw in language." In context almost all ambiguity goes unnoticed; speakers and listeners use knowledge of the world to choose.

"Rewrite rules describe how the brain generates sentences in time." A grammar is a statement of what is allowed. How a mind computes a sentence is a separate question about processing.

"Recursion means long sentences." Recursion means a category containing itself. A short sentence can use it (the cat on the mat).

Try it

The first demo counts how many different trees a small grammar assigns to a sentence. It uses a memoised chart over spans (the idea behind real parsers). Add more with-phrases and watch the counts jump.

Python Counting parses

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second demo plots how quickly the number of binary bracketings grows with sentence length. This is why linguists and engineers need systematic methods.

Python The Catalan explosion

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does the rule NP โ†’ Det N mean?

    A rewrite rule says what a category may consist of, in order.
  2. 2. Which pair of rules makes English recursive?

    An NP can contain a PP that contains an NP, so the loop can repeat without end.
  3. 3. Why is I saw the man with a telescope ambiguous?

    The ambiguity is structural: two attachments, two trees.
  4. 4. A sentence like The horse raced past the barn fell is called:

    Readers are led down a wrong structural path and must reanalyse.
  5. 5. How many binary bracketings does a string of 5 words have?

    That is the Catalan number C(4) = 14.

Summary

  • Rewrite rules list what each category may contain; a derivation builds a tree.
  • Recursion lets a finite grammar generate unlimited sentences.
  • Structural ambiguity arises when a phrase can attach in more than one place.
  • Possible structures multiply very quickly with sentence length.

Next: Movement and dependencies