feat(formal): Wave 3 capstone — quantitative typing tracks usage soundly#634
Merged
Conversation
…dly (QttTyping.v)
Fuses the three Wave-1/2 pieces — the term/typing structure of P2_Stlc, the
multiplicity semiring of QttSemiring, and the occurrence-count usage of
AffineUsage — into one judgment whose context tracks quantities:
qtt Γ t A (Γ : uctx = var ↦ quantity)
Q_Var consumes one variable once (usingle x);
Q_App ADDS the two subcontexts (Γ₁ + Γ₂, context-splitting read backwards);
Q_Lam binds a variable at the multiplicity it is used.
Capstone theorem usage_soundness: the typing context records EXACTLY the QTT
usage of every variable —
qtt Γ t A → ∀ x, usage x t = Γ x
— so the static quantity bookkeeping is sound w.r.t. actual occurrence counts.
Corollary linear_uses_once: a term typed in a singleton context uses that one
variable exactly once (linearity, read off the typing). Axiom-free, no Admitted.
Scope: the static quantity discipline is now unified and proven sound against
usage. The dynamic half — operational progress+preservation preserving the
quantity accounting under reduction (a quantitative substitution lemma over
P2_Stlc) — is the remaining step.
Track now 13 files, 20 closure reports, no axioms. justfile/_CoqProject build
QttTyping; .hypatia-ignore extends the Coq-not-V-lang carve-out; README gains
the Wave-3 capstone; PROOF-NEEDS P-4 row updated.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KPG9mEQXFyA3k7NWAzMNMr
🔍 Hypatia Security ScanFindings: 41 issues detected
View findings[
{
"reason": "Action denoland/setup-deno@v2 needs attention",
"type": "unpinned_action",
"file": "publish-jsr.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in instant-sync.yml",
"type": "secret_action_without_presence_gate",
"file": "instant-sync.yml",
"action": "peter-evans/repository-dispatch",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "Shell execution -- validate input before passing to shell (1 occurrences, CWE-78)",
"type": "js_exec_sync",
"file": "/home/runner/work/affinescript/affinescript/packages/affinescript-cli/mod.js",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "Shell execution -- validate input before passing to shell (2 occurrences, CWE-78)",
"type": "js_exec_sync",
"file": "/home/runner/work/affinescript/affinescript/packages/affine-vscode/mod.js",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "Shell execution -- validate input before passing to shell (1 occurrences, CWE-78)",
"type": "js_exec_sync",
"file": "/home/runner/work/affinescript/affinescript/affinescript-vite/src/affine-plugin-improved.js",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "expect() in hot path (32 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/affinescript/affinescript/affinescriptiser/src/codegen/wasm_gen.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "expect() in hot path (29 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/affinescript/affinescript/affinescriptiser/src/codegen/affine_gen.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unsafe block -- requires SAFETY comment (2 occurrences, CWE-676)",
"type": "unsafe_block",
"file": "/home/runner/work/affinescript/affinescript/runtime/src/panic.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unsafe block -- requires SAFETY comment (1 occurrences, CWE-676)",
"type": "unsafe_block",
"file": "/home/runner/work/affinescript/affinescript/runtime/src/alloc.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unsafe block -- requires SAFETY comment (3 occurrences, CWE-676)",
"type": "unsafe_block",
"file": "/home/runner/work/affinescript/affinescript/runtime/src/ffi.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
hyperpolymath
added a commit
that referenced
this pull request
Jun 21, 2026
…ve 1–3 (#636) ## What `docs/PROOF-NEEDS.adoc`'s **status tables were already correct** (§2 P-rows, §4 F-rows track every obligation accurately), but two **narrative sections went stale** during the Wave 1/2/3 mechanization that landed in #632 / #634. This refresh re-grounds them against the live `formal/` tree. Ground truth at time of writing: **13 `.v` files, 22 `Print Assumptions` closure reports, all axiom-free** (verified by recompiling the whole track with `coqc -Q . ASFormal` and auditing for `Axioms:`). ## Changes (docs only) - **§1 `formal/` baseline** listed only **8 of the 13** proof files — it predated `P2_Stlc`, `P3_BorrowGraph`, and the QTT trio (`QttSemiring` / `AffineUsage` / `QttTyping`). Now lists all 13 with the true count. - **§6 sequencing table** reframed: the doc described Waves 1–3 as *future* and cited "11 closure reports". Waves 1 (model growth) and 2 (static QTT) are **done**; Wave 3 is now correctly stated as **the real lift** — formalise the real AffineScript AST + real typed-WASM operational semantics, then the remaining prose/absent obligations. - **K-1 bullet** now notes `K1Let_CodegenPreservation.v` grows the seed with de Bruijn variables / `let` / environment. - **K-3 bullet** now notes `P3_BorrowSound.v` / `P3_BorrowGraph.v` already reject the #554 witness in-model (was "should be written"). - **Intro** "almost none mechanized" → "a growing axiom-free Coq core (small models; no full-language theorem discharged yet)". No proof content changes; no status-column downgrades. This only makes the prose match the tables and the tree. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KPG9mEQXFyA3k7NWAzMNMr --- _Generated by [Claude Code](https://claude.ai/code/session_01KPG9mEQXFyA3k7NWAzMNMr)_ Co-authored-by: hyperpolymath <paraordinate@yahoo.co.uk> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Wave 3 (capstone): a quantitative type system. Fuses the three Wave-1/2 pieces — the term/typing structure of
P2_Stlc, the multiplicity semiring ofQttSemiring, and the occurrence-count usage ofAffineUsage— into one judgment whose context tracks quantities.Capstone theorem
Theorem usage_soundness : qtt G t A -> forall x, usage x t = G x.The typing context records exactly the QTT usage of every variable — so the static quantity bookkeeping is sound w.r.t. actual occurrence counts. Corollary
linear_uses_once: a term typed in a singleton context uses that one variable exactly once — linearity, read straight off the typing.Axiom-free, no
Admitted— bothPrint Assumptionsclosed.Scope (honest)
This is the static quantity discipline, now unified and proven sound against usage. The dynamic half — operational progress + preservation that preserves the quantity accounting under reduction (a quantitative substitution lemma over
P2_Stlc.v) — is the remaining step.Track status
13 files, 20 closure reports, zero axioms.
justfile/_CoqProjectbuild it;.hypatia-ignoreextends the Coq-.v-isn't-V-lang carve-out; README gains the Wave-3 capstone;PROOF-NEEDS.adocP-4 row updated.🤖 Generated with Claude Code
https://claude.ai/code/session_01KPG9mEQXFyA3k7NWAzMNMr
Generated by Claude Code