docs: analyze Hemlock against the gradual guarantee and blame theorem - #624
Open
nbeerbower wants to merge 1 commit into
Open
docs: analyze Hemlock against the gradual guarantee and blame theorem#624nbeerbower wants to merge 1 commit into
nbeerbower wants to merge 1 commit into
Conversation
Formalizes what Hemlock's optional annotations actually do (convert_to_type is a lossy, effectful coercion rather than a cast) and tests the language against the two standard gradual-typing correctness criteria: - Static gradual guarantee: VIOLATED - inference pins unannotated bindings to rigid types, so erasing 'let a: array' introduces a type error. - Dynamic gradual guarantee: VIOLATED - ascription converts values (3.99 -> 3, 3 -> true), annotation checks mutate shared aggregates in place (element coercion, optional-field materialization, nominal brands observed by match), and removing an annotation can introduce a crash. Separately documents the inherent numeric-semantics obstruction (i32/i64 overflow policy) that justifies a weakened criterion. - Blame theorem: FAILS - function-type casts are erased (no monitoring), boundary failures surface inside and are attributed to well-typed code, ref parameters skip checks entirely, and failure discipline is split across catchable/uncatchable/no-location regimes. Includes 17 runnable witness programs (docs/design/gradual-typing/), all verified against both backends; interpreter and compiler agree on every witness except blame3_ref.hml, where the static checker rejects what the interpreter runs. Closes with a repair taxonomy: which behaviors are design (weaken the criterion), which are semantic choices to change, and which are bugs under any reading. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBoD5i9DECci3pWURU1CTW
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.
Formalizes what Hemlock's optional annotations actually do (convert_to_type
is a lossy, effectful coercion rather than a cast) and tests the language
against the two standard gradual-typing correctness criteria:
to rigid types, so erasing 'let a: array' introduces a type error.
(3.99 -> 3, 3 -> true), annotation checks mutate shared aggregates in
place (element coercion, optional-field materialization, nominal brands
observed by match), and removing an annotation can introduce a crash.
Separately documents the inherent numeric-semantics obstruction (i32/i64
overflow policy) that justifies a weakened criterion.
boundary failures surface inside and are attributed to well-typed code,
ref parameters skip checks entirely, and failure discipline is split
across catchable/uncatchable/no-location regimes.
Includes 17 runnable witness programs (docs/design/gradual-typing/), all
verified against both backends; interpreter and compiler agree on every
witness except blame3_ref.hml, where the static checker rejects what the
interpreter runs. Closes with a repair taxonomy: which behaviors are
design (weaken the criterion), which are semantic choices to change, and
which are bugs under any reading.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01XBoD5i9DECci3pWURU1CTW