Skip to content

Commit f3e57fd

Browse files
hyperpolymathclaude
andcommitted
proofs(P43): port canonical_* forms to the L1 modality-polymorphic judgment
Closes proof-debt P43 prerequisite from the comprehensive inventory. Prerequisite for P42 (progress_l1). What lands Seven modality-polymorphic canonical-forms lemmas at the end of formal/Semantics_L1.v, mirroring the legacy Linear-only versions at formal/Semantics.v:603-630: - canonical_unit_l1_m : v : TBase TUnit + is_value v → v = EUnit - canonical_bool_l1_m : v : TBase TBool + is_value v → ∃ b, v = EBool b - canonical_i32_l1_m : v : TBase TI32 + is_value v → ∃ n, v = EI32 n - canonical_fun_l1_m : v : TFun T1 T2 + is_value v → ∃ body, v = ELam T1 body - canonical_prod_l1_m : v : TProd T1 T2 + is_value v → ∃ v1 v2, v = EPair v1 v2 ∧ ... - canonical_sum_l1_m : v : TSum T1 T2 + is_value v → (∃ v0, v = EInl T v0 ∧ ...) ∨ (∃ v0, v = EInr T v0 ∧ ...) - canonical_string_l1_m : v : TString r + is_value v → ∃ l, v = ELoc l r The `_m` suffix follows the convention established by region_shrink_preserves_typing_l1_gen_m and subst_typing_gen_l1_m. A pre-existing Linear-only canonical_string_l1 at line 908 is left untouched (it predates the L2 modality hybrid; the new _m version generalises it). All 7 proofs are single-line inversions: intros; inversion H0; subst; inversion H; subst; <discharge> Same structural pattern as the legacy proofs — the L1 judgment's value-typing rules are sufficiently rigid that inversion on is_value v + the typing derivation pins the constructor. Build oracle: just -f formal/Justfile all clean. All 7 Print Assumptions blocks (added inline) print "Closed under the global context" — these lemmas surface ZERO axioms, exactly as the canonical-forms framework requires. Next: progress_l1 (P42) uses these as the case analysis on the type of a closed well-typed value. Stated separately because it requires the step relation's totality on non-value terms. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 29080c7 commit f3e57fd

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

formal/Semantics_L1.v

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,3 +3265,86 @@ Proof.
32653265
- exact preservation_l3_region_active_echo.
32663266
- exact preservation_l3_drop_echo.
32673267
Qed.
3268+
3269+
(** ============================================================
3270+
Canonical forms for the L1 judgment (proof-debt P43)
3271+
============================================================
3272+
3273+
Mirror of the legacy [canonical_*] lemmas at [Semantics.v:603-630]
3274+
on the [has_type_l1] judgment. Together these are the
3275+
prerequisite for [progress_l1] (proof-debt P42).
3276+
3277+
A canonical-forms lemma reads: "if [v] is a value of type [T],
3278+
then [v] is of the canonical syntactic shape for [T]". This is
3279+
invertibility of value-typing rules from the value side: it
3280+
inverts the [is_value v] view of a closed [has_type_l1] derivation
3281+
into the constructor pattern of [v].
3282+
3283+
Modality-polymorphic by design — the structural property holds
3284+
in both [Linear] and [Affine] modes; the modality parameter
3285+
threads through inversion unchanged.
3286+
3287+
All 7 follow the same pattern as the legacy proofs: inversion on
3288+
[is_value v] (case-splits the value constructors), then inversion
3289+
on the typing derivation (rules that don't produce [T] are
3290+
contradictory). [eauto] discharges the existential witnesses. *)
3291+
3292+
Lemma canonical_unit_l1_m :
3293+
forall m R R' G G' v,
3294+
has_type_l1 m R G v (TBase TUnit) R' G' -> is_value v -> v = EUnit.
3295+
Proof. intros; inversion H0; subst; inversion H; subst; reflexivity. Qed.
3296+
3297+
Lemma canonical_bool_l1_m :
3298+
forall m R R' G G' v,
3299+
has_type_l1 m R G v (TBase TBool) R' G' -> is_value v ->
3300+
exists b, v = EBool b.
3301+
Proof. intros; inversion H0; subst; inversion H; subst; eauto. Qed.
3302+
3303+
Lemma canonical_i32_l1_m :
3304+
forall m R R' G G' v,
3305+
has_type_l1 m R G v (TBase TI32) R' G' -> is_value v ->
3306+
exists n, v = EI32 n.
3307+
Proof. intros; inversion H0; subst; inversion H; subst; eauto. Qed.
3308+
3309+
Lemma canonical_fun_l1_m :
3310+
forall m R R' G G' v T1 T2,
3311+
has_type_l1 m R G v (TFun T1 T2) R' G' -> is_value v ->
3312+
exists body, v = ELam T1 body.
3313+
Proof. intros; inversion H0; subst; inversion H; subst; eauto. Qed.
3314+
3315+
Lemma canonical_prod_l1_m :
3316+
forall m R R' G G' v T1 T2,
3317+
has_type_l1 m R G v (TProd T1 T2) R' G' -> is_value v ->
3318+
exists v1 v2, v = EPair v1 v2 /\ is_value v1 /\ is_value v2.
3319+
Proof. intros; inversion H0; subst; inversion H; subst; eexists _, _; auto. Qed.
3320+
3321+
Lemma canonical_sum_l1_m :
3322+
forall m R R' G G' v T1 T2,
3323+
has_type_l1 m R G v (TSum T1 T2) R' G' -> is_value v ->
3324+
(exists T v0, v = EInl T v0 /\ is_value v0) \/
3325+
(exists T v0, v = EInr T v0 /\ is_value v0).
3326+
Proof.
3327+
intros; inversion H0; subst; inversion H; subst;
3328+
[left|right]; eexists _, _; auto.
3329+
Qed.
3330+
3331+
Lemma canonical_string_l1_m :
3332+
forall m R R' G G' v r,
3333+
has_type_l1 m R G v (TString r) R' G' -> is_value v ->
3334+
exists l, v = ELoc l r.
3335+
Proof. intros; inversion H0; subst; inversion H; subst; eauto. Qed.
3336+
3337+
(** ============================================================
3338+
Print Assumptions — Canonical-forms axiom audit
3339+
============================================================
3340+
Verify each canonical-forms lemma is clean: their statement is
3341+
structurally derivable from the typing-rule shapes + [is_value]
3342+
inversion, so they should not surface any axiom. *)
3343+
3344+
Print Assumptions canonical_unit_l1_m.
3345+
Print Assumptions canonical_bool_l1_m.
3346+
Print Assumptions canonical_i32_l1_m.
3347+
Print Assumptions canonical_fun_l1_m.
3348+
Print Assumptions canonical_prod_l1_m.
3349+
Print Assumptions canonical_sum_l1_m.
3350+
Print Assumptions canonical_string_l1_m.

0 commit comments

Comments
 (0)