A research program and an open book
Can the grammar of a computational structure become part of the machinery that computes over it?
Computational Grammar Theory studies the formal grammars through which data structures expose, constrain, compose and resolve their operations — and asks, with proofs, experiments and counterexamples, exactly when such grammars change what computation costs.
Begin reading: Chapter 1Table of contentsOpen the laboratoryPDF edition
The three questions kept apart
- Syntax — which expressions are admissible?
- Semantics — what do they denote in a structure?
- Execution — what does it cost to resolve them?
Every claim in this book is filed under exactly one of these questions, and every cost is stated with its machine model.
What has been established so far
15 definitions and 29 proved or cited results across 22 chapters, each with an evidence badge: Proved here Established Empirical Conjecture Rejected.
Negative results are central, not hidden: see the counterexample ledger.
Run it yourself
The CGT SDK (Python, standard library only) implements every structure and algorithm in the book with explicit cost accounting. The laboratory runs real operations in your browser, validated against the SDK.
Contents at a glance
Part I What Is a Computational Structure?
Ordinary data structures, treated from first principles: elements, relations, operations, representations and costs — before any new notation.
- 1Structures, Representations, and Operations
Elements, relations, state, operations and machine models — and the three questions this book never lets collapse into one.
mixed - 2Arrays: Addresses You Can Compute
The array as the first and purest example of a grammar whose words are arithmetic — and what that costs when the array must grow, shift or become multidimensional.
mixed - 3Lists, Stacks, Queues, and Deques
Pointer-based sequences, and the first structure whose language of defined operation sequences is not regular.
mixed - 4Hash Tables, Sets, Maps, and Tries
When names are not dense numbers — hashing computes an address anyway, at the price of collisions; tries turn keys into words read by an automaton.
mixed - 5Trees, Heaps, Search Trees, and Forests
Tree addresses as words, the heap numeration and exactly when it gives constant-time navigation, search trees, and forests compressed by sharing.
mixed - 6Graphs and Paths
Graph representations, walks versus simple paths, and the relational semantics that makes "a path is an edge followed by a path" a theorem rather than a slogan.
mixed
Part II Grammar as a Computational Object
The formal core: operational grammars, three semantic layers, and the admissibility languages that constrain operations.
- 7Operational Grammars
The formal object of Computational Grammar Theory — moves, relational semantics, admissibility languages, adequate representations, cost profiles — and the five mechanisms through which grammar can affect cost.
mixed - 8Admissibility Languages and the Product Construction
How an admissibility language is compiled into an automaton, how a structure is searched under it, and exactly how much a constraint can help or hurt.
mixed
Part III Classical Algorithms Reconstructed
Baseline algorithms with proofs, implementations and counted costs, each mapped to its grammar — including the many cases where grammar adds nothing.
- 9Searching and Sorting Reconstructed
Linear and binary search, four comparison sorts and counting sort — with invariants, counted costs, the comparison lower bound, and the one way around it.
mixed - 10Graph Algorithms Reconstructed
Traversal, ordering, components, shortest paths, spanning trees and closure — and the theorem that evaluating a path grammar is computing a closure, with cost depending on the grammar's shape.
mixed - 11Range Queries, Dynamic Programming, and Strings
Fenwick and segment trees as arithmetic addressing, sparse tables as precomputation, dynamic programming as shared derivations, and string matching as automata.
mixed
Part IV Cost, Information, and the Limits of Grammar
Preprocessing, information lower bounds, compiled operations, and what grammars cannot do to complexity classes.
- 12Cost Profiles, Preprocessing, and Information
When does precomputing pay? What is the least information a "grammar of all answers" must contain? And what happens when the structure changes?
mixed - 13Compiling Operations: When Grammar Becomes Arithmetic
A move word of any length can be compiled into a constant-size operation on some structures and provably not on others. This chapter finds the line.
Proved here - 14The Limits: Advice, Restriction, and P versus NP
What a grammar can and cannot do to complexity classes — stated as precise challenges with their proof obligations, and answered.
mixed
Part V PageRank, Search, and Information Retrieval
A long-form case study: the mathematics of PageRank from first principles, and what a grammatical view does and does not add.
- 15PageRank from First Principles
The random surfer, stochastic matrices, dangling pages, damping, existence and uniqueness of the ranking, power iteration with certified error, solvers, sparse representations, updates and personalization.
mixed - 16PageRank Through the Lens of Grammar
The random surfer as a probabilistic operational grammar, rankings constrained by admissibility languages, block structure as a structural grammar — and an honest list of what the grammatical view does not improve.
mixed
Part VI Modern Computational Systems
Explicit models of computation graphs, retrieval, vector search and agent workflows — and careful limits on what grammar can claim about them.
- 17Computation Graphs, Retrieval, and Agent Systems
Where computational grammars apply to modern AI systems — computation graphs, attention masks, retrieval pipelines, vector search and agent workflows — and where they do not.
mixed
Part VII The Laboratory, the SDK, and Grammar as a Service
The executable companion: how to use, extend and serve computational grammars.
- 18The CGT SDK
A tutorial for the executable companion to this book — structures, grammars, the three layers, cost models, comparisons, experiment records and extension points.
mixed - 19Grammar as a Service
A contract for requesting operations on versioned grammars, with layered rejection, quotas, determinism, provenance and cache validity — and an argument about what should run where.
Proposed
Part VIII Conclusions
What has actually been established, what has not, and where the research goes next.
- 20What Computational Grammar Theory Has Established
The confirmed contributions, the negative results, the open questions and the research agenda — without inflating any of them.
mixed
Appendices
- Appendix ANotation and Conventions
The symbols, cost conventions and evidence labels used throughout the book.
Definition - Appendix BReproducing This Book
How to rerun every experiment, test, example and build step, and what reproducibility means for each.
Definition