rei-lang 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +230 -191
- package/PEACE_USE_CLAUSE.md +95 -0
- package/README.md +257 -186
- package/bin/rei.js +259 -144
- package/dist/index.d.mts +257 -0
- package/dist/index.d.ts +181 -93
- package/dist/index.js +5710 -239
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8741 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +73 -62
- package/spec/REI_BNF_v0.2.md +398 -0
- package/spec/REI_BNF_v0.3.md +358 -0
- package/spec/REI_SPEC_v0.1.md +587 -0
- package/theory/LICENSE-THEORY.md +57 -0
- package/theory/README.md +85 -0
- package/theory/category-c-design.md +502 -0
- package/theory/core-theories-11-14.md +799 -0
- package/theory/core-theories-15-21.md +675 -0
- package/theory/core-theories-8-10.md +582 -0
- package/theory/d-fumt-overview.md +99 -0
- package/theory/genesis-axiom-system.md +124 -0
- package/theory/gft-theory.md +160 -0
- package/theory/index.ts +9 -0
- package/theory/notation-equivalence.md +134 -0
- package/theory/semantic-compressor.ts +903 -0
- package/theory/stdlib-tier1-design.md +477 -0
- package/theory/theories-11-14.ts +466 -0
- package/theory/theories-15-21.ts +762 -0
- package/theory/theories-22-28.ts +794 -0
- package/theory/theories-29-35.ts +607 -0
- package/theory/theories-36-42.ts +937 -0
- package/theory/theories-43-49.ts +1298 -0
- package/theory/theories-50-56.ts +1449 -0
- package/theory/theories-57-66.ts +1724 -0
- package/theory/theories-67.ts +1696 -0
- package/theory/theories-8-10.ts +284 -0
- package/dist/index.cjs +0 -3282
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -169
package/package.json
CHANGED
|
@@ -1,62 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rei-lang",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Rei (0
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
],
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "rei-lang",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Rei (0₀式 / れいしき) — A mathematical computation language based on D-FUMT. Center-periphery patterns as language primitives achieve 74% average code reduction. Now with RCT semantic compression and 6-attribute system.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"rei": "./bin/rei.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"bin",
|
|
21
|
+
"spec",
|
|
22
|
+
"theory",
|
|
23
|
+
"PEACE_USE_CLAUSE.md",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"lint": "tsc --noEmit",
|
|
32
|
+
"prepublishOnly": "npm run lint && npm run test && npm run build",
|
|
33
|
+
"repl": "node bin/rei.js"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"rei",
|
|
37
|
+
"0₀式",
|
|
38
|
+
"れいしき",
|
|
39
|
+
"d-fumt",
|
|
40
|
+
"multi-dimensional-numbers",
|
|
41
|
+
"mathematical-computation",
|
|
42
|
+
"programming-language",
|
|
43
|
+
"zero-extension",
|
|
44
|
+
"center-periphery",
|
|
45
|
+
"compress",
|
|
46
|
+
"semantic-compression",
|
|
47
|
+
"rct",
|
|
48
|
+
"peace-use",
|
|
49
|
+
"ethical-source",
|
|
50
|
+
"nobuki-fujimoto"
|
|
51
|
+
],
|
|
52
|
+
"author": {
|
|
53
|
+
"name": "Nobuki Fujimoto"
|
|
54
|
+
},
|
|
55
|
+
"license": "Apache-2.0",
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/fc0web/rei-lang"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/fc0web/rei-lang#readme",
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/fc0web/rei-lang/issues"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/node": "^25.2.3",
|
|
66
|
+
"tsup": "^8.0.0",
|
|
67
|
+
"typescript": "^5.7.0",
|
|
68
|
+
"vitest": "^3.0.0"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=18.0.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
# Rei (0₀式) Language — Complete BNF v0.2
|
|
2
|
+
|
|
3
|
+
**Author:** Nobuki Fujimoto
|
|
4
|
+
**Date:** 2026-02-10
|
|
5
|
+
**Status:** Specification Draft
|
|
6
|
+
**Changes from v0.1:** Integration of Theory #8–#21 (14 theories, 31 keywords, 2 operators, 3 types)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Changelog from v0.1
|
|
11
|
+
|
|
12
|
+
| Item | v0.1 | v0.2 | Change |
|
|
13
|
+
|------|------|------|--------|
|
|
14
|
+
| Theory coverage | #1–#7 (core) | #1–#21 | +14 theories |
|
|
15
|
+
| Keywords | 14 | 45 | +31 |
|
|
16
|
+
| Operators | 8 | 10 | +2 (`⤊`/`⤋`, `◁`) |
|
|
17
|
+
| Types | 6 | 9 | +3 (`Temporal`, `Timeless`, `Quad`) |
|
|
18
|
+
| Compress modes | 1 (default) | 5 | +4 (`:zero`, `:pi`, `:e`, `:phi`) |
|
|
19
|
+
| Breaking changes | — | — | 0 |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Complete BNF Grammar
|
|
24
|
+
|
|
25
|
+
```ebnf
|
|
26
|
+
(* ============================================================ *)
|
|
27
|
+
(* Rei (0₀式) Language — Complete BNF v0.2 *)
|
|
28
|
+
(* Author: Nobuki Fujimoto *)
|
|
29
|
+
(* Theories: #1–#21 integrated *)
|
|
30
|
+
(* ============================================================ *)
|
|
31
|
+
|
|
32
|
+
(* ============================================================ *)
|
|
33
|
+
(* I. Program Structure *)
|
|
34
|
+
(* ============================================================ *)
|
|
35
|
+
|
|
36
|
+
program ::= statement*
|
|
37
|
+
|
|
38
|
+
statement ::= let_stmt
|
|
39
|
+
| compress_def
|
|
40
|
+
| expr_stmt
|
|
41
|
+
|
|
42
|
+
(* --- Variable Binding --- *)
|
|
43
|
+
let_stmt ::= 'let' 'mut'? IDENT (':' type_expr phase_guard?)?
|
|
44
|
+
'=' expr witness_clause?
|
|
45
|
+
|
|
46
|
+
witness_clause ::= 'witnessed' 'by' STRING
|
|
47
|
+
|
|
48
|
+
(* --- Compression Definition --- *)
|
|
49
|
+
compress_def ::= compress_level? 'compress' IDENT
|
|
50
|
+
'(' param_list ')' return_guard? '=' expr
|
|
51
|
+
|
|
52
|
+
compress_level ::= 'compress⁰' | 'compress¹' | 'compress²'
|
|
53
|
+
| 'compress³' | 'compress∞'
|
|
54
|
+
| 'compress' '[' NUMBER ']' (* ASCII fallback *)
|
|
55
|
+
|
|
56
|
+
param_list ::= (param_decl (',' param_decl)*)?
|
|
57
|
+
param_decl ::= IDENT ':' type_expr phase_guard?
|
|
58
|
+
|
|
59
|
+
return_guard ::= '->' type_expr phase_guard?
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
(* ============================================================ *)
|
|
63
|
+
(* II. Phase System *)
|
|
64
|
+
(* Genesis Axioms + ISL (#1–#7, GA-v2) *)
|
|
65
|
+
(* ============================================================ *)
|
|
66
|
+
|
|
67
|
+
phase_guard ::= '@' phase_type
|
|
68
|
+
phase_type ::= 'Open' | 'Sealed' | 'Compacted' (* ISL phases *)
|
|
69
|
+
| 'void' | 'dot' | 'zero_zero' (* Genesis phases *)
|
|
70
|
+
| 'zero' | 'number'
|
|
71
|
+
| 'evolving' | 'stationary' | 'periodic' (* #19 Temporal phases *)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
(* ============================================================ *)
|
|
75
|
+
(* III. Expression Hierarchy *)
|
|
76
|
+
(* ============================================================ *)
|
|
77
|
+
|
|
78
|
+
expr ::= pipe_expr
|
|
79
|
+
|
|
80
|
+
(* --- Pipe Expressions (core + #18 expand) --- *)
|
|
81
|
+
pipe_expr ::= curvature_expr (pipe_op cmd arg*
|
|
82
|
+
| '◁' expand_cmd (* #18 展開演算子 *)
|
|
83
|
+
)*
|
|
84
|
+
|
|
85
|
+
pipe_op ::= '|>' (* standard pipe *)
|
|
86
|
+
| '|>' '⟨' direction_set '⟩' (* directional pipe *)
|
|
87
|
+
| '<|' '⟨' direction_set '⟩' (* reverse pipe *)
|
|
88
|
+
|
|
89
|
+
direction_set ::= '*' | 'ortho' | 'diag'
|
|
90
|
+
| direction (',' direction)*
|
|
91
|
+
direction ::= 'N' | 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW'
|
|
92
|
+
|
|
93
|
+
(* --- Curvature Expressions (#4 曲率理論) --- *)
|
|
94
|
+
curvature_expr ::= add_expr ('>κ' add_expr
|
|
95
|
+
| '<κ' add_expr
|
|
96
|
+
| '=κ' add_expr)?
|
|
97
|
+
|
|
98
|
+
(* --- Arithmetic --- *)
|
|
99
|
+
add_expr ::= mul_expr (('⊕' | '+') mul_expr)*
|
|
100
|
+
mul_expr ::= ext_expr (('⊗' | '*' | '·') ext_expr)*
|
|
101
|
+
|
|
102
|
+
(* --- Extension/Reduction + Spiral (#1 ゼロ拡張, #16 DSZT, #17 無限拡張) --- *)
|
|
103
|
+
ext_expr ::= unary_expr ('>>' ':' ext_subscript (* 拡張 *)
|
|
104
|
+
| '<<' (* 縮約 *)
|
|
105
|
+
| '⤊' angle_expr (* #16 螺旋的次元上昇 *)
|
|
106
|
+
| '⤋' angle_expr? (* #16 螺旋的次元降下 *)
|
|
107
|
+
)*
|
|
108
|
+
|
|
109
|
+
ext_subscript ::= NUMBER (* 数値拡張: 0,1,2,... *)
|
|
110
|
+
| MATH_CONST (* 定数拡張: π, e, φ *)
|
|
111
|
+
| IDENT (* 変数拡張 *)
|
|
112
|
+
| SUBSCRIPT (* v0.1互換 *)
|
|
113
|
+
|
|
114
|
+
angle_expr ::= NUMBER (* ラジアン *)
|
|
115
|
+
| 'π' '/' NUMBER (* π分数 *)
|
|
116
|
+
| IDENT (* 変数 *)
|
|
117
|
+
|
|
118
|
+
(* --- Unary --- *)
|
|
119
|
+
unary_expr ::= primary ('.' IDENT | '.κ')*
|
|
120
|
+
|
|
121
|
+
(* --- Primary --- *)
|
|
122
|
+
primary ::= md_literal (* 多次元数リテラル *)
|
|
123
|
+
| curvature_literal (* 曲率リテラル *)
|
|
124
|
+
| quad_literal (* #21 四価リテラル *)
|
|
125
|
+
| NUMBER
|
|
126
|
+
| EXT_LIT
|
|
127
|
+
| CHAIN_LIT
|
|
128
|
+
| STRING
|
|
129
|
+
| IDENT
|
|
130
|
+
| '(' expr ')'
|
|
131
|
+
| CONST
|
|
132
|
+
| 'match' expr '{' match_arm+ '}'
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
(* ============================================================ *)
|
|
136
|
+
(* IV. Literals *)
|
|
137
|
+
(* ============================================================ *)
|
|
138
|
+
|
|
139
|
+
(* --- Multidimensional Number (#2 多次元数 + #19 時相) --- *)
|
|
140
|
+
md_literal ::= '𝕄' '{' expr ';' expr_list
|
|
141
|
+
('weight' expr_list)?
|
|
142
|
+
('mode' COMP_MODE)?
|
|
143
|
+
temporal_tag? (* #19 *)
|
|
144
|
+
'}'
|
|
145
|
+
|
|
146
|
+
temporal_tag ::= '|' 't' '=' expr (* #19 時刻タグ *)
|
|
147
|
+
|
|
148
|
+
(* --- Curvature Literal (#4 曲率) --- *)
|
|
149
|
+
curvature_literal ::= (NUMBER | EXT_LIT) 'κ' NUMBER
|
|
150
|
+
|
|
151
|
+
(* --- Four-valued Logic Literal (#21 四価0π) --- *)
|
|
152
|
+
quad_literal ::= '⊤' (* true *)
|
|
153
|
+
| '⊥' (* false *)
|
|
154
|
+
| '⊤π' (* latent true *)
|
|
155
|
+
| '⊥π' (* latent false *)
|
|
156
|
+
|
|
157
|
+
(* --- Chain Literal (#1 ゼロ拡張) --- *)
|
|
158
|
+
CHAIN_LIT ::= BASE '→' SUBSCRIPT_CHAR ('→' SUBSCRIPT_CHAR)*
|
|
159
|
+
('→' '{' SUBSCRIPT_CHAR (',' SUBSCRIPT_CHAR)* '}')?
|
|
160
|
+
|
|
161
|
+
(* --- Dot Literal (#10 点数体系) --- *)
|
|
162
|
+
dot_literal ::= '・' (* 原始点 *)
|
|
163
|
+
| '・' '⊕' '・' ('⊕' '・')* (* 点結合 *)
|
|
164
|
+
|
|
165
|
+
(* --- Dimension Slice --- *)
|
|
166
|
+
dim_slice ::= '[' 'dim' ':' direction_set ']'
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
(* ============================================================ *)
|
|
170
|
+
(* V. Pipe Commands (v0.1 core + #8–#21 extensions) *)
|
|
171
|
+
(* ============================================================ *)
|
|
172
|
+
|
|
173
|
+
cmd ::= core_cmd
|
|
174
|
+
| compress_cmd
|
|
175
|
+
| genesis_cmd
|
|
176
|
+
| theory_cmd
|
|
177
|
+
|
|
178
|
+
(* --- Core Commands (v0.1) --- *)
|
|
179
|
+
core_cmd ::= 'sum' | 'mean' | 'max' | 'min' | 'median'
|
|
180
|
+
| 'convolve' | 'gradient' | 'smooth'
|
|
181
|
+
| 'normalize' | 'classify'
|
|
182
|
+
| 'energize' | 'seal' | 'compute'
|
|
183
|
+
| IDENT (* user-defined *)
|
|
184
|
+
|
|
185
|
+
(* --- Compress Commands (v0.1 + #8 + #15) --- *)
|
|
186
|
+
compress_cmd ::= 'compress' compress_mode?
|
|
187
|
+
|
|
188
|
+
compress_mode ::= ':zero' (* #8 縮小ゼロ *)
|
|
189
|
+
| ':pi' (* #15 π縮小 *)
|
|
190
|
+
| ':e' (* #15 e縮小 *)
|
|
191
|
+
| ':phi' (* #15 φ縮小 *)
|
|
192
|
+
| ':' IDENT (* 将来の拡張 *)
|
|
193
|
+
|
|
194
|
+
(* --- Genesis Commands (GA-v2) --- *)
|
|
195
|
+
genesis_cmd ::= 'genesis' | 'phi' | 'psi' | 'omega'
|
|
196
|
+
|
|
197
|
+
(* --- Theory Extension Commands (#8–#21) --- *)
|
|
198
|
+
theory_cmd ::= contraction_cmd (* #8 縮小ゼロ *)
|
|
199
|
+
| linear_cmd (* #9 直線数体系 *)
|
|
200
|
+
| dot_cmd (* #10 点数体系 *)
|
|
201
|
+
| inverse_cmd (* #11 逆数理構築 *)
|
|
202
|
+
| decompose_cmd (* #12 数理分解構築 *)
|
|
203
|
+
| mirror_cmd (* #13 合わせ鏡 *)
|
|
204
|
+
| spiral_cmd (* #14 螺旋数体系 *)
|
|
205
|
+
| dszt_cmd (* #16 DSZT *)
|
|
206
|
+
| ext_query_cmd (* #17 無限拡張 *)
|
|
207
|
+
| temporal_cmd (* #19 時相 *)
|
|
208
|
+
| timeless_cmd (* #20 無時間性 *)
|
|
209
|
+
| quad_cmd (* #21 四価0π *)
|
|
210
|
+
|
|
211
|
+
(* #8 縮小ゼロ理論 *)
|
|
212
|
+
contraction_cmd ::= 'contract_to_zero'
|
|
213
|
+
| 'dynamic_equilibrium'
|
|
214
|
+
| 'contraction_limit'
|
|
215
|
+
|
|
216
|
+
(* #9 直線数体系理論 *)
|
|
217
|
+
linear_cmd ::= 'project' ':' axis_spec
|
|
218
|
+
| 'linear_interpolate'
|
|
219
|
+
axis_spec ::= ':axial' | ':radial' | ':tangent' | IDENT
|
|
220
|
+
|
|
221
|
+
(* #10 点数体系理論 *)
|
|
222
|
+
dot_cmd ::= 'to_dots'
|
|
223
|
+
| 'from_dots'
|
|
224
|
+
| 'dot_merge'
|
|
225
|
+
|
|
226
|
+
(* #11 逆数理構築理論 *)
|
|
227
|
+
inverse_cmd ::= 'inverse_construct' '(' constraint_list ')'
|
|
228
|
+
| 'solve_for' '(' IDENT ')'
|
|
229
|
+
|
|
230
|
+
(* #12 数理分解構築理論 *)
|
|
231
|
+
decompose_cmd ::= 'decompose' ':' decompose_basis
|
|
232
|
+
| 'reconstruct'
|
|
233
|
+
decompose_basis ::= ':axial' | ':spectral' | ':hierarchical' | IDENT
|
|
234
|
+
|
|
235
|
+
(* #13 合わせ鏡計算式 *)
|
|
236
|
+
mirror_cmd ::= 'mirror' '(' mirror_params ')'
|
|
237
|
+
| 'mirror_fixpoint'
|
|
238
|
+
mirror_params ::= 'depth' ':' NUMBER (',' 'damping' ':' NUMBER)?
|
|
239
|
+
|
|
240
|
+
(* #14 螺旋数体系理論 *)
|
|
241
|
+
spiral_cmd ::= 'spiral_traverse' '(' spiral_params ')'
|
|
242
|
+
| 'spiral_fold'
|
|
243
|
+
| 'spiral_unfold'
|
|
244
|
+
|
|
245
|
+
(* #16 次元螺旋零点理論 *)
|
|
246
|
+
dszt_cmd ::= 'spiral_extend' '(' dszt_params ')'
|
|
247
|
+
| 'find_spiral_zeros'
|
|
248
|
+
dszt_params ::= 'depth' ':' NUMBER (',' 'twist' ':' angle_expr)?
|
|
249
|
+
|
|
250
|
+
(* #17 無限拡張数学理論 *)
|
|
251
|
+
ext_query_cmd ::= 'extension_depth'
|
|
252
|
+
| 'extension_base'
|
|
253
|
+
| 'extension_root'
|
|
254
|
+
| 'extension_chain'
|
|
255
|
+
|
|
256
|
+
(* #18 縮小理論 — expand *)
|
|
257
|
+
expand_cmd ::= 'expand' expand_mode '(' expand_params ')'
|
|
258
|
+
|
|
259
|
+
expand_mode ::= ':uniform'
|
|
260
|
+
| ':maxent'
|
|
261
|
+
| ':pi' | ':e' | ':phi'
|
|
262
|
+
| ':' IDENT
|
|
263
|
+
|
|
264
|
+
expand_params ::= NUMBER (',' constraint_list)?
|
|
265
|
+
|
|
266
|
+
constraint_list ::= constraint (',' constraint)*
|
|
267
|
+
constraint ::= 'symmetry' ':' sym_type
|
|
268
|
+
| 'preserve' ':' IDENT
|
|
269
|
+
| 'prior' ':' expr
|
|
270
|
+
sym_type ::= ':ortho' | ':diag' | ':full' | ':none'
|
|
271
|
+
|
|
272
|
+
(* #19 時相数体系理論 *)
|
|
273
|
+
temporal_cmd ::= 'evolve' '(' evolve_params ')'
|
|
274
|
+
| 'at' '(' 't' ':' expr ')'
|
|
275
|
+
| 'temporal_diff'
|
|
276
|
+
| 'window' '(' 'from' ':' expr ',' 'to' ':' expr ')'
|
|
277
|
+
|
|
278
|
+
evolve_params ::= 'dt' ':' expr ',' 'steps' ':' expr
|
|
279
|
+
(',' 'rule' ':' evolve_rule)?
|
|
280
|
+
|
|
281
|
+
evolve_rule ::= ':diffusion' | ':wave' | ':advection'
|
|
282
|
+
| ':custom' '(' expr ')'
|
|
283
|
+
|
|
284
|
+
(* #20 無時間性数体系理論 *)
|
|
285
|
+
timeless_cmd ::= 'extract_invariant'
|
|
286
|
+
| 'assert_invariant' '(' expr ')'
|
|
287
|
+
| 'timeless_project'
|
|
288
|
+
| 'timeless_pipe' '[' cmd_list ']'
|
|
289
|
+
|
|
290
|
+
cmd_list ::= IDENT (',' IDENT)*
|
|
291
|
+
|
|
292
|
+
(* #21 四価0π理論 *)
|
|
293
|
+
quad_cmd ::= 'resolve' '(' 'condition' ':' expr ')'
|
|
294
|
+
| 'certainty'
|
|
295
|
+
| 'collapse'
|
|
296
|
+
| 'is_latent'
|
|
297
|
+
| 'is_definite'
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
(* ============================================================ *)
|
|
301
|
+
(* VI. Type System *)
|
|
302
|
+
(* ============================================================ *)
|
|
303
|
+
|
|
304
|
+
type_expr ::= base_type
|
|
305
|
+
| parameterized_type
|
|
306
|
+
| type_expr '[' ']'
|
|
307
|
+
|
|
308
|
+
base_type ::= 'Num' | 'ExtNum' | 'MultiDim' | 'Unified'
|
|
309
|
+
| 'Pipeline' | 'Genesis'
|
|
310
|
+
| 'CurvatureNum'
|
|
311
|
+
| 'Quad' (* #21 四価論理型 *)
|
|
312
|
+
| 'Dot' (* #10 点型 *)
|
|
313
|
+
| 'LinearNum' (* #9 直線数型 *)
|
|
314
|
+
| 'SpiralNum' (* #14 螺旋数型 *)
|
|
315
|
+
|
|
316
|
+
parameterized_type
|
|
317
|
+
::= 'Temporal' '<' type_expr '>' (* #19 時相型 *)
|
|
318
|
+
| 'Timeless' '<' type_expr '>' (* #20 無時間型 *)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
(* ============================================================ *)
|
|
322
|
+
(* VII. Pattern Matching (extended for #21) *)
|
|
323
|
+
(* ============================================================ *)
|
|
324
|
+
|
|
325
|
+
match_arm ::= pattern '=>' expr ','?
|
|
326
|
+
|
|
327
|
+
pattern ::= quad_literal (* #21 四価パターン *)
|
|
328
|
+
| NUMBER
|
|
329
|
+
| STRING
|
|
330
|
+
| IDENT
|
|
331
|
+
| '_' (* wildcard *)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
(* ============================================================ *)
|
|
335
|
+
(* VIII. Logic Operators (extended for #21) *)
|
|
336
|
+
(* ============================================================ *)
|
|
337
|
+
|
|
338
|
+
(* Four-valued logic extends standard boolean operators *)
|
|
339
|
+
logic_expr ::= expr '∧' expr (* AND — 四価拡張 *)
|
|
340
|
+
| expr '∨' expr (* OR — 四価拡張 *)
|
|
341
|
+
| '¬' expr (* NOT — 四価拡張 *)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
(* ============================================================ *)
|
|
345
|
+
(* IX. Terminal Symbols *)
|
|
346
|
+
(* ============================================================ *)
|
|
347
|
+
|
|
348
|
+
COMP_MODE ::= 'weighted' | 'multiplicative'
|
|
349
|
+
| 'harmonic' | 'exponential'
|
|
350
|
+
|
|
351
|
+
BASE ::= '0' | 'π' | 'e' | 'φ' | 'i' | NUMBER
|
|
352
|
+
|
|
353
|
+
SUBSCRIPT_CHAR ::= [oxzwensbua]
|
|
354
|
+
|
|
355
|
+
MATH_CONST ::= 'π' | 'e' | 'φ'
|
|
356
|
+
|
|
357
|
+
CONST ::= 'Φ' | 'Ψ' | 'Ω' | '∅' | '・' | '0₀'
|
|
358
|
+
|
|
359
|
+
IDENT ::= [a-zA-Z_] [a-zA-Z0-9_]*
|
|
360
|
+
|
|
361
|
+
NUMBER ::= [0-9]+ ('.' [0-9]+)?
|
|
362
|
+
|
|
363
|
+
STRING ::= '"' [^"]* '"'
|
|
364
|
+
|
|
365
|
+
SUBSCRIPT ::= [a-z0-9]+
|
|
366
|
+
|
|
367
|
+
arg ::= '(' expr_list ')'
|
|
368
|
+
expr_list ::= expr (',' expr)*
|
|
369
|
+
expr_stmt ::= expr
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Operator Precedence (low → high)
|
|
375
|
+
|
|
376
|
+
| Level | Operators | Associativity | Theory |
|
|
377
|
+
|-------|-----------|---------------|--------|
|
|
378
|
+
| 1 | `\|>`, `\|>⟨⟩`, `<\|⟨⟩`, `◁` | left | core, #18 |
|
|
379
|
+
| 2 | `∧`, `∨` | left | #21 |
|
|
380
|
+
| 3 | `>κ`, `<κ`, `=κ` | none | #4 |
|
|
381
|
+
| 4 | `⊕`, `+` | left | core |
|
|
382
|
+
| 5 | `⊗`, `*`, `·` | left | core |
|
|
383
|
+
| 6 | `>>`, `<<`, `⤊`, `⤋` | left | #1, #16, #17 |
|
|
384
|
+
| 7 | `¬` | right (prefix) | #21 |
|
|
385
|
+
| 8 | `.`, `.κ` | left | core |
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## v0.1 → v0.2 Migration
|
|
390
|
+
|
|
391
|
+
**完全後方互換。** v0.1で有効な全てのプログラムは、v0.2でも同一のセマンティクスで動作する。
|
|
392
|
+
|
|
393
|
+
新機能は全て以下のいずれかとして追加:
|
|
394
|
+
- パイプコマンド(`|> new_command`)
|
|
395
|
+
- compress モード(`compress :pi`)
|
|
396
|
+
- 型修飾子(`Temporal<T>`, `Timeless<T>`)
|
|
397
|
+
- リテラル(`⊤`, `⊥`, `⊤π`, `⊥π`)
|
|
398
|
+
- 演算子(`⤊`, `⤋`, `◁`)— 既存演算子との文法的衝突なし
|