vekatze / neut

A functional programming language with static memory management
https://vekatze.github.io/neut/
MIT License
840 stars 11 forks source link

Reformulate borrowing using the T-necessity modality #195

Closed vekatze closed 3 months ago

vekatze commented 3 months ago

This PR reformulates the let-on stuff (or "borrowing") via the Curry-Howard correspondence of the T-necessity modality.

Docs

Here

Summary

Inference Rules

meta

Γ1; ...; Γn ⊢ t: type
-------------------------- (□-form)
Γ1; ...; Γn ⊢ meta t: type

box

Γ1; ...; Γn; Δ ⊢ e1: a
------------------------------------- (□-intro)
Γ1; ...; Γn, &Δ ⊢ box Δ {e1}: meta a

letbox

Γ1; ...; Γn, &Δ ⊢ e1: meta a
Γ1; ...; Γn; Δ, Δ', x: a ⊢ e2: b
------------------------------------------------ (□-elim)
Γ1; ...; Γn; Δ, Δ' ⊢ letbox x on Δ = e1 in e2: b

letbox-T

Γ1; ...; Γn, &Δ ⊢ e1: meta a
Γ1; ...; Γn, Δ, Δ', x: a ⊢ e2: b
-------------------------------------------------- (□-elim-T)
Γ1; ...; Γn, Δ, Δ' ⊢ letbox-T x on Δ = e1 in e2: b