Skip to content

Phase 3b design gap: option (a) precondition insufficient for T_Lam_L1_*_Eff body cases #235

@hyperpolymath

Description

@hyperpolymath

Finding

Phase D slice 4 Phase 3b's stated precondition

(forall r, In r (regions_introduced_by e) -> In r R_in_v)

(option (a) per formal/SUBST-LEMMA-GENERALIZATION-DESIGN.md) is insufficient to discharge the T_Lam_L1_*_Eff body cases of the planned subst_typing_gen_l1_m_tfuneff lemma.

Why

The substitution lemma recurses into inner lambda bodies (mirroring Phase 2's subst_typing_gen_l1_m_ground_nonlinear at lines 1929-1942 of formal/Semantics_L1.v). For inner T_Lam_L1_*_Eff cases, the body sub-derivation is typed at the inner lambda's declared R_in_inner, not at the outer R or at any region listed in regions_introduced_by(e):

  • T_Lam_L1_Linear_Eff / T_Lam_L1_Affine_Eff formation rules (TypingL1.v:221, 226):

    R_in ; ctx_extend G T1 |=L1[m] ebody : T2 -| R_out ; ((T1, _) :: G)
    

    The body is typed at R_in, an arbitrary declared region environment in the FUNCTION TYPE.

  • The IH at this case wants v retyped at R_in_inner. The available retype lemma is tfuneff_lambda_retype_l1_m (Semantics_L1.v:1257-1278), which requires R' ⊆ R_in_v.

  • Neither regions_introduced_by(e) (syntactic ERegion subterms) nor the outer R contains R_in_inner's regions in general. R_in_inner is type-level, not syntactic.

Phase 2 dodge that doesn't apply

Phase 2's subst_typing_gen_l1_m_ground_nonlinear discharges the same cases via ground_nonlinear_retype_l1_m, which is fully (m, R, G)-polymorphic — ground non-linear values type at ANY region env. Phase 3b's TFunEff retype carries the R' ⊆ R_in_v obligation, which has no analogous escape hatch.

Three resolution options

(1) Strengthen the precondition to a type-level over-approximation

Add a helper Fixpoint declared_lambda_r_ins (e : expr) : list region_name that walks ELam T body, extracts R_in from T when T = TFunEff _ _ R_in _, and unions with the recursive call.

Blocker: ELam syntax (Syntax.v) carries the parameter type, not the function type. The function type's R_in is determined by typing, not syntax. So this helper can't be defined as a syntactic Fixpoint without an annotation extension to ELam.

(2) Semantic precondition over the derivation

State the precondition as: "for every sub-derivation Htype' of Htype at R'_in, R'_in ⊆ R_in_v". Clean meaning, awkward in Coq (would require either an inductive predicate over has_type_l1 derivations or a fixpoint indexed by derivation depth).

(3) Restrict scope — Phase 3b leaf-only

Ship Phase 3b only for the leaf-lambda case: bodies that do not themselves contain T_Lam_L1_*_Eff sub-derivations. Add an inductive predicate lambda_free e and condition the lemma on it. Document the limitation; defer the recursive case to Phase 5 (compound non-linear).

Recommendation

Option (3) as a tactical landing for Phase 3b. The leaf-only case unblocks the immediate consumer (preservation_l2 β-case for TFunEff arguments whose body uses ERegion but not nested function abstractions). The recursive case rides Phase 5's compound-value redesign.

Owner decision needed before Phase 3b implementation can start.

Owner-directive compliance

  • Does NOT propose closing legacy preservation in Semantics.v.
  • Does NOT extend Semantics.v.
  • Does NOT close residual Semantics_L1.v admits.
  • Reports a structural finding before patching; per CLAUDE.md §"DO" Claude/ephapax linear types e00 zs #4 ("Escalate before patching when a side-condition is needed").

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions