# RRLS Geometry Lab 0.10 — experimental

**New problem-driven revision cycle:** [Problem-driven theory revisions](PROBLEM_DRIVEN_REVISIONS.md) repairs all three failed signal models within declared scopes, proves the fixed-input photograph task infeasible, and keeps the next unresolved problem active. The clock-aware chirp model passed 6,291,456 newly generated continuation targets. Use `python problem_cli.py status` to inspect the current agenda, and `problem_cli.py predict` for governed reuse of accepted programs.

The new accepted programs are stored in `results/revision-cycle/revision-vocabulary.json`. Original counterexamples and contradicted parent schemas remain intact. The separately retained cubic reference hypothesis keeps its previous version and coefficients.

**New cross-domain run:** 31,588,403 scalar values across 30 streams; three initially validated predictors later contradicted; actual image/text input conflicts; held-out digit-coordinate reduction; a separately scoped measured-force candidate. Start with [Cross-domain stress results](CROSS_DOMAIN_STRESS.md). Source snapshots, seeds, fixed contracts, counterexamples, and complete counts are included.

This release also fixes a quadratic SVD allocation and the add-on's exact RRLS output serialization. The frozen cubic hypothesis keeps the same coefficients, policy, and version. Its current-runtime ledger is `results/reality-ledger-compatible.json`; the v08 ledger is retained separately for compatibility review.

**New governing mode:** [Frozen reality protocol](FROZEN_REALITY_PROTOCOL.md) locks a geometric hypothesis until recorded observations contradict it, then gates revisions on old-evidence replay and fresh coordinates. Use `reality_cli.py` for this mode.

**New in this revision:** composition search, saved-composition reuse, fitted affine readouts, and exact polynomial relation mining. Start with [Discovery cycle 2](DISCOVERY_CYCLE_02.md) for the new results and commands. The results below describe the retained 0.7 baseline.

This adds a geometry vocabulary, coordinate-based learner, and algebraic shortcut compiler to the supplied RRLS Studio 0.6 sequence engine. It contains **29 catalog entries**, **15 tested transformation-recognition categories**, a saved bank of fitted operators, a desktop lab, a JSON command line interface, and reproducible results. The original 0.6 files remain in `source/RRLS_Studio_v06`; their hashes match the uploaded archive, excluding Python bytecode caches.

This is an extensible finite implementation. There are infinitely many transformations, parameter choices, compositions, and dimensions. No universal enumeration or globally shortest-program guarantee is claimed. Here, “teach” means fitting and saving parameters within supplied mathematical families, retaining reusable compiled programs, and using the original RRLS to learn exact parameter sequences. It does not mean training neural-network weights or discovering all the rewrite laws from observations.

## Run it

Install Python 3 with NumPy. The desktop lab also needs Tcl/Tk, normally included with Python's Windows installer.

```text
py -3 -m pip install -r requirements.txt
py -3 geometry_lab.py
```

On Windows, `launch_geometry_windows.bat` checks the dependencies and opens the lab. On other platforms, use `python` in place of `py -3`. The launcher does not install dependencies automatically. The core and CLI were tested on Python 3.12.13 with NumPy 2.3.5. Tkinter imported successfully; the actual Windows GUI has not been run in this environment.

Choose a demo, edit its JSON operations, and click **Run + simplify**. **Fit from samples** generates paired coordinates from that demo, keeps a suffix out of fitting, and saves an accepted fit to `results/my-vocabulary.json`. It is a synthetic demonstration; use the CLI below with your own paired coordinates for real input data. The copies example expects a list of per-copy programs. Other examples expect a single program.

![Computed geometric actions](results/geometry-action-gallery.png)

Gray points are inputs. Transformed-point colors retain the original x coordinate, so a reflection of a symmetric square remains visible. A marked point distinguishes its source location from its image. Higher-dimensional panels are declared linear shadows; the calculations retain all coordinates. These are point samples, not reconstructed solid meshes.

## What actions are covered?

| Family | Implemented behavior | Inverse and simplification conditions |
|---|---|---|
| Move, rotate, mirror, scale, shear | Affine maps in arbitrary finite coordinate dimension | Ordered chains fuse to `A*x+b`; inverse needs a square nonsingular matrix |
| Horizontal and vertical mirror | Negate x or y, respectively | Two identical mirrors cancel; mirror direction names are disambiguated in the catalog |
| Copy and transform copies | Shared base coordinates plus separate programs | Keeps copy multiplicity; a copy collection is not a Boolean union |
| Twist | A plane rotates according to another coordinate | Same plane/driver twists add rates and offsets; inverse negates them |
| Bend | A plane wraps around a curvature-dependent center | Inverse requires the declared positive-radius branch and angle range |
| Taper | Two coordinates scale with an unchanged driver | Excludes zero factor; repeated rates do not simply add |
| Sine and polynomial shear | Add a function of another coordinate | Negating that function inverts it; matching generators combine |
| Central, sphere, reciprocal inversion | Three distinct operations | Sphere and reciprocal inversions exclude singular inputs |
| Fold | Absolute value of one coordinate | Idempotent but loses the sign; no global inverse |
| Projective transformation | Homogeneous map with a division | Denominator exclusions remain; no unsafe projective cancellation |
| Embedding, selection, feature lift | Add constants/monomials or select coordinates | Remove unused dimensions and features when algebra permits |
| Products and extrusion | Cartesian point products and continuous product predicates | Dimensions add; an interval factor extrudes a planar region to 3D |
| Minkowski sum | All point sums or a direct support query | Support values add without constructing every pair |
| Union, intersection, difference, complement | Membership predicates over boxes, balls, halfspaces, products | Set identities simplify expressions; no mesh Boolean reconstruction |

`operator-vocabulary.json` is the full machine-readable catalog: formulas, dimensions, domains, inverse conditions, learner coverage, and unsupported families. It is documentation of the implemented dispatch, not a dynamic plugin loader. General spline deformation, physical bending simulation, arbitrary manifold charts, topology-changing mesh edits, and noisy or unlabelled registration are outside this release.

## The pattern behind the shortcuts

1. **Composition removes intermediate work.** If `T1(x)=A1*x+b1` and `T2(x)=A2*x+b2`, then `T2(T1(x))=(A2*A1)*x+(A2*b1+b2)`. The order matters. Rotating and then translating generally differs from translating and then rotating.
2. **Repeated generators can collapse.** Translation amounts add; scales multiply; the supported twist, sine-shear, and polynomial-shear generators accumulate their parameters. A repeated affine map is computed by exponentiation by squaring. A repeated bend or taper does not inherit an unsupported addition rule.
3. **Symmetry gives compact representations.** An orthogonal transformation in d-dimensional Euclidean space can be represented by at most d hyperplane reflections. The lab constructs and checks this known decomposition. It is not necessarily the fastest or shortest representation in another instruction vocabulary.
4. **Redundant coordinates can disappear.** Embedding 3D coordinates into 6D and selecting the original three coordinates is identity. A polynomial feature lift followed by a linear readout becomes a sparse polynomial map; unused monomials disappear.
5. **Intrinsic constraints permit reduction.** The SVD example encodes a 2D affine plane sitting inside 4D using two coordinates. New points must satisfy that same constraint. The code rejects off-plane points; it does not infer a universal nonlinear manifold from a finite sample.
6. **Missing information must be retained somewhere.** For a linear projection `y=P*x`, the lab stores the missing kernel coordinates `h=K.T*x`. Reconstruction uses `x=P_pseudoinverse*y+K*h`. A generic projection alone is not reversible. This preserves information by retaining it, not by making it vanish.
7. **Factorization avoids large constructions.** A tensor-factor action evaluates `A*X*B.T` without building a dense Kronecker matrix. Minkowski support uses `h_(A+B)=h_A+h_B`. Copies share base geometry. Convex product face counts use polynomial convolution.

These are computational shortcuts between equivalent descriptions or queries. They do not establish physical travel through dimensions. Compiler rewrites preserve endpoint maps, not all intermediate animation frames, collision events, or path-dependent quantities. Minimizing step count, time, memory, and description length are different objectives; this compiler does not prove global optimality for any of them.

## What was learned, and what was supplied?

**Supplied mathematics:** operation formulas, candidate families, inverse formulas, reflection construction, and the rewrite rules. Each compiler trace labels this provenance.

**Fitted from paired coordinates:** transformation parameters and matrix coefficients. The recognizer fits on the first 75% of paired points, selects one training-fitting candidate using a cost proxy, then validates that winner on the untouched suffix. The suffix cannot refit it or choose a different winner. A validated result is saved with errors, sample counts, a training hash, dimensions, and provenance. Finite numerical agreement is evidence within the candidate family, not a proof of a unique global function or its causal history. Multiple named operations may implement the same map.

**Learned using the original RRLS engine:** six exact parameter schedules, with eight future values checked per schedule. This accepts supplied exact histories such as translation offsets or rotation increments. It does not automatically turn noisy coordinate fits into exact symbolic time laws. RRLS uses its own candidate selection logic; the extra future values in the benchmark are external checks.

The recognizer requires at least 24 matched input/output points, full ambient affine span in the training inputs, and enough samples for each candidate's features. It does not solve point correspondence. Single bend/twist/taper operators are recognized in the supported coordinate-plane forms; arbitrary compositions of nonlinear operators may remain unresolved. Sine discovery tests four fixed frequencies; sphere-inversion discovery fixes its center at the origin; projective fitting uses one normalization chart; general polynomial discovery is limited to degree 3 with at most four input coordinates. The runtime supports broader supplied parameters where the catalog says so.

## Results from the included run

Full data and timings are in `results/transform-benchmark.json`.

| Check | Result |
|---|---:|
| Rational affine-chain equality on a complete affine basis, dimensions 2/3/4/6/8 | 60/60 |
| Nonlinear program equivalence cases | 40/40 |
| Registered nonlinear inverse round trips | 8/8 |
| Singularities, branch violations and invalid global inverses rejected | 7/7 |
| Deliberately wrong commutation/addition identities contradicted | 3/3 |
| Orthogonal matrices reconstructed with at most d reflections | 30/30 |
| Transformation fits across 15 categories | 75/75 |
| Transfer of those fitted maps to additional curved point sets | 75/75 |
| Shuffled input/output correspondences rejected | 60/60; zero false accepts |
| Original RRLS future parameter values | 48/48 across six schedules |

The numerical fit suffix error was at most `4.45e-15`; transfer error at most `7.11e-15`. These results use synthetic targets generated with the runtime kernels. The independent point sets, exact affine-basis checks, and negative controls test different failure modes; they are not independent experimental evidence about real-world shapes. This release has no noise-robustness claim.

| Endpoint computation | Original | Compiled/factored | Observed warm speedup |
|---|---:|---:|---:|
| Affine chain, 12,000 points in 4D | 192 steps; 45.71 ms | 1 map; 0.222 ms | about 206x |
| Twist, 6,000 points in 3D | 512 repetitions; 87.95 ms | 1 twist; 0.250 ms | about 352x |
| 1024-by-1024 Kronecker action | 8 MiB operator | two factors totaling 16 KiB | about 5.6x; 512x smaller operator storage |

These are medians from one machine, not portable guarantees. Affine compilation itself took about 48.57 ms, so it pays off through reuse; a single run can cost more overall. Twist timings also exclude compilation. The largest error in the repeated-twist timing comparison was `1.84e-14`. Tensor storage numbers exclude the input/output arrays common to both methods. Copy savings exclude Python object overhead and do not eliminate the cost of materializing every output point.

Affine coefficients are composed as exact fractions, including the finite decimal coefficients produced by trigonometric functions. This does not make irrational rotations algebraically exact. Point evaluation is float64; reassociation need not be bitwise equal and may behave differently at overflow, underflow, or catastrophic cancellation. Mathematical domain guards are retained for cancelled partial involutions; they do not promise identical floating-point exceptions at extreme magnitudes. Supply structurally valid programs, finite well-scaled coordinates, and appropriate tolerances.

## Use your own data

Input JSON must pair corresponding coordinates in matching order:

```json
{"source_points": [[0,0,0], [1,0,0]], "target_points": [[1,0,0], [2,0,0]]}
```

That two-point snippet only illustrates the format; fitting requires at least 24 sufficiently independent pairs. The included `examples/paired-twist.json` has 96 pairs.

```text
python geometry_cli.py learn examples/paired-twist.json --name my-twist --bank results/my-vocabulary.json
python geometry_cli.py use results/my-vocabulary.json my-twist examples/points-3d.json
python geometry_cli.py optimize examples/twist-repeat.json --dim 3 --out results/optimized.json
python geometry_cli.py apply results/optimized.json examples/points-3d.json
python geometry_cli.py inverse examples/twist-repeat.json --dim 3
python geometry_cli.py schedule examples/parameter-values.json --forecast 8
python geometry_cli.py catalog
```

Only held-out-validated fits enter a bank. Unresolved or rejected fits are reported without saving them. `--out` writes the command result to a JSON file. All programs are parsed as JSON; they are not evaluated as executable Python.

## Connection to square times triangle

The Cartesian product of a filled square and filled triangle is four-dimensional. Its face-count vector, including the 4D body, is `[12, 24, 19, 7, 1]`. The face-count polynomials multiply:

```text
(4 + 4*t + t^2) * (3 + 3*t + t^2) = 12 + 24*t + 19*t^2 + 7*t^3 + t^4
```

`face_count_product([4,4,1],[3,3,1])` computes this convolution. The earlier learned count vocabulary and reusable add-on are included. For convex m-gons and n-gons, they represent `V=m*n`, `E=2*V`, `C=m+n`, `F=V+C`. Those formulas concern combinatorial faces of the actual 4D product, not its 3D shadow. Nonlinear deformations and projections do not generally preserve polytope face geometry.

```text
python geometry_addon/rrls_geometry_vocabulary.py --vocabulary examples/geometry-words.json --predict 4 3
```

## Reproduce and extend

```text
python benchmark_transforms.py
python geometry_cli.py demo
python check_interfaces.py
python -m pip install -r requirements-gallery.txt
python make_gallery.py
```

The first command regenerates the benchmark, learned demonstration vocabulary, parameter schedules, and long-chain examples. The gallery command regenerates the illustration and sample JSON. `check_interfaces.py` covers CLI learning, persistence, reuse, inversion and examples; it does not interact with the desktop GUI.

To add a family: implement its coordinate map and shape/domain checks in `rrls_transforms.py`; add a valid inverse only if justified; add an estimator to `identify` in `rrls_transform_learning.py`; give any rewrite an explicit algebraic condition; add positive, held-out and counterexample checks; record the scope in `operator-vocabulary.json`. Never promote sampled coincidence into an unconditional rewrite rule.

## Mathematical sources

- Ordered affine composition and homogeneous coordinates: [Stanford CS248 transformation notes](https://graphics.stanford.edu/courses/cs248-04/xform/xform2.html).
- Established twist, bend and taper deformation families: [Alan Barr, Global and Local Deformations of Solid Primitives, 1984](https://authors.library.caltech.edu/records/99pd2-73028). The exact formulas and branch conventions implemented here are documented in our catalog.
- Orthogonal maps generated by at most d reflections: [Jules Jacobs, Cartan–Dieudonné proof](https://julesjacobs.com/notes/cartandieudonne/cartandieudonne.pdf).
- Why unrestricted shortest-description search cannot be guaranteed: [Paul Vitányi, How Incomputable Is Kolmogorov Complexity?, 2020](https://pmc.ncbi.nlm.nih.gov/articles/PMC7516884/). This is a theoretical limit on unrestricted shortest-program claims, not a barrier to the bounded optimizations implemented here.

Benchmark results in this document come from the included code and result files, not from these external sources.
