alpha-2027 · draft-alpha-2027 · tests/language/prophecyView source

Feature contract: resolve#

(resolve GHOST VALUE WITNESS) closes the prophecy whose ghost is GHOST. It is part of the prophecy feature; its normative contract is prophecy, sections 1, 2, 5 and 7. In brief:

1. Lexical and grammar rules, including precedence and termination#

A three-operand head whose first operand is an identifier; inside a do it may replace the final (return VALUE). A missing or extra operand is ALPHA-PARSE-UNEXPECTED.

2. Scope and binding rules, including generated names#

resolve is a reserved head in every edition (SPECIFICATION §2): a function or binder named resolve is applied as (app resolve x); (resolve x) is this form, and under alpha-2026 the edition gate refuses it.

GHOST must be the ghost of an enclosing prophecy, not shadowed by a nearer binder; it binds nothing.

3. Type and quantity requirements#

VALUE is checked at the prophecy's value type and WITNESS at the relation instantiated with the ghost and VALUE. The ghost itself may not be VALUE (it is erased).

4. Effects, totality, and evaluation-order rules#

It is a pure pair, or the return of one; it performs no effect.

5. Elaboration into existing core or a specifically versioned new core extension#

(pair (sigma unrestricted RESOLVED : A . R) VALUE WITNESS), wrapped in return at an expected computation type or, with nothing expected, in the prophecy's own row. No core constructor of its own.

6. Representation and target support, where relevant#

As for pair and return, except that the enclosing prophecy is not lowered by the direct lane (docs/generated/ALPHA-BACKEND-COVERAGE.md), so a program using resolve runs on the evaluator lane only.

7. Error codes and primary/secondary origins#

ALPHA-PROPHECY-RESOLVE-UNBOUND, ALPHA-PROPHECY-RESOLVE-SCOPE; ALPHA-PARSE-UNEXPECTED for a wrong operand count (the parser's ALPHA-PARSE-PROPHECY "unterminated resolve" needs a token stream without its end marker, which no source file produces); a witness that does not prove the relation is ALPHA-TYPE-MISMATCH, and the ghost as the value is ALPHA-QUANTITY-VIOLATION.

8. Formatting and migration rules#

One line when it fits; expanded inspection prints the pair.

9. Positive, negative, execution, and edge-case tests#

tests/language/prophecy/ (see the prophecy contract, section 9). tests/language/draft/resolve/ checks the three positions (the body, a do's final step, a bind continuation) and refuses an unbound or shadowed ghost, the outer ghost from an inner body, a wrong witness, the ghost as the value and a missing witness.

10. Compatibility with the old edition, serialized forms, and cache keys#

alpha-2026 rejects the head. The self-hosted AST checkpoint codec gives it tag 35 (ProphecyResolve; 32 is reflexivity).