# DMSD Generalized Formal Core v1
## Multiscale Serializable Mathematical Domain — Property-Independent Formalization

**版本：** v1.0  
**日期：** 2026-09-30  
**性質：** Generalized Formal Core  
**定位：** 將 DMSD 從 decimal/prime-specific prototype 抽象為 property-independent runtime framework

---

# 1. 核心目的

DMSD 的核心不再定義成：

> 用十進制金字塔看質數。

而定義成：

> **對理論可無界、實際必須有限運算的數學域，建立可序列化尺度、局部解析度、知識狀態、property summary、source depth 與 budget policy 的統一 runtime。**

因此：

\[
\boxed{
\text{DMSD Core}
\neq
\text{Prime Model}.
}
\]

Prime 只是一個壓力測試插件。

---

# 2. Core Object

DMSD v1 暫定為：

\[
\boxed{
\mathfrak D
=
(
\mathcal G,
\mathcal B,
\mathcal R,
\mathcal L,
\mathcal K,
\mathcal A,
\mathcal M,
\mathcal F,
\Pi,
\mathcal H
)
}
\]

其中：

- \(\mathcal G\)：Scale Grammar；
- \(\mathcal B\)：Block Space；
- \(\mathcal R\)：Refinement Operators；
- \(\mathcal L\)：Property Layers；
- \(\mathcal K\)：Knowledge States；
- \(\mathcal A\)：Summary Algebras；
- \(\mathcal M\)：Baseline / Residual Models；
- \(\mathcal F\)：Source-Efficiency Frontiers；
- \(\Pi\)：Budgeted Source Policies；
- \(\mathcal H\)：Provenance / History。

---

# 3. Scale Grammar

定義：

\[
\mathcal G=(I,\gamma,\preceq),
\]

其中：

- \(I\)：scale index set；
- \(\gamma(k)\)：第 \(k\) 層對應的 domain block；
- \(\preceq\)：scale ordering。

Decimal 只是：

\[
\gamma_{10}(k)
=
[10^k,10^{k+1}).
\]

Binary、octal、hex、adaptive scale 都只是不同：

\[
\mathcal G.
\]

所以：

\[
\boxed{
\text{Scale Grammar}
\neq
\text{Mathematical Ontology}.
}
\]

---

# 4. Block

一個 block：

\[
\boxed{
B
=
(
g,
k,
[a,b),
\rho,
\eta,
\pi_B
)
}
\]

其中：

- \(g\)：scale grammar；
- \(k\)：scale index；
- \([a,b)\)：實際 domain region；
- \(\rho\)：resolution depth；
- \(\eta\)：source depth；
- \(\pi_B\)：refinement path。

因此：

\[
\boxed{
\rho
\neq
\eta.
}
\]

Spatial / resolution refinement 與 source / epistemic refinement 是兩個獨立軸。

---

# 5. Refinement Operator

對 block：

\[
B,
\]

refinement：

\[
\mathcal R(B)
=
(B_1,\ldots,B_m)
\]

必須滿足：

\[
B
=
\bigsqcup_{i=1}^{m}B_i.
\]

也就是：

### Coverage

\[
\bigcup_i B_i=B.
\]

### Disjointness

\[
B_i\cap B_j=\varnothing
\qquad i\neq j.
\]

### Order Preservation

若 domain 有序：

\[
b_i=a_{i+1}.
\]

---

# 6. Property Layer

任意 property / mathematical task \(Q\) 以插件形式註冊：

\[
\boxed{
\mathfrak P_Q
=
(
Q,
\Sigma_Q,
\sigma_Q,
\oplus_Q,
\Gamma_Q
)
}
\]

其中：

- \(Q\)：property / target；
- \(\Sigma_Q\)：summary state space；
- \(\sigma_Q(B)\)：block summarizer；
- \(\oplus_Q\)：summary merge algebra；
- \(\Gamma_Q\)：certificate / admission rules。

---

# 7. Summary Algebra

若：

\[
B=\bigsqcup_iB_i
\]

且 children summaries 都具有足夠 exactness，

則要求：

\[
\boxed{
\sigma_Q(B)
=
\bigoplus_i\sigma_Q(B_i).
}
\]

這是 DMSD 最核心的 algebraic invariant 之一。

例：

### Parity

\[
\Sigma_Q=(O,E)
\]

\[
(O,E)
=
\sum_i(O_i,E_i).
\]

### Residue

\[
\Sigma_Q=
(C_0,\ldots,C_{m-1}).
\]

### Square

\[
\Sigma_Q=
(C,q_{\min},q_{\max}).
\]

其 merge 不是單純 vector sum，
而是：

```text
count = sum
first = first nonempty child first
last = last nonempty child last
```

所以：

\[
\boxed{
\oplus_Q
}
\]

可以是任意已註冊、可驗證的 merge algebra。

---

# 8. Knowledge State

DMSD v1 定義：

```text
UNKNOWN
ESTIMATED
PROBABLE
EXACT_COMPUTED
EXACT_MERGED
EXACT_CERTIFIED
```

這些狀態不是單純「真假值」。

它們描述的是：

\[
\boxed{
\text{Epistemic Admission State}.
}
\]

---

# 9. Exact States

Exact family：

\[
\mathcal K_{\rm exact}
=
\{
\texttt{EXACT\_COMPUTED},
\texttt{EXACT\_MERGED},
\texttt{EXACT\_CERTIFIED}
\}.
\]

它們在 target semantics 上都要求 exact，
差異在 provenance：

- direct computation；
- exact child composition；
- proof / certificate。

---

# 10. No False Closure Axiom

若存在任何 child：

\[
K(B_i)\notin\mathcal K_{\rm exact},
\]

則不能僅靠 exact merge rule 把 parent 升格為：

\[
\texttt{EXACT\_MERGED}.
\]

形式上：

\[
\boxed{
\exists i:
K(B_i)\notin\mathcal K_{\rm exact}
\Rightarrow
K_{\rm merge}(B)\neq
\texttt{EXACT\_MERGED}.
}
\]

這是：

\[
\boxed{
\textbf{No False Closure Axiom}.
}
\]

---

# 11. Baseline / Residual Model

若 property observation：

\[
O(B)
\]

具有已知 reference structure，
可註冊 baseline：

\[
\beta(B).
\]

residual：

\[
\boxed{
R(B;\beta)
=
\Delta(O(B),\beta(B)).
}
\]

其中：

\[
\Delta
\]

可依 task 是：

- subtraction；
- normalized residual；
- likelihood residual；
- divergence；
- certificate gap。

所以 residual 永遠是：

\[
\boxed{
\text{baseline-relative}.
}
\]

不能脫離 baseline provenance 單獨解讀。

---

# 12. Baseline–Source Compatibility

若 source depth：

\[
\eta
\]

增加，
source 可能逐漸吸收 baseline 已解釋的資訊。

因此 baseline 應寫成：

\[
\beta_\eta
\]

而不是固定：

\[
\beta.
\]

DMSD 要求檢查：

\[
\boxed{
\text{Baseline Compatibility}
(
\beta,\eta
).
}
\]

若 source 已包含相同 effect，
則 baseline 必須：

- 重校準；
- 弱化；
- 或移除。

---

# 13. Source Family

定義 nested source family：

\[
\mathcal S_\eta.
\]

若 source depth 有 ordering：

\[
\eta_1\preceq\eta_2,
\]

通常希望：

\[
\mathcal S_{\eta_2}
\]

包含至少不弱於：

\[
\mathcal S_{\eta_1}
\]

的 task information。

但 DMSD 不要求所有 source family 必須 nested；
nested 只是 Phase 3 prime-divisibility 實驗的一種常見情況。

---

# 14. Source Gain

對 source depth：

\[
\eta,
\]

定義 task-specific gain：

\[
G(\eta).
\]

它可以是：

- ambiguity reduction；
- uncertainty reduction；
- certificate completion；
- residual reduction；
- exact coverage；
- task loss reduction。

因此：

\[
\boxed{
G
}
\]

不是固定只能表示 prime candidate elimination。

---

# 15. Source Burden

定義：

\[
C(\eta).
\]

它可以量：

- operation count；
- wall-clock；
- memory；
- source predicates；
- certificate bytes；
- verifier cost；
- energy；
- external query cost。

因此 source frontier 是：

\[
\boxed{
\mathcal F
=
\{
(C(\eta),G(\eta))
\}.
}
\]

---

# 16. Source-Efficiency Frontier

若兩個 source options：

\[
\eta_1,\eta_2
\]

滿足：

\[
C(\eta_1)\le C(\eta_2)
\]

且：

\[
G(\eta_1)\ge G(\eta_2),
\]

至少一個 strict，

則：

\[
\eta_2
\]

被支配。

保留所有 nondominated source options：

\[
\boxed{
\operatorname{Pareto}(\mathcal F).
}
\]

---

# 17. Budgeted Source Policy

對 blocks：

\[
B_1,\ldots,B_m,
\]

每個 block 有自己的 source menu：

\[
\mathcal F_i.
\]

給定 task weights：

\[
w_i
\]

以及 budget：

\[
B,
\]

求：

\[
\boxed{
\max_{\eta_1,\ldots,\eta_m}
\sum_iw_iG_i(\eta_i)
}
\]

subject to：

\[
\boxed{
\sum_iC_i(\eta_i)\le B.
}
\]

輸出：

\[
\Pi_B
=
(\eta_1,\ldots,\eta_m).
\]

---

# 18. Lazy Source Depth

因此 source depth 是 block-local：

\[
\boxed{
\eta_i
}
\]

而不是 global constant。

這形成：

\[
\boxed{
\text{Lazy Source Depth}.
}
\]

與：

\[
\boxed{
\text{Lazy Resolution}.
}
\]

並列。

---

# 19. DMSD 三種 LOD

v1 正式區分：

## Spatial LOD

\[
\rho
\]

看多細。

## Mathematical LOD

\[
\sigma_Q
\]

summary 有多豐富。

## Source LOD

\[
\eta
\]

知道多深／驗證多深。

因此：

\[
\boxed{
\text{DMSD LOD}
=
(\rho,\Sigma_Q,\eta).
}
\]

---

# 20. Projection Layer

visualization 不得直接等同 core ontology。

Projection：

\[
V:
\mathfrak D
\to
\mathcal Y.
\]

例如：

- Pyramid；
- Staircase；
- histogram；
- frontier chart。

都只是：

\[
\boxed{
\text{Observation Projection}.
}
\]

換 projection 不應改變 underlying block / property state。

---

# 21. Provenance

任何非 trivial state 必須能回答：

```text
where did this value come from?
what scale?
what resolution?
what source depth?
which property layer?
which baseline?
which method?
which certificate?
which parent / children?
```

因此：

\[
\mathcal H
\]

不是附加 metadata，
而是 DMSD Core 的正式成員。

---

# 22. DMSD v1 Core Axioms

---

## A1 — Partition Soundness

\[
B=\bigsqcup_iB_i.
\]

---

## A2 — Scale Extensibility

只要 scale grammar 定義下一層生成規則，
有限 runtime 不限制理論域繼續延伸。

---

## A3 — Exact Summary Composition

若 property layer 宣告 merge algebra，
則 exact children 必須可被 verifier 重組回 exact parent summary。

---

## A4 — No False Closure

非 exact child 不得靠 merge 偷渡 exact parent。

---

## A5 — Projection Separation

\[
\text{Projection Change}
\not\Rightarrow
\text{Ontology Change}.
\]

---

## A6 — Baseline Relativity

residual 必須綁定 baseline provenance。

---

## A7 — Baseline–Source Compatibility

source depth 改變後，
baseline validity 必須重新檢查。

---

## A8 — Independent Lazy Axes

\[
\rho
\]

與：

\[
\eta
\]

可獨立增加。

---

## A9 — Budget Feasibility

policy output 必須滿足：

\[
\sum_iC_i(\eta_i)\le B.
\]

---

## A10 — Finite-to-Infinite Boundary

有限 validation 不得自動升格成：

\[
\mathcal D_\infty
\]

的全域 theorem。

---

# 23. Property Class Taxonomy

DMSD v1 暫定：

### E1 — Periodic Exact

例：

```text
parity
mod m
```

### E2 — Boundary-Analytic Exact

例：

```text
perfect squares
```

### E3 — Computed Exact

必須實際運算 block。

### E4 — Certificate Exact

依 proof object / verifier。

### A1 — Approximate / Estimated

附：

```text
error model
scope
baseline
```

### P1 — Probable

附：

```text
algorithm
risk semantics
scope
```

一個 property 可以同時支援多個 admission path。

---

# 24. Core 與 Plugin 邊界

以下屬於 Core：

- Scale Grammar；
- Block；
- Refinement；
- Knowledge State；
- PropertyLayer protocol；
- Summary Algebra protocol；
- Baseline protocol；
- Source Frontier；
- Budget Policy；
- Provenance。

以下不是 Core：

```text
prime
square
parity
mod 7
PNT
W30030
trial division
decimal base
```

它們全部是：

\[
\boxed{
\text{Plugins / Registered Instances}.
}
\]

---

# 25. Prime Phase 的角色

Prime Phase 並沒有被刪除。

它現在成為：

\[
\boxed{
\text{DMSD Reference Stress Test A}.
}
\]

它驗證了：

- UNKNOWN state；
- exact computed / merged；
- baseline / residual；
- representation audit；
- source depth；
- source burden；
- budgeted policy。

但這些能力本身已被抽離 prime ontology。

---

# 26. Formal Runtime Interface

本包提供：

```text
dmsd_core.py
```

包含：

```text
ScaleGrammar
Block
SummaryEnvelope
PropertyLayer
KnowledgeState
SourceOption
SourceFrontier
BudgetPolicy
split_block()
verify_partition()
```

這不是 production runtime，
而是 Formal Core v1 的 reference implementation。

---

# 27. Schema

本包提供：

```text
dmsd_core_schema.json
```

正式記錄：

- scale grammar；
- block；
- knowledge envelope；
- property layer；
- source frontier；
- policy。

目的不是宣稱 schema 已終極固定，
而是讓後續版本能做 compatibility / migration。

---

# 28. 驗證

Generalized randomized validation：

```text
Partition trials:                  500
Parity merge trials:              300
Residue mod-7 merge trials:       300
Square structured merge trials:   300
Prime exact merge trials:         250
Unknown-gate cases:                 3
Source frontier trials:           300
Budget policy trials:             250
```

全部：

```text
PASS
```

總計：

\[
\boxed{
2203
}
\]

個 registered validation cases / gates。

---

# 29. Runtime Self-Validation

reference module 本身另外做 direct import / execution audit：

```text
module import: PASS
ScaleGrammar: PASS
Block partition: PASS
Parity plugin compute: PASS
Exact merge: PASS
UNKNOWN merge gate: PASS
SourceFrontier: PASS
BudgetPolicy: PASS
```

所以 Formal Core 不只是文檔定義，
而是可以被 Python 直接 instantiate。

---

# 30. 一個最小使用流程

```text
1. register ScaleGrammar
2. create Block
3. refine Block if needed
4. attach PropertyLayer
5. compute / estimate / certify summary
6. store KnowledgeState
7. merge exact children when admissible
8. attach Baseline if needed
9. compute Residual if needed
10. register SourceFrontier
11. allocate Source Depth under Budget
12. preserve Provenance
```

---

# 31. 最短定義

若把 DMSD v1 壓成一句：

\[
\boxed{
\text{一個讓數學域、解析度、知識深度與計算負擔都能局部按需展開的可序列化 runtime。}
}
\]

---

# 32. 與最初構想的對照

最初：

```text
十進制金字塔
+
階梯
+
往上 / 往下
+
局部 zoom
```

現在成為：

```text
Scale Grammar
+
Block Refinement
+
Projection
+
Property Summary Algebra
+
Knowledge State
+
Baseline / Residual
+
Source Depth
+
Source Frontier
+
Budget Policy
+
Provenance
```

也就是最初的可視化直覺，
已經被壓成 property-independent core。

---

# 33. v1 的停止條件

Formal Core v1 到這裡先停止擴張。

下一步不應再立刻增加新名詞。

只有在以下情況才升級 Core：

1. 新 property 無法由目前 protocol 表示；
2. merge soundness 出現反例；
3. knowledge admission 不足；
4. source policy 需要新的正式軸；
5. cross-runtime serialization 發生不相容；
6. formal proof 發現定義衝突。

否則新研究應優先做：

\[
\boxed{
\text{Plugin},
}
\]

而不是改 Core。

---

# 34. 結論

DMSD Phase 4 完成後，
DMSD 已不再是一個「質數可視化方法」。

它現在是一個：

\[
\boxed{
\text{Multiscale Serializable Mathematical Runtime Framework}.
}
\]

其核心結構是：

\[
\boxed{
\text{Domain}
\times
\text{Resolution}
\times
\text{Property}
\times
\text{Knowledge}
\times
\text{Source}
\times
\text{Burden}.
}
\]

而最重要的兩條 lazy 原則是：

\[
\boxed{
\text{Compute only what you need to see}
}
\]

以及：

\[
\boxed{
\text{Know deeply only what you need to certify}.
}
\]

---

```text
DMSD Phase 4: COMPLETE
Generalized Formal Core v1: FROZEN FOR VALIDATION

Prime Phase:
demoted from Core to Reference Stress Test A

Next recommended:
cross-property / cross-runtime validation
before any Core v1.1 expansion
```
