proof/: add StarForth_Dictionary_Words.thy (HERE/ALIGN/ALLOT/,/C,/2,/PAD/LATEST)

Adds VM_MEMORY_SIZE and DICTIONARY_MEMORY_SIZE constants to StarForth_Base.thy
(previously only STACK_SIZE existed). SP@/SP! left unmodelled (oops-flagged
with explanation) -- the list-based data_stack model has no independent dsp
register distinct from list length, which is exactly what SP! manipulates.

Genuine findings recorded in comments, not fixed:
- LATEST has an identical body to HERE (both just push vm->here) rather than
  consulting vm->latest -- doesn't return what its own doc comment claims.
- ALIGN (via vm_align/vm_allot) bounds-checks here against
  DICTIONARY_MEMORY_SIZE (2MB), while ALLOT/,/C,/2, bound-check directly
  against VM_MEMORY_SIZE (5MB) instead -- two different ceilings for the
  same dictionary pointer.

Full suite (26 theory files) verifies with zero errors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Robert Allan James
2026-08-13 18:12:54 -04:00
co-authored by Claude Sonnet 5
parent d0fcd2ed86
commit 92474c5219
3 changed files with 318 additions and 0 deletions
+16
View File
@@ -202,6 +202,22 @@ type_synonym forth_stack = "cell list"
re-proved to ensure they still hold. *)
definition STACK_SIZE :: nat where "STACK_SIZE = 1024"
(* ○ CODE-MUST-MATCH: #define VM_MEMORY_SIZE (5 * 1024 * 1024) in include/vm.h.
⚠ HUMAN-REVIEW: If this changes in C, update here and re-check
StarForth_Dictionary_Words.thy's ALLOT/,/C,/2, bound lemmas. *)
definition VM_MEMORY_SIZE :: nat where "VM_MEMORY_SIZE = 5242880"
(* ○ CODE-MUST-MATCH: #define BLOCK_SIZE 1024, DICTIONARY_BLOCKS 2048,
DICTIONARY_MEMORY_SIZE (DICTIONARY_BLOCKS*BLOCK_SIZE) in include/vm.h.
⚠ HUMAN-REVIEW: this is a SMALLER bound than VM_MEMORY_SIZE (2MB vs 5MB).
vm_allot() (src/memory_management.c) -- used by ALIGN via vm_align -- checks
`here` against THIS bound, but ALLOT/,/C,/2, in dictionary_words.c bypass
vm_allot and check `here` directly against VM_MEMORY_SIZE instead. Two
different ceilings for the same pointer -- a real inconsistency in the C
source, transcribed faithfully here rather than picking one. See
StarForth_Dictionary_Words.thy. *)
definition DICTIONARY_MEMORY_SIZE :: nat where "DICTIONARY_MEMORY_SIZE = 2097152"
(* ○ CODE-MUST-MATCH: Makefile default parameters for rolling window.
⚠ HUMAN-REVIEW: These values appear in multiple C files:
- ROLLING_WINDOW_SIZE: src/rolling_window_of_truth.c, include/vm.h