Skip to content

Coupling step 2: my-lang surface → verified QTT core (surface engine + ast bridge)#117

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/dreamy-hypatia-O8XHo
Jun 18, 2026
Merged

Coupling step 2: my-lang surface → verified QTT core (surface engine + ast bridge)#117
hyperpolymath merged 2 commits into
mainfrom
claude/dreamy-hypatia-O8XHo

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Coupling step 2 — the bridge from the my-lang surface to the verified QTT core, so the machine-checked usage-walk runs on real programs. Follows PR #116 (which landed my-qtt, the faithful Rust port of the Coq R5/R5b check).

2a · my-qtt::surface — named-variable elaboration engine

The named surface → de Bruijn Tm pass the verified check consumes. SExpr/STy are the resource-relevant fragment of ast::Expr/ast::Type; elaborate resolves names to de Bruijn against a Scope (innermost last, matching Tctx); check_surface runs the machine-checked walk. 6 tests — a linear binder dropped at the named surface is rejected by the verified algorithm; the same body under ω is accepted; nested binders resolve to correct indices.

2b · my-lang::qtt_bridge — lower the real ast::Expr

my-qtt now sits in my-lang's dependency graph — the proofs' own algorithm is in the compiler. qtt_bridge lowers the resource-relevant fragment of the running compiler's ast::Expr/ast::Type onto my_qtt::surface, and check_expr runs the verified check on it. 6 tests over real ast::Expr nodes — a real |x| x is accepted, a real |x| { 0 } (drops x) is rejected.

Honest scope: opaque base types → Unit; ->/tuples map structurally; out-of-fragment constructs (binary/unary/match/record/AI/…) return Unsupported (no silent passes). The Coq check is exact-usage and Param has no quantity syntax yet, so the bridge applies the linear default (One) — it enforces "use each binder once" on the real AST. Surface quantity syntax (a small parser+AST follow-on) activates real per-binder quantities with no engine change.

Test plan

  • cargo test -p my-qtt → 13 passed (engine + the original R5/R5b oracle tests)
  • cargo test -p my-lang qtt_bridge → 6 passed (real ast::Expr)
  • Idris/Coq tracks unchanged

Refs proofs/STATUS.md §"Implementation ⇄ spec coupling"

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits June 18, 2026 02:17
…core (coupling step 2a)

The bridge from a named surface to the de Bruijn core the verified check
consumes, so the resource axis can be enforced on real programs. SExpr/STy =
the resource-relevant fragment of my-lang's ast::Expr/ast::Type (var, λ-with-
quantity, app, both products, sums, let, echo); elaborate resolves names to
de Bruijn against a Scope (innermost last, matching Tctx); check_surface runs
the machine-checked usage-walk on the elaborated term.

6 tests green: a linear binder DROPPED at the named surface is rejected by the
verified algorithm (linear_drop_rejected), the same body under ω is accepted
(omega_dup_ok), nested binders resolve to correct indices (scope_resolution),
linear let, and unbound-name elaboration errors. Quantities are explicit on
SExpr binders, so the ast lowering (step 2b) can default them today and thread
real linearity syntax later with no engine change.
…core (coupling step 2b)

my-qtt now sits in my-lang's dependency graph — the proofs' own usage-walk is
in the compiler. qtt_bridge lowers the resource-relevant fragment of the
running compiler's ast::Expr/ast::Type (var, λ, application, let/block, literal)
onto my_qtt::surface, and check_expr runs the machine-checked check on it.

Honest scope: opaque base types -> Unit; -> and tuples map structurally;
out-of-fragment constructs (binary/unary/match/record/AI/try/restrict) return
BridgeError::Unsupported (no silent passes). Quantity default = One (linear),
since Param has no quantity syntax yet and the Coq check is exact-usage — so
the bridge ENFORCES 'use each binder exactly once' on the real AST: a real
|x| x is accepted, a real |x| { 0 } (drops x) is rejected by the verified walk.
Surface quantity syntax (small follow-on) activates real per-binder quantities
with no engine change.

6 tests green over real ast::Expr nodes. With step 2a (the engine), item 1
(coupling step 2) is complete: proofs -> implementation is wired and enforcing.
@hyperpolymath
hyperpolymath marked this pull request as ready for review June 18, 2026 06:12
@hyperpolymath
hyperpolymath merged commit a7765e7 into main Jun 18, 2026
21 of 23 checks passed
@hyperpolymath
hyperpolymath deleted the claude/dreamy-hypatia-O8XHo branch June 18, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants