rei-lang 0.5.1 → 0.5.3
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 +171 -339
- package/bin/rei.js +1 -1
- package/dist/index.d.mts +292 -3
- package/dist/index.d.ts +292 -3
- package/dist/index.js +1382 -151
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1369 -152
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,45 +1,67 @@
|
|
|
1
|
-
# Rei (0₀式) —
|
|
1
|
+
# Rei (0₀式) — Values That Know Themselves
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/rei-lang)
|
|
4
4
|
[](./LICENSE)
|
|
5
|
-
[]()
|
|
6
|
+
[](./PEACE_USE_CLAUSE.md)
|
|
6
7
|
|
|
7
|
-
**Rei**
|
|
8
|
+
**Rei** is a computation language where every value carries six attributes — field, flow, memory, layer, relation, and will — as language primitives. Where other languages lose context at every step, Rei values know where they are, where they came from, and what they're connected to.
|
|
8
9
|
|
|
9
|
-
**Author:** Nobuki Fujimoto
|
|
10
|
+
**Author:** Nobuki Fujimoto (藤本 伸樹)
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
##
|
|
14
|
+
## Why Rei?
|
|
14
15
|
|
|
15
|
-
|
|
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`.
|
|
16
|
+
In conventional languages, spatial structure, history, and relationships are things you build on top. In Rei, they're built in.
|
|
21
17
|
|
|
22
18
|
```rei
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
// A value with spatial context: center 5, neighbors [1, 2, 3]
|
|
20
|
+
let mut x = 𝕄{5; 1, 2, 3}
|
|
21
|
+
|
|
22
|
+
// One pipe gives you the full picture — no manual tracking needed
|
|
23
|
+
x |> sigma
|
|
24
|
+
// → { field: { center: 5, neighbors: [1,2,3], dim: 3 },
|
|
25
|
+
// flow: { velocity: 0, phase: "rest" },
|
|
26
|
+
// memory: { entries: [...], trajectory: [...] },
|
|
27
|
+
// layer: { depth: 1, structure: "flat" },
|
|
28
|
+
// relation: { refs: [], isolated: true },
|
|
29
|
+
// will: { tendency: "rest", strength: 0 } }
|
|
30
|
+
```
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
game("tictactoe") |> agent_play("competitive", "cooperative")
|
|
29
|
-
game("tictactoe") |> agent_match // Full match to completion
|
|
32
|
+
This isn't a library feature. It's **what values are** in Rei.
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
### What this enables
|
|
35
|
+
|
|
36
|
+
**Dependency tracing without instrumentation:**
|
|
37
|
+
```rei
|
|
38
|
+
let mut a = 𝕄{5; 1, 2, 3}
|
|
39
|
+
let mut b = 𝕄{10; 4, 5, 6}
|
|
40
|
+
let mut c = 𝕄{7; 8, 9}
|
|
41
|
+
a |> bind("b", "mirror")
|
|
42
|
+
b |> bind("c", "mirror")
|
|
43
|
+
|
|
44
|
+
a |> trace
|
|
45
|
+
// → { root: "a", chains: [["a","b","c"]], maxDepth: 2 }
|
|
46
|
+
// a knows its entire dependency graph — automatically
|
|
34
47
|
```
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
**Influence scoring between connected values:**
|
|
50
|
+
```rei
|
|
51
|
+
a |> influence("c")
|
|
52
|
+
// → { from: "a", to: "c", score: 1, path: ["a","b","c"], hops: 2 }
|
|
53
|
+
```
|
|
37
54
|
|
|
38
|
-
|
|
55
|
+
**Values that evolve their own intentions:**
|
|
56
|
+
```rei
|
|
57
|
+
let mut w = 𝕄{5; 1, 2, 3}
|
|
58
|
+
w |> intend("maximize")
|
|
59
|
+
w |> will_evolve
|
|
60
|
+
// → { previous: {tendency:"rest"}, evolved: {tendency:"rest", strength:0.3},
|
|
61
|
+
// reason: "弱い意志 → 内在傾向に回帰", autonomous: true }
|
|
62
|
+
```
|
|
39
63
|
|
|
40
|
-
|
|
41
|
-
- **Entity Agent** — Six-attribute autonomous agents (perceive → decide → act cycle)
|
|
42
|
-
- **Mediator** — Concurrent execution engine with conflict detection and resolution strategies
|
|
64
|
+
In Python, every one of these features requires a framework, manual state tracking, and hundreds of lines of boilerplate. In Rei, they're one pipe away.
|
|
43
65
|
|
|
44
66
|
---
|
|
45
67
|
|
|
@@ -49,31 +71,27 @@ v0.5 introduced a **self-organizing agent runtime** — entities perceive, decid
|
|
|
49
71
|
npm install rei-lang
|
|
50
72
|
```
|
|
51
73
|
|
|
52
|
-
## Quick Start
|
|
74
|
+
## Quick Start (5 minutes)
|
|
53
75
|
|
|
54
76
|
### As a Library
|
|
55
77
|
|
|
56
78
|
```typescript
|
|
57
79
|
import { rei } from 'rei-lang';
|
|
58
80
|
|
|
59
|
-
// Multi-dimensional
|
|
81
|
+
// Multi-dimensional numbers: center-periphery computation
|
|
60
82
|
rei('let field = 𝕄{5; 1, 2, 3, 4}');
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
rei('compress
|
|
66
|
-
rei('
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
//
|
|
70
|
-
rei('
|
|
71
|
-
|
|
72
|
-
rei(
|
|
73
|
-
console.log(rei('g.state')); // "line"
|
|
74
|
-
|
|
75
|
-
// Reset state between sessions
|
|
76
|
-
rei.reset();
|
|
83
|
+
rei('field |> compute :weighted'); // → 7.5
|
|
84
|
+
rei('field |> compute :harmonic'); // → harmonic aggregation
|
|
85
|
+
|
|
86
|
+
// Functions compress complexity
|
|
87
|
+
rei('compress distance(x, y) = sqrt(x * x + y * y)');
|
|
88
|
+
rei('distance(3, 4)'); // → 5
|
|
89
|
+
|
|
90
|
+
// Pipes flow naturally
|
|
91
|
+
rei('-25 |> abs |> sqrt'); // → 5
|
|
92
|
+
rei('[5, 3, 8, 1] |> sort |> reverse'); // → [8, 5, 3, 1]
|
|
93
|
+
|
|
94
|
+
rei.reset(); // clear state between sessions
|
|
77
95
|
```
|
|
78
96
|
|
|
79
97
|
### Interactive REPL
|
|
@@ -84,33 +102,24 @@ npx rei
|
|
|
84
102
|
|
|
85
103
|
```
|
|
86
104
|
╔══════════════════════════════════════════╗
|
|
87
|
-
║ Rei (0₀式) REPL v0.5.
|
|
105
|
+
║ Rei (0₀式) REPL v0.5.2 ║
|
|
88
106
|
║ D-FUMT Computational Language ║
|
|
89
107
|
╚══════════════════════════════════════════╝
|
|
90
108
|
|
|
91
109
|
零 > 𝕄{5; 1, 2, 3, 4} |> compute :weighted
|
|
92
110
|
7.5
|
|
93
111
|
|
|
94
|
-
零 >
|
|
95
|
-
|
|
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
|
|
112
|
+
零 > 𝕄{5; 1, 2, 3} |> sigma
|
|
113
|
+
{ field: { center: 5, ... }, flow: { ... }, memory: { ... }, ... }
|
|
105
114
|
```
|
|
106
115
|
|
|
107
116
|
---
|
|
108
117
|
|
|
109
|
-
##
|
|
118
|
+
## Core Concepts
|
|
110
119
|
|
|
111
|
-
### Multi-Dimensional Numbers
|
|
120
|
+
### 𝕄 — Multi-Dimensional Numbers
|
|
112
121
|
|
|
113
|
-
The
|
|
122
|
+
The fundamental data type. A center value surrounded by neighbors, computed in four modes:
|
|
114
123
|
|
|
115
124
|
```rei
|
|
116
125
|
let m = 𝕄{5; 1, 2, 3, 4}
|
|
@@ -121,354 +130,177 @@ m |> compute :harmonic // center + n / Σ(1/|nᵢ|)
|
|
|
121
130
|
m |> compute :exponential // center × avg(e^nᵢ)
|
|
122
131
|
```
|
|
123
132
|
|
|
124
|
-
|
|
133
|
+
This isn't an array with an index. It's a value with spatial awareness — the center knows its periphery.
|
|
125
134
|
|
|
126
|
-
|
|
135
|
+
### σ (Sigma) — Six Attributes
|
|
127
136
|
|
|
128
|
-
|
|
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
|
|
137
|
+
Every value in Rei carries six attributes, accessible via `|> sigma`:
|
|
133
138
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
| Attribute | 日本語 | What it tracks |
|
|
140
|
+
|-----------|--------|---------------|
|
|
141
|
+
| **field** | 場 | Spatial context: center, neighbors, dimension |
|
|
142
|
+
| **flow** | 流れ | Temporal state: velocity, acceleration, phase |
|
|
143
|
+
| **memory** | 記憶 | History: past operations, trajectory, causes |
|
|
144
|
+
| **layer** | 層 | Structural depth: nesting, components |
|
|
145
|
+
| **relation** | 関係 | Connections: bindings, dependencies, entanglements |
|
|
146
|
+
| **will** | 意志 | Intention: tendency, strength, prediction |
|
|
137
147
|
|
|
138
|
-
###
|
|
148
|
+
### Relation Deep — 縁起的追跡
|
|
139
149
|
|
|
140
|
-
|
|
150
|
+
Track how values depend on each other:
|
|
141
151
|
|
|
142
152
|
```rei
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
let mut a = 𝕄{5; 1, 2}
|
|
154
|
+
let mut b = 𝕄{10; 3, 4}
|
|
155
|
+
a |> bind("b", "mirror") // create a relation
|
|
156
|
+
|
|
157
|
+
a |> trace // dependency chain (BFS, cycle-safe)
|
|
158
|
+
a |> influence("b") // influence score between values
|
|
159
|
+
a |> entangle("b") // deep bidirectional entanglement
|
|
160
|
+
// also: 追跡, 影響("b"), 縁起("b") — full Japanese support
|
|
148
161
|
```
|
|
149
162
|
|
|
150
|
-
###
|
|
163
|
+
### Will Deep — 意志の自律性
|
|
151
164
|
|
|
152
|
-
|
|
165
|
+
Values can carry and evolve intentions:
|
|
153
166
|
|
|
154
167
|
```rei
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
let mut x = 𝕄{5; 1, 2, 3}
|
|
169
|
+
x |> intend("maximize") // set intention
|
|
170
|
+
x |> will_evolve // autonomous evolution based on history
|
|
171
|
+
|
|
172
|
+
let mut y = 𝕄{10; 4, 5}
|
|
173
|
+
y |> intend("minimize")
|
|
174
|
+
x |> bind("y")
|
|
175
|
+
x |> will_align("y") // harmonize intentions
|
|
176
|
+
x |> will_conflict("y") // detect and resolve tension
|
|
177
|
+
// also: 意志進化, 意志調律("y"), 意志衝突("y")
|
|
159
178
|
```
|
|
160
179
|
|
|
161
|
-
### Genesis Axiom System
|
|
180
|
+
### Genesis Axiom System — 生成公理系
|
|
162
181
|
|
|
163
|
-
|
|
182
|
+
Computational emergence from void:
|
|
164
183
|
|
|
165
184
|
```rei
|
|
166
|
-
let g = genesis()
|
|
167
|
-
g |> forward
|
|
168
|
-
g |> forward
|
|
169
|
-
g |> forward
|
|
170
|
-
g |> forward
|
|
171
|
-
g |> forward
|
|
172
|
-
g.omega // 1
|
|
185
|
+
let g = genesis() // void
|
|
186
|
+
g |> forward // void → dot
|
|
187
|
+
g |> forward // dot → line
|
|
188
|
+
g |> forward // line → surface
|
|
189
|
+
g |> forward // surface → solid
|
|
190
|
+
g |> forward // solid → omega (Ω)
|
|
173
191
|
```
|
|
174
192
|
|
|
175
|
-
###
|
|
193
|
+
### Compress — 関数定義
|
|
176
194
|
|
|
177
|
-
|
|
195
|
+
Functions are defined with `compress`, reflecting D-FUMT's compression philosophy:
|
|
178
196
|
|
|
179
197
|
```rei
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
¬⊤ // ⊥
|
|
186
|
-
⊤ ∧ ⊥ // ⊥
|
|
187
|
-
⊥ ∨ ⊤ // ⊤
|
|
198
|
+
compress energy(m) = m |> compute :weighted
|
|
199
|
+
compress karma(i, e, r) = i * e * r
|
|
200
|
+
|
|
201
|
+
energy(𝕄{0; 10, 20, 30}) // → 20
|
|
202
|
+
karma(0.8, 0.9, 0.7) // → 0.504
|
|
188
203
|
```
|
|
189
204
|
|
|
190
205
|
---
|
|
191
206
|
|
|
192
|
-
##
|
|
193
|
-
|
|
194
|
-
### EventBus (イベントバス)
|
|
207
|
+
## Benchmarks
|
|
195
208
|
|
|
196
|
-
|
|
209
|
+
### Code Reduction
|
|
197
210
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
```
|
|
211
|
+
| Task | Conventional | Rei | Reduction |
|
|
212
|
+
|------|-------------|-----|-----------|
|
|
213
|
+
| Image kernel computation | 32 lines | 8 lines | **4×** |
|
|
214
|
+
| Multi-dimensional aggregation | 45 lines | 12 lines | **3.7×** |
|
|
215
|
+
| Graph structure transformation | 52 lines | 14 lines | **3.7×** |
|
|
216
|
+
| **Average** | | | **74%** |
|
|
216
217
|
|
|
217
|
-
|
|
218
|
+
See [`benchmarks/`](./benchmarks/) for runnable comparisons with equivalent Python code.
|
|
218
219
|
|
|
219
|
-
|
|
220
|
-
// Emit a custom event
|
|
221
|
-
"mySource" |> emit("entity:transform", "data")
|
|
220
|
+
### What Benchmarks Don't Capture
|
|
222
221
|
|
|
223
|
-
|
|
224
|
-
"entity:*" |> subscribe
|
|
222
|
+
The deeper advantage isn't line count — it's **what you don't have to build**. In Rei, dependency tracking, metadata propagation, and structural awareness are free. In other languages, they're projects.
|
|
225
223
|
|
|
226
|
-
|
|
227
|
-
0 |> flow_momentum // → { state: "expanding", rate: 12.5, ... }
|
|
228
|
-
```
|
|
224
|
+
---
|
|
229
225
|
|
|
230
|
-
|
|
226
|
+
## Agent Runtime (v0.5)
|
|
231
227
|
|
|
232
|
-
|
|
228
|
+
Rei includes a self-organizing agent system where entities perceive, decide, and act autonomously:
|
|
233
229
|
|
|
234
230
|
```rei
|
|
235
|
-
// Spawn
|
|
236
|
-
let a = 𝕄{10; 1, 2, 3} |>
|
|
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
|
-
```
|
|
231
|
+
// Spawn agents from values
|
|
232
|
+
let mut a = 𝕄{10; 1, 2, 3} |> agent
|
|
233
|
+
a |> agent_sigma // full agent state
|
|
264
234
|
|
|
265
|
-
|
|
235
|
+
// Puzzle solving: 81 cooperative agents solve sudoku
|
|
236
|
+
30 |> generate_sudoku(42) |> agent_solve
|
|
266
237
|
|
|
267
|
-
|
|
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 |> 調停σ // 日本語版
|
|
238
|
+
// Game playing: competitive match
|
|
239
|
+
"tic_tac_toe" |> game |> agent_match
|
|
286
240
|
```
|
|
287
241
|
|
|
288
|
-
|
|
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
|
-
```
|
|
242
|
+
Puzzles and games are the same abstraction — the only difference is agent behavior and mediator strategy.
|
|
318
243
|
|
|
319
244
|
---
|
|
320
245
|
|
|
321
|
-
##
|
|
322
|
-
|
|
323
|
-
Every entity in Rei carries six attributes from D-FUMT theory:
|
|
246
|
+
## Bilingual Support (日本語対応)
|
|
324
247
|
|
|
325
|
-
|
|
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 |
|
|
248
|
+
All commands have Japanese aliases:
|
|
333
249
|
|
|
334
250
|
```rei
|
|
335
|
-
//
|
|
336
|
-
|
|
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)
|
|
251
|
+
𝕄{5; 1, 2, 3} |> sigma // English
|
|
252
|
+
𝕄{5; 1, 2, 3} |> 自律σ // 日本語
|
|
349
253
|
|
|
350
|
-
|
|
254
|
+
"b" |> bind("a") // English
|
|
255
|
+
"b" |> 結合("a") // 日本語
|
|
351
256
|
|
|
352
|
-
|
|
353
|
-
//
|
|
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}" |> 意味圧縮 // 日本語版
|
|
257
|
+
// trace → 追跡, influence → 影響, entangle → 縁起
|
|
258
|
+
// will_evolve → 意志進化, will_align → 意志調律
|
|
361
259
|
```
|
|
362
260
|
|
|
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%** |
|
|
261
|
+
See [full command reference](./docs/KANJI-README.md) for the complete bilingual table.
|
|
373
262
|
|
|
374
263
|
---
|
|
375
264
|
|
|
376
|
-
##
|
|
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
|
|
265
|
+
## Documentation
|
|
403
266
|
|
|
404
|
-
|
|
|
405
|
-
|
|
406
|
-
|
|
|
407
|
-
|
|
|
408
|
-
|
|
|
409
|
-
|
|
|
410
|
-
|
|
|
411
|
-
|
|
|
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/).
|
|
267
|
+
| Document | Content |
|
|
268
|
+
|----------|---------|
|
|
269
|
+
| [TUTORIAL.md](./docs/TUTORIAL.md) | Getting started in 15 minutes |
|
|
270
|
+
| [KANJI-README.md](./docs/KANJI-README.md) | Full bilingual command reference |
|
|
271
|
+
| [PHASE4D-DESIGN.md](./PHASE4D-DESIGN.md) | Current development phase |
|
|
272
|
+
| [ARCH.md](./ARCH.md) | Architecture overview |
|
|
273
|
+
| [spec/](./spec/) | BNF specification (v0.3) |
|
|
274
|
+
| [theory/](./theory/) | D-FUMT theoretical foundation (66 theories) |
|
|
446
275
|
|
|
447
276
|
---
|
|
448
277
|
|
|
449
278
|
## Theoretical Foundation
|
|
450
279
|
|
|
451
|
-
Rei is grounded in **D-FUMT** (Dimensional Fujimoto Universal Mathematical Theory), a framework of 66 interconnected theories
|
|
280
|
+
Rei is grounded in **D-FUMT** (Dimensional Fujimoto Universal Mathematical Theory), a framework of 66 interconnected theories. The language's core innovation — center-periphery patterns and six-attribute metadata — derives from D-FUMT's multi-dimensional number system and consciousness mathematics.
|
|
452
281
|
|
|
453
|
-
|
|
282
|
+
Key theoretical concepts:
|
|
283
|
+
- **Extended Zero** (0₀, 0₀₀, 0owo) — dimensional extension of zero
|
|
284
|
+
- **Four-Valued Logic** (⊤, ⊥, ⊤π, ⊥π) — beyond true/false
|
|
285
|
+
- **Genesis Axioms** — computational emergence from void
|
|
286
|
+
- **RCT** (Rei Compression Theory) — generative compression
|
|
287
|
+
|
|
288
|
+
See [`theory/`](./theory/) for complete documentation.
|
|
454
289
|
|
|
455
290
|
---
|
|
456
291
|
|
|
457
|
-
## ☮️ Peace Use Clause
|
|
292
|
+
## ☮️ Peace Use Clause
|
|
458
293
|
|
|
459
|
-
Rei is licensed under Apache 2.0 with
|
|
460
|
-
Rei は Apache 2.0 ライセンスに加え、平和利用条項が適用されます。
|
|
294
|
+
Rei is licensed under Apache 2.0 with a Peace Use Clause. It is designed exclusively for the peaceful advancement of humanity.
|
|
461
295
|
|
|
462
|
-
|
|
463
|
-
|
|
296
|
+
🚫 Weapons, military systems, or autonomous lethal weapons
|
|
297
|
+
🚫 Human rights violations
|
|
298
|
+
🚫 Intentional environmental destruction
|
|
464
299
|
|
|
465
|
-
|
|
466
|
-
🚫 Human rights violations / 人権侵害
|
|
467
|
-
🚫 Intentional environmental destruction / 意図的な環境破壊
|
|
300
|
+
✅ Education, research, humanitarian aid, and creative endeavors
|
|
468
301
|
|
|
469
|
-
|
|
470
|
-
✅ 教育・研究・人道支援・創造的活動での使用を推奨します。
|
|
302
|
+
See [PEACE_USE_CLAUSE.md](./PEACE_USE_CLAUSE.md) for details.
|
|
471
303
|
|
|
472
|
-
|
|
304
|
+
---
|
|
473
305
|
|
|
474
306
|
Apache 2.0 © Nobuki Fujimoto
|