Skip to content

Commit 3c4ed86

Browse files
committed
docs: interactive N0120 key map + v2 roadmap
- docs/keymap.html: interactive keyboard mockup of the NumWorks N0120 showing the RPN key mapping; unused keys highlighted, key/command views, click-to-cross-highlight between keys and the mapping table. - Link it from the landing page and README. - docs/ROADMAP.md: plan for a v2 symbolic stack with Poincare-style 2D result presentation (exact + approximate, lazy reduction).
1 parent 56d5d02 commit 3c4ed86

4 files changed

Lines changed: 650 additions & 0 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ two levels.
4242

4343
## Key map
4444

45+
🎹 **Interactive keyboard map:** <https://1e1.github.io/numworks-RPN/keymap.html>
46+
click a key, a table row, or a category; unused keys are highlighted.
47+
4548
Operator and function keys keep their printed symbol but **apply to the stack**
4649
instead of inserting text. Keys with no RPN meaning are repurposed for stack ops.
4750

@@ -104,6 +107,12 @@ tests/ host unit tests for the numeric core
104107
docs/ GitHub Pages landing page
105108
```
106109

110+
## Roadmap
111+
112+
The next version aims for a **symbolic stack with Poincaré-style result
113+
presentation** (2D layouts, exact + approximate). See
114+
[docs/ROADMAP.md](docs/ROADMAP.md).
115+
107116
## License
108117

109118
See [LICENSE](LICENSE).

docs/ROADMAP.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Roadmap — v2: symbolic stack with Poincaré-style presentation
2+
3+
v1.0.0 is a numeric RPN calculator: the stack holds *numbers* (exact rationals
4+
or doubles) and every operator computes eagerly. v2 changes the nature of the
5+
stack.
6+
7+
## Vision
8+
9+
The stack holds **expression terms**, not just numbers — a bit like lambda
10+
calculus: operators **build a term**, and a **reduction** step normalizes it on
11+
demand rather than computing eagerly. Results are then **presented like
12+
Poincaré**: real 2D math layout (stacked fractions, radicals, raised exponents)
13+
with the **exact form and its decimal approximation** shown together, exactly
14+
the feel of the standard NumWorks app.
15+
16+
```
17+
2 ENTER 8 √ × level 1: 2·√8 ── exact, unreduced term
18+
reduce level 1: 4·√2 ── normalized
19+
→Num level 1: 5.656854
20+
```
21+
22+
## The core constraint (unchanged from v1)
23+
24+
An external app cannot call Poincaré (EADK sandbox). Two routes to the vision:
25+
26+
| | Route A — native fork | Route B — self-contained engine |
27+
|---|---|---|
28+
| Where | RPL mode inside Epsilon (the `epsilon` fork) | still a portable `.nwa` |
29+
| Math | reuse Poincaré `Expression` + simplification + `Layout` | build a small term engine + 2D renderer ourselves |
30+
| Fidelity | full (real Poincaré look & CAS) | good, bounded |
31+
| Cost | fork maintenance, upstream sync, bigger build | more app code, but stays portable |
32+
33+
**Recommendation:** prototype **Route B, Phase 1** first — it extends the
34+
existing host-tested pure core and keeps the app a single `.nwa`. Keep Route A
35+
as the escape hatch if you later want true Poincaré fidelity.
36+
37+
## Architecture
38+
39+
### 1. Term model (`expr`)
40+
Replace the flat `Value` on the stack with an expression tree:
41+
42+
- Leaves: `Integer`, `Rational`, `Constant` (π, e, i), `Symbol` (future).
43+
- Nodes: n-ary `Add`, n-ary `Mul`, `Pow`, `Neg`, `Func` (sin, ln, …).
44+
- N-ary `Add`/`Mul` with **sorted, canonicalized** operands so equal terms
45+
collapse (`√2 + √2 → 2·√2`).
46+
47+
The stack becomes a stack of `Expr` (kept small: arena/pool allocation, no heap
48+
churn — important on the device).
49+
50+
### 2. Reduction (the "lambda" step)
51+
Operators are **constructors**: `×` just builds `Mul(a, b)`. A `reduce()` pass
52+
normalizes to a canonical form:
53+
54+
- rational arithmetic (reuse v1's overflow-checked `Value`),
55+
- constant folding, like-term collection, `` extraction of square factors,
56+
power rules (`xᵃ·xᵇ → xᵃ⁺ᵇ`), sign normalization.
57+
58+
Two outputs from any term: **exact** (the normalized tree) and **approximate**
59+
(numeric eval to double). Reduction runs on `ENTER` / on demand — building a
60+
term then reducing it mirrors *build → β-reduce → normal form*.
61+
62+
### 3. 2D layout renderer (`layout`) — the Poincaré look
63+
The biggest new piece in Route B. A layout tree of boxes with a **measure**
64+
(width, height, baseline) then **draw** pass over the EADK framebuffer:
65+
66+
- `HBox` / `VBox`, `FractionLayout` (numerator over bar over denominator),
67+
- `RadicalLayout` (√ with vinculum), `SuperscriptLayout` (raised exponent).
68+
69+
Reuses the two EADK font sizes; measurement drives right-alignment on the stack.
70+
71+
### 4. Presentation
72+
Each stack level renders its **exact 2D layout**; a secondary line (or a
73+
per-level toggle) shows the **decimal approximation**, like the standard app's
74+
exact/approx duality. `→Num` forces the approximate view.
75+
76+
## Phasing
77+
78+
1. **Term engine + reducer** for rationals, ``, π, basic simplification — pure
79+
C++, unit-tested on host (extends the current `make test` harness). 1D text
80+
output first (`4·√2`).
81+
2. **2D layout renderer**: fractions, powers, radicals over the framebuffer.
82+
3. **Exact / approximate dual presentation** + `→Num`.
83+
4. *(optional)* evaluate a **Route A** native-fork port if fidelity or scope
84+
demands the real Poincaré engine.
85+
86+
## Risks & bounds
87+
88+
- **Binary size** — v1 is already ~500 KB; a layout engine adds more. Budget it;
89+
consider dropping `_printf_float` via a hand-rolled number formatter.
90+
- **Mini-CAS scope creep** — explicitly *not* a general algebra system. Bound it
91+
to: exact rationals, ``, π/e, like-term collection, power/product rules.
92+
- **Device memory** — pool-allocate terms; cap expression depth/size and report
93+
when a level exceeds it rather than failing silently.
94+
95+
## What carries over from v1
96+
97+
The pure, host-tested core (`value`, `stack`, `input_field`, `rpn`) is the
98+
foundation: `Value` becomes the numeric leaf of the term model, `Stack` becomes
99+
a stack of `Expr`, and the `make test` harness extends to cover reduction rules.

docs/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ <h2>See it in action</h2>
148148
<section>
149149
<h2>Key map</h2>
150150
<p style="color:var(--muted);margin-top:-6px">Operator keys apply to the stack; RPN-useless keys become stack operations.</p>
151+
<p style="margin:2px 0 18px"><a class="btn btn-primary" href="keymap.html" style="padding:11px 20px;font-size:15px">↳ Open the interactive keyboard map</a></p>
151152
<div class="tbl-scroll">
152153
<table>
153154
<tr><th>Key</th><th>Action</th></tr>

0 commit comments

Comments
 (0)