# GERES P2：全域尺度引擎

**Global Scale Engine for World-Equivalent Geometry**

版本：v0.1  
系列：GERES — Global Equivalence Reconstruction and Scaling  
階段：P2  
性質：演算法規格／世界模型引擎設計／可視化與驗證基礎  
主要 benchmark：Perfect Cuboid  
Canonical source：UTF-8 Markdown

---

## 摘要

GERES P0 建立「全域等價重建與縮放」研究綱領；P1 則把世界、容器、中心、物件、關係、度量、constraint、gauge 與 arithmetic state 形式化。

P2 的任務，是第一次把這些形式物件變成一個真正可以運行的世界變換引擎。

本文定義 Global Scale Engine，簡記：

$$
\mathrm{GSE}.
$$

其核心不是把一串數字乘上一個比例，而是對整個 world state 執行同步 transformation：

$$
S_{\lambda,\mathfrak c}:
W
\longrightarrow
W'.
$$

合法的 GSE 必須同時處理：

1. container；
2. center；
3. primitive geometry；
4. derived geometry；
5. metric quantities；
6. constraint graph；
7. gauge state；
8. representation state；
9. arithmetic annotations；
10. invariant verification；
11. transformation ledger；
12. rollback / replay。

因此，GSE 的核心目標可以寫成：

$$
\boxed{
\text{Scale the whole world, not the numbers independently.}
}
$$

P2 並不嘗試解決 Perfect Cuboid 的 exact rational reconstruction。它只完成一個更基礎但必要的問題：

> 如何保證一個世界在縮放前後仍是同一個等價世界，且這件事可以由程式、數學 invariant 與 certificate 同時驗證？

這將成為後續 P3 Synthetic Rational Recovery、P4 Irrational Gate 與 Perfect Cuboid candidate experiments 的共同執行底座。

---

# 1. P2 的核心輸入與輸出

GSE 接收：

$$
(W,\lambda,\Pi_S),
$$

其中：

- $W$：符合 P1 語義的 world；
- $\lambda$：尺度參數；
- $\Pi_S$：scale policy。

輸出：

$$
(W',\mathcal V,\mathcal L),
$$

其中：

- $W'$：縮放後世界；
- $\mathcal V$：verification report；
- $\mathcal L$：transformation ledger entry。

形式上：

$$
\mathrm{GSE}
:
(W,\lambda,\Pi_S)
\mapsto
(W',\mathcal V,\mathcal L).
$$

---

# 2. Scale Policy

定義：

$$
\Pi_S
=
(
\mathsf{anchor},
\mathsf{container},
\mathsf{derived},
\mathsf{precision},
\mathsf{verification},
\mathsf{gauge}
).
$$

各欄位決定：

- 以哪個 center / anchor 縮放；
- container 是否跟著縮放；
- derived quantities 要重新計算或直接依權重縮放；
- 使用何種數值 backend；
- 執行哪些 invariant gate；
- 縮放後是否重新 gauge-fix。

同一個 $\lambda$ 不應隱含不同語義。

因此所有 transformation 必須顯式攜帶 policy。

---

# 3. Center-Relative Scale Action

對 position vector $x$：

$$
S_{\lambda,\mathfrak c}(x)
=
\mathfrak c+\lambda(x-\mathfrak c).
$$

若：

$$
\lambda=1,
$$

則：

$$
S_{1,\mathfrak c}
=
\operatorname{id}.
$$

若：

$$
\lambda>1,
$$

世界相對中心放大。

若：

$$
0<\lambda<1,
$$

世界相對中心縮小。

第一版 GERES 不允許：

$$
\lambda=0,
$$

因為這會把整個非退化世界 collapse 到 center，失去 scale-equivalence invertibility。

若允許：

$$
\lambda<0,
$$

則會額外引入 orientation reversal。

因此 P2 預設 domain：

$$
\lambda\in\mathbb R_{>0}.
$$

---

# 4. Scale Action 的群結構

正實數乘法群：

$$
(\mathbb R_{>0},\cdot)
$$

作用於世界：

$$
S:
\mathbb R_{>0}\times W
\rightarrow
W.
$$

滿足：

$$
S_1(W)=W,
$$

以及：

$$
S_{\lambda_2}(S_{\lambda_1}(W))
=
S_{\lambda_2\lambda_1}(W).
$$

因此：

$$
S_{\lambda}^{-1}
=
S_{1/\lambda}.
$$

這讓 scale engine 天然具有：

- replay；
- inverse；
- rollback；
- orbit tracing。

---

# 5. Scale Orbit

定義世界的尺度軌道：

$$
\mathcal O_S(W)
=
\{
S_\lambda(W)
:
\lambda>0
\}.
$$

在 scale-equivalence 下：

$$
[W]_S
=
\mathcal O_S(W).
$$

因此 GSE 不只是產生另一個幾何體，而是在同一條 orbit 上移動。

可視化軟體後續應直接顯示：

$$
\lambda
\mapsto
S_\lambda(W)
$$

而不是只顯示一個孤立 frame。

---

# 6. Quantity Scale Weights

對每個 quantity $q$ 指派：

$$
\omega(q)\in\mathbb Z.
$$

GSE 執行：

$$
S_\lambda(q)
=
\lambda^{\omega(q)}q.
$$

典型規則：

$$
\omega(\text{coordinate offset})=1,
$$

$$
\omega(\text{length})=1,
$$

$$
\omega(\text{area})=2,
$$

$$
\omega(\text{volume})=3,
$$

$$
\omega(\text{angle})=0,
$$

$$
\omega(\text{length ratio})=0.
$$

如果 quantity 的 scale weight 未定義，P2 原則上應拒絕 silent transformation。

---

# 7. Container Synchronization

## 7.1 數學 Container

若 container 本身只是：

$$
\mathbb R^n,
$$

則其集合不需要改變。

但其 frame、reference bounds、grid scale 或 visualization window 可能需要同步更新。

---

## 7.2 Finite Container

若：

$$
\mathcal C
=
[B_{\min},B_{\max}],
$$

且要求 container 與 world 同步縮放，則：

$$
B'_{\min}
=
\mathfrak c+\lambda(B_{\min}-\mathfrak c),
$$

$$
B'_{\max}
=
\mathfrak c+\lambda(B_{\max}-\mathfrak c).
$$

因此：

$$
S_\lambda(\mathcal C)
$$

必須與：

$$
S_\lambda(W)
$$

共享同一：

$$
(\lambda,\mathfrak c).
$$

---

# 8. Container 與 Viewport 必須分離

可視化程式中容易把：

$$
\mathcal C_{\mathrm{math}}
$$

與：

$$
\mathcal C_{\mathrm{view}}
$$

混淆。

GSE 強制區分：

$$
\mathcal C_{\mathrm{math}}
\neq
\mathcal C_{\mathrm{view}}.
$$

viewport 的 zoom：

$$
Z_{\mathrm{view}}
$$

不能改變 world。

world scaling：

$$
S_\lambda
$$

則必須改變 world。

這是未來 UI 最重要的防錯之一。

---

# 9. Camera Zoom 不是 World Scaling

若畫面做：

$$
\operatorname{Zoom}_{k},
$$

而 world coordinates 不變，則：

$$
W'=W.
$$

反之，GSE 執行：

$$
W'=S_\lambda(W),
$$

即使 viewport 自動調整讓畫面看起來尺寸相同，world state 已發生合法 scale transformation。

因此 UI 必須同時顯示：

$$
\lambda_{\mathrm{world}}
$$

與：

$$
z_{\mathrm{camera}}.
$$

禁止把兩者合併成一個 slider。

---

# 10. Primitive-First 模式

假設 primitive quantities：

$$
\mathcal Q_P
=
\{q_1,\ldots,q_k\}.
$$

GSE 可以先執行：

$$
q_i'
=
\lambda^{\omega_i}q_i.
$$

然後由 generative dependency graph 重算所有 derived quantities：

$$
q_j'
=
f_j(q_{i_1}',\ldots,q_{i_m}').
$$

此模式稱：

$$
\mathrm{PrimitiveFirst}.
$$

優點是可以驗證 dependency functions 本身是否 commute with scale。

---

# 11. All-Quantity 模式

另一模式直接對所有 quantities：

$$
q_i'
=
\lambda^{\omega_i}q_i.
$$

稱：

$$
\mathrm{AllQuantity}.
$$

此模式較快，但若 derived quantity 的 scale weight 或 dependency metadata 錯誤，可能同時把錯誤傳下去。

因此研究模式建議：

$$
\mathrm{PrimitiveFirst}
$$

作主模式，

而：

$$
\mathrm{AllQuantity}
$$

作 cross-check。

---

# 12. Dual Execution

最強驗證模式同時執行：

$$
W_A'
=
S_\lambda^{\mathrm{PrimitiveFirst}}(W),
$$

以及：

$$
W_B'
=
S_\lambda^{\mathrm{AllQuantity}}(W).
$$

理論上應有：

$$
W_A'
=
W_B'
$$

在指定 precision / exact domain 下成立。

若不成立，表示：

- dependency graph 有錯；
- scale weight 有錯；
- formula implementation 有錯；
- numerical precision 不足。

此模式稱：

$$
\mathrm{DualScaleCheck}.
$$

---

# 13. Derived Quantity Commutation Test

若：

$$
q_d
=
f(q_1,\ldots,q_k),
$$

則要求：

$$
S_\lambda(q_d)
=
f(S_\lambda(q_1),\ldots,S_\lambda(q_k)).
$$

也就是 commutative diagram：

$$
\boxed{
S_\lambda\circ f
=
f\circ S_\lambda
}
$$

對每個 derived quantity 都可以自動生成一個單元測試。

---

# 14. Constraint Homogeneity Metadata

每個 constraint：

$$
\phi_i
$$

增加 metadata：

$$
\deg_S(\phi_i).
$$

若：

$$
\phi_i(S_\lambda W)
=
\lambda^{d_i}\phi_i(W),
$$

則：

$$
d_i
=
\deg_S(\phi_i).
$$

對 Perfect Cuboid：

$$
d_i=2.
$$

因此：

$$
\phi_i(W)=0
$$

必然推出：

$$
\phi_i(S_\lambda W)=0.
$$

---

# 15. Constraint Verification Gate

縮放後必須執行兩類檢查。

## Gate A：Exact Preservation

若 source constraint 是 exact：

$$
\phi_i(W)=0,
$$

則要求：

$$
\phi_i(W')=0
$$

在 exact backend 中成立。

## Gate B：Residual Law

若 source 為 floating observation，則檢查：

$$
r_i(W')
\approx
\lambda^{d_i}r_i(W).
$$

這可抓出錯誤 transformation。

---

# 16. Exact Backend

當 quantity 屬於：

$$
\mathbb Z
$$

或：

$$
\mathbb Q,
$$

GSE 應使用 exact arithmetic。

例如：

$$
q=\frac pq
$$

不應先轉成 IEEE float 再縮放。

若：

$$
\lambda\in\mathbb Q,
$$

則：

$$
S_\lambda(q)\in\mathbb Q.
$$

因此 exact rational world 可以沿 rational scale orbit 精確移動。

---

# 17. Floating Backend

對：

$$
\mathbb R_{\mathrm{float}},
$$

需要：

- selectable precision；
- interval envelope；
- residual propagation；
- repeatability。

建議至少提供：

$$
p\in\{53,100,200,500,\ldots\}
$$

bits 或 decimal precision policy。

---

# 18. Interval Backend

若：

$$
q\in[a,b],
$$

且：

$$
\lambda>0,
$$

則：

$$
S_\lambda(q)
\in
[\lambda a,\lambda b]
$$

對 center-relative coordinate 則作用於 interval endpoints 後重新排序。

Interval mode 可以回答：

> 在所有允許 floating uncertainty 下，scale-equivalence invariant 是否仍被包住？

---

# 19. Symbolic Backend

若 quantity 以 symbolic expression 儲存：

$$
q=\sqrt{x^2+y^2},
$$

則 GSE 可選擇保持 symbolic：

$$
q'
=
\sqrt{(\lambda x)^2+(\lambda y)^2}.
$$

再化簡：

$$
q'
=
\lambda\sqrt{x^2+y^2}
$$

對：

$$
\lambda>0.
$$

這是 algorithm-to-theorem compilation 的重要資料。

---

# 20. Arithmetic Annotation 在縮放中的轉移

若：

$$
q\in\mathbb Q
$$

且：

$$
\lambda\in\mathbb Q,
$$

則：

$$
\lambda q\in\mathbb Q.
$$

若：

$$
q\notin\mathbb Q
$$

且：

$$
\lambda\in\mathbb Q^\times,
$$

一般仍有：

$$
\lambda q\notin\mathbb Q.
$$

因此 arithmetic annotation transition 必須遵守可證明規則。

禁止：

$$
\mathrm{Float}
\rightarrow
\mathrm{Rational}
$$

只因為 decimal 看起來更接近整數。

---

# 21. Rationality-Preservation Gate

對已知 arithmetic state，可檢查：

$$
\alpha(q')
=
\mathcal T_\alpha(\alpha(q),\alpha(\lambda)).
$$

例如：

$$
(\mathrm{Rational},\mathrm{Rational})
\mapsto
\mathrm{Rational}.
$$

但：

$$
(\mathrm{Unresolved},\mathrm{Rational})
$$

只能得到：

$$
\mathrm{Unresolved},
$$

不能自動升級成 Rational。

---

# 22. Gauge 與 Scaling

若 world 已固定：

$$
g=1,
$$

直接做：

$$
S_\lambda
$$

會使：

$$
g'=\lambda.
$$

因此 normalized world space 與 physical scale orbit 是不同層。

可以定義：

$$
N(W)
=
\frac{1}{g}W.
$$

則：

$$
N(S_\lambda W)
=
N(W).
$$

因此 normalization map 把整條 scale orbit 壓到同一 shape point。

---

# 23. Gauge Invariance Test

對任意：

$$
\lambda>0,
$$

應檢查：

$$
N(S_\lambda W)
=
N(W)
$$

在 exact world 中完全成立。

這是 GSE 最重要的 regression test 之一。

---

# 24. Shape Fingerprint

定義：

$$
\mathfrak F(W)
=
N(W)
$$

或更一般的 normalized invariant tuple。

例如 Perfect Cuboid：

$$
\mathfrak F_{\mathrm{PC}}(W)
=
\left(
\frac ag,
\frac bg,
\frac cg,
\frac{d_{ab}}g,
\frac{d_{ac}}g,
\frac{d_{bc}}g
\right).
$$

合法 global scaling 必須保持：

$$
\mathfrak F(S_\lambda W)
=
\mathfrak F(W).
$$

這可以視為世界的 scale fingerprint。

---

# 25. Perfect Cuboid 的 GSE

輸入：

$$
W_{\mathrm{PC}}
=
(a,b,c,d_{ab},d_{ac},d_{bc},g).
$$

GSE 作用：

$$
S_\lambda(W_{\mathrm{PC}})
=
(
\lambda a,
\lambda b,
\lambda c,
\lambda d_{ab},
\lambda d_{ac},
\lambda d_{bc},
\lambda g
).
$$

constraint residuals：

$$
r_{ab}
=
a^2+b^2-d_{ab}^2,
$$

因此：

$$
r'_{ab}
=
\lambda^2r_{ab}.
$$

其餘同理。

---

# 26. Centered Vertex Representation

若採用八頂點 representation：

$$
v_{\epsilon_1\epsilon_2\epsilon_3}
=
\left(
\epsilon_1\frac a2,
\epsilon_2\frac b2,
\epsilon_3\frac c2
\right),
$$

其中：

$$
\epsilon_i\in\{-1,+1\},
$$

則：

$$
S_{\lambda,0}(v)
=
\lambda v.
$$

所有：

- edges；
- face diagonals；
- body diagonals；

會自動同步。

這是最適合可視化世界模型的 representation。

---

# 27. 非原點中心

若 world center：

$$
\mathfrak c
\neq0,
$$

則：

$$
v'
=
\mathfrak c+\lambda(v-\mathfrak c).
$$

邊向量：

$$
e_{ij}
=
v_i-v_j
$$

會變成：

$$
e_{ij}'
=
\lambda e_{ij}.
$$

因此：

$$
\|e_{ij}'\|
=
\lambda\|e_{ij}\|.
$$

中心平移本身不影響尺度 law。

---

# 28. 中心也可能移動

若 transformation policy 包含新的 world placement：

$$
\mathfrak c
\mapsto
\mathfrak c',
$$

則可以寫成：

$$
x'
=
\mathfrak c'
+
\lambda(x-\mathfrak c).
$$

這是：

$$
\text{scale}
+
\text{translation}.
$$

第一版 GSE 可支援，但應把 translation 與 scaling ledger 分開。

---

# 29. Rotation Composition

更一般的 similarity transformation：

$$
x'
=
\mathfrak c'
+
\lambda R(x-\mathfrak c),
$$

其中：

$$
R^\top R=I.
$$

P2 主核心仍是：

$$
R=I.
$$

但 software architecture 應預留 $R$，讓後續升級到 full similarity engine。

---

# 30. Transactional Transformation

GSE 不應邊改 world 邊驗證。

建議採 transaction：

$$
W
\rightarrow
W_{\mathrm{candidate}}'
\rightarrow
\mathrm{Verify}
\rightarrow
\mathrm{Commit}.
$$

若 verification fail：

$$
\mathrm{Rollback}.
$$

形式：

$$
\boxed{
\text{prepare}
\rightarrow
\text{transform}
\rightarrow
\text{validate}
\rightarrow
\text{commit}
}
$$

這與正式數學 source「validate before commit」原則一致。

---

# 31. Immutable Source State

每次 transformation 前保留：

$$
H(W)
$$

作為 source hash。

transformation 完成後保存：

$$
H(W').
$$

ledger entry：

$$
\ell
=
(
H(W),
\lambda,
\Pi_S,
H(W'),
\mathcal V
).
$$

因此任何結果都能 replay。

---

# 32. Determinism

在同一：

$$
(W,\lambda,\Pi_S,p)
$$

下，GSE 應盡可能 deterministic。

對 exact backend，要求：

$$
\mathrm{GSE}(x)
=
\mathrm{GSE}(x)
$$

bit-for-bit canonical serialization identical。

對 floating backend，至少要求 tolerance-stable result。

---

# 33. Invariant Registry

定義：

$$
\mathcal I
=
\{
I_1,\ldots,I_k
\}.
$$

每個 invariant 包含：

$$
I_j
=
(
\mathrm{name},
\mathrm{scope},
\mathrm{evaluator},
\mathrm{mode},
\mathrm{tolerance}
).
$$

例如：

$$
I_1
=
\frac ab.
$$

exact world 中：

$$
I_1(W')=I_1(W).
$$

floating world 中：

$$
|I_1(W')-I_1(W)|\le\epsilon.
$$

---

# 34. Invariant Classes

GSE 至少追蹤：

### Structural

$$
I_{\mathrm{struct}}.
$$

### Topological

$$
I_{\mathrm{topo}}.
$$

### Angular

$$
I_{\theta}.
$$

### Ratio

$$
I_{\mathrm{ratio}}.
$$

### Normalized Shape

$$
I_{\mathrm{shape}}.
$$

### Constraint Closure Pattern

$$
I_{\mathrm{closure}}.
$$

---

# 35. Closure Vector 在 Scaling 下

若：

$$
\operatorname{ClosureVector}(W)
=
(c_1,\ldots,c_m),
$$

純合法 global scaling 不應改變 exact arithmetic closure status。

因此：

$$
\operatorname{ClosureVector}(S_\lambda W)
=
\operatorname{ClosureVector}(W)
$$

只要 $\lambda$ 屬於不改變指定 arithmetic domain 的合法尺度。

例如對 rational closure，要求：

$$
\lambda\in\mathbb Q^\times.
$$

---

# 36. 一個重要反例

假設：

$$
q=\sqrt2.
$$

取：

$$
\lambda=10^6.
$$

得到：

$$
q'
=
10^6\sqrt2.
$$

它可能在有限 decimal 顯示下非常接近某個 integer。

但：

$$
q'\notin\mathbb Q.
$$

因此：

$$
\text{visual integer proximity}
$$

不是：

$$
\text{arithmetic closure}.
$$

GSE 必須把這個反例內建成 regression test。

---

# 37. Scale Sweep

P2 可支援：

$$
\Lambda
=
\{\lambda_1,\ldots,\lambda_N\}.
$$

執行：

$$
W_i=S_{\lambda_i}(W).
$$

但這個 sweep 的目的不是找某個「看起來最整數」的比例。

合法目的包括：

- 測試 invariants；
- 測試 numerical stability；
- 觀察 representation error；
- 分析 denominator growth；
- 對照不同 backend。

---

# 38. Log-Scale Orbit

因為 $\lambda$ 可跨巨大範圍，可定義：

$$
s=\log\lambda.
$$

則：

$$
\lambda=e^s.
$$

scale orbit 變成：

$$
s\in\mathbb R.
$$

而 composition：

$$
s_{\mathrm{total}}
=
s_1+s_2.
$$

可視化 slider 可以使用 log-space，避免：

$$
10^{-9}
$$

到：

$$
10^9
$$

時操作不穩。

---

# 39. Scale Velocity

若引入動畫時間 $t$：

$$
\lambda=\lambda(t),
$$

則：

$$
x(t)
=
\mathfrak c+\lambda(t)(x_0-\mathfrak c).
$$

導數：

$$
\dot x(t)
=
\dot\lambda(t)(x_0-\mathfrak c).
$$

這只是 visualization dynamics，不代表 physical dynamics。

UI 必須標示：

$$
\text{kinematic visualization only}.
$$

---

# 40. Continuous Scale Animation

一個理想的 scale animation 使用：

$$
\lambda(t)
=
e^{st}.
$$

則：

$$
\lambda(t_1+t_2)
=
\lambda(t_1)\lambda(t_2).
$$

視覺上可以連續觀察世界從中心展開或收縮。

但所有 exact verification 應只在離散 sampled states 執行。

---

# 41. Scale Engine Pseudocode

```text
function global_scale(world, lambda, policy):
    assert lambda > 0

    source = immutable_copy(world)
    candidate = clone(world)

    resolve_center(candidate, policy)
    resolve_scale_weights(candidate)

    if policy.container == "coupled":
        scale_container(candidate, lambda)

    if policy.mode == "primitive_first":
        scale_primitives(candidate, lambda)
        recompute_derived(candidate)

    else if policy.mode == "all_quantity":
        scale_all_quantities(candidate, lambda)

    update_geometry(candidate)
    update_representation(candidate)

    verification = verify_scale_equivalence(
        source,
        candidate,
        lambda,
        policy
    )

    if verification.pass:
        append_ledger(source, candidate, verification)
        return commit(candidate)
    else:
        return rollback_with_report(source, verification)
```

---

# 42. Verification Pseudocode

```text
function verify_scale_equivalence(W0, W1, lambda, policy):
    check_object_identity_map()
    check_relation_preservation()
    check_scale_weight_laws()
    check_derived_commutation()
    check_constraint_homogeneity()
    check_normalized_shape()
    check_dimensionless_invariants()
    check_arithmetic_transition_rules()
    check_gauge_policy()
    return report
```

---

# 43. Exact Perfect Cuboid Unit Test

建立已知 rectangular box：

$$
(a,b,c)=(3,4,12).
$$

則：

$$
d_{ab}=5,
$$

$$
d_{ac}=\sqrt{153},
$$

$$
d_{bc}=4\sqrt{10},
$$

$$
g=13.
$$

雖然不是 Perfect Cuboid，但幾何 constraints exact。

取：

$$
\lambda=7.
$$

得到：

$$
(21,28,84).
$$

應有：

$$
d_{ab}'=35,
$$

$$
d_{ac}'=7\sqrt{153},
$$

$$
d_{bc}'=28\sqrt{10},
$$

$$
g'=91.
$$

全部 constraints exact 保持。

這是 geometry preservation test，不是 arithmetic Perfect Cuboid test。

---

# 44. Rational World Unit Test

選一個所有 tracked ratios 為 rational 的 2D 或 3D synthetic world。

例如 3-4-5 triangle：

$$
(3,4,5).
$$

取：

$$
\lambda=\frac{7}{3}.
$$

得到：

$$
\left(
7,
\frac{28}{3},
\frac{35}{3}
\right).
$$

仍然：

$$
3^2+4^2=5^2
$$

的 scale-equivalent rational representative。

再取：

$$
\lambda=3
$$

即可 integralize。

---

# 45. Irrational World Unit Test

使用：

$$
(1,1,\sqrt2).
$$

不論 rational：

$$
\lambda\neq0
$$

如何作用，

都不能讓：

$$
\sqrt2
$$

成為 rational ratio。

此測試應保證 arithmetic annotation 不被錯誤升級。

---

# 46. Floating Drift Test

對同一 world 連續做：

$$
S_{\lambda_1},
S_{\lambda_2},
\ldots,
S_{\lambda_n}
$$

再做 inverse：

$$
S_{1/(\lambda_1\cdots\lambda_n)}.
$$

exact backend 必須回到完全相同 state。

floating backend 則量測：

$$
D_{\mathrm{roundtrip}}.
$$

這可以直接測試 numerical drift。

---

# 47. One-Step vs Multi-Step Test

群作用要求：

$$
S_{\lambda_2}
(
S_{\lambda_1}(W)
)
=
S_{\lambda_1\lambda_2}(W).
$$

因此對 exact backend 應：

$$
W_{\mathrm{multi}}
=
W_{\mathrm{single}}.
$$

對 floating backend量測：

$$
D(
W_{\mathrm{multi}},
W_{\mathrm{single}}
).
$$

---

# 48. Gauge Roundtrip Test

對任意：

$$
W,
$$

取：

$$
W'
=
S_\lambda(W).
$$

要求：

$$
N(W')=N(W).
$$

如果 normalized world 產生差異，表示：

- scale engine 錯；
- normalization 錯；
- precision 不足；
- metadata 錯。

---

# 49. Perfect Cuboid Candidate 的 P2 使用方式

對目前 floating candidate：

$$
\widetilde W_{\mathrm{PC}},
$$

P2 不問：

> 它能不能被縮成整數？

P2 只問：

1. scale orbit 是否正確生成；
2. normalized fingerprint 是否完全穩定；
3. residual 是否按：

$$
\lambda^2
$$

縮放；
4. closure vector 是否沒有被假性改變；
5. floating representation 在極端尺度下是否產生 numerical artifacts。

這些結果將直接告訴 P3／後續 reconstruction engine：

> 哪些 apparent arithmetic patterns 是世界本身的，哪些只是 representation scale 的幻象。

---

# 50. World-Equivalent Scaling Lab

P2 同時定義第一版 WESL 視覺工具。

介面分成五個視區。

## View A：World

顯示 container、center、geometry。

## View B：Scale Orbit

顯示：

$$
\lambda
$$

與 log scale：

$$
s=\log\lambda.
$$

## View C：Invariant Panel

即時顯示：

$$
I_j(W)
$$

與：

$$
I_j(W').
$$

## View D：Constraint Panel

顯示：

$$
\phi_i(W),
$$

$$
\phi_i(W'),
$$

以及 expected scale law。

## View E：Arithmetic State

顯示每個 quantity 的：

- domain；
- exact / float；
- rational status；
- denominator；
- closure status。

---

# 51. UI 的「喀一聲」必須重新定義

未來可視化確實可以保留「喀一聲」或 snap feedback。

但只有以下情況才允許出現 **Exact Lock**：

$$
\operatorname{Closed}_{\mathbb A}(W)
=
\mathrm{True}.
$$

若只是：

$$
|q-n|<\epsilon,
$$

只能顯示：

**Visual Near-Lock**

不能顯示：

**Exact Lock**。

這個 UI 規則非常重要，因為它直接避免把人類視覺直覺當成數學證明。

---

# 52. Dual Color / State Semantics

每個 quantity 可採狀態標示：

- Observed Float；
- Interval；
- Exact Rational；
- Exact Integer；
- Unresolved；
- Constraint Failed。

但顏色只屬於 UI。

Canonical state 必須保留文字或 enum：

$$
\mathrm{ArithmeticState}.
$$

不能讓顏色成為唯一語義。

---

# 53. Transformation Ledger UI

每次 world scale 顯示：

$$
\lambda,
$$

source hash，

target hash，

policy，

verification result。

使用者可以：

- replay；
- inverse；
- compare；
- branch。

這讓 WESL 不只是動畫，而是一個小型 world experiment runtime。

---

# 54. Branching Worlds

允許從：

$$
W_0
$$

建立：

$$
W_1=S_{\lambda_1}(W_0),
$$

以及：

$$
W_2=S_{\lambda_2}(W_0).
$$

world history 變成 DAG：

$$
\mathcal G_H.
$$

不同 scale branches 理論上都屬同一：

$$
[W_0]_S.
$$

這可以測試 canonicalization 是否真正把它們重新合併。

---

# 55. Canonical Merge Test

若：

$$
W_1\sim_sW_2,
$$

則：

$$
\kappa(W_1)
=
\kappa(W_2).
$$

這是 P2 到 P3 的橋樑。

scale engine 負責生成多個 representatives；

canonicalizer 負責證明它們最後回到同一 canonical world。

---

# 56. Scale Engine 的錯誤類型

建議定義：

$$
\mathrm{GSEError}
$$

至少包括：

- InvalidScale；
- UndefinedScaleWeight；
- GaugeSingularity；
- DerivedMismatch；
- ConstraintViolation；
- InvariantViolation；
- ArithmeticStateConflict；
- ContainerPolicyConflict；
- PrecisionInsufficient；
- NonDeterministicReplay。

---

# 57. Precision Insufficient 不是 Constraint Failed

如果 floating backend 無法分辨：

$$
r=0
$$

與：

$$
|r|<10^{-p},
$$

應回傳：

$$
\mathrm{PrecisionInsufficient}
$$

而不是：

$$
\mathrm{ConstraintPassed}.
$$

這一規則後續對 Perfect Cuboid 浮點候補尤其重要。

---

# 58. Scale Stress Test

選：

$$
\lambda
\in
\{
10^{-100},
10^{-50},
10^{-10},
1,
10^{10},
10^{50},
10^{100}
\}.
$$

測試：

- overflow；
- underflow；
- normalization；
- residual law；
- invariant stability；
- interval propagation。

exact symbolic / rational backend 應能避免大部分浮點問題。

---

# 59. Randomized Property Testing

對隨機：

$$
\lambda_1,\lambda_2>0,
$$

測：

$$
S_{\lambda_1\lambda_2}(W)
=
S_{\lambda_1}(S_{\lambda_2}(W)).
$$

以及：

$$
N(S_\lambda W)=N(W).
$$

這類 property-based testing 比只寫幾個固定案例更適合世界變換引擎。

---

# 60. Metamorphic Testing

即使不知道某個 candidate 的 exact答案，也可以測 metamorphic relations。

例如：

$$
W'
=
S_\lambda(W)
$$

之後：

$$
\frac{a'}{g'}
=
\frac ag.
$$

若失敗，scale engine 一定有錯。

這種測試特別適合未知 Perfect Cuboid candidate。

---

# 61. GSE 與 GER 的邊界

P2 必須保持：

$$
\mathrm{GSE}
\neq
\mathrm{GER}.
$$

GSE 已知 $W$，只改變其等價 representative。

GER 面對：

$$
\widetilde W
$$

要推斷：

$$
W^\ast.
$$

因此：

$$
\mathrm{GSE}
$$

是 deterministic transformation engine，

而：

$$
\mathrm{GER}
$$

是 constrained reconstruction engine。

---

# 62. GSE 為何仍是 GER 的必要前置

因為 reconstruction engine 必須知道：

> 哪些改變只是 scale orbit，哪些改變才是真的 shape / arithmetic change？

若沒有 GSE / quotient semantics，GER 很容易把同一 solution 的無限多 scale representatives 當成不同候選。

因此：

$$
\boxed{
\mathrm{GSE}
\rightarrow
\text{scale quotient}
\rightarrow
\mathrm{GER}
}
$$

是合理順序。

---

# 63. P2 的主要命題

### 命題 P2-A：Scale Group Action

在 $\lambda>0$ 下，GSE 的 ideal exact action 構成：

$$
\mathbb R_{>0}
$$

對 admissible world space 的群作用。

### 命題 P2-B：Normalized Fingerprint Invariance

若 normalization 合法，則：

$$
\mathfrak F(S_\lambda W)
=
\mathfrak F(W).
$$

### 命題 P2-C：Constraint Degree Law

對 scale-homogeneous constraint：

$$
\phi_i(S_\lambda W)
=
\lambda^{d_i}\phi_i(W).
$$

### 命題 P2-D：Exact Closure Preservation

若：

$$
W
$$

在 arithmetic domain $\mathbb A$ exact closed，且 $\lambda$ 是 $\mathbb A$ 內可逆的合法 scale，則：

$$
S_\lambda(W)
$$

仍在同一 arithmetic closure class。

### 命題 P2-E：Scaling Cannot Repair Shape Arithmetic

若某 dimensionless invariant 不屬於目標 arithmetic domain，單純 global scaling 不會改變該 invariant 的 arithmetic status。

---

# 64. P2-E 對 Perfect Cuboid 的直接含義

若：

$$
\frac{d_{ab}}g
\notin\mathbb Q,
$$

則取任意 rational：

$$
\lambda\neq0
$$

仍有：

$$
\frac{\lambda d_{ab}}{\lambda g}
=
\frac{d_{ab}}g
\notin\mathbb Q.
$$

因此：

$$
\boxed{
\text{真正要被 GER 找到的是另一個 exact source representative，不是靠 GSE 把 irrational ratio 變 rational。}
}
$$

這正是 P0 最重要的安全邊界，在 P2 中變成可執行 invariant gate。

---

# 65. 軟體模組架構

建議：

```text
geres/
├── world/
│   ├── model
│   ├── object_graph
│   ├── constraint_graph
│   └── arithmetic_state
├── transform/
│   ├── scale
│   ├── normalize
│   ├── canonicalize
│   └── similarity
├── verify/
│   ├── invariants
│   ├── constraints
│   ├── arithmetic
│   └── metamorphic
├── numeric/
│   ├── float
│   ├── interval
│   ├── rational
│   └── symbolic
├── ledger/
│   ├── transaction
│   ├── replay
│   └── certificate
└── ui/
    ├── world_view
    ├── orbit_view
    ├── constraint_view
    └── arithmetic_view
```

---

# 66. Canonical API 草案

```text
scale_world(
    world,
    lambda,
    policy
) -> ScaleResult
```

```text
normalize_world(
    world,
    gauge
) -> NormalizedWorld
```

```text
verify_equivalence(
    source,
    target,
    relation
) -> VerificationReport
```

```text
compare_fingerprint(
    world_a,
    world_b
) -> FingerprintReport
```

```text
replay_transformation(
    ledger_entry
) -> World
```

---

# 67. ScaleResult

```text
ScaleResult
├── status
├── source_world_id
├── target_world_id
├── lambda
├── policy
├── transformed_world
├── invariant_report
├── constraint_report
├── arithmetic_report
├── ledger_entry
└── errors[]
```

---

# 68. Verification Report

核心欄位：

```text
VerificationReport
├── structural_pass
├── relation_pass
├── scale_weight_pass
├── derived_commutation_pass
├── constraint_law_pass
├── normalized_fingerprint_pass
├── arithmetic_transition_pass
├── roundtrip_pass
└── final_status
```

final_status 只能是：

- PASS；
- FAIL；
- INCONCLUSIVE。

---

# 69. INCONCLUSIVE 是第一級結果

GERES 不應只有 true / false。

若因 precision、missing metadata、unknown arithmetic state 無法決定，就必須回：

$$
\mathrm{INCONCLUSIVE}.
$$

這比「猜一個結果」更適合之後的 theorem extraction。

---

# 70. 與既有 Perfect Cuboid 可視化程式的改造關係

若已有：

- X-Diagonal Sandbox；
- centered cuboid renderer；
- floating candidate loader；

則 P2 不需要重寫幾何 renderer。

應新增：

1. World Adapter；
2. Scale Engine；
3. Normalization Layer；
4. Constraint Registry；
5. Invariant Monitor；
6. Arithmetic State Panel；
7. Ledger；
8. Exact / Float Backend Switch。

也就是：

$$
\text{Visualizer}
\rightarrow
\text{World Runtime}.
$$

---

# 71. P2 最小可行實作 MVP

第一個 MVP 只需要：

### MVP-1

載入一個 cuboid world。

### MVP-2

以 center 為 anchor 做 global scaling。

### MVP-3

顯示七個 tracked lengths。

### MVP-4

即時計算四個 constraints。

### MVP-5

顯示 normalized fingerprint。

### MVP-6

做 source / target equivalence check。

### MVP-7

保存 transformation ledger。

### MVP-8

支援 inverse scale。

做到 MVP-8 就已足以進 P3。

---

# 72. P2 驗收條件

P2 不以「畫面看起來正常」作為完成。

必須至少通過：

1. identity test；
2. composition test；
3. inverse test；
4. derived commutation test；
5. constraint degree test；
6. gauge invariance test；
7. rationality non-creation test；
8. floating roundtrip test；
9. extreme scale stress test；
10. deterministic replay test。

---

# 73. Perfect Cuboid Benchmark 驗收

對任意合法 cuboid world：

$$
W,
$$

以及任意：

$$
\lambda>0,
$$

若 exact backend 可表示，要求：

$$
\phi_i(W)=0
\Longrightarrow
\phi_i(S_\lambda W)=0.
$$

並要求：

$$
\mathfrak F(W)
=
\mathfrak F(S_\lambda W).
$$

若 source 有 partial closure vector：

$$
C(W),
$$

對 rational $\lambda$ 應有：

$$
C(S_\lambda W)=C(W).
$$

---

# 74. P2 不宣稱的事情

P2 不宣稱：

- scaling 可以產生 Perfect Cuboid；
- floating candidate 對應 exact rational world；
- 某個 $\lambda$ 能修復 irrational ratio；
- visual snap 是 arithmetic proof；
- 近整數表示具有 theorem significance。

P2 只建立：

$$
\boxed{
\text{合法、可逆、可驗證的 world-equivalent scale transformation。}
}
$$

---

# 75. P2 與下一階段的交界

完成 GSE 後，我們第一次擁有一個可以回答下列問題的實驗平台：

> 同一個 world 在不同尺度 representation 下，哪些模式永遠不變？

下一階段 P3 則反過來問：

> 若一個 known exact rational world 被投影成 floating observation，我們能不能從 observation 把 exact source world 找回來？

因此：

$$
\boxed{
\mathrm{P2}:
W^\ast
\rightarrow
\widetilde W_\lambda
}
$$

而：

$$
\boxed{
\mathrm{P3}:
\widetilde W
\rightarrow
W^\ast
}
$$

P2 是 forward engine。

P3 是 inverse reconstruction experiment。

---

# 76. 結論

GERES P2 把「全域等價縮放」從一句幾何直覺變成可執行 world transformation contract。

核心 transformation：

$$
S_{\lambda,\mathfrak c}(x)
=
\mathfrak c+\lambda(x-\mathfrak c)
$$

本身很簡單。

真正重要的是它必須同時作用在：

$$
\boxed{
\mathcal C,
\mathfrak c,
\mathcal O,
\mathcal R,
\mathcal M,
\Phi,
\Gamma,
R_W,
A_W
}
$$

並經過 invariant、constraint、arithmetic 與 replay gate 驗證。

因此 P2 的真正產物不是：

$$
x\mapsto\lambda x,
$$

而是：

$$
\boxed{
\text{World-Preserving Transformation Runtime}.
}
$$

這讓我們之後可以很乾淨地區分：

$$
\text{world scaling}
$$

與：

$$
\text{arithmetic reconstruction},
$$

並最終研究：

$$
\boxed{
\text{一個 floating world 是否來自某個 exact arithmetic world？}
}
$$

---

## 下一階段

**GERES P3 — Synthetic Rational Recovery**

下一階段將第一次反轉方向。

先由我們自己生成：

$$
W^\ast\in\mathbb Q^n,
$$

再製造：

$$
\widetilde W
=
\rho_p(W^\ast)+\epsilon,
$$

最後測試：

$$
\mathrm{GER}(\widetilde W)
\stackrel{?}{=}
W^\ast.
$$

在 known-answer control 上成功以前，不直接把未知 Perfect Cuboid floating candidate 當成成功案例。

這會是 GERES 從「世界變換」真正跨入「世界重建」的第一步。
