This is a way of looking, not a programming language: represent data the way an AI already holds it, as nested points on a math surface. Each thing is a point that contains other points; it stores only what is irreducible and derives everything derivable on demand; and it hands a model exactly the slice it asks for, at the scale it asks for. The payoff is concrete, and it is not "smarter AI" (which only worries people) but cheaper and more reliable AI: roughly 99.7% fewer tokens on a focused question (tokens cost money), and the same focusing discipline that cut one verifier's made-up output from about 39% to 0%. It focuses the model, it does not change it. The library here is real and runs in your browser and in Node. Below: the two hello-worlds, the saving measured in tokens, and the full reference.
Both structures below are built live by dp.js on this page. Click a part to zoom inward; ascend to step back out. Stored facts are gold, derived lenses are green and recomputed each time you move.
A model is asked one localized question over a large nested structure. The naive way dumps the whole flattened tree into the prompt. The dimensional way lets the model navigate to the region and read the answer, pulling only that slice. Real numbers from dp.js, computed live:
This is the entire Russian Doll program and the entire Car program, with the real output printed underneath. Nothing is hidden.
The whole surface. DP is the global in the browser, or require('./dp.js') in Node.
| Member | Returns | What it does |
|---|---|---|
DP.point(name, {x,y}) | Point | Create a point. x,y are its coordinate; default spread keeps demos deterministic. |
p.contains(...children) | p | Nest points inside this one. The Russian doll. Chainable. |
p.fact(key, value) | p | STORE irreducible data. One arg reads it back. |
p.lens(name, fn) | p | Register a DERIVATION. fn(p) runs fresh on every read. |
p.derive(name) | any | Compute a lens now. Nothing is cached; recomputed each call. |
p.z | number | The coordinate value x·y. A getter; derived, never stored. |
p.zoom() / p.ascend() | parts / parent | Step inward to the contained points, or outward to the container. |
p.locate(path) | Point | Find a nested point by slash path, eg lot-A/car/engine. |
p.path() / p.depthOf() | string / number | Absolute slash path from the root, and nesting depth. |
p.walk(fn) / p.count() | p / number | Visit every point inward; count all points from here. |
p.toContext(depth) | string | The compact, self-describing slice an AI reads. Omit depth for the whole subtree. |
DP.ai(root) | AI | An interface the model drives. .command('ZOOM x' | 'ASCEND' | 'DERIVE n' | 'LOCATE path' | 'WHERE'), .context(depth), .cost() tokens used. |
DP.estTokens(str) | number | A rough ~4 chars/token estimate, labelled an estimate wherever shown. |
dp.js. The token reduction for localized questions is real and measured on this page.
dp.js, dependency-free, browser and Node