drafting subtyping rules

This commit is contained in:
Ellen Arvidsson 2025-05-23 14:13:01 +02:00
parent 55970b1baf
commit 26d0d3158f

View file

@ -10,7 +10,7 @@ s, t ::= s | t (disjunction, a.k.a. union)
| s => t (implication)
| s -> t (arrow, a.k.a. function)
| forall x . t (forall, polymorphic)
| box t (box, modular logic)
| box t (box, c.f. modular logic)
| a [t..] (type operator application)
| x (variable)
| n (nominal)
@ -27,33 +27,45 @@ a ∈ opname
## sappho subtyping rules
```
s, t, γ ⊢ δ
---- [identity]
ρ; s, γ ⊢ s, δ
---- [true-right]
ρ; γ ⊢ true, δ
---- [false-left]
ρ; false, γ ⊢ δ
ρ; s, t, γ ⊢ δ
---- [conj-left]
s & t, γ ⊢ δ
ρ; s & t, γ ⊢ δ
γ ⊢ s, t, δ
ρ; γ ⊢ s, t, δ
---- [disj-right]
γ ⊢ s | t, δ
ρ; γ ⊢ s | t, δ
s, γ ⊢ δ
t, γ ⊢ δ
ρ; s, γ ⊢ δ
ρ; t, γ ⊢ δ
---- [disj-left]
s | t, γ ⊢ δ
ρ; s | t, γ ⊢ δ
γ ⊢ s, δ
γ ⊢ t, δ
ρ; γ ⊢ s, δ
ρ; γ ⊢ t, δ
---- [conj-right]
γ ⊢ s & t, δ
ρ; γ ⊢ s & t, δ
// XXX
s => t, s, t, γ ⊢ δ
// remove s => t? always make progress
ρ; s => t, s, t, γ ⊢ δ
---- [impl-left]
s => t, s, γ ⊢ δ
ρ; s => t, s, γ ⊢ δ
// discussion about implication below
s, γ ⊢ t, δ
// check how "normal sequent calculus handles this"
ρ; s, γ ⊢ t, δ
---- [impl-right]
γ ⊢ s => t, δ
ρ; γ ⊢ s => t, δ
// box works as a kind of "forall" for concrete types
@ -62,22 +74,64 @@ box t, t, γ ⊢ δ
box t, γ ⊢ δ
// (.)-- filters the contexts.
γ-- ⊢ t, δ--
ρ; γ-- ⊢ t, δ--
---- [box-right]
γ ⊢ box t, δ
ρ; γ ⊢ box t, δ
// recursion through operators are handled using the recursion context ρ
// XXX compare with iso-recursive subtyping (double expansion)
---- [op-discharge]
a [t..], ρ; γ ⊢ a [t..], δ
a [t..]*, ρ; γ ⊢ expand(a [t..]), δ
---- [op-expand1]
ρ; γ ⊢ a [t..], δ
a [t..], ρ; γ ⊢ expand(a [t..]), δ
---- [op-expand2]
a [t..]*, ρ; γ ⊢ a [t..], δ
// member types are filtered according to member name
ρ; γ >> m ⊢ δ >> m
---- [member]
ρ; γ ⊢ δ
// foralls are unwrapped and variable substituted with fresh name
// i.e. we treat the bound variable nominally
n fresh
ρ; γ [n] ⊢ δ [n]
---- [forall]
ρ; γ ⊢ δ
```
### context operators
* box filtering
```
(t, γ)-- =def= t, γ-- if t == box s
(t, γ)-- =def= t, γ-- if t == box s, for some s
γ-- otherwise
```
* member unwrapping
```
(t, γ) >> m =def= s, (γ >> m) if t == { m : s }, for some s
γ >> m otherwise
```
* forall-unwrapping and substitution
```
(t, γ) [n] =def= s [n/x], (γ [n]) if t == forall x . s, for some x, s
γ [n] otherwise
```
What happens when box is buried under type operators, like box s & box t? It
could be that the above definition filters out too much of the contexts.