feat(v4): Phase 7 Task 4 -- the loops' words: v3's physics-freeze and inference words, F18 asking the kernel (#189)

capsules/v4/physics.4th, a kernel capsule on Hera (blocks 8200-8201): FREEZE-WORD UNFREEZE-WORD FROZEN?
HEAT! HEAT@ DECAY-RATE@ Q.VARIANCE INFER-DECAY-SLOPE INFER-WINDOW-WIDTH INFER-RUN INFER-WINDOW@ INFER-DECAY@
INFER-VARIANCE@ INFER-FIT@ INFER-EARLY-EXIT@ -- each a KERNEL-WORD, requests -21..-34 (v4/mesh.h), served by
the kernel on any node: "The compudynamics is stadium/fabric" (Captain Bob, 2026-11-14). A word is named as
v3's, the newest visible entry of CONTEXT then FORTH (the image gains CONTEXT's address); the arithmetic is
v4/system/inference.c, v3's to the bit. Q48.16 results are v4's doubles (low cell, then high). HEAT! starts
the word's decay from now. Test first with v3's POST cases in v4's address units: test_mesh_boot.c 86
checks, 95 on, 83 without opcode physics. docs/reference/v4-dictionary.tsv: the 15 words (392 live).
amd64 PASS, word_count=392. Not pushed (held to the end of Phase 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-14 00:40:27 +00:00
parent e1b731f444
commit 28ffed8f57
12 changed files with 214 additions and 5 deletions
+34 -2
View File
@@ -81,7 +81,7 @@ static int key(void) { return V4_BOOT_KEY_END; }
static const char *const words[] = { "BYE" };
static unsigned served;
static void serve(v4_node *n, unsigned request) { (void)n; if (request == 1) served++; }
static const char *const capsules[] = { "v4:centre.4th", "v4:hera.4th" };
static const char *const capsules[] = { "v4:centre.4th", "v4:hera.4th", "v4:physics.4th" };
static unsigned char ram[(size_t)BLK_RAM_BLOCKS * BLK_FORTH_SIZE];
extern void sf_time_init(void);
@@ -110,7 +110,7 @@ int main(void)
ms.reg = reg; ms.blocks = blocks; ms.nucleus = &nucleus; ms.hera = &hera; ms.kernel = kernel;
ms.room = room; ms.unroom = unroom; ms.born = born; ms.gone = gone; ms.parity = parity;
ms.out = out; ms.key = key; ms.words = words; ms.word_count = 1; ms.serve = serve;
ms.capsules = capsules; ms.capsule_count = 2; ms.im = &im; ms.self = 0;
ms.capsules = capsules; ms.capsule_count = 3; ms.im = &im; ms.self = 0;
ms.accounts = accounts; ms.is_word = is_word; ms.forgot = forgot;
ms.physics = physics; ms.alloc = alloc; ms.release = release; ms.heartrate = heartrate;
@@ -218,6 +218,38 @@ int main(void)
r = line(V4_MESH_HERA, "FORGET L8T", &how);
}
/* ---- the loops' words (#189 Phase 7, Task 4): v3's physics-freeze and inference words, F18 asking the kernel,
* which keeps the records and does the arithmetic (Captain Bob, 2026-11-14: "The compudynamics is
* stadium/fabric"). v3's POST cases, with v4's address units (a cell is one) ---- */
{
r = line(V4_MESH_HERA, ": FT1 ; S\" FT1\" FREEZE-WORD S\" FT1\" FROZEN? .", &how);
CHECK(how == V4_TEXT_COMPLETED && strcmp(r, "-1 ") == 0, "FREEZE-WORD, then FROZEN?: -1 (\"%s\")", r);
r = line(V4_MESH_HERA, "S\" FT1\" UNFREEZE-WORD S\" FT1\" FROZEN? .", &how);
CHECK(strcmp(r, "0 ") == 0, "UNFREEZE-WORD: 0 (\"%s\")", r);
r = line(V4_MESH_HERA, ": FT2 ; S\" FT2\" FROZEN? . S\" __nonexistent_xyz__\" FROZEN? .", &how);
CHECK(strcmp(r, "0 0 ") == 0, "a fresh word is not frozen, and nor is one not found (\"%s\")", r);
r = line(V4_MESH_HERA, ": HT1 ; 999 S\" HT1\" HEAT! S\" HT1\" HEAT@ . : HT2 ; S\" HT2\" HEAT@ .", &how);
CHECK(strcmp(r, "999 0 ") == 0, "HEAT! 999 then HEAT@: 999; a fresh word's: 0 (\"%s\")", r);
r = line(V4_MESH_HERA, "DECAY-RATE@ .", &how);
CHECK(strcmp(r, "1 ") == 0, "DECAY-RATE@: v3's DECAY_RATE_PER_US_Q16, 1 (\"%s\")", r);
{
uint64_t d3[3] = { 100, 200, 300 }, u3[3] = { 300, 200, 100 };
char want[64];
r = line(V4_MESH_HERA, "100 HERE ! 200 HERE 1 + ! 300 HERE 2 + ! HERE 3 Q.VARIANCE Q.TO-INT .", &how);
snprintf(want, sizeof want, "%lu ", (unsigned long)(v4_inference_variance(d3, 3) >> 16));
CHECK(strcmp(r, want) == 0, "Q.VARIANCE of 100 200 300: \"%s\" (v3's engine: \"%s\")", r, want);
r = line(V4_MESH_HERA, "300 HERE ! 200 HERE 1 + ! 100 HERE 2 + ! HERE 3 INFER-DECAY-SLOPE Q.TO-INT .", &how);
snprintf(want, sizeof want, "%lu ", (unsigned long)(v4_inference_decay_slope(u3, 3) >> 16));
CHECK(strcmp(r, want) == 0, "INFER-DECAY-SLOPE of 300 200 100: \"%s\" (\"%s\")", r, want);
r = line(V4_MESH_HERA, "100 HERE ! 200 HERE 1 + ! 300 HERE 2 + ! HERE 3 INFER-WINDOW-WIDTH .", &how);
snprintf(want, sizeof want, "%u ", v4_inference_window_width(d3, 3));
CHECK(strcmp(r, want) == 0, "INFER-WINDOW-WIDTH of 100 200 300: \"%s\" (\"%s\")", r, want);
}
r = line(V4_MESH_HERA, "INFER-RUN INFER-WINDOW@ . INFER-DECAY@ Q.TO-INT . INFER-VARIANCE@ Q.TO-INT . INFER-FIT@ Q.TO-INT . INFER-EARLY-EXIT@ .", &how);
CHECK(how == V4_TEXT_COMPLETED && strstr(r, "ERROR") == 0, "INFER-RUN and its five readings, with no error: \"%s\"", r);
r = line(V4_MESH_HERA, "FORGET FT1", &how);
}
/* ---- the opcodes (#189 Phase 7, ruling 7: every loop on the 32 F18 opcodes too; revert: OPCODE_PHYSICS 0) ---- */
{
v4_mesh_physics *p = &ms.physics[0];