proof/: complete parse+insert composition for :, CREATE, VARIABLE, DEFER

Extends the CONSTANT worked example from the previous commit to all five
name-parsing/entry-creating words. Each now has a forth_*_full definition
composing the real C order end to end, up to but not including the
data-field write (gap b, still open):

- forth_create_full: parse -> dict_insert_entry -> forth_align (reused
  directly from StarForth_Dictionary_Words.thy's ALIGN model).
- forth_variable_full: parse -> forth_align -> forth_vm_allot_raw (new --
  models the raw vm_allot() C helper VARIABLE calls directly, bounds-
  checked against DICTIONARY_MEMORY_SIZE exactly like vm_align, distinct
  from the FORTH word ALLOT's own VM_MEMORY_SIZE-bounded forth_allot) ->
  dict_insert_entry.
- forth_colon_full: nested-':' guard (checked before the parse, matching
  real C order) -> parse -> forth_colon_entry_half (mode-set + WORD_SMUDGED
  insert). Added forth_parse_word_preserves_vm_mode/dictionary/
  word_id_next to StarForth_Base.thy to support this composition cleanly.
- forth_defer_full: parse -> dict_insert_entry, the simplest of the five.

dict_insert_entry's callers (the four forth_*_entry_half definitions)
still take the parsed name as a caller parameter for standalone use.

Full suite (54 theories) verifies green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-08-15 05:29:49 -04:00
co-authored by Claude Sonnet 5
parent 1aca77d55c
commit d3d66fb608
4 changed files with 256 additions and 25 deletions
+23 -20
View File
@@ -70,7 +70,7 @@ library itself is separately covered by `StarForth_Q48_16.thy`).
| `format_words.c` | `StarForth_Format_Words.thy` | 17/19 (`#`/`#S` multi-precision division deferred) |
| `system_words.c` | `StarForth_System_Words.thy` | 10/16 + `(ABORT")` helper |
| `vocabulary_words.c` | `StarForth_Vocabulary_Words.thy` | 1/7 partial (entire subsystem is file-scope statics, see FINDINGS.md §1) |
| `defining_words.c` | `StarForth_Defining_Words.thy` | 4/19 full + 2 guard-only (`:`/`;`) + 4 entry-creation-half (`:`/CREATE/VARIABLE/CONSTANT, added 2026-08-14) |
| `defining_words.c` | `StarForth_Defining_Words.thy` | 4/19 full + `;` guard-only + `:`/CREATE/VARIABLE/CONSTANT full up to the DF write (added 2026-08-14/15) |
| `acl_words.c` | `StarForth_ACL_Words.thy` | 7/12 (5 already covered by the pre-existing `ACL_*.thy` policy theories) |
| `dictionary_heat_diagnostic_words.c` | `StarForth_Dictionary_Heat_Diagnostic_Words.thy` | 4/6 full + 1 partial |
| `physics_freeze_words.c` | `StarForth_Physics_Freeze_Words.thy` | 6/9 |
@@ -81,7 +81,7 @@ library itself is separately covered by `StarForth_Q48_16.thy`).
| `framebuffer_words.c`, `keyboard_words.c` | `StarForth_Framebuffer_Words.thy`, `StarForth_Keyboard_Words.thy` | hosted-build fallback branches fully modelled |
| `scroll_words.c`, `ttf_words.c` | `StarForth_Scroll_Words.thy`, `StarForth_TTF_Words.thy` | sentinel-only — words don't exist on hosted builds at all |
| `lifecycle_words_hosted.c` | `StarForth_Lifecycle_Words_Hosted.thy` | 100% — zero deferred remainder |
| `defer_words.c` | `StarForth_Defer_Words.thy` | live (see FINDINGS.md §3 correction); DEFER's entry-creation half modelled (added 2026-08-14) |
| `defer_words.c` | `StarForth_Defer_Words.thy` | live (see FINDINGS.md §3 correction); DEFER full up to the DF write (added 2026-08-14/15) |
| `log_words.c` | `StarForth_Log_Words.thy` | 100% |
| `q48_words.c` | `StarForth_Q48_Words.thy` | 17/23 |
| `inference_words.c` | `StarForth_Inference_Words.thy` | 5 accessors full; rest guard/shape |
@@ -95,34 +95,37 @@ effort on the scale of what's already here:
- **The disk-backed block-window cache** (`block_subsystem.h` +
`blk_vm_lbn`/`blk_vm_cbuf`/`blk_vm_dirty`/`blk_vm_next`) — blocks
`block_words.c` and `editor_words.c` almost entirely.
- **The TIB / interactive input subsystem — partially closed 2026-08-14.**
- **The TIB / interactive input subsystem — partially closed 2026-08-14/15.**
`input_buffer`/`input_length`/`input_pos` turned out to be plain per-VM
array/scalar fields, not host pointers, and `vm_parse_word` (the
whitespace-delimited name-parse every CREATE/VARIABLE/CONSTANT/`:`/
DEFER-family word depends on) is a pure scan — now modelled as
`forth_parse_word` in `StarForth_Base.thy`, composed with
`dict_insert_entry` for CONSTANT in `StarForth_Defining_Words.thy` as a
worked example. Still blocked: words needing a *different* scan shape
over the same buffer — `(`/`\` comment (skip-to-delimiter, not
whitespace-delimited), `KEY` (single raw character, not a parsed
token), `."`/`S"` (delimiter-terminated string literal), `ABORT"`'s
compile-time half, `SEE` (raw pointer walk) — each would need its own
scan function modelled against the same fields, not automatically
unlocked by `forth_parse_word`.
`forth_parse_word` in `StarForth_Base.thy`, composed end-to-end with
`dict_insert_entry` for all five name-parsing/entry-creating words
(`forth_colon_full`/`forth_create_full`/`forth_variable_full`/
`forth_constant_full`/`forth_defer_full`). Still blocked: words needing
a *different* scan shape over the same buffer — `(`/`\` comment
(skip-to-delimiter, not whitespace-delimited), `KEY` (single raw
character, not a parsed token), `."`/`S"` (delimiter-terminated string
literal), `ABORT"`'s compile-time half, `SEE` (raw pointer walk) — each
would need its own scan function modelled against the same fields, not
automatically unlocked by `forth_parse_word`.
- **Real stdio/file I/O** — `SAVE-SYSTEM`, parts of `string_words.c`.
- **Raw C-string/strtol-backed words** — the rest of `string_words.c`.
- **Raw-pointer DictEntry navigation** (`>BODY`/`>NAME`/CFA-style words) —
the abstract `dict_entry` model is word-id-indexed, not addressed; no
independent `dsp` register exists to model `SP@`/`SP!` against either.
- **Dictionary insertion** (`vm_create_word`, used by `:`, CREATE, VARIABLE,
CONSTANT, DEFER) — **partially closed 2026-08-14.** `dict_insert_entry`
(`StarForth_Defining_Words.thy`) now models the word_id-assignment/
dictionary-table/`latest_id`/`word_id_next`-counter portion, reused by
all five words' `forth_*_entry_half` definitions, which take the parsed
name as a caller-supplied parameter. `forth_constant_full` composes
`forth_parse_word` (the TIB gap above) in directly for CONSTANT, as a
worked example not yet repeated for the other four. Still not modelled
for any of the five: `vm->compiling_word` tracking (no vm_state field),
CONSTANT, DEFER) — **partially closed 2026-08-14/15.** `dict_insert_entry`
(`StarForth_Defining_Words.thy`) models the word_id-assignment/
dictionary-table/`latest_id`/`word_id_next`-counter portion. All five
words now have a `forth_*_full` definition composing the real parse,
any word-specific guard (CONSTANT's stack-underflow check, `:`'s
nested-definition check), any align/allot step (CREATE's `vm_align`,
VARIABLE's `vm_align` + a new `forth_vm_allot_raw` modelling the raw
`vm_allot` C helper), and the entry insertion itself, all the way up
to — but not including — the data-field write. Still not modelled for
any of the five: `vm->compiling_word` tracking (no vm_state field),
the data-field (DF) write each word does afterward (still gap (b)
below), and the pin-shadow name-scan guard (sidestepped via an explicit
`pinned_conflict :: bool` parameter, same technique as the XT-pop gap