Show HN: The Name in the Bracket (a free book on naming tensor dimensions)

amazing421 pts0 comments

The Name in the Bracket - Einlang

Contents

Opening

Home

Part I · Primitives

1. The Ghost in the Name

2. The Megaphone's Promise

Part II · Combinations

3. Names as Contracts

4. The Broadcast Self-Audit

5. Blocks and Skeletons

6. The Arrow in the Bracket

7. Complex Terrain

8. Names Through Differentiation

Part III · Construction

9. The Shape of Thought

10. The Name in the Mirror

Part IV · Comparisons & Limits

11. Comparison: Normalization

12. Comparison: Attention

13. Comparison: Physics

14. The Edge of the Name

Reference

Appendix

Closing

Epilogue

The Name in the Bracket

Notation determines what you can notice. When a notation has no place for a fact, that fact becomes invisible—not just to the compiler, but to the act of reading and reasoning itself.

From a Tuesday bug through naming, broadcasting, differentiation, comparison with PyTorch, and compiler construction, each chapter asks the same question—where is the name?

The bracket is where the name enters, where it is checked, and where it is finally burned. Everything between is the life of a name in source code—the only life that a compiler can see.

Download PDF

Preface

Every programmer who works with tensors has debugged a silent shape bug. The code runs. The shapes line up. The loss goes down. And yet the program is wrong—systematically, invisibly wrong—because an axis means class but the operation treated it as batch. The notation never recorded the difference. The compiler never checked it. The bug survived integration tests, code review, and the training dashboard. It was found at 3 AM by a human being who traced one number backward through twelve layers of a deployed model and realized that the axis had been silently swapped three weeks earlier.

Einlang is a small language that makes the demonstrations precise. You can type the examples. You can run them. The compiler will catch the shape-compatible wrong versions. But Einlang is not the argument. It is the microscope.

If you build things below the level of an API call—a compiler pass, a numerical library, an autodiff engine, a tensor DSL, or a notation shared by a team—this is for you. If you have ever stared at RuntimeError: mat1 and mat2 shapes cannot be multiplied at 3 AM and wished the traceback told you which dimension was supposed to be head and which one was supposed to be feature, this is for you. If you mainly want another framework function to call, it will probably spend too much time under the floorboards. That is by design.

How to read. Pick the path that fits where you are.

The full journey (all chapters, in order). For readers who want to understand what happens when tensor coordinates carry names—from the primitives through gradient derivation through compiler construction. Start at Chapter 1. Do the exercises. Derive the gradients. The chapters build on each other, and each one assumes the previous one’s vocabulary.

The comparison path (Chapters 1–2, then 11–13). Read Chapters 1–2 to learn the megaphone model and coordinate set subtraction. Then jump to Chapters 11–13, where LayerNorm, GroupNorm, multi-head attention, Flash Attention, and physical simulation are written twice: once in PyTorch/NumPy, once in Einlang. If the comparisons convince you, return to Chapters 3–8 for the deeper machinery—coordinate-aware function signatures, the broadcast self-audit, and differentiation by coordinate accounting.

The compiler path (Chapters 1–4, then 9–10). Read Chapters 1–4 to learn the primitives and the Inversion Rule. Then jump to Chapters 9–10, which build a compiler frontend: IR as S-expressions, five check rules with the detective Wall, lowering from names to integers, range inference, shape analysis, and execution strategies. The core loop is fifteen lines.

If you only have an afternoon. Read Chapter 1 (the ghost in the name), Chapter 4 (the broadcast self-audit), Chapter 14 (the edge of the name), and the Epilogue. Everything else is depth.

Part I (Chapters 1–2) introduces naming, permuting, reducing, broadcasting—with the megaphone model that unifies them. Part II (Chapters 3–8) covers coordinate-aware functions, the broadcast self-audit, normalization skeletons, recurrence, complex terrain, and differentiation. Part III (Chapters 9–10) opens the compiler: intermediate representation, five check rules, range inference, shape analysis, constraint solving, and lowering from names to integers. Part IV (Chapters 11–14) puts Einlang side by side with PyTorch and NumPy on normalization, attention, and physical simulation, then marks the boundary—what names can check and what they cannot. The Appendix and Epilogue reflect on what was built and what it means.

Turn the page.

Contents

Part I · Primitives

1. The Ghost in the Name

2. The Megaphone’s Promise<br>Part II · Combinations

3. Names as Contracts

4. The Broadcast Self-Audit

5. Blocks and Skeletons

6. The Arrow in the Bracket

7. Complex Terrain

8. Names Through Differentiation<br>Part III ·...

chapters name part compiler names bracket

Related Articles