Skip to content

Phase D slice 4 Phase 3b — TFunEff substitution-lemma extension (deferred from #224) #225

@hyperpolymath

Description

@hyperpolymath

Context

Phase 3a (#224) shipped the retype half of Phase 3 per formal/SUBST-LEMMA-GENERALIZATION-DESIGN.mdis_tfuneff_ty predicate and tfuneff_lambda_retype_l1_m lemma. The substitution-lemma extension was descoped from #224 after structural analysis.

This issue tracks Phase 3b: extend subst_typing_gen_l1_m (or a sibling lemma subst_typing_gen_l1_m_tfuneff_lambda) to cover T1 = TFunEff … lambda substituends, so that Phase 4 can close preservation_l2's T_App_L2_Eff β-case for the TFunEff non-linear T1 case.

The obstacle

Every compound case in subst_typing_gen_l1_m_ground_nonlinear (Phase 2) relies on the retype lemma being fully R-polymorphic (no side condition). For TFunEff lambda values, the retype lemma carries a side condition forall r, In r R' → In r R_in_arg, where R_in_arg is fixed by the value's type TFunEff T1 T2 R_in_arg R_out_arg.

The substitution lemma's compound cases need to retype the substituted value vv at threaded R values R_n arising inside the substitution target e. T_Region_L1 firings inside e introduce fresh regions r ∉ R_outer — and freshness wrt the threaded R does not imply r ∈ R_in_arg.

Concretely: in T_Region_L1's body, the new R is r' :: R_outer where r' is fresh wrt R_outer. To retype vv at r' :: R_outer, we need r' ∈ R_in_arg, but r' is fresh in a way that's unconstrained relative to R_in_arg.

Three candidate solutions

(a) Syntactic side condition on e

Add a Definition regions_introduced_by : expr → list region_name and require forall r, In r (regions_introduced_by e) → In r R_in_arg as a precondition. Each compound case threads the predicate to its sub-expressions (region-introductions in a parent expression contain those of all sub-expressions). T_Region_L1 case discharges r' ∈ R_in_arg directly from the side condition.

Pros: clean to state, syntactically computable.
Cons: propagating the predicate through ~28 cases is mechanical churn.

(b) Universal-R Hv_type with per-case side-condition discharge

Replace the simple Hv_type premise with a universal-R version:

(forall R_any,
   (forall r, In r R_any → In r R_in_arg) →
   has_type_l1 m R_any (remove_at k Gin) vv Tsub R_any (remove_at k Gin))

Each compound case picks the R it needs and discharges the side condition.

Pros: no new Definitions.
Cons: still doesn't help in T_Region_L1 (the new R contains a fresh region not necessarily in R_in_arg).

(c) Restrict to region-free terms

Add expr_strictly_free_of_region predicates for the introduced regions. Effectively restricts the lemma to terms without T_Region_L1 firings.

Pros: simple.
Cons: very restrictive; may not cover the actual Phase 4 use shape.

Recommendation

Prototype Phase 4 closure of preservation_l2's T_App_L2_Eff β-case first. The actual shape of subst 0 varg ebody (where ebody is vlam's body, typed at R_in_big not R_in_arg) will reveal whether T_Region_L1 firings inside ebody are a real obstacle or an edge case.

If the Phase 4 use shape only ever needs the substitution lemma for ebody with bounded R-flow, option (a) is appropriate. If T_Region_L1 inside ebody is generic, options (a)+(b) compose.

References

  • formal/SUBST-LEMMA-GENERALIZATION-DESIGN.md — original Phase 3 design.
  • formal/Semantics_L1.vsubst_typing_gen_l1_m_ground_nonlinear (Phase 2 template) at line 1752.
  • formal/Semantics_L1.vtfuneff_lambda_retype_l1_m (Phase 3a, feat(L1): Phase D slice 4 Phase 3a — tfuneff_lambda_retype_l1_m + is_tfuneff_ty #224).
  • .machine_readable/6a2/STATE.a2mlnext_action documents the three candidates.
  • standards#134 — proof-debt epic.

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