狀態機作為遞歸動態容器
State Machines as Recursive Dynamic Containers
系列: 遞歸動態狀態系統(Recursive Dynamic State Systems, RDSS)篇次: 04 / 09作者: Neo.K with Aletheia機構: EveMissLab/一言諾科技有限公司版本: v0.1 Research Draft日期: 2026-08-10文件性質: 遞歸容器形式化/階層狀態系統/動態封裝與身份研究
摘要
本文為《遞歸動態狀態系統》(RDSS)系列第四篇,正式提出「狀態機作為遞歸動態容器 」(State Machine as Recursive Dynamic Container, RDC)模型。
傳統有限狀態機主要將狀態視為轉移圖中的節點;Statecharts 已透過階層、並行與通信使狀態具有結構化內部層次;Hierarchical Finite State Machines 與 Recursive State Machines 亦已證明,狀態/控制器可以模組化地包含或調用其他狀態機。因此,「狀態中包含狀態」並不是本文的新主張。
本文真正處理的是另一個問題:
當一個高階狀態在父層是單一節點,但展開後又是一個具有自身狀態、關係、類型、歷史、接口、局部規則與子系統的完整世界時,如何在不同尺度之間保持身份、邊界契約、合法轉移與可執行性?
本文將單一遞歸動態容器定義為:
M t = ( I , S t , R t , Θ t , Δ t , A t , ∂ t , P t , K t , H t , N t ) \boxed{
\mathfrak M_t
=
(
\mathcal I,
S_t,
R_t,
\Theta_t,
\Delta_t,
\mathcal A_t,
\partial_t,
\mathcal P_t,
\mathcal K_t,
H_t,
\mathcal N_t
)
} M t = ( I , S t , R t , Θ t , Δ t , A t , ∂ t , P t , K t , H t , N t )
其中 I \mathcal I I 為持久身份, ∂ t \partial_t ∂ t 為容器邊界, P t \mathcal P_t P t 為端口集合, K t \mathcal K_t K t 為外部契約, N t \mathcal N_t N t 為子 RDSS 集合。
本文進一步提出:
State ↔ Container ↔ Process \boxed{
\text{State}
\leftrightarrow
\text{Container}
\leftrightarrow
\text{Process}
} State ↔ Container ↔ Process
不是邏輯恆等,而是尺度依賴角色轉換 。同一 M \mathfrak M M 在父尺度可被投影成一個 state,在自身尺度是一個 container,沿時間則是一條 process trajectory。
為了使遞歸封裝可治理,本文引入展開算子 E \mathcal E E 、封裝/收斂算子 V \mathcal V V 、父層投影 Π ↑ \Pi^\uparrow Π ↑ 、子層展開 Π ↓ \Pi^\downarrow Π ↓ 、邊界等價 ≡ ∂ \equiv_{\partial} ≡ ∂ 、接口保持條件、遞歸深度與活動子容器支撐。核心條件不是要求:
V ∘ E = i d , \mathcal V\circ\mathcal E
=
id, V ∘ E = i d ,
而是要求在允許內部重構的情況下:
V ( E ( M ) ) ≡ ∂ M . \boxed{
\mathcal V(\mathcal E(\mathfrak M))
\equiv_{\partial}
\mathfrak M.
} V ( E ( M )) ≡ ∂ M .
也就是:展開—重組—收斂後,內部可以改變,但對父層承諾的外部身份與契約必須在指定容許範圍內保持。
本文最終把 RABCL 的「連線即封裝」、Genesis Matrix 的 Cell → Submatrix、Dynamic MSSP 的動態角色、ODSS 的有限活動支撐,以及 RCTEP 的結構生成整合成 RDSS 的核心遞歸容器模型。
關鍵詞: 遞歸容器、階層狀態機、狀態封裝、動態邊界、接口契約、Recursive State Machine、Statecharts、RDSS、RABCL、Genesis Matrix
0. 問題:一個 state 可以是一個完整世界嗎?
在最簡狀態機中:
S = { s 1 , s 2 , … , s n } . S
=
\{
s_1,
s_2,
\ldots,
s_n
\}. S = { s 1 , s 2 , … , s n } .
每個:
s i s_i s i
通常被視為圖上的一個節點。
但對複雜系統而言,某個高階狀態可能代表:
一個城市;
一家公司;
一個 Agent;
一個軟體模組;
一個遊戲區域;
一個研究專案;
一個工作流;
一個完整子系統。
例如:
s i = C i t y . s_i
=
\mathsf{City}. s i = City .
父層只需要知道:
C i t y \mathsf{City} City
目前處於:
S t a b l e \mathsf{Stable} Stable
或:
C r i s i s . \mathsf{Crisis}. Crisis .
但展開城市後,可能存在:
{ E c o n o m y , P o p u l a t i o n , S e c u r i t y , T r a n s p o r t , P o l i t i c s , W e a t h e r , I n f r a s t r u c t u r e , … } . \{
Economy,
Population,
Security,
Transport,
Politics,
Weather,
Infrastructure,
\ldots
\}. { E co n o m y , P o p u l a t i o n , S ec u r i t y , T r an s p or t , P o l i t i cs , W e a t h er , I n f r a s t r u c t u r e , … } .
所以:
父層的一個 state \boxed{
\text{父層的一個 state}
} 父層的一個 state
可能同時是:
子層的一整個 state system . \boxed{
\text{子層的一整個 state system}.
} 子層的一整個 state system .
本文研究的就是這個尺度轉換。
1. 這不是「階層狀態機是新發明」
必須先排除錯誤的新穎性宣稱。
Statecharts 已經將傳統 state-transition diagrams 擴充為具有:
hierarchy;
concurrency;
communication;
的結構化狀態描述。
Hierarchical Finite State Machines 也可以將大型系統分解為多台子機器,利用階層結構避免每次規劃都展開完整狀態空間。
Hierarchical Finite State Controllers 甚至允許控制器呼叫其他控制器,並形成遞歸控制結構。
因此:
State contains State \boxed{
\text{State contains State}
} State contains State
本身不是 RDSS 的創新。
RDSS 的問題是:
State → Container → Rewritable Container \boxed{
\text{State}
\rightarrow
\text{Container}
\rightarrow
\text{Rewritable Container}
} State → Container → Rewritable Container
以及:
展開與收斂時,身份、接口、歷史與父子層語義如何保持?
2. 三種角色,不是三種不同物件
令:
M \mathfrak M M
為一個 RDSS 物件。
在父層尺度 σ p \sigma_p σ p :
R o l e ( M ∣ σ p ) = S t a t e . Role(\mathfrak M\mid\sigma_p)
=
\mathsf{State}. R o l e ( M ∣ σ p ) = State .
在自身尺度 σ s \sigma_s σ s :
R o l e ( M ∣ σ s ) = C o n t a i n e r . Role(\mathfrak M\mid\sigma_s)
=
\mathsf{Container}. R o l e ( M ∣ σ s ) = Container .
沿時間觀察:
R o l e ( M ∣ t 0 : t n ) = P r o c e s s . Role(\mathfrak M\mid t_0:t_n)
=
\mathsf{Process}. R o l e ( M ∣ t 0 : t n ) = Process .
因此:
S t a t e ↔ C o n t a i n e r ↔ P r o c e s s \boxed{
\mathsf{State}
\leftrightarrow
\mathsf{Container}
\leftrightarrow
\mathsf{Process}
} State ↔ Container ↔ Process
應理解為:
Role Equivalence under Scale / Temporal View \boxed{
\text{Role Equivalence under Scale / Temporal View}
} Role Equivalence under Scale / Temporal View
而不是:
S t a t e = C o n t a i n e r = P r o c e s s State
=
Container
=
Process S t a t e = C o n t ain er = P r ocess
的字面恆等。
這個區分非常重要。
3. 遞歸動態容器的最小結構
本文把 RDSS 第一篇的結構增加明確邊界與接口:
M t = ( I , S t , R t , Θ t , Δ t , A t , ∂ t , P t , K t , H t , N t ) \boxed{
\mathfrak M_t
=
(
\mathcal I,
S_t,
R_t,
\Theta_t,
\Delta_t,
\mathcal A_t,
\partial_t,
\mathcal P_t,
\mathcal K_t,
H_t,
\mathcal N_t
)
} M t = ( I , S t , R t , Θ t , Δ t , A t , ∂ t , P t , K t , H t , N t )
其中:
I \mathcal I I :持久身份;
S t S_t S t :內部有效狀態;
R t R_t R t :內部與外部關係;
Θ t \Theta_t Θ t :類型制度;
Δ t \Delta_t Δ t :合法轉移;
A t \mathcal A_t A t :可用算子;
∂ t \partial_t ∂ t :容器邊界;
P t \mathcal P_t P t :輸入/輸出/事件端口;
K t \mathcal K_t K t :外部契約;
H t H_t H t :歷史;
N t \mathcal N_t N t :子 RDSS 集合。
其中:
( ∂ t , P t , K t ) (\partial_t,\mathcal P_t,\mathcal K_t) ( ∂ t , P t , K t )
是本文新增的核心。
因為沒有邊界,容器就只是「很多東西放一起」。
沒有契約,就無法重新封裝。
4. Container 不只是集合
最簡容器可以寫:
C = { x 1 , … , x n } . C
=
\{
x_1,\ldots,x_n
\}. C = { x 1 , … , x n } .
但 RDSS 容器不是普通集合。
它至少具有:
Inside + Boundary + Interface + Rules + History . \boxed{
\text{Inside}
+
\text{Boundary}
+
\text{Interface}
+
\text{Rules}
+
\text{History}.
} Inside + Boundary + Interface + Rules + History .
也就是:
M ≠ { M 1 , … , M n } . \mathfrak M
\neq
\{M_1,\ldots,M_n\}. M = { M 1 , … , M n } .
更完整地:
M = Govern ( { M i } , R , ∂ , P , K ) . \mathfrak M
=
\operatorname{Govern}
(
\{M_i\},
R,
\partial,
\mathcal P,
\mathcal K
). M = Govern ({ M i } , R , ∂ , P , K ) .
容器不只是「裝東西」。
容器決定:
什麼能進來;
什麼能出去;
哪些內部狀態可被父層看到;
哪些關係不可跨界;
哪些行為需要批准;
哪些子系統可以被替換;
哪些狀態必須一起提交。
5. 邊界 ∂ \partial ∂ 是一級物件
本文定義:
∂ M \partial\mathfrak M ∂ M
為容器邊界。
它不是單純 UI 方框。
邊界決定:
Inside ∣ Outside . \boxed{
\text{Inside}
\mid
\text{Outside}.
} Inside ∣ Outside .
以及合法跨界作用集合:
X ∂ = { x : I n s i d e ↔ O u t s i d e } . \mathcal X_{\partial}
=
\{
x:
Inside
\leftrightarrow
Outside
\}. X ∂ = { x : I n s i d e ↔ O u t s i d e } .
對任一跨界作用:
a a a
需要:
a ∈ Allowed ( ∂ ) . a
\in
\operatorname{Allowed}(\partial). a ∈ Allowed ( ∂ ) .
否則:
a = R e j e c t e d . a
=
\mathsf{Rejected}. a = Rejected .
這把狀態容器從視覺 grouping 提升為可治理結構。
6. 端口 P \mathcal P P
一個容器不能要求父層知道全部內部結構。
因此需要有限外部端口:
P = P i n ∪ P o u t ∪ P e v e n t . \mathcal P
=
\mathcal P^{in}
\cup
\mathcal P^{out}
\cup
\mathcal P^{event}. P = P in ∪ P o u t ∪ P e v e n t .
其中:
P i n \mathcal P^{in} P in
接收輸入;
P o u t \mathcal P^{out} P o u t
輸出結果;
P e v e n t \mathcal P^{event} P e v e n t
傳遞事件。
父層不應直接操作:
S i n t e r n a l S_{\mathrm{internal}} S internal
除非經過顯式 debug / introspection capability。
因此:
Encapsulation = Internal Freedom + Finite External Surface . \boxed{
\text{Encapsulation}
=
\text{Internal Freedom}
+
\text{Finite External Surface}.
} Encapsulation = Internal Freedom + Finite External Surface .
7. 契約 K \mathcal K K
只有端口還不夠。
還需要說明:
這個容器承諾什麼?
定義:
K = ( P r e , P o s t , I n v , E f f , A u t h , Q o S ) . \mathcal K
=
(
Pre,
Post,
Inv,
Eff,
Auth,
QoS
). K = ( P r e , P os t , I n v , E f f , A u t h , Q o S ) .
其中:
P r e Pre P r e :前置條件;
P o s t Post P os t :後置條件;
I n v Inv I n v :不變量;
E f f Eff E f f :可允許副作用;
A u t h Auth A u t h :權限;
Q o S QoS Q o S :時間/資源/品質承諾。
因此兩個內部完全不同的容器:
M A \mathfrak M_A M A
與:
M B \mathfrak M_B M B
只要:
K A ≡ K B \mathcal K_A
\equiv
\mathcal K_B K A ≡ K B
且外部可觀察行為相容,就可能對父層形成可替換實現。
8. 父層看到的不是完整子世界
令:
Π ↑ \Pi^\uparrow Π ↑
為向父層的投影。
則:
s i p a r e n t = Π ↑ ( M i ) . s_i^{parent}
=
\Pi^\uparrow
(
\mathfrak M_i
). s i p a r e n t = Π ↑ ( M i ) .
例如城市內部可能有十萬個 state variable。
父層只投影:
Π ↑ ( M c i t y ) = ( S t a b i l i t y , O u t p u t , T h r e a t , P o p u l a t i o n T r e n d ) . \Pi^\uparrow(\mathfrak M_{city})
=
(
Stability,
Output,
Threat,
PopulationTrend
). Π ↑ ( M c i t y ) = ( S t abi l i t y , O u tp u t , T h r e a t , P o p u l a t i o n T r e n d ) .
因此:
Parent State = Projection of Child Container . \boxed{
\text{Parent State}
=
\text{Projection of Child Container}.
} Parent State = Projection of Child Container .
這是:
S t a t e ↔ C o n t a i n e r State
\leftrightarrow
Container S t a t e ↔ C o n t ain er
真正的數學接口。
9. 向下展開
相反地,父層節點可以被展開:
Π ↓ : s i p a r e n t ⇝ M i . \Pi^\downarrow:
s_i^{parent}
\rightsquigarrow
\mathfrak M_i. Π ↓ : s i p a r e n t ⇝ M i .
但這裡:
Π ↓ \Pi^\downarrow Π ↓
不一定是普通逆函數。
因為父層投影已經壓縮資訊。
所以一般:
Π ↓ ∘ Π ↑ ≠ i d . \Pi^\downarrow
\circ
\Pi^\uparrow
\neq
id. Π ↓ ∘ Π ↑ = i d .
更準確地:
Π ↓ \Pi^\downarrow Π ↓
是:
找到權威子容器;
載入其狀態;
恢復其歷史;
物化必要子結構;
的展開操作。
10. 展開 E \mathcal E E 與封裝 V \mathcal V V
本文定義:
E : M → D ( M ) \mathcal E:
\mathfrak M
\rightarrow
\mathcal D(\mathfrak M) E : M → D ( M )
為展開。
其中:
D ( M ) \mathcal D(\mathfrak M) D ( M )
是顯式展開後的內部結構。
封裝/收斂:
V : D ( M ) → M ′ . \mathcal V:
\mathcal D(\mathfrak M)
\rightarrow
\mathfrak M'. V : D ( M ) → M ′ .
最容易犯的錯是要求:
V ∘ E = i d . \mathcal V
\circ
\mathcal E
=
id. V ∘ E = i d .
但若內部允許學習、修正與重構,這個條件太強。
我們真正需要的是:
V ( E ( M ) ) ≡ ∂ M . \boxed{
\mathcal V
(
\mathcal E(\mathfrak M)
)
\equiv_{\partial}
\mathfrak M.
} V ( E ( M )) ≡ ∂ M .
其中:
≡ ∂ \equiv_{\partial} ≡ ∂
表示邊界契約等價 。
11. 邊界等價 ≡ ∂ \equiv_{\partial} ≡ ∂
定義:
M A ≡ ∂ M B \mathfrak M_A
\equiv_{\partial}
\mathfrak M_B M A ≡ ∂ M B
若對父層允許的觀測集合:
O ∂ \mathcal O_{\partial} O ∂
與合法輸入集合:
I ∂ \mathcal I_{\partial} I ∂
兩者在容許誤差 ε \varepsilon ε 內具有相同契約行為。
粗略寫為:
∀ i ∈ I ∂ , \forall i\in\mathcal I_{\partial}, ∀ i ∈ I ∂ ,
d ( O b s ∂ ( R u n ( M A , i ) ) , O b s ∂ ( R u n ( M B , i ) ) ) ≤ ε . d
\left(
Obs_{\partial}
(
Run(\mathfrak M_A,i)
),
Obs_{\partial}
(
Run(\mathfrak M_B,i)
)
\right)
\le
\varepsilon. d ( O b s ∂ ( R u n ( M A , i )) , O b s ∂ ( R u n ( M B , i )) ) ≤ ε .
因此:
Identity Preservation ≠ Internal Equality . \boxed{
\text{Identity Preservation}
\neq
\text{Internal Equality}.
} Identity Preservation = Internal Equality .
而可以是:
Boundary-Contract Continuity . \boxed{
\text{Boundary-Contract Continuity}.
} Boundary-Contract Continuity .
12. 這和 RABCL 的「工作流封裝」直接接軌
RABCL 已經提出:
W = ( V , E ) → E n c a p s u l a t e B W . \mathcal W
=
(V,E)
\xrightarrow{\mathsf{Encapsulate}}
B_{\mathcal W}. W = ( V , E ) Encapsulate B W .
合法工作流封裝後,不只是視覺群組,而是一個具有:
穩定身份;
外部接口;
功能契約;
權威表示;
驗證證據;
展開路徑;
演化歷史;
的一級計算物件。
而且:
B 1 , … , B n ∈ B B_1,\ldots,B_n
\in
\mathfrak B B 1 , … , B n ∈ B
若合法組合,則:
Pack ( B 1 , … , B n ) ∈ B . \operatorname{Pack}
(
B_1,\ldots,B_n
)
\in
\mathfrak B. Pack ( B 1 , … , B n ) ∈ B .
這就是 RDSS 遞歸容器最直接的工程前身。
13. 群組 Group 不等於 Container
UI 上把三個節點圈起來:
{ A , B , C } \{A,B,C\} { A , B , C }
不代表得到一個新狀態容器。
本文要求:
G r o u p < E n c a p s u l a t i o n < R e c u r s i v e C o n t a i n e r . \boxed{
Group
<
Encapsulation
<
Recursive Container.
} G r o u p < E n c a p s u l a t i o n < R ec u r s i v e C o n t ain er .
Group 只需要視覺邊界。
Encapsulation 還需要:
interface;
contract;
identity;
validation。
Recursive Container 再需要:
child state;
child history;
expand / collapse;
nested execution;
cross-scale consistency。
14. Genesis Matrix 已經有 Cell → Submatrix
創生矩陣的工程構想中,一個 Cell 可以展開成:
C e l l → S u b m a t r i x . Cell
\rightarrow
Submatrix. C e l l → S u bma t r i x .
並形成:
M a t r i x ⊃ M a t r i x ⊃ M a t r i x . \boxed{
Matrix
\supset
Matrix
\supset
Matrix.
} M a t r i x ⊃ M a t r i x ⊃ M a t r i x .
這不是單純 zoom,而是語義尺度下降。
在 RDSS 中可以重新寫成:
c i = Π ↑ ( M i ) . c_i
=
\Pi^\uparrow(\mathfrak M_i). c i = Π ↑ ( M i ) .
點擊展開:
c i → Π ↓ M i . c_i
\xrightarrow{\Pi^\downarrow}
\mathfrak M_i. c i Π ↓ M i .
所以 Genesis Matrix 可以被理解成:
RDC 的可視化 Addressing Surface . \boxed{
\text{RDC 的可視化 Addressing Surface}.
} RDC 的可視化 Addressing Surface .
它顯示的是容器投影,而不是完整本體。
15. 容器的身份不能綁定顯示位置
一個 Cell 可以從矩陣左上角移到右下角。
如果位置改變就失去身份,系統會非常脆弱。
所以:
i d ( M ) = I id(\mathfrak M)
=
\mathcal I i d ( M ) = I
與:
p o s i t i o n t ( M ) position_t(\mathfrak M) p os i t i o n t ( M )
必須分離:
I ≠ p o s i t i o n . \boxed{
\mathcal I
\neq
position.
} I = p os i t i o n .
同樣:
I ≠ p a r e n t . \mathcal I
\neq
parent. I = p a r e n t .
因為一個容器甚至可能被:
多處引用;
重新掛載;
複製;
fork;
merge。
16. Containment 與 Reference 必須分開
假設:
M A M_A M A
與:
M B M_B M B
都使用:
M C . M_C. M C .
可能有兩種完全不同的結構。
Containment
M C ⊂ M A . M_C
\subset
M_A. M C ⊂ M A .
表示生命週期與所有權被 A 包含。
Reference
M A → M C . M_A
\rightarrow
M_C. M A → M C .
只是引用 C。
若 A 被刪除:
M C M_C M C
未必被刪除。
因此:
Contains ≠ References . \boxed{
\text{Contains}
\neq
\text{References}.
} Contains = References .
否則遞歸容器會迅速陷入所有權與刪除語義混亂。
17. 樹不夠,需要容器圖
最簡階層是:
M 0 ⊃ M 1 ⊃ M 2 . M_0
\supset
M_1
\supset
M_2. M 0 ⊃ M 1 ⊃ M 2 .
但現實中可能:
多父引用;
cross-link;
shared service;
peer relation;
cyclic dependency。
所以真正結構更接近:
G M = ( V M , E c o n t a i n , E r e f , E e v e n t , E d a t a ) . \mathcal G_M
=
(
V_M,
E_{\mathrm{contain}},
E_{\mathrm{ref}},
E_{\mathrm{event}},
E_{\mathrm{data}}
). G M = ( V M , E contain , E ref , E event , E data ) .
其中只有:
E c o n t a i n E_{\mathrm{contain}} E contain
需要維持明確所有權/生命週期約束。
其他邊可以形成一般圖甚至循環。
18. 遞歸不等於無限展開
第二篇 ODSS 已經建立有限有效支撐。
本文將其套到容器:
N e f f ( Q , t , ε ) ⊆ N t . \mathcal N_{\mathrm{eff}}
(
Q,t,\varepsilon
)
\subseteq
\mathcal N_t. N eff ( Q , t , ε ) ⊆ N t .
只有:
M i ∈ N e f f \mathfrak M_i
\in
\mathcal N_{\mathrm{eff}} M i ∈ N eff
才需要物化。
因此:
Potentially Recursive ≠ Fully Materialized . \boxed{
\text{Potentially Recursive}
\neq
\text{Fully Materialized}.
} Potentially Recursive = Fully Materialized .
例如世界中存在一百萬個 NPC 子容器。
玩家所在場景可能只物化:
37 37 37
個。
19. 展開深度也是狀態
令:
d t d_t d t
為當前展開深度。
可以依任務:
d ∗ = d ∗ ( Q , t , ε , B ) d^\ast
=
d^\ast(Q,t,\varepsilon,B) d ∗ = d ∗ ( Q , t , ε , B )
決定。
其中:
B B B
是計算預算。
因此:
d t d_t d t
不是固定 UI zoom。
它是 runtime resource allocation 的一部分。
20. 父層事件如何進入子容器?
父層發生事件:
e p . e_p. e p .
不應直接廣播到所有內部節點。
需要 event router:
ρ ∂ : e p → { e c 1 , … , e c k } . \rho_{\partial}:
e_p
\rightarrow
\{
e_{c_1},
\ldots,
e_{c_k}
\}. ρ ∂ : e p → { e c 1 , … , e c k } .
並要求:
k ≪ ∣ N ∣ . k
\ll
|\mathcal N|. k ≪ ∣ N ∣.
也就是只路由給相關子容器。
如此可避免:
Global Broadcast Explosion . \boxed{
\text{Global Broadcast Explosion}.
} Global Broadcast Explosion .
21. 子層事件如何上升?
子容器:
M i \mathfrak M_i M i
內部可能產生數千個事件。
父層通常不需要全部知道。
所以定義事件收斂:
α ↑ : { e 1 , … , e n } → e p a r e n t . \alpha^\uparrow:
\{e_1,\ldots,e_n\}
\rightarrow
e^{parent}. α ↑ : { e 1 , … , e n } → e p a r e n t .
例如:
{ b a n k _ f a i l u r e , r i o t , f o o d _ s h o r t a g e } \{
bank\_failure,
riot,
food\_shortage
\} { bank _ f ai l u r e , r i o t , f oo d _ s h or t a g e }
可以收斂為:
c i t y _ c r i s i s . city\_crisis. c i t y _ cr i s i s .
這就是事件層的:
Convergence . \boxed{
\text{Convergence}.
} Convergence .
22. 父子層一致性
假設父層投影:
s p = H e a l t h y . s_p
=
\mathsf{Healthy}. s p = Healthy .
但子容器內部已:
70 % 70\% 70%
關鍵節點故障。
此時產生:
Cross-Level Inconsistency . \boxed{
\text{Cross-Level Inconsistency}.
} Cross-Level Inconsistency .
所以需要一致性條件:
C o n s i s t e n t ( s p , Π ↑ ( M c ) ) = 1. Consistent
(
s_p,
\Pi^\uparrow(\mathfrak M_c)
)
=
1. C o n s i s t e n t ( s p , Π ↑ ( M c )) = 1.
若:
= 0 , =0, = 0 ,
則父層狀態必須:
更新;
標記 stale;
進入 unknown;
或觸發重新投影。
23. 父層狀態可以是快取,但不能是假真相
為效率,父層可以快取:
s ^ p \hat s_p s ^ p
而不是每次都展開子容器。
但需要:
V e r s i o n ( s ^ p ) Version(\hat s_p) V er s i o n ( s ^ p )
與:
V e r s i o n ( M c ) Version(\mathfrak M_c) V er s i o n ( M c )
關聯。
若:
L a g ( s ^ p , M c ) > τ , Lag
(
\hat s_p,
\mathfrak M_c
)
>
\tau, L a g ( s ^ p , M c ) > τ ,
則:
s ^ p = S t a l e . \hat s_p
=
\mathsf{Stale}. s ^ p = Stale .
這和 MSSP × RDR 中「索引可落後、但不能冒充唯一權威」的原則一致。
24. 容器內部可以重構
假設:
M t \mathfrak M_t M t
內部原本是:
A → B → C . A\rightarrow B\rightarrow C. A → B → C .
後來改成:
A → D → C . A
\rightarrow
D
\rightarrow
C. A → D → C .
只要:
M t ≡ ∂ M t + 1 , \mathfrak M_t
\equiv_{\partial}
\mathfrak M_{t+1}, M t ≡ ∂ M t + 1 ,
父層可以不用知道內部重構。
因此遞歸容器提供:
Local Structural Freedom \boxed{
\text{Local Structural Freedom}
} Local Structural Freedom
同時保持:
Global Contract Stability . \boxed{
\text{Global Contract Stability}.
} Global Contract Stability .
25. 但契約也可以演化
前一節不表示:
K t \mathcal K_t K t
永遠不能變。
若契約改變:
K t → K t + 1 , \mathcal K_t
\rightarrow
\mathcal K_{t+1}, K t → K t + 1 ,
這是一個更高階事件:
Boundary Regime Change . \boxed{
\text{Boundary Regime Change}.
} Boundary Regime Change .
此時父層必須知道。
所以:
Internal Rewrite \text{Internal Rewrite} Internal Rewrite
與:
Contract Rewrite \text{Contract Rewrite} Contract Rewrite
需要不同治理等級。
26. 身份保持的三級標準
本文提出三種身份保持強度。
I1 — Exact Internal Identity
M t + 1 = M t . \mathfrak M_{t+1}
=
\mathfrak M_t. M t + 1 = M t .
最強,但動態系統幾乎不適用。
I2 — Structural Continuity
內部可改,但主要結構與歷史鏈保持。
H t + 1 = H t ⊕ Δ t . H_{t+1}
=
H_t
\oplus
\Delta_t. H t + 1 = H t ⊕ Δ t .
I3 — Boundary-Contract Identity
內部可大幅改寫,只要求:
M t + 1 ≡ ∂ M t . \mathfrak M_{t+1}
\equiv_{\partial}
\mathfrak M_t. M t + 1 ≡ ∂ M t .
工程上通常最實用。
27. Fork、Clone 與 Same Identity
如果:
C l o n e ( M ) = M ′ Clone(\mathfrak M)
=
\mathfrak M' C l o n e ( M ) = M ′
且初始內容完全一樣,也不代表:
I ′ = I . \mathcal I'
=
\mathcal I. I ′ = I .
應區分:
State Equality ≠ Identity Equality . \boxed{
\text{State Equality}
\neq
\text{Identity Equality}.
} State Equality = Identity Equality .
Clone:
I ′ ≠ I . \mathcal I'
\neq
\mathcal I. I ′ = I .
Fork:
P a r e n t I d e n t i t y ( I ′ ) = I . ParentIdentity(\mathcal I')
=
\mathcal I. P a r e n t I d e n t i t y ( I ′ ) = I .
Move:
I ′ = I . \mathcal I'
=
\mathcal I. I ′ = I .
這會在未來 AI Agent、虛擬世界與可複製 runtime 中非常重要。
28. 封裝不是資訊刪除
當:
V : D ( M ) → M \mathcal V:
\mathcal D(\mathfrak M)
\rightarrow
\mathfrak M V : D ( M ) → M
發生時,父層只看壓縮狀態。
但內部資訊不一定被刪除。
因此區分:
Hidden ≠ Erased . \boxed{
\text{Hidden}
\neq
\text{Erased}.
} Hidden = Erased .
封裝可以:
但仍保留可恢復路徑。
29. 真正不可逆的收斂
也存在:
V \mathcal V V
造成信息真正丟失。
例如:
V l o s s y . \mathcal V_{lossy}. V l ossy .
此時必須記錄:
L V > 0. L_{\mathcal V}
>
0. L V > 0.
所以:
Collapse \boxed{
\text{Collapse}
} Collapse
至少有:
reversible collapse;
lossy convergence;
兩類。
這與前面 ODSS 的 Loss Accounting 一致。
30. RCTEP:容器甚至能生成新的容器結構
截至目前,容器只是:
M t → M t + 1 . \mathfrak M_t
\rightarrow
\mathfrak M_{t+1}. M t → M t + 1 .
RCTEP 更進一步允許:
( x , Σ , Γ , K ) → ( x ′ , Σ ′ , Γ ′ , K ′ ) . (x,\Sigma,\Gamma,\mathcal K)
\rightarrow
(x',\Sigma',\Gamma',\mathcal K'). ( x , Σ , Γ , K ) → ( x ′ , Σ ′ , Γ ′ , K ′ ) .
亦即:
都可能出現。
RDSS 對此的容器版本是:
M t → M t + 1 \boxed{
\mathfrak M_t
\rightarrow
\mathfrak M_{t+1}
} M t → M t + 1
且:
S c h e m a ( M t ) ≠ S c h e m a ( M t + 1 ) . Schema(\mathfrak M_t)
\neq
Schema(\mathfrak M_{t+1}). S c h e ma ( M t ) = S c h e ma ( M t + 1 ) .
因此容器不只是會動。
它還可以:
grow new internal world structure . \boxed{
\text{grow new internal world structure}.
} grow new internal world structure .
31. 生成必須有 witness
如果容器突然新增:
M n e w , M_{\mathrm{new}}, M new ,
卻不知道:
從何生成;
哪些狀態導致;
哪個規則允許;
哪些歷史條件存在;
哪些不變量被保持;
那「生成」很容易退化成任意修改。
因此每個結構生成事件:
g g g
應附帶:
w g = ( S o u r c e , R u l e , H i s t o r y , C o n s t r a i n t , R e s u l t , I n v a r i a n t , P r o v e n a n c e ) . w_g
=
(
Source,
Rule,
History,
Constraint,
Result,
Invariant,
Provenance
). w g = ( S o u r ce , R u l e , H i s t or y , C o n s t r ain t , R es u l t , I n v a r ian t , P r o v e nan ce ) .
這直接承接 RCTEP 的生成見證思想。
32. 遞歸容器的原子提交
如果子容器內部:
A , B , C A,B,C A , B , C
一起改寫,但父層在中途讀到:
A ′ , B , C ′ A'
,
B,
C' A ′ , B , C ′
可能得到不存在的中間狀態。
因此某些容器需要:
Atomic Local Commit . \boxed{
\text{Atomic Local Commit}.
} Atomic Local Commit .
流程:
M t → M ~ t + 1 → V a l i d a t e → C o m m i t → M t + 1 . \mathfrak M_t
\rightarrow
\widetilde{\mathfrak M}_{t+1}
\rightarrow
Validate
\rightarrow
Commit
\rightarrow
\mathfrak M_{t+1}. M t → M t + 1 → V a l i d a t e → C o mmi t → M t + 1 .
這也是 CAIR / RABCL 封裝靜止屏障可重新利用的地方。
33. 不需要全域原子
但不能因此要求整個世界:
M w o r l d M_{world} M w or l d
每次都 global lock。
應區分:
Local Atomicity + Cross-Container Eventual Consistency . \boxed{
\text{Local Atomicity}
+
\text{Cross-Container Eventual Consistency}.
} Local Atomicity + Cross-Container Eventual Consistency .
父子容器可以透過:
version;
event;
snapshot;
causal order;
同步。
否則遞歸世界會被全域鎖拖垮。
34. 容器的最小可執行接口
本文暫定每個 RDC 至少提供:
inspect()
snapshot()
expand()
collapse()
dispatch(event)
apply(action)
validate(delta)
commit(delta)
project(view)
history()
其中:
expand():
S t a t e → C o n t a i n e r V i e w . State
\rightarrow
ContainerView. S t a t e → C o n t ain er V i e w .
collapse():
C o n t a i n e r → S t a t e P r o j e c t i o n . Container
\rightarrow
StateProjection. C o n t ain er → S t a t e P r o j ec t i o n .
dispatch():
父事件向內路由。
project():
產生父層或人類/AI 需要的觀測投影。
35. 一個最小遊戲世界例子
父層:
W o r l d = { T o w n A , T o w n B , D u n g e o n C } . World
=
\{
Town_A,
Town_B,
Dungeon_C
\}. W or l d = { T o w n A , T o w n B , D u n g eo n C } .
其中:
T o w n A Town_A T o w n A
在父層是一個 stateful node。
父層看到:
T o w n A = ( s t a b l e , p o p u l a t i o n = 12000 , t h r e a t = 0.2 ) . Town_A
=
(
stable,
population=12000,
threat=0.2
). T o w n A = ( s t ab l e , p o p u l a t i o n = 12000 , t h r e a t = 0.2 ) .
展開:
Π ↓ ( T o w n A ) = M T o w n A . \Pi^\downarrow(Town_A)
=
\mathfrak M_{Town_A}. Π ↓ ( T o w n A ) = M T o w n A .
內部:
{ E c o n o m y , G u a r d s , S h o p s , N P C s , C r i m e , P o l i t i c s } . \{
Economy,
Guards,
Shops,
NPCs,
Crime,
Politics
\}. { E co n o m y , G u a r d s , S h o p s , N P C s , C r im e , P o l i t i cs } .
玩家進入城鎮後:
N e f f \mathcal N_{\mathrm{eff}} N eff
只物化附近:
N P C , S h o p , G u a r d , Q u e s t NPC,
Shop,
Guard,
Quest N P C , S h o p , G u a r d , Q u es t
相關子容器。
玩家離開後:
V \mathcal V V
重新收斂:
M T o w n A → T o w n A p a r e n t . \mathfrak M_{Town_A}
\rightarrow
Town_A^{parent}. M T o w n A → T o w n A p a r e n t .
父世界不需要保存每個 NPC 每一幀的全部狀態。
只保存:
這就是狀態機作為動態世界容器的基本形式。
36. 一個軟體系統例子
父層:
A p p l i c a t i o n = { A u t h , B i l l i n g , S e a r c h } . Application
=
\{
Auth,
Billing,
Search
\}. A ppl i c a t i o n = { A u t h , B i l l in g , S e a r c h } .
其中:
B i l l i n g Billing B i l l in g
對父層是一個模組 state。
展開:
B i l l i n g → { I n v o i c e , P a y m e n t , R e f u n d , T a x , L e d g e r } . Billing
\rightarrow
\{
Invoice,
Payment,
Refund,
Tax,
Ledger
\}. B i l l in g → { I n v o i ce , P a y m e n t , R e f u n d , T a x , L e d g er } .
如果內部把:
P a y m e n t V 1 PaymentV1 P a y m e n t V 1
換成:
P a y m e n t V 2 , PaymentV2, P a y m e n t V 2 ,
只要:
B i l l i n g v 1 ≡ ∂ B i l l i n g v 2 , Billing_{v1}
\equiv_{\partial}
Billing_{v2}, B i l l in g v 1 ≡ ∂ B i l l in g v 2 ,
父層不必修改。
但若:
R e f u n d P o l i c y RefundPolicy R e f u n d P o l i cy
改變對外契約:
K t ≠ K t + 1 , \mathcal K_t
\neq
\mathcal K_{t+1}, K t = K t + 1 ,
則必須升級父層依賴。
37. 一個 AI Agent 例子
父層只看到:
A g e n t A = ( A v a i l a b l e , C a p a b i l i t y , A u t h o r i t y , R i s k ) . Agent_A
=
(
Available,
Capability,
Authority,
Risk
). A g e n t A = ( A v ai l ab l e , C a p abi l i t y , A u t h or i t y , R i s k ) .
展開後可能有:
{ P l a n n e r , M e m o r y , T o o l s , W o r l d S t a t e , S u b A g e n t s , P o l i c i e s } . \{
Planner,
Memory,
Tools,
WorldState,
SubAgents,
Policies
\}. { P l ann er , M e m or y , T oo l s , W or l d S t a t e , S u b A g e n t s , P o l i c i es } .
父層不需要每輪把 Agent 全部內部記憶重新讀入。
而是:
Π ↑ ( A g e n t A ) \Pi^\uparrow
(
Agent_A
) Π ↑ ( A g e n t A )
保留當前父層需要的狀態投影。
這正是世界狀態機+AI 架構可節省重複上下文的一個形式理由。
38. 遞歸容器與「存在」
到這裡可以重新回到第一篇的本體論問題。
若:
x x x
在父層是一個節點,
展開後是一個容器,
沿時間是一條持續演化軌跡,
那麼對動態存在者而言:
I d e n t i t y ( x ) \boxed{
Identity(x)
} I d e n t i t y ( x )
可能更自然地由:
( B o u n d a r y , C o n t r a c t , H i s t o r y , I n t e r n a l D y n a m i c s ) (
Boundary,
Contract,
History,
InternalDynamics
) ( B o u n d a r y , C o n t r a c t , H i s t or y , I n t er na l D y nami cs )
共同維持。
因此可以提出中等強度命題:
Dynamic Entity ≈ Persistent Recursive State Container . \boxed{
\text{Dynamic Entity}
\approx
\text{Persistent Recursive State Container}.
} Dynamic Entity ≈ Persistent Recursive State Container .
但本文仍不把它提升成:
E v e r y t h i n g = S t a t e M a c h i n e . Everything
=
StateMachine. E v er y t hin g = S t a t e M a c hin e .
39. 可證偽問題
39.1 Scale Projection 是否保真?
比較:
D e c i s i o n ( Π ↑ ( M ) ) Decision
(
\Pi^\uparrow(\mathfrak M)
) D ec i s i o n ( Π ↑ ( M ))
與使用完整子狀態決策的差異。
39.2 Encapsulation 是否真的降低複雜度?
測量:
C o s t f l a t Cost_{\mathrm{flat}} C os t flat
與:
C o s t r e c u r s i v e . Cost_{\mathrm{recursive}}. C os t recursive .
39.3 Boundary Contract 是否足以保持父層穩定?
若內部頻繁重構仍迫使父層修改,則封裝失敗。
39.4 Expand / Collapse 是否可重播?
需要:
R e p l a y ( H t ) → M t . Replay
(
H_t
)
\rightarrow
\mathfrak M_t. R e pl a y ( H t ) → M t .
39.5 遞歸是否造成隱藏複雜度?
如果只是把複雜度藏進容器:
C o m p l e x i t y t o t a l Complexity_{\mathrm{total}} C o m pl e x i t y total
沒有降低,且 debugging 更困難,則 RDC 工程價值必須重新評估。
40. 本文的八個容器不變量候選
C1 — Persistent Identity
I \mathcal I I
不能因顯示位置或普通內部重構任意改變。
C2 — Explicit Boundary
每個正式容器必須有:
∂ . \partial. ∂ .
C3 — Finite External Interface
父層操作面:
∣ P ∣ |\mathcal P| ∣ P ∣
應顯著小於完整內部狀態面。
C4 — Contracted Encapsulation
所有正式封裝都必須有:
K . \mathcal K. K .
C5 — Expandability
父層 state 必須存在可追蹤:
S t a t e → C o n t a i n e r State
\rightarrow
Container S t a t e → C o n t ain er
路徑。
C6 — Convergibility
子容器必須能形成父層有效投影:
C o n t a i n e r → S t a t e . Container
\rightarrow
State. C o n t ain er → S t a t e .
C7 — Historical Continuity
內部重構必須保持可追溯:
H t → H t + 1 . H_t
\rightarrow
H_{t+1}. H t → H t + 1 .
C8 — Bounded Materialization
任何實際任務只物化有限:
N e f f . \mathcal N_{\mathrm{eff}}. N eff .
41. 與前 3 篇的統一
第一篇得到:
S t a t e ↔ C o n t a i n e r ↔ P r o c e s s . \boxed{
State
\leftrightarrow
Container
\leftrightarrow
Process.
} S t a t e ↔ C o n t ain er ↔ P r ocess .
第二篇建立:
O p e n S c h e m a + F i n i t e S u p p o r t . \boxed{
Open\ Schema
+
Finite\ Support.
} O p e n S c h e ma + F ini t e S u pp or t .
第三篇建立:
C l a s s i f i c a t i o n = S t a t e f u l S u b s y s t e m . \boxed{
Classification
=
Stateful\ Subsystem.
} C l a ss i f i c a t i o n = S t a t e f u l S u b sy s t e m .
本篇則補上:
B o u n d a r y + I n t e r f a c e + C o n t r a c t + R e c u r s i v e C o n t a i n m e n t . \boxed{
Boundary
+
Interface
+
Contract
+
Recursive\ Containment.
} B o u n d a r y + I n t er f a ce + C o n t r a c t + R ec u r s i v e C o n t ainm e n t .
所以 RDSS 的核心物件可以更新成:
M t = ( I , S t , R t , Θ t , Δ t , A t , ∂ t , P t , K t , Π t , H t , T t , N t ) . \boxed{
\mathfrak M_t
=
(
\mathcal I,
S_t,
R_t,
\Theta_t,
\Delta_t,
\mathcal A_t,
\partial_t,
\mathcal P_t,
\mathcal K_t,
\Pi_t,
H_t,
\mathbb T_t,
\mathcal N_t
).
} M t = ( I , S t , R t , Θ t , Δ t , A t , ∂ t , P t , K t , Π t , H t , T t , N t ) .
42. 下一步:三元循環正式成為容器演化算子
有了遞歸容器後,第五篇才能真正處理:
E = E x p a n s i o n , \mathcal E
=
Expansion, E = E x p an s i o n ,
C = C o n n e c t i o n , \mathcal C
=
Connection, C = C o nn ec t i o n ,
V = C o n v e r g e n c e . \mathcal V
=
Convergence. V = C o n v er g e n ce .
因為現在我們已經知道:
展開什麼?
展開:
M \boxed{
\mathfrak M
} M
本身。
連接什麼?
連接:
M i ↔ M j . \boxed{
\mathfrak M_i
\leftrightarrow
\mathfrak M_j.
} M i ↔ M j .
收斂成什麼?
收斂為:
M ′ \boxed{
\mathfrak M'
} M ′
新的高階狀態容器。
因此下一篇:
《展開—連接—收斂:三元本體論的狀態系統實現》
將第一次不只是把 TUO 當哲學元框架,而是把:
V ∘ C ∘ E \boxed{
\mathcal V
\circ
\mathcal C
\circ
\mathcal E
} V ∘ C ∘ E
正式寫成 RDSS 的生成循環。
43. 結論
本文最核心的問題是:
一個 state 能不能本身就是一個世界?
答案不是簡單的「可以」。
因為如果只是:
S t a t e ⊃ S t a t e s , State
\supset
States, S t a t e ⊃ S t a t es ,
我們早已有大量階層狀態機形式。
RDSS 真正需要的是:
State ↔ Converge Expand Dynamic Container . \boxed{
\text{State}
\xleftrightarrow[
\text{Converge}
]{
\text{Expand}
}
\text{Dynamic Container}.
} State Expand Converge Dynamic Container .
而這個容器必須同時保持:
I d e n t i t y + B o u n d a r y + I n t e r f a c e + C o n t r a c t + H i s t o r y + E x e c u t a b l e S e m a n t i c s . \boxed{
Identity
+
Boundary
+
Interface
+
Contract
+
History
+
Executable Semantics.
} I d e n t i t y + B o u n d a r y + I n t er f a ce + C o n t r a c t + H i s t or y + E x ec u t ab l e S e man t i cs .
因此:
父層的一個狀態 \boxed{
\text{父層的一個狀態}
} 父層的一個狀態
可以是:
自身尺度的一個完整動態世界 . \boxed{
\text{自身尺度的一個完整動態世界}.
} 自身尺度的一個完整動態世界 .
但父層不需要理解全部世界。
它只需要:
Π ↑ ( M ) . \boxed{
\Pi^\uparrow(\mathfrak M).
} Π ↑ ( M ) .
當需要深入時:
Π ↓ \boxed{
\Pi^\downarrow
} Π ↓
再展開。
所以遞歸狀態系統的真正價值,不是「把一切無限展開」。
恰恰相反。
它提供:
可以無限繼續細化的表示能力 \boxed{
\text{可以無限繼續細化的表示能力}
} 可以無限繼續細化的表示能力
與:
永遠只在當前尺度暴露有限可操作表面 \boxed{
\text{永遠只在當前尺度暴露有限可操作表面}
} 永遠只在當前尺度暴露有限可操作表面
之間的橋。
這就是「狀態機作為遞歸動態容器」的核心。
參考文獻
外部文獻
Harel, D. (1987). Statecharts: A Visual Formalism for Complex Systems . Science of Computer Programming, 8(3), 231–274. DOI: 10.1016/0167-6423(87)90035-9.
Segovia-Aguas, J., Jiménez, S., & Jonsson, A. (2019). Hierarchical Finite State Controllers for Generalized Planning . arXiv:1911.02887.
Stefansson, E., & Johansson, K. H. (2022). Hierarchical Finite State Machines for Efficient Optimal Planning in Large-scale Systems . arXiv:2212.03724.
Stefansson, E., & Johansson, K. H. (2023). Efficient and Reconfigurable Optimal Planning in Large-Scale Systems Using Hierarchical Finite State Machines . arXiv:2303.16567.
EveMissLab 內部前置
Neo.K with Aletheia,《狀態、容器與存在:遞歸動態狀態系統的總命題》。
Neo.K with Aletheia,《從有限狀態機到開放維度狀態系統》。
Neo.K with Aletheia,《分類即狀態:從靜態類型到動態類型體制》。
Neo.K with Aletheia,《連線即封裝:從工作流到高階語言基元的總命題》。
Neo.K,《創生矩陣:以矩陣方塊底空間、格子語義封裝與 Agent 操作介面為核心的統一計算架構》。
Neo.K,《反身因果張量湧生積》。
Neo.K,《空間狀態論》。
Neo.K,《MSSP × RDR 整合規格書》。