The book · Decision Lab
Applied Higher Order Functions
A functional architecture of optimisation, decision making and validation.
Operations research is taught as hundreds of unrelated recipes. I wrote this book to make the opposite case: that most of it, from continuous and discrete optimisation through sequential decision-making under uncertainty to temporal-logic validation, is a small set of higher-order-function patterns composed in different orders. I did not want the claim to rest on my say-so, so every algorithm in the book is expressed in Clojure against orhof, and the library it calls carries 187 deterministic tests.
347 pages · CC BY-SA 4.0 · by Jiri Knesl, founder of Flexiana
- algorithms catalogued
- about 480
- patterns underneath them all
- 10
- code listings, each parse-checked
- 167
- library dependencies (orhof)
- 0
- pages
- 347
The claim
Why the book is 480 examples long
That gradient descent, conjugate gradient and Adam are one descent
framework with different parts is an observation I had years before I had a book, and on
its own it would not have persuaded anyone, including me. So the book makes the same
observation roughly four hundred and eighty times, across
three domains that are usually taught in separate courses, and shows the same handful of
higher-order functions underneath each one. At that point it stops being a neat trick and
starts being a claim about how the field is put together.
That is also why it is a book and not a long article, and why it took about twice as long to write as I told anyone it would. The catalogue at the back annotates each algorithm with the patterns it is built from, so you can check the structure yourself rather than take my word for it.
It is also the working vocabulary of our Decision Lab. When we model a client's decision, this is the shared language that lets senior people hand work between each other without re-deriving the basics. I wrote it partly so that I would stop having to explain the same ten things in every kick-off.
What is inside
What is inside
Five parts, sixteen chapters and three appendices. It starts with the vocabulary, goes through optimisation and decision-making under uncertainty, and ends with validation and the architecture that ties the three together.
- I
The Foundation of Higher-Order Functions
What a higher-order function is as an object of design, S → T, and the small vocabulary the rest of the book composes: iterate, reduce, comp, partial, and how to design a new one deliberately.
- II
The Algorithmic Toolkit
Optimisation as composition. The population pipeline (annealing, genetic algorithms, PSO, differential evolution as one shape), the descent framework (gradient, Newton, Adam, Lion as one operator with different parts), and constraints as function decorators: penalties, Lagrangians, duality.
- III
HOFs for Decision Making
Sequential decisions under uncertainty. The Bellman operator as a function transformer behind value and policy iteration; online learning and the fold pattern behind Q-learning and SARSA; Monte Carlo Tree Search as a tree explorer.
- IV
HOFs for Validation
Temporal logic as function combinators: always, eventually, until as higher-order functions with continuous truth values; falsification recast as optimisation; reachability and sensitivity via set propagators and sampler constructors.
- V
Synthesis and Architecture
Where the patterns meet across domains, the algorithm taxonomy that carries the argument at scale, and how to build production systems on the same small vocabulary: the practical idioms and library design behind orhof.
Appendix B is the API reference for the companion library. Every code listing in the book is written against it, and all 167 are extracted from the manuscript source and parse-checked as a suite. So nothing in the text has drifted from code that Clojure will read. That drift was the failure I most feared in a book with this much code in it.
Runnable
The library and the prover behind it
Companion library · MIT
orhof
A dependency-free Clojure library that reconstructs the book's algorithms as compositions of higher-order-function patterns. Appendix B is its reference, and every listing in the book is written against it.
Machine-checked · open source
Rainbow
Our theorem prover uses the same algorithm catalogue as its proving curriculum, turning the book's structural claims into properties a machine can check, one algorithm at a time.
Prefer the short version first? The one-page summary is in the research library.
Format
The hardback
347 pages, in hardback. The text is under Creative Commons Attribution-ShareAlike 4.0, and the companion library, orhof, is MIT-licensed.
€75 a copy, including VAT, plus shipping.
- Author
- Jiri Knesl
- Extent
- 347 pages
- Code
- Clojure · orhof
- Book licence
- CC BY-SA 4.0
- Library licence
- MIT
Hardback
Order the hardback
€75 a copy, including VAT, plus shipping. Orders inside the EU are posted from Spain, so there is nothing to pay on delivery. Orders from everywhere else are posted from Gibraltar.
We reply by email with the shipping cost and an invoice from Flexiana s.r.o., and post the book once it is paid.
FAQ
The book: questions answered
What does the book argue?
That most of operations research, from continuous and discrete optimisation through sequential decision-making under uncertainty to temporal-logic validation, is a small set of higher-order-function patterns composed in different orders. I could not have made that claim on ten examples, and I would not have believed it on fifty. So the book does it roughly 480 times, across three domains usually taught in separate courses, and ends up with ten patterns underneath all of them.
Who is it for?
Anyone who works with these algorithms and wants the structure underneath them, where a cookbook would give hundreds of unrelated recipes. It is also the working vocabulary of our Decision Lab. When senior people hand work between each other here, this is the language they use, and it saves us re-deriving the basics on every engagement.
What is the relationship between the book and orhof?
orhof is a dependency-free Clojure library that reconstructs the book's algorithms as compositions of higher-order-function patterns. Appendix B is its API reference, and every code listing in the book is written against it. All 167 are extracted from the manuscript source and parse-checked as a suite, so the text cannot drift from code Clojure will read. orhof itself carries 187 deterministic tests.
Does the code run?
Not in the sense some books mean it. The 167 listings are extracted from the manuscript source and checked as a suite: a script reads every one and fails the run if any does not parse. What they are written against is the companion library orhof, which is separately tested: 251 functions under 187 deterministic tests. So the library the listings call is exercised, and the listings themselves are kept in step with the text. I am not going to claim more than the tooling shows, because a reader who runs a listing and finds it broken will not open the book again.
Can I get a hardback?
Yes. The hardback costs €75 including VAT, plus shipping. Use the order form on this page and we will email you the shipping cost and an invoice from Flexiana s.r.o. Orders inside the EU are posted from Spain, so there is nothing to pay on delivery.
From the book to your problem
From the book to your own decision
The book is the theory. In the Decision Lab we apply it to a specific, valuable decision under your constraints. Bring us one and I, or a partner, will take a look.