Skip to content

Commit 6098311

Browse files
committed
docs: fold adversarial-review findings (honesty/divergence clarifications)
An adversarial review of the control-flow block-scoping increment found 0 soundness defects (the proof is kernel-verified hole-free); every confirmed finding was a documentation/honesty improvement. Fold them in: - File header: the "Verified theorems" list said statement *typing* (no execution) — stale since Phase 1b. Now records StmtExec/StmtsExec and the two preservation theorems, marked preservation-only, and adds a "Documented divergences (model vs. the real language)" subsection: loop bool-vs-counted-int, attempt result-channel abstraction, consent permission oracle abstraction, early-exit unmodeled, maybe-type unimplemented. - §7e doc comment: updated from "simple-statement fragment / control-flow deferred" to "all forms, with block scoping", pointing at the divergences. - StmtExec: noted the option-A scoping choice; reworded the attemptErr / consentDeny comments to label them ABSTRACTIONS (attemptErr models the store effect of a caught error — expression panics are not propagated through StmtExec, so it is not a derivation-driven catch; consent's #care oracle is unmodeled), rather than implying full error/permission semantics. - Roadmap baseline table: statement "typing (no execution)" -> "typing + execution (all nine forms; store-typing preservation)"; Progress entry records the review outcome (0 soundness defects). Documentation only — no proof or definition changed; the file still compiles hole-free (classical kernel base, no sorryAx). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL
1 parent bd610dd commit 6098311

2 files changed

Lines changed: 73 additions & 19 deletions

File tree

docs/proofs/VERIFICATION-ROADMAP.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ of every proof document and the implementation (2026-06).
3434

3535
| File | Covers |
3636
|---|---|
37-
| `verification/WokeLang.lean` / `.v` | expression-core **type safety** (progress, preservation, type-safety, canonical forms, arrays, `Result`/`unwrap` panic); statement *typing* (no execution); consent monotonicity/preservation; capability preorder |
37+
| `verification/WokeLang.lean` / `.v` | expression-core **type safety** (progress, preservation, type-safety, canonical forms, arrays, `Result`/`unwrap` panic); statement **typing + execution** (all nine forms — simple + control-flow with faithful lexical block scoping; store-typing preservation); consent monotonicity/preservation; capability preorder |
3838
| `verification/WokeGrammar.lean` | verified-parser core (soundness, completeness, termination, precedence, determinism) |
3939
| `verification/WokeGrammarStructure.{lean,v}` | no-left-recursion (whole grammar), maximal munch, keyword priority, LL(1)✗/LL(2)✓ |
4040
| `verification/WokeGrammar{CFL,Regular,Pumping}.lean` | CFL closure, non-regularity, the CFL pumping lemma, `aⁿbⁿcⁿ ∉ CFL`, ∩ non-closure |
@@ -199,7 +199,12 @@ unlock Phases 1c / 3a / 4a.
199199
`StmtWellTyped.loop : … .bool`) whereas the interpreters use a counted-`int` loop (deferred —
200200
changing it edits merged statics); `consent`/`attempt` abstract the permission oracle and
201201
result channel; early exit (return/break/continue) is unmodeled. This is a preservation-only
202-
result (no statement-progress/determinism claim).
202+
result (no statement-progress/determinism claim). *Adversarially reviewed* (faithfulness vs the
203+
Rust interpreter, non-vacuity, scoping edge-cases, honesty): **0 soundness defects** — the
204+
scary cases (loop non-termination has no derivation; `ifTrue` over an arbitrary `ρb`; duplicate
205+
declarations) were all confirmed sound; the confirmed findings were documentation/honesty
206+
improvements (surfacing the divergences above, clarifying `attemptErr` as a store-effect
207+
abstraction), folded into the file header and §7e comments.
203208
- [ ] Phase 1 (cont.: `[T-Call]` after 1b), 1b (counted-int loop; statement progress/determinism), 1c — type-safety + operational metatheory.
204209
- [ ] Phase 2b, 2c — consent + capability state machines.
205210
- [ ] Phase 3a (+3b) — HM inference.

docs/proofs/verification/WokeLang.lean

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,37 @@
3535
- preservation: stepping preserves types
3636
- type_safety: multi-step evaluation preserves types (by induction + preservation)
3737
- consent_monotonicity / consent_preservation: consent system properties
38+
- StmtExec / StmtsExec (§7e): a big-step statement-execution relation covering
39+
ALL nine statement forms — the simple statements (complain, expr, varDecl,
40+
assign, return_) and the control-flow forms (if_, loop, attempt, consent)
41+
with faithful lexical block scoping (restoreVars rolls block-local
42+
declarations back on exit; enclosing-variable mutations persist).
43+
- stmt_exec_preservation / stmts_exec_preservation: store-typing preservation
44+
for statement execution (a well-typed statement/block run in a well-typed
45+
store yields a store well-typed against its output context). This is a
46+
PRESERVATION-only result: there is no statement-progress or determinism claim.
47+
48+
### Documented divergences (model vs. the real language)
49+
The execution model is faithful to the type system and to the parts of the
50+
interpreters it covers, but it deliberately abstracts/defers the following —
51+
none is hidden:
52+
- **loop is bool/while-guarded**, inheriting `StmtWellTyped.loop : … .bool`
53+
(the guard is re-evaluated each iteration), whereas the Rust/OCaml
54+
interpreters run a **counted-`int`** loop (`for _ in 0..n`). Making the model
55+
counted would edit the merged statics (`.bool` → `.int`); deferred.
56+
- **attempt** abstracts the result channel: `attemptOk`/`attemptErr` model only
57+
the STORE effect (success keeps outer mutations; error restores the entry
58+
store). Expression panics are not propagated through StmtExec (the simple
59+
rules require evaluation to a `.lit` value), so `attemptErr` is an
60+
abstraction of "an error occurred" rather than a derivation-driven catch; the
61+
`hname` handler binding and the Okay/Oops result wrapping are unmodeled.
62+
- **consent** abstracts the `#care` permission oracle: `consentGrant`/
63+
`consentDeny` are both always available (intentional non-determinism); the
64+
real capability/permission decision lives in the consent/capability theorems.
65+
- **early exit** (return/break/continue) is unmodeled — bodies run to
66+
completion; `return_` only evaluates its expression and keeps the store.
67+
- the `maybe` type constructor exists in `WokeType` but has no typing/eval
68+
rules yet (pre-existing; `result` is the supported option type).
3869
3970
### Arrays (parity with Coq's WokeLang.v):
4071
`tArray` / `tArrayVal` type array expressions and array literal values
@@ -1779,22 +1810,30 @@ theorem preservation_via_store {e e' : Expr} {ρ ρ' : Env} {t : WokeType}
17791810
store_step_preservation (fun x t h => by simp [emptyTypeEnv] at h) ht hs
17801811

17811812
-- =========================================================================
1782-
-- 7e. Statement execution — simple-statement fragment (Phase 1b)
1813+
-- 7e. Statement execution — all forms, with block scoping (Phase 1b)
17831814
-- =========================================================================
17841815

17851816
/- A big-step statement-execution relation `StmtExec s ρ ρ'` ("statement `s`
17861817
run in store `ρ` produces store `ρ'`"), with `StmtsExec` threading a block
1787-
left-to-right. This increment covers the **simple** statements — those with no
1788-
embedded sub-blocks: `complain`, `expr`, `varDecl`, `assign`, `return_`. Each
1789-
evaluates its expression (if any) to a value via the closed-store `MultiStep`
1790-
(the store is invariant under expression evaluation, `step_store_invariant`),
1791-
then applies its store effect. `return_`'s value-propagation / block
1792-
short-circuit and the control-flow forms (`if`/`loop`/`attempt`/`consent`,
1793-
which introduce block scoping) are deliberately deferred to a later increment.
1794-
1795-
The metatheorem is **store-typing preservation**: a well-typed statement run in
1796-
a well-typed store yields a store well-typed against the statement's output
1797-
context (`StmtWellTyped Γ s Γ'`). -/
1818+
left-to-right. It covers ALL nine statement forms:
1819+
1820+
- the **simple** statements — `complain`, `expr`, `varDecl`, `assign`,
1821+
`return_` — each of which evaluates its expression (if any) to a value via
1822+
the closed-store `MultiStep` (the store is invariant under expression
1823+
evaluation, `step_store_invariant`) then applies its store effect;
1824+
- the **control-flow** forms — `if`/`loop`/`attempt`/`consent` — which run a
1825+
sub-block and then RESTORE the names that block declared to their entry
1826+
values (`restoreVars` + `declaredVars`), faithful lexical scoping in which
1827+
block-local declarations vanish on exit while enclosing-variable mutations
1828+
persist (`loop` carries those mutations across iterations via the restored
1829+
store). See the file header's "Documented divergences" for what `loop`'s
1830+
bool guard, `attempt`'s error/result channel, and `consent`'s permission
1831+
oracle deliberately abstract or defer.
1832+
1833+
The metatheorem is **store-typing preservation**: a well-typed statement (or
1834+
block) run in a well-typed store yields a store well-typed against its output
1835+
context (`StmtWellTyped Γ s Γ'`). It is preservation-only — there is no
1836+
statement-progress or determinism claim. -/
17981837

17991838
/-- Multi-step store-typed preservation: evaluating a well-typed expression to
18001839
completion in a well-typed store yields a value of the same type. The store is
@@ -1904,7 +1943,10 @@ theorem store_wellTyped_restore {Γ Γ₁ : TypeEnv} {ρ ρb : Env} {body : List
19041943
exact ⟨v, by simp only [restoreVars, if_neg hmem]; exact hv, hvt⟩
19051944

19061945
mutual
1907-
/-- Big-step execution of a single (simple) statement. -/
1946+
/-- Big-step execution of a single statement. Scoping (option A — the Rust
1947+
`Environment{bindings,parent}` discipline) is realized by `restoreVars`; see the
1948+
file header's "Documented divergences" for `loop`'s bool guard, `attempt`'s
1949+
abstracted error/result channel, and `consent`'s abstracted permission oracle. -/
19081950
inductive StmtExec : Stmt → Env → Env → Prop where
19091951
| complain : ∀ m ρ, StmtExec (.complain m) ρ ρ
19101952
| expr : ∀ e v ρ, MultiStep e ρ (.lit v) ρ → StmtExec (.expr e) ρ ρ
@@ -1916,8 +1958,8 @@ inductive StmtExec : Stmt → Env → Env → Prop where
19161958
-- Control-flow forms. Each runs its body block, then RESTORES the names the
19171959
-- block declared to their entry values (faithful lexical scoping); outer-var
19181960
-- mutations survive. The bool guard inherits `StmtWellTyped.{if_,loop}`'s
1919-
-- `HasType Γ c .bool` premise (see the divergence note: the interpreters use a
1920-
-- counted-int `loop`; the merged statics fix `.bool`, deferred to a follow-up).
1961+
-- `HasType Γ c .bool` premise — DIVERGENCE: the interpreters use a counted-int
1962+
-- `loop` (`for _ in 0..n`); the merged statics fix `.bool`, deferred (see header).
19211963
| ifTrue : ∀ c thn els ρ ρb, MultiStep c ρ (.lit (.vBool true)) ρ → StmtsExec thn ρ ρb →
19221964
StmtExec (.if_ c thn els) ρ (restoreVars (declaredVars thn) ρ ρb)
19231965
| ifFalse : ∀ c thn els ρ ρb, MultiStep c ρ (.lit (.vBool false)) ρ → StmtsExec els ρ ρb →
@@ -1928,11 +1970,18 @@ inductive StmtExec : Stmt → Env → Env → Prop where
19281970
StmtExec (.loop c body) ρ ρ'
19291971
| attemptOk : ∀ body hname ρ ρb, StmtsExec body ρ ρb →
19301972
StmtExec (.attempt body hname) ρ (restoreVars (declaredVars body) ρ ρb)
1931-
-- error mid-body: catch, restore the entry store (op-sem [B-Attempt-Err]).
1973+
-- ABSTRACTION: `attemptErr` models the *store* effect of a caught error —
1974+
-- restore the entry store (op-sem [B-Attempt-Err]). Expression panics are NOT
1975+
-- propagated through StmtExec (the simple rules require evaluation to a `.lit`
1976+
-- value), so this is an abstraction of "an error occurred mid-body" rather than
1977+
-- a derivation-driven catch; it is intentionally available non-deterministically
1978+
-- alongside `attemptOk`. The `hname` handler binding / Okay-Oops result are unmodeled.
19321979
| attemptErr : ∀ body hname ρ, StmtExec (.attempt body hname) ρ ρ
19331980
| consentGrant : ∀ p body ρ ρb, StmtsExec body ρ ρb →
19341981
StmtExec (.consent p body) ρ (restoreVars (declaredVars body) ρ ρb)
1935-
-- permission denied: skip the body (op-sem [B-Consent-Deny]).
1982+
-- ABSTRACTION: permission denied → skip the body (op-sem [B-Consent-Deny]).
1983+
-- `consentGrant`/`consentDeny` are both always available (the real `#care`
1984+
-- permission oracle is unmodeled here — it lives in the consent/capability theorems).
19361985
| consentDeny : ∀ p body ρ, StmtExec (.consent p body) ρ ρ
19371986
/-- Big-step execution of a block, threading the store left-to-right. -/
19381987
inductive StmtsExec : List Stmt → Env → Env → Prop where

0 commit comments

Comments
 (0)