Context-free grammars

Context-free grammars are rule systems that describe how sentences can be built from smaller parts using production rules. In Intro to Linguistics, they model syntax and let you analyze recursive structures.

Last updated July 2026

What are context-free grammars?

Context-free grammars are formal rule systems in Intro to Linguistics that describe how phrases and sentences are built from smaller units. They use a start symbol, nonterminal symbols, terminal symbols, and production rules to show how language can be generated step by step.

The big idea is that a rule can rewrite a symbol no matter what surrounds it, which is why the grammar is called context-free. For example, a rule might say that a sentence can be rewritten as a noun phrase plus a verb phrase. That kind of rule does not care about the rest of the sentence, only about the category being expanded.

This matters because syntax is not just a list of words in order. A context-free grammar captures hierarchy, which means it can show how words group into phrases inside larger phrases. That is how you represent nested structure, like a noun phrase inside a prepositional phrase inside another phrase.

In computational linguistics, context-free grammars are a basic way to formalize sentence structure so a computer can parse it. A parser tries to match an actual string of words to the grammar and build a parse tree that shows the structure. That is a lot more useful than just checking whether a string is made of English words.

They are also a good bridge between linguistics and programming. Programming languages often need very strict syntax, and context-free grammars are strong enough to describe many of those patterns. Natural language is messier, but the same tool still helps linguists model the underlying structure of sentences.

A common misconception is that context-free grammars are just about memorizing rules. They are really about explaining why sentences can be grouped and nested the way they are. The grammar is the model, and the parse tree is the structure it produces.

Why context-free grammars matter in Intro to Linguistics

Context-free grammars are one of the clearest ways to make sentence structure visible in Intro to Linguistics. Once you can read a grammar, you can explain why a sentence has a certain phrase structure instead of just saying it "sounds right."

They connect directly to parse trees, because every successful parse tree shows one possible derivation from the grammar. That gives you a way to trace how a sentence is built from the start symbol down to the actual words.

This term also sits at the center of computational linguistics. When a language app, parser, or translation system needs to handle syntax, it has to represent structure in a formal way. Context-free grammars are one of the first tools used to do that.

In class, this term often shows up when you compare simple phrase structure rules to more complicated sentence patterns. It also helps you see where natural language goes beyond neat rule systems, especially when ambiguity or attachment problems create more than one possible parse.

Keep studying Intro to Linguistics Unit 13

How context-free grammars connect across the course

Production Rules

Production rules are the individual steps inside a context-free grammar. They show how one symbol can be rewritten as another sequence of symbols, such as a sentence expanding into a noun phrase and a verb phrase. If you understand the rules, you can trace how a string gets generated and why some sentences fit the grammar while others do not.

Parse Trees

Parse trees are the visual output of a context-free grammar. They show the hierarchical structure created by the grammar, not just the word order on the page. In Intro to Linguistics, you use them to explain phrase grouping, recursion, and why one sentence can have more than one possible structure.

Chomsky Hierarchy

The Chomsky Hierarchy is where context-free grammars fit into the larger classification of formal languages. It shows that these grammars are more powerful than regular grammars, but still limited compared with some other formal systems. That comparison helps you see what kinds of language patterns CFGs can model well and where they start to struggle.

context-dependence

Context-dependence is the main contrast term for context-free grammars. A context-free rule applies no matter what is around the symbol being rewritten, while a context-dependent rule changes based on surrounding material. This comparison is useful when you are deciding whether a language pattern can be captured by simple phrase structure rules or needs something more specific.

Are context-free grammars on the Intro to Linguistics exam?

A quiz question might give you a set of phrase structure rules and ask you to generate a sentence or build its parse tree. You may also be asked to decide whether a grammar is context-free by checking whether its rules rewrite a single nonterminal without needing surrounding context.

In short-answer work, you might explain why a sentence is ambiguous because two different parse trees are possible under the same grammar. If a prompt gives you a nested sentence, you can point to the recursive rule that allows one phrase to sit inside another. For computational linguistics questions, you might describe how a parser uses the grammar to assign structure to an input string.

Context-free grammars vs context-dependence

These two are easy to mix up because both deal with sentence structure. Context-free grammars use rules that apply to a symbol on its own, while context-dependent rules change based on what comes before or after. If the rule needs neighboring material to work, it is not context-free.

Key things to remember about context-free grammars

  • Context-free grammars are formal rule systems that generate sentence structure from a start symbol using production rules.

  • They are called context-free because each rule rewrites a symbol without needing to check the surrounding words or symbols.

  • Their main job in Intro to Linguistics is to model syntax, especially hierarchical and recursive structure.

  • Parse trees show the output of a context-free grammar by mapping the hidden structure of a sentence.

  • These grammars are central in computational linguistics because they give computers a way to parse language systematically.

Frequently asked questions about context-free grammars

What is context-free grammars in Intro to Linguistics?

Context-free grammars are formal systems that describe how sentences are built from smaller parts using rewrite rules. In Intro to Linguistics, they are a way to model syntax and show hierarchical structure, including recursion. You use them to explain how words combine into phrases and how phrases combine into sentences.

How do context-free grammars work?

They start with a symbol, then apply production rules that replace that symbol with other categories or words. For example, a sentence can expand into a noun phrase plus a verb phrase, and each of those can keep expanding until you reach actual words. That step-by-step expansion is what makes the grammar useful for parsing.

Are context-free grammars the same as parse trees?

No, but they are closely related. A context-free grammar is the rule system, while a parse tree is the structure you get when a sentence is analyzed using those rules. The grammar generates the possibility, and the parse tree shows one actual analysis.

Why are context-free grammars useful for natural language?

They capture the hierarchical structure of sentences, which is a big part of syntax. They work especially well for nested structures like embedded clauses or phrases inside phrases. They are not perfect for every detail of natural language, but they give linguists and computers a clear starting point.