Effect4

R9: Never goes wrong: M7a–c on M7Fragment (the empty host table, answer-free tapes)req:R9

Requirement R9: Well-typed programs never go wrongabout:req:R9

This page explains requirement R9 in Effect4. It covers what the requirement asks for type safety and defect exclusion, why non-halting matters, and how the property is checked.

What the requirement asksabout:req:R9:what-it-asks

Requirement R9 formalizes type safety by proving that every typed program execution satisfies ExitOk and never halts (docs/core/system-map.md §8, DB-16):

  • Exit correctness: ExitOk w ty ex := FitsExit w ty ex ∧ NoShapeDefect ty ex holds at every typed exit position.
  • Shape defect exclusion: NoShapeDefect excludes reserved malformed code defects such as badName and notImplemented (decisions row 107).
  • Non-halting: the small-step transition system never encounters a stuck configuration (machineTyped_not_halted).

The property is scoped to M7Fragment: a lawful source, an empty row table, an admitted closed program, and an answer-free tape.

Why it mattersabout:req:R9:why-it-matters

Type systems aim to prove that well-typed programs cannot go wrong (Milner 1978).

In untyped JavaScript, unhandled shapes, missing services, and internal runtime bugs cause unexpected crashes.

Requirement R9 asks that a checked program end in a value or a typed cause, and never halt the machine.

How it is checkedabout:req:R9:how-it-is-checked

The requirement is checked by assembling the milestone proofs M5, M6, and M7:

  • The route theorem m7_of_ledger states that load typing (M5) and the preservation of ConfigTyped by each command (M6) imply milestone M7 (src/Effect4/Laws/Program/Typed/Assembly.lean).
  • The theorem machineTyped_not_halted, in the same file, states that a typed machine is never halted.
  • Milestone results are stated by m7_proved in src/Effect4/Laws/Program/Typed/Commands/Clauses/All.lean.
  • Source program admission connecting checked programs to M7 is stated by m7_admitted (src/Effect4/Laws/Program/Typed/AdmittedSource.lean).

The plan on this page gives each theorem's status and the goals it rests on.

The open part of R9: its planned goals and the theorems proved modulo them. An arrow goes from a node to a node its proof reaches first.
The figure in words
R9 by concept: each concept its nodes are placed at, by tag or by module. An arrow goes where a node's proof reaches a node of another concept.
The figure in words
NodeStatusRests onNearest nodes
m7_provedmodulocountdown_parks_positionaldecision_preserves, loadsTyped, m7_of_ledger
m7_admittedmodulocountdown_parks_positionalm7_proved, lawfulSig_of_admitted
countdown_parks_positionalgoalcountdown_parks_positional—
decision_preservesmodulocountdown_parks_positionalfits_subN, satisfies_empty, order_refl, fits_mono, order_trans, mono, subN_trans, configTyped_frame, hom_eq_cata_ty, wake_preserves, close_typed, seq_typed, registrationDone_preserves, launch_preserves, subN_never, guardBind_typed, deliver_preserves, loop_preserves, driveState_lift
loadsTypedproved—denotesTyped, checkModule_eq_check, check_complete, checkModule_sound, satisfies_empty
m7_of_ledgerproved—at_append, order_trans, order_refl
lawfulSig_of_admittedproved—admitSig_ok_iff
fits_subNproved—subN_trans, fits_normalize
satisfies_emptyproved——
order_reflproved——
fits_monoproved——
order_transproved——
monoproved—order_trans
subN_transproved——
configTyped_frameproved—satisfies_empty, fits_mono, order_trans, mono, order_refl, hom_eq_cata_ty
hom_eq_cata_typroved——
wake_preservesproved—order_refl, configTyped_frame, fits_mono, completionStrong_await, hom_eq_cata_ty
close_typedproved——
seq_typedproved—subN_refl, fits_subN, guardBind_typed
registrationDone_preservesproved—order_refl, fits_mono, order_trans, mono, satisfies_empty, close_typed, fits_subN
launch_preservesproved—subN_refl, fits_subN, satisfies_empty, order_refl, fits_mono, order_trans, mono, satisfies_weaken
subN_neverproved——
guardBind_typedproved——
deliver_preservesmodulocountdown_parks_positionalorder_refl, satisfies_empty, fits_mono, order_trans, mono, satisfies_weaken, settle_callback, hom_eq_cata_ty, completionStrong_await, memoBuild_extension, deferredMake_extension, refMake_extension, subN_never, fits_subN, scopeParams_child, at_child, denotesTyped, listOf_upper, fits_normalize, normalize_idem, lift_sound, subN_trans, causeInputError_upper, matchArgsB_sound, subN_refl, at_append, scopeParams_below, fiberTy_upper, matchB_sound, syncRow_typed, withParams_of_none, errOf_payload, isPayload_of_hasTy_record, foreignFinalizer_ambient, fits_scope_inv, seq_typed, closeSeqProtocol, configTyped_frame, close_typed, clause_scoped, clause_closeScope, scopeParams_ref, scopeParams_layer_below, satisfies_union, withParams_serviceTy, guardBind_typed, countdown_parks_positional
loop_preservesmodulocountdown_parks_positionalorder_refl, satisfies_empty, fits_mono, order_trans, mono, satisfies_weaken, settle_callback, hom_eq_cata_ty, completionStrong_await, memoBuild_extension, deferredMake_extension, refMake_extension, subN_never, fits_subN, scopeParams_child, at_child, denotesTyped, listOf_upper, fits_normalize, normalize_idem, lift_sound, subN_trans, causeInputError_upper, matchArgsB_sound, subN_refl, at_append, scopeParams_below, fiberTy_upper, matchB_sound, syncRow_typed, withParams_of_none, errOf_payload, isPayload_of_hasTy_record, foreignFinalizer_ambient, fits_scope_inv, seq_typed, closeSeqProtocol, configTyped_frame, close_typed, clause_scoped, clause_closeScope, scopeParams_ref, scopeParams_layer_below, satisfies_union, withParams_serviceTy, guardBind_typed, countdown_parks_positional
driveState_liftproved——
denotesTypedproved—provideLayerArm, at_child, subN_refl, fits_subN, fits_normalize, fiberTy_upper, scopeParams_child, hom_eq_cata_ty, subN_trans, matchB_sound, syncRow_typed, withParams_of_none, listOf_upper, normalize_idem, lift_sound, causeInputError_upper, matchArgsB_sound, errOf_payload, isPayload_of_hasTy_record, satisfies_weaken, subN_never, fits_mono, order_trans, invoke_arm, optionTy_upper, withParams_serviceTy, scopeParams_below, exitOf_upper, fits_scope_inv, param_arm, call_arm
checkModule_eq_checkproved——
check_completeproved——
checkModule_soundproved—check_sound
at_appendproved——
admitSig_ok_iffproved——
fits_normalizeproved—subN_trans, normalize_idem
completionStrong_awaitproved—subN_trans
subN_reflproved——
satisfies_weakenproved——
settle_callbackproved—fits_subN, fits_mono, subN_never, subN_refl, order_refl, scopeParams_child, at_child, order_trans, fits_scope_inv, seq_typed, closeOrder_eq, mono, satisfies_empty, configTyped_frame, hom_eq_cata_ty
memoBuild_extensionproved——
deferredMake_extensionproved——
refMake_extensionproved——
scopeParams_childproved——
at_childproved—at_append
listOf_upperproved—list_eliminator, normalize_idem, subN_trans, subN_refl, extendAll_upper
normalize_idemproved——
lift_soundproved—lift_transfer
causeInputError_upperproved—cause_upper, cause_mono, normalize_idem, subN_trans, subN_refl, UnionRule.lift_upper, subN_causeOf_causeUpper, subN_exitOf_causeUpper, extendAll_eq_some_iff
matchArgsB_soundproved——
scopeParams_belowproved——
fiberTy_upperproved—fiber_eliminator, normalize_idem, subN_trans, subN_refl, extendAll_upper
matchB_soundproved—lookup_solve_seed
syncRow_typedproved—fits_normalize, subN_trans, fits_subN, termMaps_of_typed, matchB_sound, hom_eq_cata_ty, errOf_payload, isPayload_of_hasTy_record, normalize_idem, subN_refl
withParams_of_noneproved——
errOf_payloadproved——
isPayload_of_hasTy_recordproved—handles_of_payloadFieldTy
foreignFinalizer_ambientproved—subN_never, fits_subN, fits_mono, order_refl, scopeParams_child, at_child, order_trans
fits_scope_invproved——
closeSeqProtocolproved—order_trans, fits_mono
clause_scopedproved—fits_mono, order_trans, mono, order_refl, satisfies_empty, denotesTyped, configTyped_frame, hom_eq_cata_ty
clause_closeScopeproved—fits_mono, order_trans, mono, subN_never, fits_subN, order_refl, scopeParams_child, at_child, fits_scope_inv, seq_typed, closeOrder_eq, satisfies_empty, configTyped_frame, hom_eq_cata_ty
scopeParams_refproved——
scopeParams_layer_belowproved——
satisfies_unionproved——
withParams_serviceTyproved——
provideLayerArmproved—fits_subN, subN_refl, fits_normalize, fiberTy_upper, scopeParams_child, at_child, hom_eq_cata_ty, subN_trans, matchB_sound, syncRow_typed, withParams_of_none, listOf_upper, normalize_idem, lift_sound, causeInputError_upper, matchArgsB_sound, errOf_payload, isPayload_of_hasTy_record, satisfies_weaken, subN_never, fits_mono, order_trans, fits_scope_inv
invoke_armproved—normalize_idem, fits_mono, fits_subN, order_trans, at_child, scopeParams_below, listOf_upper, fits_normalize, lift_sound, subN_trans, causeInputError_upper, matchArgsB_sound, hom_eq_cata_ty, scopeParams_body, withParams_defOf
optionTy_upperproved—option_eliminator, normalize_idem, subN_trans, subN_refl, Eliminator.lift_upper
exitOf_upperproved—exit_eliminator, normalize_idem, subN_trans, subN_refl, extendAll_upper
param_armproved—normalize_idem, fits_mono, fits_subN, order_trans, listOf_upper, fits_normalize, lift_sound, subN_trans, causeInputError_upper, matchArgsB_sound, hom_eq_cata_ty, scopeParams_decl, withParams_param
call_armproved—fits_mono, fits_subN, normalize_idem, order_trans, listOf_upper, fits_normalize, lift_sound, subN_trans, causeInputError_upper, matchArgsB_sound, hom_eq_cata_ty, scopeParams_body, withParams_of_none
check_soundproved——
closeOrder_eqproved——
list_eliminatorproved—subN_list_iff, normalize_idem, subN_trans, subN_refl
extendAll_upperproved—extendAll_adjoint
lift_transferproved—joinAll_keeps, mapM_answer
cause_upperproved—subN_causeOf_causeUpper, subN_exitOf_causeUpper
cause_monoproved—subN_exitOf_iff, subN_causeOf_causeUpper, subN_trans, subN_causeOf_iff
UnionRule.lift_upperproved—le_joinAll, subN_trans, mapM_answer
subN_causeOf_causeUpperproved——
subN_exitOf_causeUpperproved—subN_trans, subN_refl, subN_exitOf_iff
extendAll_eq_some_iffproved——
fiber_eliminatorproved—subN_fiberOf_iff, normalize_idem, subN_trans, subN_refl
lookup_solve_seedproved——
termMaps_of_typedproved—listOf_upper, fits_subN, fits_normalize, normalize_idem, lift_sound, subN_trans, causeInputError_upper, matchArgsB_sound, hom_eq_cata_ty, fits_mono
handles_of_payloadFieldTyproved——
scopeParams_bodyproved——
withParams_defOfproved——
option_eliminatorproved—subN_option_iff, normalize_idem, subN_trans, subN_refl
Eliminator.lift_upperproved—subN_refl, UnionRule.lift_upper
exit_eliminatorproved—subN_exitOf_iff, normalize_idem, subN_trans, subN_refl
scopeParams_declproved——
withParams_paramproved——
subN_list_iffproved——
extendAll_adjointproved—adjoint, extendAll_eq_some_iff
joinAll_keepsproved—foldl_keeps
mapM_answerproved—mapM_cons_eq_some
subN_exitOf_iffproved——
subN_causeOf_iffproved——
le_joinAllproved—joinAll_keeps
subN_fiberOf_iffproved——
subN_option_iffproved——
adjointproved—Eliminator.lift_least, subN_trans, mapM_total, Eliminator.lift_upper
foldl_keepsproved——
mapM_cons_eq_someproved——
Eliminator.lift_leastproved—UnionRule.lift_least
mapM_totalproved—mapM_cons_eq_some
UnionRule.lift_leastproved—subN_trans, mapM_source, joinAll_le
mapM_sourceproved—mapM_cons_eq_some
joinAll_leproved—joinAll_all
joinAll_allproved—foldl_all
foldl_allproved——