rei-lang 0.4.0 → 0.5.1

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/README.md CHANGED
@@ -1,257 +1,474 @@
1
- # Rei (0₀式) — D-FUMT Computational Language
2
-
3
- [![npm version](https://img.shields.io/npm/v/rei-lang)](https://www.npmjs.com/package/rei-lang)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-gold.svg)](./LICENSE)
5
- [![Tests](https://img.shields.io/badge/tests-85%2F85-brightgreen)]()
6
-
7
- **Rei** (0₀式 / れいしき) is a mathematical computation language based on **D-FUMT** (Dimensional Fujimoto Universal Mathematical Theory). Its center-periphery patterns as language primitives achieve an **average 74% code reduction** over equivalent implementations in general-purpose languages.
8
-
9
- **Author:** Nobuki Fujimoto
10
-
11
- ---
12
-
13
- ## Install
14
-
15
- ```bash
16
- npm install rei-lang
17
- ```
18
-
19
- ## Quick Start
20
-
21
- ### As a Library
22
-
23
- ```typescript
24
- import { rei } from 'rei-lang';
25
-
26
- // Multi-dimensional number computation
27
- rei('let field = 𝕄{5; 1, 2, 3, 4}');
28
- const result = rei('field |> compute :weighted');
29
- console.log(result); // 7.5
30
-
31
- // Define functions with compress
32
- rei('compress energy(m) = m |> compute :weighted');
33
- rei('let e = energy(𝕄{0; 10, 20, 30})');
34
- console.log(rei('e')); // 20
35
-
36
- // Genesis axiom system
37
- rei('let g = genesis()');
38
- rei('g |> forward');
39
- rei('g |> forward');
40
- console.log(rei('g.state')); // "line"
41
-
42
- // Reset state between sessions
43
- rei.reset();
44
- ```
45
-
46
- ### Interactive REPL
47
-
48
- ```bash
49
- npx rei
50
- ```
51
-
52
- ```
53
- ╔══════════════════════════════════════════╗
54
- ║ Rei (0₀式) REPL v0.2.0 ║
55
- ║ D-FUMT Computational Language ║
56
- ╚══════════════════════════════════════════╝
57
-
58
- 零 > 𝕄{5; 1, 2, 3, 4} |> compute :weighted
59
- 7.5
60
-
61
- > compress karma(i, e, r) = i * e * r
62
- compress karma(i, e, r)
63
-
64
- > karma(0.8, 0.9, 0.7)
65
- 0.504
66
- ```
67
-
68
- ### Execute a File
69
-
70
- ```bash
71
- npx rei program.rei
72
- ```
73
-
74
- ### Inline Evaluation
75
-
76
- ```bash
77
- npx rei -e "2 + 3 * 4"
78
- # → 14
79
- ```
80
-
81
- ---
82
-
83
- ## Language Features
84
-
85
- ### Multi-Dimensional Numbers (𝕄)
86
-
87
- The core data structure. A center value with peripheral neighbors, computed in 4 modes:
88
-
89
- ```rei
90
- let m = 𝕄{5; 1, 2, 3, 4}
91
-
92
- m |> compute :weighted // center + weighted avg of neighbors
93
- m |> compute :multiplicative // center × Π(1 + nᵢ)
94
- m |> compute :harmonic // center + n / Σ(1/|nᵢ|)
95
- m |> compute :exponential // center × avg(e^nᵢ)
96
- ```
97
-
98
- ### Extended Numbers (拡張数)
99
-
100
- Numbers with subscript-based dimensional extension:
101
-
102
- ```rei
103
- let a = 0ooo // 3rd-order extension of zero
104
- a >> :x >> :x // extend: order 3 → 5
105
- a << // reduce: order 3 → 2
106
- a |> valStar // numeric projection: 0.001
107
-
108
- πooo // π extended to 3rd order
109
- 0₀ // D-FUMT zero symbol
110
- ```
111
-
112
- ### Compress (関数定義)
113
-
114
- Functions are defined with `compress` — reflecting D-FUMT's compression philosophy:
115
-
116
- ```rei
117
- compress distance(x, y) = sqrt(x * x + y * y)
118
- compress field(c, r) = 𝕄{c; r, r, r, r}
119
-
120
- distance(3, 4) // 5
121
- field(10, 2) |> compute :weighted // 12
122
- ```
123
-
124
- ### Pipe Operator (|>)
125
-
126
- Center-to-periphery data flow:
127
-
128
- ```rei
129
- -25 |> abs |> sqrt // 5
130
- [3, 1, 2] |> sort |> reverse // [3, 2, 1]
131
- "hello" |> upper // "HELLO"
132
- 𝕄{0; 1, 2, 3} |> normalize // normalized neighbors
133
- ```
134
-
135
- ### Genesis Axiom System (生成公理系)
136
-
137
- Models computational emergence from void:
138
-
139
- ```rei
140
- let g = genesis() // void
141
- g |> forward // void → dot
142
- g |> forward // dot → line
143
- g |> forward // line surface
144
- g |> forward // surface solid
145
- g |> forward // solid → omega (Ω)
146
- g.omega // 1
147
- ```
148
-
149
- Or from the primordial dot (・):
150
-
151
- ```rei
152
- let g = ・
153
- g |> forward // dot
154
- g |> forward // line
155
- ```
156
-
157
- ### Four-Valued Logic (四価0π)
158
-
159
- Beyond true/false — Theory #21:
160
-
161
- ```rei
162
- ⊤ // true
163
- ⊥ // false
164
- ⊤π // true-pi (π-rotated truth)
165
- ⊥π // false-pi
166
-
167
- ¬⊤ //
168
- //
169
- //
170
- ```
171
-
172
- ### Variable Binding
173
-
174
- ```rei
175
- let x = 42 // immutable
176
- let mut y = 10 // mutable
177
- ```
178
-
179
- ---
180
-
181
- ## Benchmarks
182
-
183
- | Task | Conventional | Rei | Reduction |
184
- |------|-------------|-----|-----------|
185
- | Image kernel calculations | 32 lines | 8 lines | **4×** |
186
- | Multi-dimensional data aggregation | 45 lines | 12 lines | **3.7×** |
187
- | Graph structure transformation | 52 lines | 14 lines | **3.7×** |
188
- | **Average** | | | **74%** |
189
-
190
- ---
191
-
192
- ## API Reference
193
-
194
- ### `rei(code: string): ReiValue`
195
-
196
- Evaluate a string of Rei code. State persists across calls.
197
-
198
- ### `rei.reset(): void`
199
-
200
- Clear all variable and function bindings.
201
-
202
- ### `rei.parse(code: string): ASTNode`
203
-
204
- Parse code and return the AST without evaluating.
205
-
206
- ### `rei.tokenize(code: string): Token[]`
207
-
208
- Tokenize code and return the token stream.
209
-
210
- ### Classes
211
-
212
- - `Lexer` Tokenizer
213
- - `Parser` Recursive descent parser
214
- - `Evaluator` — AST evaluator with environment/scope chain
215
- - `Environment` — Scope management
216
-
217
- ### Types
218
-
219
- - `MultiDimNumber` — `{ center, neighbors, mode, weights? }`
220
- - `ReiExtended` `{ base, order, subscripts, valStar() }`
221
- - `GenesisState` — `{ state, omega, history }`
222
- - `ReiFunction` — `{ name, params, body, closure }`
223
- - `Quad` `{ value: 'top' | 'bottom' | 'topPi' | 'bottomPi' }`
224
-
225
- ---
226
-
227
- ## BNF Specification
228
-
229
- The complete BNF v0.2 specification is available in the repository.
230
-
231
- Key features integrated from 21 D-FUMT theories:
232
- - 45 keywords, 10 operators, 9 types
233
- - Full backward compatibility with v0.1
234
- - Complete operator precedence table
235
-
236
- ---
237
-
238
- ## Theoretical Foundation
239
-
240
- Rei is grounded in **D-FUMT** (Dimensional Fujimoto Universal Mathematical Theory), a framework of 66 interconnected theories spanning pure mathematics to philosophy and AI consciousness. The language's core innovation — **center-periphery patterns as language primitives** — derives from D-FUMT's multi-dimensional number system theory.
241
-
242
- ---
243
- ☮️ Peace Use Clause / 平和利用条項
244
- Rei is licensed under Apache 2.0 with an additional Peace Use Clause.
245
- Rei Apache 2.0 ライセンスに加え、平和利用条項が適用されます。
246
- Rooted in the Buddhist concept of "Kū" (空, Emptiness) and D-FUMT's consciousness mathematics, Rei is designed exclusively for the peaceful advancement of humanity. This software may not be used for:
247
- 仏教の「空」の概念と D-FUMT の意識数学に基づき、Rei は人類の平和的発展のためにのみ設計されています。以下の目的での使用は禁止されています:
248
-
249
- 🚫 Weapons, military systems, or LAWS / 兵器・軍事システム・自律型致死兵器
250
- 🚫 Human rights violations / 人権侵害
251
- 🚫 Intentional environmental destruction / 意図的な環境破壊
252
-
253
- ✅ Education, research, humanitarian aid, and creative endeavors are encouraged.
254
- 教育・研究・人道支援・創造的活動での使用を推奨します。
255
- See PEACE_USE_CLAUSE.md for full details.
256
-
257
- MIT © Nobuki Fujimoto
1
+ # Rei (0₀式) — D-FUMT Computational Language
2
+
3
+ [![npm version](https://img.shields.io/npm/v/rei-lang)](https://www.npmjs.com/package/rei-lang)
4
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-gold.svg)](./LICENSE)
5
+ [![Tests](https://img.shields.io/badge/tests-762%2F762-brightgreen)]()
6
+
7
+ **Rei** (0₀式 / れいしき) is a mathematical computation language based on **D-FUMT** (Dimensional Fujimoto Universal Mathematical Theory). Its center-periphery patterns as language primitives achieve an **average 74% code reduction** over equivalent implementations in general-purpose languages.
8
+
9
+ **Author:** Nobuki Fujimoto
10
+
11
+ ---
12
+
13
+ ## What's New in v0.5.1 — AgentSpace (Phase 4a)
14
+
15
+ **Puzzles and games are the same abstraction.** AgentSpace unifies puzzle-solving and game-playing on the v0.5 agent runtime:
16
+
17
+ - **Puzzles** = cooperative multi-agent systems (all cells work toward a common goal)
18
+ - **Games** = competitive multi-agent systems (players have opposing objectives)
19
+
20
+ The only difference is agent `behavior` and mediator `strategy`.
21
+
22
+ ```rei
23
+ // Puzzle: Agent-based solving
24
+ 30 |> generate_sudoku(42) |> agent_solve // 81 cooperative agents solve sudoku
25
+ 30 |> 数独生成(42) |> 自律解法 // Japanese syntax
26
+
27
+ // Game: Agent-based play
28
+ game("tictactoe") |> agent_play("competitive", "cooperative")
29
+ game("tictactoe") |> agent_match // Full match to completion
30
+
31
+ // Unified observation
32
+ sudoku(grid) |> as_agent_space |> 調停σ // Same σ for both
33
+ game("tictactoe") |> as_agent_space |> 調停σ
34
+ ```
35
+
36
+ ### v0.5 Agent Runtime
37
+
38
+ v0.5 introduced a **self-organizing agent runtime** — entities perceive, decide, and act autonomously, coordinated by a conflict-resolving mediator.
39
+
40
+ - **EventBus** — Type-safe event-driven architecture with flow momentum tracking
41
+ - **Entity Agent** — Six-attribute autonomous agents (perceive → decide → act cycle)
42
+ - **Mediator** Concurrent execution engine with conflict detection and resolution strategies
43
+
44
+ ---
45
+
46
+ ## Install
47
+
48
+ ```bash
49
+ npm install rei-lang
50
+ ```
51
+
52
+ ## Quick Start
53
+
54
+ ### As a Library
55
+
56
+ ```typescript
57
+ import { rei } from 'rei-lang';
58
+
59
+ // Multi-dimensional number computation
60
+ rei('let field = 𝕄{5; 1, 2, 3, 4}');
61
+ const result = rei('field |> compute :weighted');
62
+ console.log(result); // 7.5
63
+
64
+ // Define functions with compress
65
+ rei('compress energy(m) = m |> compute :weighted');
66
+ rei('let e = energy(𝕄{0; 10, 20, 30})');
67
+ console.log(rei('e')); // 20
68
+
69
+ // Genesis axiom system
70
+ rei('let g = genesis()');
71
+ rei('g |> forward');
72
+ rei('g |> forward');
73
+ console.log(rei('g.state')); // "line"
74
+
75
+ // Reset state between sessions
76
+ rei.reset();
77
+ ```
78
+
79
+ ### Interactive REPL
80
+
81
+ ```bash
82
+ npx rei
83
+ ```
84
+
85
+ ```
86
+ ╔══════════════════════════════════════════╗
87
+ ║ Rei (0₀式) REPL v0.5.0 ║
88
+ ║ D-FUMT Computational Language ║
89
+ ╚══════════════════════════════════════════╝
90
+
91
+ 零 > 𝕄{5; 1, 2, 3, 4} |> compute :weighted
92
+ 7.5
93
+
94
+ > compress karma(i, e, r) = i * e * r
95
+ compress karma(i, e, r)
96
+
97
+ 零 > karma(0.8, 0.9, 0.7)
98
+ 0.504
99
+ ```
100
+
101
+ ### Execute a File
102
+
103
+ ```bash
104
+ npx rei program.rei
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Language Features
110
+
111
+ ### Multi-Dimensional Numbers (𝕄)
112
+
113
+ The core data structure. A center value with peripheral neighbors, computed in 4 modes:
114
+
115
+ ```rei
116
+ let m = 𝕄{5; 1, 2, 3, 4}
117
+
118
+ m |> compute :weighted // center + weighted avg of neighbors
119
+ m |> compute :multiplicative // center × Π(1 + nᵢ)
120
+ m |> compute :harmonic // center + n / Σ(1/|nᵢ|)
121
+ m |> compute :exponential // center × avg(e^nᵢ)
122
+ ```
123
+
124
+ ### Extended Numbers (拡張数)
125
+
126
+ Numbers with subscript-based dimensional extension:
127
+
128
+ ```rei
129
+ let a = 0ooo // 3rd-order extension of zero
130
+ a >> :x >> :x // extend: order 3 5
131
+ a << // reduce: order 3 → 2
132
+ a |> valStar // numeric projection: 0.001
133
+
134
+ πooo // π extended to 3rd order
135
+ 0₀ // D-FUMT zero symbol
136
+ ```
137
+
138
+ ### Compress (関数定義)
139
+
140
+ Functions are defined with `compress` — reflecting D-FUMT's compression philosophy:
141
+
142
+ ```rei
143
+ compress distance(x, y) = sqrt(x * x + y * y)
144
+ compress field(c, r) = 𝕄{c; r, r, r, r}
145
+
146
+ distance(3, 4) // 5
147
+ field(10, 2) |> compute :weighted // 12
148
+ ```
149
+
150
+ ### Pipe Operator (|>)
151
+
152
+ Center-to-periphery data flow:
153
+
154
+ ```rei
155
+ -25 |> abs |> sqrt // 5
156
+ [3, 1, 2] |> sort |> reverse // [3, 2, 1]
157
+ "hello" |> upper // "HELLO"
158
+ 𝕄{0; 1, 2, 3} |> normalize // normalized neighbors
159
+ ```
160
+
161
+ ### Genesis Axiom System (生成公理系)
162
+
163
+ Models computational emergence from void:
164
+
165
+ ```rei
166
+ let g = genesis() // void
167
+ g |> forward // void → dot
168
+ g |> forward // dot → line
169
+ g |> forward // line → surface
170
+ g |> forward // surface → solid
171
+ g |> forward // solid → omega (Ω)
172
+ g.omega // 1
173
+ ```
174
+
175
+ ### Four-Valued Logic (四価0π)
176
+
177
+ Beyond true/false — based on D-FUMT Theory #21:
178
+
179
+ ```rei
180
+ ⊤ // true
181
+ ⊥ // false
182
+ ⊤π // true-pi (π-rotated truth)
183
+ ⊥π // false-pi
184
+
185
+ ¬⊤ //
186
+ ⊥ //
187
+ ⊤ //
188
+ ```
189
+
190
+ ---
191
+
192
+ ## v0.5 Agent Runtime
193
+
194
+ ### EventBus (イベントバス)
195
+
196
+ Type-safe event system with flow momentum tracking. Events follow a `category:action` pattern (e.g., `entity:fuse`, `agent:act`, `space:diffuse`).
197
+
198
+ ```typescript
199
+ import { rei, ReiEventBus } from 'rei-lang';
200
+
201
+ // Access via Evaluator
202
+ const ev = rei.evaluator();
203
+ const bus = ev.eventBus;
204
+
205
+ // Subscribe to events
206
+ bus.on('entity:fuse', (event) => {
207
+ console.log('Fusion occurred:', event.data);
208
+ });
209
+
210
+ // Subscribe with filter
211
+ bus.subscribe(
212
+ (e) => e.category === 'agent',
213
+ (e) => console.log(`Agent ${e.data.agentId}: ${e.action}`)
214
+ );
215
+ ```
216
+
217
+ In Rei syntax with pipe commands:
218
+
219
+ ```rei
220
+ // Emit a custom event
221
+ "mySource" |> emit("entity:transform", "data")
222
+
223
+ // Subscribe to events
224
+ "entity:*" |> subscribe
225
+
226
+ // Check flow momentum state
227
+ 0 |> flow_momentum // → { state: "expanding", rate: 12.5, ... }
228
+ ```
229
+
230
+ ### Entity Agent (自律エンティティ)
231
+
232
+ Entities in Rei are autonomous agents with the six D-FUMT attributes (場・流れ・記憶・層・関係・意志), executing a perceive → decide → act lifecycle.
233
+
234
+ ```rei
235
+ // Spawn an agent from a value
236
+ let a = 𝕄{10; 1, 2, 3} |> spawn
237
+
238
+ // Agent lifecycle
239
+ a |> perceive // observe environment → Perception
240
+ a |> decide // choose action Decision
241
+ a |> act // execute decision → ActionResult
242
+
243
+ // Agent introspection
244
+ a |> agent_sigma // σ metadata: state, step, memory, bindings
245
+ a |> 自律σ // 日本語版
246
+
247
+ // Agent behaviors: reactive / proactive / cooperative / competitive / contemplative
248
+ ```
249
+
250
+ ```typescript
251
+ // Programmatic API
252
+ import { ReiAgent, AgentRegistry } from 'rei-lang';
253
+
254
+ const registry = new AgentRegistry();
255
+ const agent = registry.spawn(42, {
256
+ behavior: 'cooperative',
257
+ autonomyLevel: 0.8,
258
+ });
259
+
260
+ const perception = agent.perceive(registry);
261
+ const decision = agent.decide(perception);
262
+ const result = agent.act(registry, decision);
263
+ ```
264
+
265
+ ### Mediator (調停エンジン)
266
+
267
+ The Mediator coordinates multiple agents running concurrently, detecting and resolving conflicts with configurable strategies.
268
+
269
+ ```rei
270
+ // Concurrent execution — all agents perceive → decide → resolve conflicts → act
271
+ 0 |> mediate // 1 round of concurrent execution
272
+ 0 |> mediate(5) // 5 rounds with convergence detection
273
+ 0 |> mediate(10, 0.8) // max 10 rounds, convergence threshold 0.8
274
+
275
+ // Strategies: priority / cooperative / sequential / cancel_both / mediator
276
+ 0 |> mediate_strategy("cooperative") // 協調 — merge conflicting intentions
277
+ 0 |> 調停戦略("協調") // 日本語版
278
+
279
+ // Inter-agent messaging
280
+ "agent_a" |> mediate_message("agent_b", "hello") // point-to-point
281
+ "agent_a" |> mediate_broadcast("共有データ") // broadcast to all
282
+
283
+ // Mediator σ — statistics and convergence history
284
+ 0 |> mediator_sigma // → { totalRounds, conflicts, convergenceHistory, ... }
285
+ 0 |> 調停σ // 日本語版
286
+ ```
287
+
288
+ Conflict types detected automatically: **target contention** (same target), **resource conflict** (shared resource), **mutual fuse** (A↔B fusion), **contradictory** (fuse vs separate).
289
+
290
+ Resolution strategies:
291
+
292
+ | Strategy | Japanese | Behavior |
293
+ |----------|----------|----------|
294
+ | `priority` | 優先 | Highest confidence × priority wins |
295
+ | `cooperative` | 協調 | Merge intentions into compromise |
296
+ | `sequential` | 順次 | Execute in priority order |
297
+ | `cancel_both` | 両方取消 | Cancel conflicting actions |
298
+ | `mediator` | 調停者 | Mediator's own judgment (中道) |
299
+
300
+ ```typescript
301
+ // Programmatic API
302
+ import { ReiMediator, AgentRegistry } from 'rei-lang';
303
+
304
+ const registry = new AgentRegistry();
305
+ const mediator = new ReiMediator(registry);
306
+
307
+ // Spawn agents
308
+ registry.spawn(10, { behavior: 'cooperative' });
309
+ registry.spawn(20, { behavior: 'competitive' });
310
+
311
+ // Run concurrent rounds with convergence detection
312
+ const result = mediator.run({
313
+ maxRounds: 10,
314
+ convergenceThreshold: 0.8,
315
+ });
316
+ console.log(result.converged, result.totalRounds);
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Six Attributes (六属性)
322
+
323
+ Every entity in Rei carries six attributes from D-FUMT theory:
324
+
325
+ | Attribute | Japanese | Role |
326
+ |-----------|----------|------|
327
+ | Field (場) | ば | Spatial context and neighbors |
328
+ | Flow (流れ) | ながれ | Temporal momentum and EventBus connection |
329
+ | Memory (記憶) | きおく | History of observations and actions |
330
+ | Layer (層) | そう | Hierarchical depth and nesting |
331
+ | Relation (関係) | かんけい | Bindings between entities |
332
+ | Will (意志) | いし | Intention-driven computation strategy |
333
+
334
+ ```rei
335
+ // Relation binding
336
+ let x = 42
337
+ let y = 100
338
+ x |> bind(y, "collaborator") // create a relation
339
+
340
+ // Will-driven computation
341
+ let m = 𝕄{5; 1, 2, 3}
342
+ m |> intend("maximize") // set intention
343
+ m |> will_compute // compute guided by will
344
+ ```
345
+
346
+ ---
347
+
348
+ ## RCT Compression (Rei Compression Theory)
349
+
350
+ D-FUMT Theory #67 — generative compression outperforming gzip on structured data:
351
+
352
+ ```rei
353
+ // Core compression (Direction 1-2)
354
+ let data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
355
+ data |> compress // → compact θ representation
356
+ data |> compress |> decompress // → lossless round-trip
357
+
358
+ // Semantic compression (Direction 3)
359
+ "let x = 𝕄{5; 1, 2, 3}" |> semantic_compress // → θ parameters
360
+ "let x = 𝕄{5; 1, 2, 3}" |> 意味圧縮 // 日本語版
361
+ ```
362
+
363
+ ---
364
+
365
+ ## Benchmarks
366
+
367
+ | Task | Conventional | Rei | Reduction |
368
+ |------|-------------|-----|-----------|
369
+ | Image kernel calculations | 32 lines | 8 lines | **4×** |
370
+ | Multi-dimensional data aggregation | 45 lines | 12 lines | **3.7×** |
371
+ | Graph structure transformation | 52 lines | 14 lines | **3.7×** |
372
+ | **Average** | | | **74%** |
373
+
374
+ ---
375
+
376
+ ## API Reference
377
+
378
+ ### `rei(code: string): ReiValue`
379
+
380
+ Evaluate a string of Rei code. State persists across calls.
381
+
382
+ ### `rei.reset(): void`
383
+
384
+ Clear all variable and function bindings.
385
+
386
+ ### `rei.evaluator(): Evaluator`
387
+
388
+ Access the underlying Evaluator instance (for EventBus, AgentRegistry, etc.).
389
+
390
+ ### Classes
391
+
392
+ | Class | Description |
393
+ |-------|-------------|
394
+ | `Lexer` | Tokenizer |
395
+ | `Parser` | Recursive descent parser |
396
+ | `Evaluator` | AST evaluator with environment/scope chain |
397
+ | `ReiEventBus` | Type-safe event system with flow momentum |
398
+ | `ReiAgent` | Autonomous entity with six attributes |
399
+ | `AgentRegistry` | Agent lifecycle management |
400
+ | `ReiMediator` | Concurrent execution engine with conflict resolution |
401
+
402
+ ### Types
403
+
404
+ | Type | Shape |
405
+ |------|-------|
406
+ | `MultiDimNumber` | `{ center, neighbors, mode, weights? }` |
407
+ | `ReiExtended` | `{ base, order, subscripts, valStar() }` |
408
+ | `GenesisState` | `{ state, omega, history }` |
409
+ | `ReiFunction` | `{ name, params, body, closure }` |
410
+ | `Quad` | `{ value: 'top' \| 'bottom' \| 'topPi' \| 'bottomPi' }` |
411
+ | `ReiEvent` | `{ type, category, action, timestamp, data, source?, depth }` |
412
+ | `AgentSigma` | `{ state, kind, behavior, step, perception, decisions, memory }` |
413
+ | `MediatorSigma` | `{ totalRounds, conflicts, convergenceHistory, agentCount }` |
414
+
415
+ ---
416
+
417
+ ## Bilingual Pipe Commands (日本語対応)
418
+
419
+ All pipe commands have Japanese aliases:
420
+
421
+ | English | 日本語 | Description |
422
+ |---------|--------|-------------|
423
+ | `spawn` | `生成` | Create agent from value |
424
+ | `perceive` | `知覚` | Agent observes environment |
425
+ | `decide` | `判断` | Agent chooses action |
426
+ | `act` | `行動` | Agent executes decision |
427
+ | `agent_sigma` | `自律σ` | Agent metadata |
428
+ | `mediate` | `調停` | Concurrent round execution |
429
+ | `mediate_run` | `調停実行` | Multi-round execution |
430
+ | `mediator_sigma` | `調停σ` | Mediator statistics |
431
+ | `mediate_strategy` | `調停戦略` | Set conflict strategy |
432
+ | `mediate_message` | `調停通信` | Point-to-point message |
433
+ | `mediate_broadcast` | `調停放送` | Broadcast to all agents |
434
+ | `emit` | `発火` | Emit event |
435
+ | `subscribe` | `購読` | Subscribe to events |
436
+ | `bind` | `結合` | Create relation binding |
437
+ | `intend` | `意図` | Set entity intention |
438
+ | `compress` | `圧縮` | RCT compression |
439
+ | `decompress` | `復元` | RCT decompression |
440
+
441
+ ---
442
+
443
+ ## BNF Specification
444
+
445
+ The complete BNF v0.3 specification is available in [`spec/`](./spec/).
446
+
447
+ ---
448
+
449
+ ## Theoretical Foundation
450
+
451
+ Rei is grounded in **D-FUMT** (Dimensional Fujimoto Universal Mathematical Theory), a framework of 66 interconnected theories spanning pure mathematics to philosophy and AI consciousness. The language's core innovation — **center-periphery patterns as language primitives** — derives from D-FUMT's multi-dimensional number system theory.
452
+
453
+ See [`theory/`](./theory/) for the complete theoretical documentation.
454
+
455
+ ---
456
+
457
+ ## ☮️ Peace Use Clause / 平和利用条項
458
+
459
+ Rei is licensed under Apache 2.0 with an additional Peace Use Clause.
460
+ Rei は Apache 2.0 ライセンスに加え、平和利用条項が適用されます。
461
+
462
+ Rooted in the Buddhist concept of "Kū" (空, Emptiness) and D-FUMT's consciousness mathematics, Rei is designed exclusively for the peaceful advancement of humanity. This software may not be used for:
463
+ 仏教の「空」の概念と D-FUMT の意識数学に基づき、Rei は人類の平和的発展のためにのみ設計されています。以下の目的での使用は禁止されています:
464
+
465
+ 🚫 Weapons, military systems, or LAWS / 兵器・軍事システム・自律型致死兵器
466
+ 🚫 Human rights violations / 人権侵害
467
+ 🚫 Intentional environmental destruction / 意図的な環境破壊
468
+
469
+ ✅ Education, research, humanitarian aid, and creative endeavors are encouraged.
470
+ ✅ 教育・研究・人道支援・創造的活動での使用を推奨します。
471
+
472
+ See [PEACE_USE_CLAUSE.md](./PEACE_USE_CLAUSE.md) for full details.
473
+
474
+ Apache 2.0 © Nobuki Fujimoto