proof/: all 23 Isabelle theory files now verify under Isabelle2025-2

Isabelle toolchain replaced (was genuinely 2011, 14+ years stale) and every
theory file fixed to actually compile -- most had apparently never been
checked under a working Isabelle at all. Fixed the vm_state self-reference
in StarForth_Base.thy properly (word_table is now a free-standing global
constant, not a circular record field), corrected the word_physics_transparent
axiom (was claiming full state equality from mere exec-equivalence, provably
too strong), and worked through 14 years of HOL-Library drift plus several
missing-hypothesis bugs across the physics-loop and ACL theories.

Two genuine (non-tactical) bugs found and left oops-flagged rather than
silently resolved: forth_roll's index arithmetic disagrees with both its own
test lemma and the real C ROLL implementation (three-way inconsistency), and
pm_wf isn't actually preserved by pm_record_hit/pm_record_miss. Both need a
decision, not a proof-script fix.

Full writeup in FABRIC-2.md item 5.2.
This commit is contained in:
Robert Allan James
2026-08-13 12:30:30 -04:00
parent 5787718c30
commit 422ef2fa29
20 changed files with 561 additions and 198 deletions
+17 -13
View File
@@ -2,6 +2,10 @@ theory StarForth_Memory_Words
imports StarForth_Base
begin
(* AND/OR/XOR infix notation moved behind an opt-in bundle at some point
after 2011 -- unbundled by default now. Same fix as StarForth_Q48_16.thy. *)
unbundle bit_operations_syntax
(* =========================================================================
POST-05: Memory Access Words
Mirrors: src/word_source/memory_words.c
@@ -38,7 +42,7 @@ lemma mem_write_read_same:
lemma mem_write_read_other:
assumes "a \<noteq> b"
shows "mem_read (mem_write mem a v) b = mem_read mem b"
by (simp add: mem_read_def mem_write_def assms)
using assms by (auto simp: mem_read_def mem_write_def)
(* ── @ ( addr -- n ) ───────────────────────────────────────────────────── *)
(* Pops addr from data stack, reads cell from memory at addr, pushes value.
@@ -57,7 +61,7 @@ lemma fetch_normal:
assumes "data_stack vm = addr # xs"
assumes "addr \<ge> 0"
shows "data_stack (forth_fetch vm) = mem_read (memory vm) (nat addr) # xs"
by (simp add: forth_fetch_def assms)
using assms by (auto simp: forth_fetch_def)
lemma fetch_reads_stored_value:
assumes "memory vm = mem_write m a v"
@@ -101,26 +105,26 @@ lemma store_normal:
assumes "addr \<ge> 0"
shows "data_stack (forth_store vm) = xs"
and "memory (forth_store vm) = mem_write (memory vm) (nat addr) n"
by (simp add: forth_store_def assms)+
using assms by (auto simp: forth_store_def)
lemma store_writes_value:
assumes "data_stack vm = addr # n # xs"
assumes "addr \<ge> 0"
shows "mem_read (memory (forth_store vm)) (nat addr) = n"
by (simp add: forth_store_def mem_write_def mem_read_def assms)
using assms by (auto simp: forth_store_def mem_write_def mem_read_def)
lemma store_depth_decreases:
assumes "data_stack vm = addr # n # xs"
assumes "addr \<ge> 0"
shows "length (data_stack (forth_store vm)) = length (data_stack vm) - 2"
by (simp add: forth_store_def assms)
using assms by (auto simp: forth_store_def)
lemma store_other_unchanged:
assumes "data_stack vm = addr # n # xs"
assumes "addr \<ge> 0"
assumes "nat addr \<noteq> b"
shows "mem_read (memory (forth_store vm)) b = mem_read (memory vm) b"
by (simp add: forth_store_def mem_write_def mem_read_def assms)
using assms by (auto simp: forth_store_def mem_write_def mem_read_def)
lemma store_underflow_nil:
assumes "data_stack vm = []"
@@ -147,7 +151,7 @@ lemma store_then_fetch:
assumes "memory vm' = memory (forth_store vm)"
assumes "addr \<ge> 0"
shows "hd (data_stack (forth_fetch vm')) = n"
by (simp add: forth_fetch_def forth_store_def mem_write_def mem_read_def assms)
using assms by (auto simp: forth_fetch_def forth_store_def mem_write_def mem_read_def)
(* ── C@ ( addr -- c ) ──────────────────────────────────────────────────── *)
(* Reads a single byte (0..255) from memory, zero-extended to cell width.
@@ -169,14 +173,14 @@ lemma cfetch_normal:
assumes "addr \<ge> 0"
shows "data_stack (forth_cfetch vm) =
(mem_read (memory vm) (nat addr) AND 0xFF) # xs"
by (simp add: forth_cfetch_def assms)
using assms by (auto simp: forth_cfetch_def)
lemma cfetch_byte_range:
assumes "data_stack vm = addr # xs"
assumes "addr \<ge> 0"
shows "0 \<le> hd (data_stack (forth_cfetch vm))"
and "hd (data_stack (forth_cfetch vm)) \<le> 255"
by (simp add: forth_cfetch_def assms)+
using assms by (auto simp: forth_cfetch_def)
lemma cfetch_underflow:
assumes "data_stack vm = []"
@@ -208,19 +212,19 @@ lemma cstore_normal:
assumes "addr \<ge> 0"
shows "data_stack (forth_cstore vm) = xs"
and "memory (forth_cstore vm) = mem_write (memory vm) (nat addr) (c AND 0xFF)"
by (simp add: forth_cstore_def assms)+
using assms by (auto simp: forth_cstore_def)
lemma cstore_writes_byte:
assumes "data_stack vm = addr # c # xs"
assumes "addr \<ge> 0"
shows "mem_read (memory (forth_cstore vm)) (nat addr) = c AND 0xFF"
by (simp add: forth_cstore_def mem_write_def mem_read_def assms)
using assms by (auto simp: forth_cstore_def mem_write_def mem_read_def)
lemma cstore_depth_decreases:
assumes "data_stack vm = addr # c # xs"
assumes "addr \<ge> 0"
shows "length (data_stack (forth_cstore vm)) = length (data_stack vm) - 2"
by (simp add: forth_cstore_def assms)
using assms by (auto simp: forth_cstore_def)
lemma cstore_underflow_nil:
assumes "data_stack vm = []"
@@ -245,6 +249,6 @@ lemma cstore_then_cfetch:
assumes "data_stack vm' = addr # xs"
assumes "memory vm' = memory (forth_cstore vm)"
shows "hd (data_stack (forth_cfetch vm')) = c AND 0xFF"
by (simp add: forth_cfetch_def forth_cstore_def mem_write_def mem_read_def assms)
using assms by (auto simp: forth_cfetch_def forth_cstore_def mem_write_def mem_read_def)
end