Chapter 5Mathematical Structuresslides.en.pdf:347-349

Phrase-Structure Grammars

4-tuple ⟨N, Σ, P, S⟩ that generates a language

Def 1.1PSG (slides)Def 1.2Record data structuresDef 1.5Structure signature
Concept

Phrase-structure grammars (PSG) are the most general kind of grammar — the type 0 grammars of the Chomsky hierarchy. Per the slides Chapter 8 (Def 1.1, p.347), a PSG is a 4-tuple N,Σ,P,S\langle N, \Sigma, P, S \rangle where:
- NN — a finite set of nonterminal symbols (placeholders that get rewritten).
- Σ\Sigma — a finite set of terminal symbols (the actual characters of the language). NΣ=N \cap \Sigma = \emptyset.
- PN+×(NΣ)P \subseteq N^+ \times (N \cup \Sigma)^* — a finite set of production rules of the form hbh \rightarrow b (head → body).
- SNS \in N — a distinguished start symbol.

The language L(G)L(G) generated by GG is the set of all terminal strings derivable from SS.

But to talk rigorously about any mathematical object we need more than a pile of sets — we need a way to bundle them together. The slides introduce record data structures (Def 1.2, p.347) for this: container types with named components, accessed via dot notation. C structs, OOP classes, and SML records are all examples. A PSG N,Σ,P,S\langle N, \Sigma, P, S \rangle is naturally a record with four named fields.

The slides go further with structure signatures (Def 1.5, p.349): a tabular overview listing each component, its type, and an accessor name. We will use signatures throughout Chapter 5 to keep track of what each structure contains.

Animation — psg record diagram
Transcript — click a line to jump9 cues
  1. 0.0sA PSG as a record
  2. 1.0sCyan rounded box draws with header: Phrase-Structure Grammar
  3. 2.0sThree divider lines split the box into four fields
  4. 2.8sFields fade in: N, Sigma, P, S
  5. 4.5sAmber arrow points at N: non-terminals
  6. 5.3sArrow moves to Sigma: terminal alphabet
  7. 6.1sArrow moves to P: production rules
  8. 6.9sArrow moves to S: start symbol
  9. 8.3sA PSG is a 4-tuple N Sigma P S, as code it's a struct or class
Worked example
Step 0 of 1
Practice — score 100% to advance
Multiple choice
Q1
Per Def 1.1, a PSG is a 4-tuple. What are its components?
Q2
Which is the role of S in a PSG?
Q3
Per Def 1.2, what is a record data structure?
Q4
What is a structure signature (Def 1.5)?
Q5
Can a production hbh \rightarrow b have an empty body b=εb = \varepsilon?
Loading…