This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

11institutetext: Imperial College London, United Kingdom

Depending on Session-Typed Processes

Bernardo Toninho    Nobuko Yoshida
Abstract

This work proposes a dependent type theory that combines functions and session-typed processes (with value dependencies) through a contextual monad, internalising typed processes in a dependently-typed λ\lambda-calculus. The proposed framework, by allowing session processes to depend on functions and vice-versa, enables us to specify and statically verify protocols where the choice of the next communication action can depend on specific values of received data. Moreover, the type theoretic nature of the framework endows us with the ability to internally describe and prove predicates on process behaviours. Our main results are type soundness of the framework, and a faithful embedding of the functional layer of the calculus within the session-typed layer, showcasing the expressiveness of dependent session types.

1 Introduction

Session types [26, 14] are a typing discipline for communication protocols, whose simplicity provides an extensible framework that allows for integration with a variety of functional type features. One useful instance arising from the proof theoretic exploration of logical quantification is value dependent session types [27]. In this work, one can express properties of exchanged data in protocol specifications separately from communication, but cannot describe protocols where communication actions depend on the actual exchanged data (e.g. [17, § 2]). Moreover, it does not allow functions or values to depend on protocols (i.e. sessions) or communication, thus preventing reasoning about dependent process behaviours, exploring the proofs-as-programs paradigm of dependent type theory, e.g. [18, 8].

Our work addresses the limitations of existing formulations of session types by proposing a type theory that integrates dependent functions and session types using a contextual monad. This monad internalises a session-typed calculus within a dependently-typed λ\lambda-calculus. By allowing session types to depend on λ\lambda-terms and λ\lambda-terms to depend on typed processes (using the monad), we are able to achieve heightened degrees of expressiveness. Exploiting the former direction, we enable writing actual data-dependent communication protocols. Exploiting the latter, we can define and prove properties of linearly-typed objects (i.e. processes) within our intuitionistic theory.

To informally demonstrate how our type theory goes beyond the state of the art in order to represent data-dependent protocols, consider the following session type (we write τA\tau\wedge A for x:τ.A\exists x{:}\tau.A where xx does not occur in AA and similarly τA\tau\supset A for x:τ.A\forall x{:}\tau.A when xx is not free in AA), T𝖡𝗈𝗈𝗅{𝚝:𝖭𝖺𝗍𝟏,𝚏:𝖡𝗈𝗈𝗅𝟏}T\triangleq\mathsf{Bool}\supset\oplus\{\mathtt{t}:\mathsf{Nat}\wedge\mathbf{1},\mathtt{f}:\mathsf{Bool}\wedge\mathbf{1}\}, representable in existing session typing systems. The type TT denotes a protocol which first, inputs a boolean and then either emits the label 𝚝\mathtt{t}, which will be followed by an output of a natural number; or emits the label 𝚏\mathtt{f} and a boolean. The intended protocol described by TT is to take the 𝚝\mathtt{t} branch if the received value is 𝚝\mathtt{t} and the 𝚏\mathtt{f} branch otherwise, which we can implement as QQ with channel zz typed by TT as follows:

Qz(x).𝖼𝖺𝗌𝖾x𝗈𝖿(𝗍𝗋𝗎𝖾z.𝚝;z23.0,𝖿𝖺𝗅𝗌𝖾z.𝚏;z𝗍𝗋𝗎𝖾.0)\begin{array}[]{lcl}Q&\triangleq&z(x).\mathsf{case}\;x\;\mathsf{of}\;(\mathsf{true}\Rightarrow z.\mathtt{t};z\langle 23\rangle.\boldsymbol{0},\ \mathsf{false}\Rightarrow z.\mathtt{f};z\langle\mathsf{true}\rangle.\boldsymbol{0})\end{array}

where z(x).Pz(x).P denotes an input process, z.𝚝z.\mathtt{t} is a process which selects label 𝚝\mathtt{t} and z23.Pz\langle 23\rangle.P is an output on zz. However, since the specification is imprecise, process z(x).𝖼𝖺𝗌𝖾x𝗈𝖿(𝖿𝖺𝗅𝗌𝖾z.𝚝;z23.0,𝗍𝗋𝗎𝖾z.𝚏;z𝗍𝗋𝗎𝖾.0)z(x).\mathsf{case}\;x\;\mathsf{of}\;(\mathsf{false}\Rightarrow z.\mathtt{t};z\langle 23\rangle.\boldsymbol{0},\ \mathsf{true}\Rightarrow z.\mathtt{f};z\langle\mathsf{true}\rangle.\boldsymbol{0}) is also a type-correct implementation of TT that does not adhere to the intended protocol. Using our dependent type system, we can narrow the specification to guarantee that the desired protocol is precisely enforced. Consider the following definition of a session-type level conditional where we assume inductive definition and dependent pattern matching mechanisms (𝗌𝗍𝗒𝗉𝖾\mathsf{stype} denotes the kind of session types):

𝚒𝚏::𝖡𝗈𝗈𝗅𝗌𝗍𝗒𝗉𝖾𝗌𝗍𝗒𝗉𝖾𝗌𝗍𝗒𝗉𝖾𝚒𝚏𝗍𝗋𝗎𝖾AB=A𝚒𝚏𝖿𝖺𝗅𝗌𝖾AB=B\begin{array}[]{l}\mathtt{if}::\mathsf{Bool}\rightarrow\mathsf{stype}\rightarrow\mathsf{stype}\rightarrow\mathsf{stype}\\ \mathtt{if}\ \mathsf{true}\,A\,B\ =\ A\quad\quad\mathtt{if}\ \mathsf{false}\,A\,B\ =\ B\end{array}

The type-level function above case analyses the boolean and produces its first session type argument if the value is 𝗍𝗋𝗎𝖾\mathsf{true} and the second otherwise. We may now specify a session type that faithfully implements the protocol:

Tx:𝖡𝗈𝗈𝗅.𝚒𝚏x(𝖭𝖺𝗍𝟏)(𝖡𝗈𝗈𝗅𝟏)T^{\prime}\triangleq\forall x{:}\mathsf{Bool}.\mathtt{if}\,x\,(\mathsf{Nat}\wedge\mathbf{1})\,(\mathsf{Bool}\wedge\mathbf{1})

A process RR implementing such a type on channel zz is given below:

Rz(x).𝖼𝖺𝗌𝖾x𝗈𝖿(𝗍𝗋𝗎𝖾z23.0,𝖿𝖺𝗅𝗌𝖾z𝗍𝗋𝗎𝖾.0)\begin{array}[]{lcl}R\triangleq z(x).\mathsf{case}\;x\;\mathsf{of}\;(\mathsf{true}\Rightarrow z\langle 23\rangle.\boldsymbol{0},\ \mathsf{false}\Rightarrow z\langle\mathsf{true}\rangle.\boldsymbol{0})\end{array}

Note that if we flip the two branches of the case analysis in RR, the session is no longer typable with TT^{\prime}, ensuring that the protocol is implemented faithfully.

The example above illustrates a simple yet useful data-dependent protocol. When we further extend our dependent types with a process monad [31], where {cPuj¯;di¯}\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\} is a functional term denoting a process that may be spawned by other processes by instantiating the names in uj¯\overline{u_{j}} and di¯\overline{d_{i}}, we can provide more powerful reasoning on processes, enabling refined specifications through the use of type indices (i.e. type families) and an ability to internally specify and verify predicates on process behaviours. We also show that all functional types and terms can be faithfully embedded in the process layer using the dependently-typed sessions and process monads.

Contributions.

§ 2 introduces our dependent type theory, augmenting the example above by showing how we can reason about process behaviour using type families and dependently-typed functions (§ 2.3). We then establish the soundness of the theory (§ 2.4). § 3 develops a faithful embedding of the dependent function space in the process layer (Theorem 3.4). § 4 concludes with related work. This article is a long version of [34] containing omitted definitions, proofs and additional examples.

2 A Dependent Type Theory of Processes

Kinds K,K::=𝗍𝗒𝗉𝖾𝗌𝗍𝗒𝗉𝖾Πx:τ.KΠt:K.KFunctionalτ,σ::=Πx:τ.σλx:τ.στM{uj:Bj¯;di:Ai¯c:A}λt::K.ττσSessionsA,B::=!AABABx:τ.Ax:τ.A𝟏&{li:Ai¯}{li:Ai¯}λx:τ.AAMλt::K.AABTerms M,N::=λx:τ.M{cPuj¯;di¯}MNxProcesses P,Q::=c¯d.P(𝝂c)Pc(x).PcM.P!c(x).Pc.𝖼𝖺𝗌𝖾{liPi¯}c.l;P[cd]𝟎cMuj¯;di¯;Q\begin{array}[]{llcl}\mbox{Kinds }&K,K^{\prime}&::=&\mathsf{type}\mid\mathsf{stype}\mid\Pi x{:}\tau.K\mid\Pi t{:}K.K^{\prime}\\ \mbox{Functional}&\tau,\sigma&::=&\Pi x{:}\tau.\sigma\mid\lambda x{:}\tau.\sigma\mid\tau\;M\mid\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}\mid\lambda t::K.\tau\mid\tau\,\sigma\\ \mbox{Sessions}&A,B&::=&{!}A\mid A\multimap B\mid A\otimes B\mid\forall x{:}\tau.A\mid\exists x{:}\tau.A\mid\mathbf{1}\\ &&\mid&\mathbin{\binampersand}\{\overline{l_{i}:A_{i}}\}\mid\oplus\{\overline{l_{i}:A_{i}}\}\mid\lambda x{:}\tau.A\mid A\;M\mid\lambda t{::}K.A\mid A\,B\\ \mbox{Terms }&M,N&::=&\lambda x{:}\tau.M\mid\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}\mid M\,N\mid x\\ \mbox{Processes }&P,Q&::=&\overline{c}\langle d\rangle.P\mid({\boldsymbol{\nu}}c)P\mid c(x).P\mid c\langle M\rangle.P\mid{!}c(x).P\\ &&\mid&c.\mathsf{case}\{\overline{l_{i}\Rightarrow P_{i}}\}\mid c.l;P\mid[c\leftrightarrow d]\mid\boldsymbol{0}\mid c\leftarrow M\leftarrow\overline{u_{j}};\overline{d_{i}};Q\end{array}

Figure 1: Syntax of Kinds, Types, Terms and Processes

This section introduces our dependent type theory combining session-typed processes and functions. The theory is a generalisation of the line of work relating linear logic and session types [4, 27, 31], considering type-level functions and dependent kinds in an intensional type theory with full mutual dependencies between functions and processes. This generalisation enables us to express more sophisticated session types (such as those of § 1) and also to define and prove properties of processes expressed as type families with proofs as their inhabitants. We focus on the new rules and judgements, pointing the interested reader to [27, 5, 28] for additional details on the base theory.

2.1 Syntax

The calculus is stratified into two mutually dependent layers of processes and terms, which we often refer to as the process and functional layers, respectively. The syntax of the theory is given in Fig. 1 (we use x,yx,y for variables ranging over terms and tt for variables ranging over types).

Types and Kinds.

The process layer is able to refer to terms of the functional layer via appropriate (dependently-typed) communication actions and through a spawn construct, allowing for processes encapsulated as functional values to be executed. Dually, the functional layer can refer to the process layer via a contextual monad [31] that internalises (open) typed processes as opaque functional values. This mutual dependency is also explicit in the type structure on several axes: process channel usages are typed by a language of session types, which specifies the communication protocols implemented on the used channels, extended with two dependent communication operations x:τ.A\forall x{:}\tau.A and x:τ.A\exists x{:}\tau.A, where τ\tau is a functional type and AA is a session type in which xx may occur. Moreover, we also extend the language of session types with type-level λ\lambda-abstraction over terms λx:τ.A\lambda x{:}\tau.A and session types λt::K.A\lambda t{::}K.A (with the corresponding elimination forms AMA\,M and ABA\,B). As we show in § 1, the combination of these features allows for a new degree of expressiveness, enabling us to construct session types whose structure depends on previously communicated values.

The remaining session constructs are standard, following [5]: !A{!}A denotes a shared session of type AA that may be used an arbitrary (finite) number of times; ABA\multimap B represents a session offering to input a session of type AA to then offer the session behaviour BB; ABA\otimes B is the dual operator, denoting a session that outputs AA and proceeds as BB; {li:Ai¯}\oplus\{\overline{l_{i}:A_{i}}\} and &{li:Ai¯}\mathbin{\binampersand}\{\overline{l_{i}:A_{i}}\} represent internal and external labelled choice, respectively; 𝟏\mathbf{1} denotes the terminated session.

The functional layer is a λ\lambda-calculus with dependent functions Πx:τ.σ\Pi x{:}\tau.\sigma, type-level λ\lambda-abstractions over terms and types (and respective type-level applications) and a contextual monadic type {uj:Bj¯;di:Ai¯c:A}\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}, denoting a (quoted) process offering session c:Ac{:}A by using the linear sessions di:Ai¯\overline{d_{i}{:}A_{i}} and shared sessions uj:Bj¯\overline{u_{j}{:}B_{j}} [31]. We often write {A}\{A\} for {;c:A}\{\cdot;\cdot\vdash c{:}A\}. The kinding system for our theory contains two base kinds 𝗍𝗒𝗉𝖾\mathsf{type} and 𝗌𝗍𝗒𝗉𝖾\mathsf{stype} of functional and session types, respectively. Type-level λ\lambda-abstractions require dependent kinds Πx:τ.K\Pi x{:}\tau.K and Πt::K.K\Pi t{::}K.K^{\prime}, respectively. We note that the functional connectives form a standard dependent type theory [11, 23].

Terms and Processes.

Terms include the standard λ\lambda-abstractions λx:τ.M\lambda x{:}\tau.M, applications MNM\,N and variables xx. In order to internalise processes within the functional layer we make use of a monadic process wrapper, written {cPuj¯;di¯}\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}. In such a construct, the channels cc, uj¯\overline{u_{j}} and di¯\overline{d_{i}} are bound in PP, where cc is the session channel being offered and uj¯\overline{u_{j}} and di¯\overline{d_{i}} are the session channels (linear and shared, respectively) being used. We write {cPϵ}\{c\leftarrow P\leftarrow\epsilon\} when PP does not use any ambient channels, which we abbreviate to {P}\{P\}.

The syntax of processes follows that of [5] extended with the monadic elimination form cMuj¯;di¯;Qc\leftarrow M\leftarrow\overline{u_{j}};\overline{d_{i}};Q. Such a process construct denotes a term MM that is to be evaluated to a monadic value of the form {cPuj¯;di¯}\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\} which will then be executed in parallel with QQ, sharing with it a session channel cc and using the provided channels uj¯\overline{u_{j}} and di¯\overline{d_{i}}. We write cMϵ;Qc\leftarrow M\leftarrow\epsilon;Q when no channels are provided for the execution of MM and often abbreviate this to cM;Qc\leftarrow M;Q. The process c¯d.P\overline{c}\langle d\rangle.P denotes the output of the fresh channel dd along channel cc with continuation PP, which binds dd; (𝝂c)P({\boldsymbol{\nu}}c)P denotes channel hiding, restricting the scope of cc to PP; c(x).Pc(x).P denotes an input along cc, bound to xx in PP; cM.Pc\langle M\rangle.P denotes the output of term MM along cc with continuation PP; !c(x).P{!}c(x).P denotes a replicated input which spawns copies of PP; the construct c.𝖼𝖺𝗌𝖾{liPi¯}c.\mathsf{case}\{\overline{l_{i}\Rightarrow P_{i}}\} codifies a process that waits to receive some label ljl_{j} along cc, with continuation PjP_{j}; dually, c.l;Pc.l;P denotes a process that emits a label ll along cc and continues as PP; [cd][c\leftrightarrow d] denotes a forwarder between cc and dd, which is operationally implemented as renaming; PQP\mid Q denotes parallel composition and 𝟎\boldsymbol{0} the null process.

2.2 A Dependent Typing System

We now introduce our typing system, defined by a series of mutually inductive judgements, given in Fig. 2. We use Ψ\Psi to stand for a typing context for dependent λ\lambda-terms (i.e. assumptions of the form x:τx{:}\tau or t::Kt::K, not subject to exchange), Γ\Gamma for a typing context for shared sessions of the form u:Au{:}A (implicitly subject to weakening and contraction) and Δ\Delta for a linear context of sessions x:Ax{:}A. The context well-formedness judgments Ψ\Psi\vdash and Ψ;Δ\Psi;\Delta\vdash require that types and kinds (resp. session types) in Ψ\Psi (resp. Δ\Delta) are well-formed. The judgments ΨK\Psi\vdash K, Ψτ::K\Psi\vdash\tau::K and ΨA::K\Psi\vdash A::K codify well-formedness of kinds, functional and session types (with kind KK), respectively. Their rules are standard.

ΨContext Ψ is well-formed.Ψ;ΔContext Δ is well-formed, under assumptions in Ψ.ΨKK is a kind in context Ψ.Ψτ::Kτ is a (functional) type of kind K in context Ψ.ΨA::KA is a session type of kind K in context Ψ.ΨM:τM has type τ in context Ψ.Ψ;Γ;ΔP::z:AP offers session z:A when composed with processesoffering sessions specified in Γ and Δ in context Ψ.ΨK1=K2Kinds K1 and K2 are equal.Ψτ=σ::KTypes τ and σ are equal of kind K.ΨA=B::KSession types A and B are equal of kind K.ΨM=N:τTerms M and N are equal of type τ.ΨΔ=Δ::𝗌𝗍𝗒𝗉𝖾Contexts Δ and Δ are equal, under the assumptions in Ψ.Ψ;Γ;ΔP=Q::z:AProcesses P and Q are equal with typing z:A.\small\begin{array}[]{ll}\Psi\vdash&\mbox{Context $\Psi$ is well-formed.}\\ \Psi;\Delta\vdash&\mbox{Context $\Delta$ is well-formed, under assumptions in $\Psi$.}\\ \Psi\vdash K&\mbox{$K$ is a kind in context $\Psi$.}\\ \Psi\vdash\tau::K&\mbox{$\tau$ is a (functional) type of kind $K$ in context $\Psi$.}\\ \Psi\vdash A::K&\mbox{$A$ is a session type of kind $K$ in context $\Psi$.}\\ \Psi\vdash M:\tau&\mbox{$M$ has type $\tau$ in context $\Psi$.}\\ \Psi;\Gamma;\Delta\vdash P::z{:}A&\mbox{$P$ offers session $z{:}A$ when composed with processes}\\ &\mbox{offering sessions specified in $\Gamma$ and $\Delta$ in context $\Psi$.}\\ \Psi\vdash K_{1}=K_{2}&\mbox{Kinds $K_{1}$ and $K_{2}$ are equal.}\\ \Psi\vdash\tau=\sigma::K&\mbox{Types $\tau$ and $\sigma$ are equal of kind $K$.}\\ \Psi\vdash A=B::K&\mbox{Session types $A$ and $B$ are equal of kind $K$.}\\ \Psi\vdash M=N:\tau&\mbox{Terms $M$ and $N$ are equal of type $\tau$.}\\ \Psi\vdash\Delta=\Delta^{\prime}::\mathsf{stype}&\mbox{Contexts $\Delta$ and $\Delta^{\prime}$ are equal, under the assumptions in $\Psi$.}\\ \Psi;\Gamma;\Delta\vdash P=Q::z{:}A&\mbox{Processes $P$ and $Q$ are equal with typing $z{:}A$.}\\ \end{array}
Figure 2: Typing Judgements
Typing.

An excerpt of the typing rules for terms and processes is given in Fig. 3 and 4, respectively, noting that typing enforces types to be of base kind 𝗍𝗒𝗉𝖾\mathsf{type} (respectively 𝗌𝗍𝗒𝗉𝖾\mathsf{stype}). The rules for dependent functions are standard, including the type conversion rule which internalises definitional equality of types. We highlight the introduction rule for the monadic construct, which requires the appropriate session types to be well-formed and the process PP to offer c:Ac{:}A when provided with the appropriate session contexts.

In the typing rules for processes (Fig. 4), presented as a set of right and left rules (the former identifying how to offer a session of a given type and the latter how to use such a session), we highlight the rules for dependently-typed communication and monadic elimination (for type-checking purposes we annotate constructs with the respective dependent type – this is akin to functional type theories). To offer a session c:x:τ.Ac{:}\exists x{:}\tau.A we send a term MM of type τ\tau and then offer a session c:A{M/x}c{:}A\{M/x\}; dually, to use such a session we perform an input along cc, bound to xx in QQ, warranting a use of cc as a session of (open) type AA. The rules for the universal are dual. Offering a session c:x:τ.Ac{:}\forall x{:}\tau.A entails receiving on cc a term of type τ\tau and offering c:Ac{:}A. Using a session of such a type requires sending along cc a term MM of type τ\tau, warranting the use of cc as a session of type A{M/x}A\{M/x\}.

The rule for the monadic elimination form requires that the term MM be of the appropriate monadic type and that the provided channels uj¯\overline{u_{j}} and yi¯\overline{y_{i}} adhere to the typing specified in MM’s type. Under these conditions, the process QQ may then use the session cc as session AA. The type conversion rules reflect session type definitional equality in typing.

(ΠI)         Ψτ::typeΨ,x:τM:σ        Ψλx:τ.M:Πx:τ.σ (ΠE)         ΨM:Πx:τ.σΨN:τ      ΨMN:σ{/Nx} ({}I)           i,j.ΨAi,Bj::stypeΨ;¯:ujBj;¯:diAiP::c:A          Ψ{cP¯uj;¯di}:{¯:ujBj;¯:diAic:A} (Conv)         ΨM:τΨτ=σ::type    ΨM:σ \small\begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\Pi I)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 58.51054pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\vdash M:\sigma}$}}}\vbox{}}}\over\hbox{\hskip 47.23216pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\Pi E)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 57.91542pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\Pi x{:}\tau.\sigma\quad\Psi\vdash N:\tau}$}}}\vbox{}}}\over\hbox{\hskip 40.81242pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M\,N:\sigma\{N/x\}}$}}}}}}$}}}\\[13.87491pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\{\}I)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 83.41368pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\forall i,j.\Psi\vdash A_{i},B_{j}::\mathsf{stype}\quad\Psi;\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash P::c{:}A}$}}}\vbox{}}}\over\hbox{\hskip 66.80363pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}:A_{i}}\vdash c{:}A\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{Conv})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 56.40291pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\tau\quad\Psi\vdash\tau=\sigma::\mathsf{type}}$}}}\vbox{}}}\over\hbox{\hskip 20.44588pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\sigma}$}}}}}}$}}}\end{array}
Figure 3: Typing for Terms (Excerpt – See Appendix 0.A.4)
(R)           ΨM:τΨ;Γ;ΔP::c:A{/Mx}           Ψ;Γ;ΔcMx:τ.A.P::c:x:τ.A (L)            Ψτ::typeΨ,x:τ;Γ;Δ,c:AQ::d:D            Ψ;Γ;Δ,c:x:τ.Ac(:xτ).Q::d:D (R)          Ψτ::typeΨ,x:τ;Γ;ΔP::c:A          Ψ;Γ;Δc(:xτ).P::c:x:τ.A (L)            ΨM:τΨ;Γ;Δ,c:A{/Mx}Q::d:D            Ψ;Γ;Δ,c:x:τ.AcMx:τ.A.Q::d:D ({}E)                Δ=¯:diBi¯:ujCjΓΨM:{¯:ujCj;¯:diBic:A}Ψ;Γ;Δ,c:AQ::z:C          Ψ;Γ;Δ,ΔcM¯uj;¯yi;Q::z:C (ConvR)           Ψ;Γ;ΔP::z:AΨA=B::stype       Ψ;Γ;ΔP::z:B (ConvL)           Ψ;Γ;ΔP::z:AΨ;Γ;Δ=Ψ;Γ;Δ       Ψ;Γ;ΔP::z:A (𝖼𝗎𝗍)   Ψ;Γ;ΔP::c:AΨ;Γ;Δ,c:AQ::d:D   Ψ;Γ;Δ,Δ(νc)(PQ)::d:D \small\begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\exists}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 78.68091pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M{:}\tau\quad\Psi;\Gamma;\Delta\vdash P::c{:}A\{M/x\}}$}}}\vbox{}}}\over\hbox{\hskip 76.36896pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash c\langle M\rangle_{\exists x{:}\tau.A}.P::c{:}\exists x{:}\tau.A}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\exists}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 87.5016pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\mathrel{;}\Gamma;\Delta,c{:}A\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 79.25394pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\mathrel{;}\Gamma;\Delta,c{:}\exists x{:}\tau.A\vdash c(x{:}\tau).Q::d{:}D}$}}}}}}$}}}\\[13.87491pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\forall}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 75.20087pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\mathrel{;}\Gamma;\Delta\vdash P::c{:}A}$}}}\vbox{}}}\over\hbox{\hskip 67.72401pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash c(x{:}\tau).P::c{:}\forall x{:}\tau.A}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\forall}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 90.98164pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M{:}\tau\quad\Psi;\Gamma;\Delta,c{:}A\{M/x\}\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 88.6697pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}\forall x{:}\tau.A\vdash c\langle M\rangle_{\forall x{:}\tau.A}.Q::d{:}D}$}}}}}}$}}}\\[13.87491pt] {\vbox{\hbox{\hbox{\small\sc($\displaystyle\{\}E$)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 127.48303pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Delta^{\prime}=\overline{d_{i}:B_{i}}\quad\overline{u_{j}{:}C_{j}}\subseteq\Gamma\quad\Psi\vdash M:\{\overline{u_{j}{:}C_{j}};\overline{d_{i}{:}B_{i}}\vdash c{:}A\}\quad\Psi;\Gamma;\Delta,c{:}A\vdash Q::z{:}C}$}}}\vbox{}}}\over\hbox{\hskip 74.16861pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta^{\prime},\Delta\vdash c\leftarrow M\leftarrow\overline{u_{j}};\overline{y_{i}};Q::z{:}C}$}}}}}}$}}}\\[13.87491pt] {\vbox{\hbox{\hbox{\small\sc($\displaystyle{{\mathsf{Conv}}\mathsf{R}}$)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 79.10013pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}A\quad\Psi\vdash A=B::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 38.50598pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}B}$}}}}}}$}}}\par\quad\par{\vbox{\hbox{\hbox{\small\sc($\displaystyle{{\mathsf{Conv}}\mathsf{L}}$)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 80.98608pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma^{\prime};\Delta^{\prime}\vdash P::z{:}A\quad\Psi;\Gamma^{\prime};\Delta^{\prime}=\Psi;\Gamma;\Delta}$}}}\vbox{}}}\over\hbox{\hskip 38.25026pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}A}$}}}}}}$}}}\\[13.87491pt] \raise 6.125pt\hbox{$\hbox{$\hbox{\small\sc$(\mathsf{cut})$}\,$}{\hbox{$\displaystyle\displaystyle{\hbox{\hskip 94.14183pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::c{:}A\quad\Psi;\Gamma;\Delta^{\prime},c{:}A\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 63.01134pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,\Delta^{\prime}\vdash({\boldsymbol{\nu}}c)(P\mid Q)::d{:}D}$}}}}}}$}}\hbox{}$}\end{array}
Figure 4: Typing for Processes (Excerpt – See Appendix 0.A.5)
Definitional Equality.

The crux of any dependent type theory lies in its definitional equality. Type equality relies on equality of terms which, by including the monadic construct, necessarily relies on a notion of process equality.

Our presentation of an intensional definitional equality of terms follows that of [12], where we consider an intrinsically typed relation, including β\beta and η\eta conversion (similarly for type equality which includes β\beta and η\eta principles for the type-level λ\lambda-abstractions). An excerpt of the rules for term equality is given in Fig. 5. The remaining rules are congruence rules and closure under symmetry, reflexivity and transitivity. Rule (𝖳𝖬𝖤𝗊β)(\mathsf{TMEq}\beta) captures the β\beta-reduction, identifying a λ\lambda-abstraction applied to an argument with the substitution of the argument in the function body (typed with the appropriately substituted type). We highlight rule (𝖳𝖬𝖤𝗊{}η)(\mathsf{TMEq}\{\}\eta), which codifies a general η\eta-like principle for arbitrary terms of monadic type: We form a monadic term that applies the monadic elimination form to MM, forwarding the result along the appropriate channel, which becomes a term equivalent to MM.

Definitional equality of processes is summarised in Fig. 6. We rely on process reduction defined below. Definitional equality of processes consists of the usual congruence rules, (typed) reductions and the commutting conversions of linear logic and η\eta-like principles, which allows for forwarding actions to be equated with the primitive syntactic forwarding construct. Commutting conversions amount to sound observational equivalences between processes [24], given that session composition requires name restriction (embodied by the (𝖼𝗎𝗍)(\mathsf{cut}) rule): In rule (𝖯𝖤𝗊𝖢𝖢)(\mathsf{PEqCC}\forall), either process can only be interacted with via channel cc and so postponing actions of PP to after the input on cc (when reading the equality from left to right) cannot impact the process’ observable behaviours. While PP can in general interact with sessions in Δ\Delta (or with QQ), these interactions are unobservable due to hiding in the (𝖼𝗎𝗍)(\mathsf{cut}) rule.

(TMEqβ)           Ψτ::typeΨ,x:τM:σΨN:τ           Ψ=(λx:τ.M)NM{/Nx}:σ{/Nx} (TMEqη)         ΨM:Πx:τ.σxfv(M)         Ψλx:τ.Mx=M:Πx:τ.σ (TMEq{}η)       ΨM:{¯:ujBj;¯:diAic:A}               Ψ={c(yM;¯uj;¯di;[yc])¯uj;¯di}M:{¯:ujBj;¯:diAic:A} \small\begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\beta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 82.20187pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\vdash M:\sigma\quad\Psi\vdash N:\tau}$}}}\vbox{}}}\over\hbox{\hskip 83.95088pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash(\lambda x{:}\tau.M)\,N=M\{N/x\}:\sigma\{N/x\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\eta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 64.19199pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\Pi x{:}\tau.\sigma\quad x\not\in fv(M)}$}}}\vbox{}}}\over\hbox{\hskip 61.74527pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.M\,x=M:\Pi x{:}\tau.\sigma}$}}}}}}$}}}\\[13.87491pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\{\}\eta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 42.14647pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}}$}}}\vbox{}}}\over\hbox{\hskip 116.3443pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\{c\leftarrow(y\leftarrow M;\overline{u_{j}};\overline{d_{i}};[y\leftrightarrow c])\leftarrow\overline{u_{j}};\overline{d_{i}}\}=M:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}}$}}}}}}$}}}\end{array}
Figure 5: Definitional Equality of Terms (Excerpt – See Appendix 0.A.9)
(𝖯𝖤𝗊𝖱𝖾𝖽)   Ψ;Γ;ΔP::z:APQΨ;Γ;ΔQ::z:A   Ψ;Γ;ΔP=Q::z:A (𝖯𝖤𝗊η)   Ψ;Γ;d:x:τ.Ac(x).dx.[dc]=[dc]::c:x:τ.A (𝖯𝖤𝗊𝖢𝖢)   Ψ;Γ;ΔP::d:BΨ,x:τ;Γ;Δ,d:BQ::c:A   Ψ;Γ;Δ,Δ(νd)(Pc(x).Q)=c(x).(νd)(PQ)::c:x:τ.A \small\begin{array}[]{c}\raise 5.875pt\hbox{$\hbox{$\hbox{\small\sc$(\mathsf{PEqRed})$}\,$}{\hbox{$\displaystyle\displaystyle{\hbox{\hskip 95.35843pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}A\quad P\xrightarrow{}Q\quad\Psi;\Gamma;\Delta\vdash Q::z{:}A}$}}}\vbox{}}}\over\hbox{\hskip 48.06464pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P=Q::z{:}A}$}}}}}}$}}\hbox{}$}\\[9.24994pt] \raise 6.125pt\hbox{$\hbox{$\hbox{\small\sc$(\mathsf{PEq}\forall\eta)$}\,$}{\hbox{$\displaystyle\displaystyle{\hbox{}\over\hbox{\hskip 122.9155pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;d{:}\forall x{:}\tau.A\vdash c(x).d\langle x\rangle.[d\leftrightarrow c]=[d\leftrightarrow c]::c{:}\forall x{:}\tau.A}$}}}}}}$}}\hbox{}$}\\[9.24994pt] \raise 6.125pt\hbox{$\hbox{$\hbox{\small\sc$(\mathsf{PEqCC}\forall)$}\,$}{\hbox{$\displaystyle\displaystyle{\hbox{\hskip 104.88333pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::d{:}B\quad\Psi,x{:}\tau;\Gamma;\Delta^{\prime},d{:}B\vdash Q::c{:}A}$}}}\vbox{}}}\over\hbox{\hskip 125.10547pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,\Delta^{\prime}\vdash({\boldsymbol{\nu}}d)(P\mid c(x).Q)=c(x).({\boldsymbol{\nu}}d)(P\mid Q)::c{:}\forall x{:}\tau.A}$}}}}}}$}}\hbox{}$}\par\par\end{array}

Figure 6: Definitional Equality of Processes (Excerpt – See Appendix 0.A.10)
Operational Semantics.

The operational semantics for the λ\lambda-calculus is standard, noting that no reduction can take place inside monadic terms. The operational (reduction) semantics for processes is presented below where we omit closure under structural congruence and the standard congruence rules [4, 27, 31]. The last rule defines spawning a process in a monadic term.

cM.Pc(x).QPQ{M/x}c¯x.Pc(x).Q(𝝂x)(PQ)!c(x).Pc¯x.Q!c(x).P(𝝂x)(PQ)c.𝖼𝖺𝗌𝖾{liPi¯}c.lj;QPjQ(ljli¯)(𝝂c)(P[cd])P{d/c}c{cPuj¯;di¯}uj¯;di¯;Q(𝝂c)(PQ)\small\begin{array}[]{ll}c\langle M\rangle.P\mid c(x).Q\xrightarrow{}P\mid Q\{M/x\}&\overline{c}\langle x\rangle.P\mid c(x).Q\xrightarrow{}({\boldsymbol{\nu}}x)(P\mid Q)\\[4.62497pt] {!}c(x).P\mid\overline{c}\langle x\rangle.Q\xrightarrow{}{!}c(x).P\mid({\boldsymbol{\nu}}x)(P\mid Q)&c.\mathsf{case}\{\overline{l_{i}\Rightarrow P_{i}}\}\mid c.l_{j};Q\xrightarrow{}P_{j}\mid Q\,\,\,\,(l_{j}\in\overline{l_{i}})\\[4.62497pt] ({\boldsymbol{\nu}}c)(P\mid[c\leftrightarrow d])\xrightarrow{}P\{d/c\}&\hskip-28.45274ptc\leftarrow\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}\leftarrow\overline{u_{j}};\overline{d_{i}};Q\xrightarrow{}({\boldsymbol{\nu}}c)(P\mid Q)\end{array}

2.3 Example – Reasoning about Processes using Dependent Types

The use of type indices (i.e. type families) in dependently typed frameworks adds information to types to produce more refined specifications. Our framework enables us to do this at the level of session types.

Consider a session type that “counts down” on a natural number (we assume inductive definitions and dependent pattern matching in the style of [23]):

𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇::Πx:𝖭𝖺𝗍.𝗌𝗍𝗒𝗉𝖾𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(𝗌𝗎𝖼𝖼(n))=y:𝖭𝖺𝗍.𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(n)𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇𝗓=𝟏\begin{array}[]{lcl}\mathsf{countDown}&::&\Pi x{:}\mathsf{Nat}.\mathsf{stype}\\ \mathsf{countDown}\,(\mathsf{succ}(n))&=&\exists y{:}\mathsf{Nat}.\mathsf{countDown}(n)\\ \mathsf{countDown}\,\,\,\mathsf{z}&=&\mathbf{1}\end{array}

The type family 𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(n)\mathsf{countDown}(n) denotes a session type that emits exactly nn numbers and then terminates. We can now write a (dependently-typed) function that produces processes with the appropriate type, given a starting value:

𝖼𝗈𝗎𝗇𝗍𝖾𝗋:Πx:𝖭𝖺𝗍.{𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(x)}𝖼𝗈𝗎𝗇𝗍𝖾𝗋(𝗌𝗎𝖼𝖼(n))={cc𝗌𝗎𝖼𝖼(n).d𝖼𝗈𝗎𝗇𝗍𝖾𝗋(n);[dc]}𝖼𝗈𝗎𝗇𝗍𝖾𝗋𝗓={c𝟎}\begin{array}[]{lcl}\mathsf{counter}&:&\Pi x{:}\mathsf{Nat}.\{\mathsf{countDown}(x)\}\\ \mathsf{counter}\,\,\,(\mathsf{succ}(n))&=&\{c\leftarrow c\langle\mathsf{succ}(n)\rangle.\,d\leftarrow\mathsf{counter}(n);[d\leftrightarrow c]\}\\ \mathsf{counter}\,\,\,\mathsf{z}&=&\{c\leftarrow\boldsymbol{0}\}\end{array}

Note how the type of 𝖼𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{counter}, through the type family 𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇\mathsf{countDown}, allows us to specify exactly the number of times a value is sent. This is in sharp contrast with existing recursive (or inductive/coinductive [19, 32]) session types, where one may only specify the general iterative nature of the behaviour (e.g. “send a number and then recurse or terminate”).

The example above relies on session type indexing in order to provide additional static guarantees about processes (and the functions that generate them). An alternative way is to consider “simply-typed” programs and then prove that they satisfy the desired properties, using the language itself. Consider a simply-typed version of the counter above described as an inductive session type:

𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋𝖳::𝗌𝗍𝗒𝗉𝖾𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋𝖳={𝖽𝖾𝖼:𝖭𝖺𝗍𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋𝖳,𝖽𝗈𝗇𝖾:𝟏}\begin{array}[]{lcl}\mathsf{simpleCounterT}&::&\mathsf{stype}\\ \mathsf{simpleCounterT}&=&\oplus\{\mathsf{dec}:\mathsf{Nat}\wedge\mathsf{simpleCounterT},\mathsf{done}:\mathbf{1}\}\end{array}

There are many processes that correctly implement such a type, given that the type merely dictates that the session outputs a natural number and recurses (modulo the 𝖽𝖾𝖼\mathsf{dec} and 𝖽𝗈𝗇𝖾\mathsf{done} messages to signal which branch of the internal choice is taken). A function that produces processes implementing such a session, mirroring those generated by the 𝖼𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{counter} function above, is:

𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋:𝖭𝖺𝗍{𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋𝖳}𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋(𝗌𝗎𝖼𝖼(n))={cc.𝖽𝖾𝖼;(𝝂d)(d𝗌𝗎𝖼𝖼(n).0d(x).cx.d𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋(n);[dc]}𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋𝗓={cc.𝖽𝗈𝗇𝖾;𝟎}\begin{array}[]{lcl}\mathsf{simpleCounter}&:&\mathsf{Nat}\rightarrow\{\mathsf{simpleCounterT}\}\\ \mathsf{simpleCounter}\,\,\,(\mathsf{succ}(n))&=&\{c\leftarrow c.\mathsf{dec};({\boldsymbol{\nu}}d)(d\langle\mathsf{succ}(n)\rangle.\boldsymbol{0}\mid d(x).c\langle x\rangle.\\ &&\,\,\,d\leftarrow\mathsf{simpleCounter}(n);[d\leftrightarrow c]\}\\ \mathsf{simpleCounter}\quad\mathsf{z}&=&\{c\leftarrow c.\mathsf{done};\boldsymbol{0}\}\\ \end{array}

The process generated by 𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{simpleCounter}, after emiting the 𝖽𝖾𝖼\mathsf{dec} label, spawns a process in parallel that sends the appropriate number, which is received by the parallel thread and then sent along the session cc. Despite its simplicity, this example embodies a general pattern where a computation is spawned in parallel (itself potentially spawning many other threads) and the main thread then waits for the result before proceeding.

While such a process is typable in most session typing frameworks, our theory enables us to prove that the counter implementation above indeed counts down from a given number by defining an appropriate (inductive) type family, indexed by monadic values (i.e. processes):

𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍::Πx:𝖭𝖺𝗍.Πy:{𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋𝖳}.𝗍𝗒𝗉𝖾𝖼𝗈𝗋𝗋z:𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍𝗓{cc.𝖽𝗈𝗇𝖾;𝟎}𝖼𝗈𝗋𝗋n:Πn:𝖭𝖺𝗍.ΠP:{𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋𝖳}.𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍nP𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍(𝗌𝗎𝖼𝖼(n)){cc.𝖽𝖾𝖼;c𝗌𝗎𝖼𝖼(n).dP;[dc]}\begin{array}[]{lcl}\mathsf{corrCount}&::&\Pi x{:}\mathsf{Nat}.\Pi y{:}\{\mathsf{simpleCounterT}\}.\mathsf{type}\\ \mathsf{corr}_{z}&:&\mathsf{corrCount}\,\mathsf{z}\,\{c\leftarrow c.\mathsf{done};\boldsymbol{0}\}\\ \mathsf{corr}_{n}&:&\Pi n{:}\mathsf{Nat}.\Pi P{:}\{\mathsf{simpleCounterT}\}.\mathsf{corrCount}\,n\,P\rightarrow\\ &&\mathsf{corrCount}\,(\mathsf{succ}(n))\,\{c\leftarrow c.\mathsf{dec};c\langle\mathsf{succ}(n)\rangle.d\leftarrow P;[d\leftrightarrow c]\}\end{array}

The type family 𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍\mathsf{corrCount}, indexed by a natural number and a monadic value implementing the session type 𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{simpleCounter}, is defined via two constructors: 𝖼𝗈𝗋𝗋z\mathsf{corr}_{z}, which specifies that a correct 0 counter emits the 𝖽𝗈𝗇𝖾\mathsf{done} label and terminates; and 𝖼𝗈𝗋𝗋n\mathsf{corr}_{n}, which given a monadic value PP that is a correct nn-counter, defines that a correct (n+1)(n+1)-counter emits n+1n+1 and then proceeds as PP (modulo the label emission bookkeeping).

The proof of correctness of the 𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{simpleCounter} function above is no more than a function of type Πn:𝖭𝖺𝗍.𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍n\Pi n{:}\mathsf{Nat}.\mathsf{corrCount}\,n (𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋(n))(\mathsf{simpleCounter}(n)), defined below:

𝗉𝗋𝖿:Πn:𝖭𝖺𝗍.𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍n(𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋(n))𝗉𝗋𝖿𝗓=𝖼𝗈𝗋𝗋z𝗉𝗋𝖿(𝗌𝗎𝖼𝖼(n))=𝖼𝗈𝗋𝗋nn(𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋(n))(𝗉𝗋𝖿n)\begin{array}[]{lcl}\mathsf{prf}&:&\Pi n{:}\mathsf{Nat}.\mathsf{corrCount}\,n\,(\mathsf{simpleCounter}(n))\\ \mathsf{prf}\quad\mathsf{z}&=&\mathsf{corr}_{z}\\ \mathsf{prf}\quad(\mathsf{succ}(n))&=&\mathsf{corr}_{n}\,n\,(\mathsf{simpleCounter}(n))\,(\mathsf{prf}\,n)\end{array}

Note that in this scenario, the processes that index the 𝖼𝗈𝗋𝗋𝖢𝗈𝗎𝗇𝗍\mathsf{corrCount} type family are not syntactically equal to those generated by 𝗌𝗂𝗆𝗉𝗅𝖾𝖢𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{simpleCounter}, but rather definitionally equal.

Typically, the processes that index such correctness specifications tend to be distilled versions of the actual implementations, which often perform some additional internal computation or communication steps. Since our notion of definitional equality of processes includes reduction (and also commuting conversions which account for type-preserving shuffling of internal communication actions [28]), the type conversion mechanism allows us to use the techniques described above to generally reason about specification conformance.

We may also consider a variant of the example above which does not force outputs to match precisely with the type index:

𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇::Πx:𝖭𝖺𝗍.𝗌𝗍𝗒𝗉𝖾𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(𝗌𝗎𝖼𝖼(n))=y:𝖭𝖺𝗍.𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(n)𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇𝗓=𝟏\begin{array}[]{lcl}\mathsf{countDown}^{\prime}&::&\Pi x{:}\mathsf{Nat}.\mathsf{stype}\\ \mathsf{countDown}^{\prime}\,(\mathsf{succ}(n))&=&\exists y{:}\mathsf{Nat}.\mathsf{countDown}^{\prime}(n)\\ \mathsf{countDown}^{\prime}\,\,\,\mathsf{z}&=&\mathbf{1}\end{array}

The type 𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇n\mathsf{countDown}^{\prime}\,n will still require nn outputs to be performed, but unlike with 𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇\mathsf{countDown} we do not enforce a relation between the iteration and the number being sent. An implementation of such a type is given below, using fundamentally the same code as for 𝖼𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{counter}:

𝖼𝗈𝗎𝗇𝗍𝖾𝗋:Πx:𝖭𝖺𝗍.{𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(x)}𝖼𝗈𝗎𝗇𝗍𝖾𝗋(𝗌𝗎𝖼𝖼(n))={cc𝗌𝗎𝖼𝖼(n).d𝖼𝗈𝗎𝗇𝗍𝖾𝗋(n);[dc]}𝖼𝗈𝗎𝗇𝗍𝖾𝗋𝗓={c𝟎}\begin{array}[]{lcl}\mathsf{counter}^{\prime}&:&\Pi x{:}\mathsf{Nat}.\{\mathsf{countDown}^{\prime}(x)\}\\ \mathsf{counter}^{\prime}\,\,\,(\mathsf{succ}(n))&=&\{c\leftarrow c\langle\mathsf{succ}(n)\rangle.\\ &&\qquad\,\,\,d\leftarrow\mathsf{counter}^{\prime}(n);\\ &&\qquad\,\,\,[d\leftrightarrow c]\}\\ \mathsf{counter}^{\prime}\,\,\,\mathsf{z}&=&\{c\leftarrow\boldsymbol{0}\}\end{array}

We may then use an heterogeneous equality (a special case of the so-called John Major equality [20]) of the form

𝖩𝖬𝖤𝗊::ΠA:𝗌𝗍𝗒𝗉𝖾.ΠB:𝗌𝗍𝗒𝗉𝖾.Πx:{A}.Πy:{B}.𝗍𝗒𝗉𝖾𝖩𝖬𝖤𝗊𝖱𝖾𝖿𝗅:λA:𝗌𝗍𝗒𝗉𝖾.λx:{A}.𝖩𝖬𝖤𝗊AAxx\begin{array}[]{lcl}\mathsf{JMEq}&::&\Pi A{:}\mathsf{stype}.\Pi B{:}\mathsf{stype}.\Pi x{:}\{A\}.\Pi y{:}\{B\}.\mathsf{type}\\ \mathsf{JMEqRefl}&:&\lambda A{:}\mathsf{stype}.\lambda x{:}\{A\}.\mathsf{JMEq}\,A\,A\,x\,x\end{array}

to inductively show that the processes produced by 𝖼𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{counter} and 𝖼𝗈𝗎𝗇𝗍𝖾𝗋\mathsf{counter}^{\prime} are indeed the same.

𝖾𝗊𝗌:Πn:𝖭𝖺𝗍.𝖩𝖬𝖤𝗊(𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(n))(𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(n))(𝖼𝗈𝗎𝗇𝗍𝖾𝗋(n))(𝖼𝗈𝗎𝗇𝗍𝖾𝗋(n))𝖾𝗊𝗌z=𝖩𝖬𝖤𝗊𝖱𝖾𝖿𝗅 1{c𝟎}𝖾𝗊𝗌(𝗌𝗎𝖼𝖼(n))=𝖼𝖺𝗌𝖾(𝖾𝗊𝗌n)𝗈𝖿{_𝖩𝖬𝖤𝗊𝖱𝖾𝖿𝗅(𝖼𝗈𝗎𝗇𝗍𝖣𝗈𝗐𝗇(𝗌𝗎𝖼𝖼(n)))(𝖼𝗈𝗎𝗇𝗍𝖾𝗋(𝗌𝗎𝖼𝖼(n))))}\begin{array}[]{l}\mathsf{eqs}:\Pi n{:}\mathsf{Nat}.\mathsf{JMEq}\,(\mathsf{countDown}(n))\,(\mathsf{countDown}^{\prime}(n))\,(\mathsf{counter}(n))\,(\mathsf{counter}^{\prime}(n))\\ \mathsf{eqs}\,z=\mathsf{JMEqRefl}\,\mathbf{1}\,\{c\leftarrow\boldsymbol{0}\}\\ \mathsf{eqs}\,(\mathsf{succ}(n))=\mathsf{case}\,(\mathsf{eqs}\,n)\,\mathsf{of}\,\{\_\Rightarrow\mathsf{JMEqRefl}\,(\mathsf{countDown}(\mathsf{succ}(n)))\\ \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\,\,\,(\mathsf{counter}(\mathsf{succ}(n))))\}\\ \end{array}

We note that the example above makes extensive use of dependent pattern matching, using some implicit assumptions on its behaviour that have not been formalised in this paper and are left for future work.

2.4 Type Soundness of the Framework

The main goal of this section is to present type soundness of our framework through a subject reduction result. We also show that our theory guarantees progress for terms and processes. The development requires a series of auxiliary results (detailed in Appendix 0.B) pertaining to the functional and process layers which are ultimately needed to produce the inversion properties necessary to establish subject reduction. We note that strong normalisation results for linear-logic based session processes are known in the literature [3, 32, 28], even in the presence of impredicative polymorphism, restricted corecursion and higher-order data. Such results are directly applicable to our work using appropriate semantics preserving type erasures.

In the remainder we often write Ψ𝒥\Psi\vdash\mathcal{J} to stand for a well-formedness, typing or definitional equality judgment of the appropriate form. Similarly for Ψ;Γ;Δ𝒥\Psi;\Gamma;\Delta\vdash\mathcal{J}. We begin with the substitution property, which naturally holds for both layers, noting that the dependently typed nature of the framework requires substitution in both contexts, terms and in types.

Lemma 2.1 (Substitution)

Let ΨM:τ\Psi\vdash M:\tau:

  1. 1.

    If Ψ,x:τ,Ψ𝒥\Psi,x{:}\tau,\Psi^{\prime}\vdash\mathcal{J} then Ψ,Ψ{M/x}𝒥{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\mathcal{J}\{M/x\};

  2. 2.

    If Ψ,x:τ,Ψ;Γ;Δ𝒥\Psi,x{:}\tau,\Psi^{\prime};\Gamma;\Delta\vdash\mathcal{J} then Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}𝒥{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash\mathcal{J}\{M/x\}

Combining substitution with a form of functionality for typing (i.e. that substitution of equal terms in a well-typed term produces equal terms) and for equality (i.e. that substitution of equal terms in a definitional equality proof produces equal terms), we can establish validity for typing and equality, which is a form of internal soundness of the type theory stating that judgments are consistent across the different levels of the theory.

Lemma 2.2 (Validity for Typing)

(1) If Ψτ::K\Psi\vdash\tau::K or ΨA::K\Psi\vdash A::K then ΨK\Psi\vdash K; (2) If ΨM:τ\Psi\vdash M:\tau then Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}; and (3) If Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A then ΨA::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A::\mathsf{stype}.

Lemma 2.3 (Validity for Equality)
  1. 1.

    If ΨM=N:τ\Psi\vdash M=N:\tau then ΨM:τ\Psi\vdash M:\tau, ΨN:τ\Psi\vdash N:\tau and Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}

  2. 2.

    If Ψτ=σ::K\Psi\vdash\tau=\sigma::K then Ψτ::K\Psi\vdash\tau::K, Ψσ::K\Psi\vdash\sigma::K and ΨK\Psi\vdash K

  3. 3.

    If ΨA=B::K\Psi\vdash A=B::K then ΨA::K\Psi\vdash A::K, ΨB::K\Psi\vdash B::K and ΨK\Psi\vdash K

  4. 4.

    If ΨK=K\Psi\vdash K=K^{\prime} then ΨK\Psi\vdash K and ΨK\Psi\vdash K^{\prime}

  5. 5.

    If Ψ;Γ;ΔP=Q::z:A\Psi;\Gamma;\Delta\vdash P=Q::z{:}A then Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A, Ψ;Γ;ΔQ::z:A\Psi;\Gamma;\Delta\vdash Q::z{:}A and ΨA::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A::\mathsf{stype}

With these results we establish the appropriate inversion and injectivity properties which then enable us to show unicity of types (and kinds).

Theorem 2.4 (Unicity of Types and Kinds)
  1. 1.

    If ΨM:τ\Psi\vdash M:\tau and ΨM:τ\Psi\vdash M:\tau^{\prime} then Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type}

  2. 2.

    If Ψτ::K\Psi\vdash\tau::K and Ψτ::K\Psi\vdash\tau::K^{\prime} then ΨK=K\Psi\vdash K=K^{\prime}

  3. 3.

    If Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A and Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A^{\prime} then ΨA=A::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=A^{\prime}::\mathsf{stype}

  4. 4.

    If ΨA::K\Psi\vdash A::K and ΨA::K\Psi\vdash A::K^{\prime} then ΨK=K\Psi\vdash K=K^{\prime}

All the results above, combined with the process-level properties established in [29, 28, 5] enable us to show the following:

Theorem 2.5 (Subject Reduction – Terms)

If ΨM:τ\Psi\vdash M:\tau and MMM\xrightarrow{}M^{\prime} then ΨM:τ\Psi\vdash M^{\prime}:\tau

Theorem 2.6 (Subject Reduction – Processes)

If Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A and PPP\xrightarrow{}P^{\prime} then Q\exists Q such that PQP^{\prime}\equiv Q and Ψ;Γ;ΔQ::z:A\Psi;\Gamma;\Delta\vdash Q::z{:}A

Theorem 2.7 (Progress – Terms)

If ΨM:τ\Psi\vdash M:\tau then either MM is a value or MMM\xrightarrow{}M^{\prime}

As common in logical-based session type theories, typing enforces a strong notion of global progress which states that closed processes that are waiting to perform communication actions cannot get stuck (this relies on a notion of live process, defined as 𝗅𝗂𝗏𝖾(P)\mathsf{live}(P) iff P(𝝂n~)(π.QR)P\equiv({\boldsymbol{\nu}}\tilde{n})(\pi.Q\mid R) for some process RR, sequence of names n~\tilde{n} and a non-replicated guarded process π.Q\pi.Q). We note that the restricted typing for PP is without loss of generality, due to the (𝖼𝗎𝗍)(\mathsf{cut}) rule.

Theorem 2.8 (Progress – Processes)

If Ψ;;P::c:𝟏\Psi;\cdot;\cdot\vdash P::c{:}\mathbf{1} and 𝗅𝗂𝗏𝖾(P)\mathsf{live}(P) then Q\exists Q such that PQP\xrightarrow{}Q

3 Embedding the Functional Layer in the Process Layer

Having introduced our type theory and showcased some of its informal expressiveness in terms of the ability to specify and statically verify true data dependent protocols, as well as the ability to prove properties of processes, we now develop a formal expressiveness result for our theory, showing that the process level type constructs are able to encode the dependently-typed functional layer, faithfully preserving type dependencies.

Specifically, we show that (1) the type-level constructs in the functional layer can be represented by those in the process layer combined with the contextual monad type, and (2) all term level constructs can be represented by session-typed processes that exchange monadic values. Thus, we show that both λ\lambda-abstraction and application can be eliminated while still preserving non-trivial type dependencies. Crucially, we note that the monadic construct cannot be fully eliminated due to the cross-layer nature of session type dependencies: In the process layer, simply-kinded dependent types (i.e. types with kind 𝗌𝗍𝗒𝗉𝖾\mathsf{stype}) are of the form x:τ.A\forall x{:}\tau.A where τ\tau is of kind 𝗍𝗒𝗉𝖾\mathsf{type} and AA of kind 𝗌𝗍𝗒𝗉𝖾\mathsf{stype} (where xx may occur). Operationally, such a session denotes an input of some term MM of type τ\tau with a continuation of type A{M/x}A\{M/x\}. Thus, to faithfully encode type dependencies we cannot represent such a type with a non-dependently typed input (e.g. a type of the form ABA\multimap B).

3.1 The Embedding

A first attempt.

Given the observation above, a seemingly reasonable option would be to attempt an encoding that maintains monadic objects solely at the level of type indices and then exploits Girard’s encoding [9] of function types τσ\tau\rightarrow\sigma as !τσ{!}\llbracket\tau\rrbracket\rightarrow\llbracket\sigma\rrbracket, which is adequate for session-typed processes [30]. Thus a candidate encoding for the type Πx:τ.σ\Pi x{:}\tau.\sigma would be x:{τ}.!τσ\forall x{:}\{\llbracket\tau\rrbracket\}.{!}\llbracket\tau\rrbracket\multimap\llbracket\sigma\rrbracket, where \llbracket{-}\rrbracket denotes our encoding on types. If we then consider the encoding at the level of terms, typing dictates the following (we write Mz\llbracket M\rrbracket_{z} for the process encoding of M:τM:\tau, where zz is the session channel along which one may observe the “result” of the encoding, typed with τ\llbracket\tau\rrbracket):

λx:τ.Mzz(x).z(x).MzMNz(𝝂x)(Mxx{Ny}.x¯x.(!x(y).Ny[xz])\begin{array}[]{lcl}\llbracket\lambda x{:}\tau.M\rrbracket_{z}&\triangleq&z(x).z(x^{\prime}).\llbracket M\rrbracket_{z}\\ \llbracket M\,N\rrbracket_{z}&\triangleq&({\boldsymbol{\nu}}x)(\llbracket M\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{y}\}\rangle.\overline{x}\langle x^{\prime}\rangle.({!}x^{\prime}(y).\llbracket N\rrbracket_{y}\mid[x\leftrightarrow z])\\ \end{array}

However, this candidate encoding breaks down once we consider definitional equality. Specifically, compositionality (i.e. the relationship between M{N/x}z\llbracket M\{N/x\}\rrbracket_{z} and the encoding of NN substituted in that of MM) requires us to relate M{N/x}z\llbracket M\{N/x\}\rrbracket_{z} with (𝝂x)(Mz{{Ny}/x}!x(y).Ny)({\boldsymbol{\nu}}x)(\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{y}\}/x\}\mid{!}x^{\prime}(y).\llbracket N\rrbracket_{y}), which relies on reasoning up-to observational equivalence of processes, a much stronger relation than our notion of definitional equality. Therefore it is fundamentally impossible for such an encoding to preserve our definitional equality, and thus it cannot preserve typing in the general case.

A faithful embedding.

We now develop our embedding of the functional layer into the process layer which is compatible with definitional equality. Our target calculus is reminiscent of a higher-order (in the sense of higher-order processes [25]) session calculus [21]. Our encoding \llbracket{-}\rrbracket is inductively defined on kinds, types, session types, terms and processes. As usual in process encodings of the λ\lambda-calculus, the encoding of a term MM is indexed by a result channel zz, written Mz\llbracket M\rrbracket_{z}, where the behaviour of MM may be observed.

Kind:𝗍𝗒𝗉𝖾𝗌𝗍𝗒𝗉𝖾𝗌𝗍𝗒𝗉𝖾𝗌𝗍𝗒𝗉𝖾Πx:τ.KΠx:{τ}.KΠt::K1.K2Πt::K1.K2Functional:Πx:τ.σx:{τ}.σ{uj:Bj¯;di:Bi¯c:A}!Bj¯Bi¯Aλx:τ.σλx:{τ}.στMτ{Mc}λt::K.τλt::K.ττστσSession:x:τ.Ax:{τ}.Ax:τ.Ax:{τ}.Aλx:τ.Aλx:{τ}.AAMA{Mc}\begin{array}[]{lcllcl}\text{\bf Kind:}\\ \ \llbracket\mathsf{type}\rrbracket&\triangleq&\mathsf{stype}&\llbracket\mathsf{stype}\rrbracket&\triangleq&\mathsf{stype}\\ \ \llbracket\Pi x{:}\tau.K\rrbracket&\triangleq&\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket&\llbracket\Pi t::K_{1}.K_{2}\rrbracket&\triangleq&\Pi t{::}\llbracket K_{1}\rrbracket.\llbracket K_{2}\rrbracket\\ \text{\bf Functional:}\\ \ \llbracket\Pi x{:}\tau.\sigma\rrbracket&\triangleq&\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket&\llbracket\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}B_{i}}\vdash c{:}A\}\rrbracket&\triangleq&\overline{{!}\llbracket B_{j}\rrbracket}\multimap\overline{\llbracket B_{i}\rrbracket}\multimap\llbracket A\rrbracket\\ \ \llbracket\lambda x{:}\tau.\sigma\rrbracket&\triangleq&\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket&\llbracket\tau\,M\rrbracket&\triangleq&\llbracket\tau\rrbracket\,\{\llbracket M\rrbracket_{c}\}\\ \ \llbracket\lambda t{::}K.\tau\rrbracket&\triangleq&\lambda t{::}\llbracket K\rrbracket.\llbracket\tau\rrbracket&\llbracket\tau\,\sigma\rrbracket&\triangleq&\llbracket\tau\rrbracket\,\llbracket\sigma\rrbracket\\ \text{\bf Session:}\\ \ \llbracket\forall x{:}\tau.A\rrbracket&\triangleq&\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket A\rrbracket&\llbracket\exists x{:}\tau.A\rrbracket&\triangleq&\exists x{:}\{\llbracket\tau\rrbracket\}.\llbracket A\rrbracket\\ \ \llbracket\lambda x{:}\tau.A\rrbracket&\triangleq&\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket A\rrbracket&\llbracket A\,M\rrbracket&\triangleq&\llbracket A\rrbracket\,\{\llbracket M\rrbracket_{c}\}\end{array}
Terms:λx:τ.Mzz(x:{τ}).MzMNz(𝝂x)(Mxx{Ny}.[xz])xzyx;[yz]{zPuj¯;di¯}zz(u0)..z(uj).z(d0)..z(dn).P\begin{array}[]{l}\text{\bf Terms:}\\ \ \llbracket\lambda x{:}\tau.M\rrbracket_{z}\triangleq z(x{:}\{\llbracket\tau\rrbracket\}).\llbracket M\rrbracket_{z}\quad\quad\llbracket M\,N\rrbracket_{z}\triangleq({\boldsymbol{\nu}}x)(\llbracket M\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{y}\}\rangle.[x\leftrightarrow z])\\ \ \llbracket x\rrbracket_{z}\triangleq y\leftarrow x;[y\leftrightarrow z]\quad\quad\llbracket\{z\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}\rrbracket_{z}\triangleq z(u_{0}).\dots.z(u_{j}).z(d_{0}).\dots.z(d_{n}).\llbracket P\rrbracket\end{array}
Processes:(𝝂x)(PQ)(𝝂x)(PQ)𝟎𝟎x¯y.(PQ)x¯y.(PQ)xM.Px{My}.Px(y).Px(y).PcMuj¯;yi¯;Q(𝝂c)(Mcc¯v1.(u1¯a1.[a1v1]c¯d1.([y1d1]c¯dn.([yndn]Q))\begin{array}[]{lcl}{\text{\bf Processes:}}\\ \ \llbracket({\boldsymbol{\nu}}x)(P\mid Q)\rrbracket&\triangleq&({\boldsymbol{\nu}}x)(\llbracket P\rrbracket\mid\llbracket Q\rrbracket)\quad\llbracket\boldsymbol{0}\rrbracket\triangleq\boldsymbol{0}\quad\llbracket\overline{x}\langle y\rangle.(P\mid Q)\rrbracket\triangleq\overline{x}\langle y\rangle.(\llbracket P\rrbracket\mid\llbracket Q\rrbracket)\\ \ \llbracket x\langle M\rangle.P\rrbracket&\triangleq&x\langle\{\llbracket M\rrbracket_{y}\}\rangle.\llbracket P\rrbracket\quad\llbracket x(y).P\rrbracket\triangleq x(y).\llbracket P\rrbracket\\ \ \llbracket c\leftarrow M\leftarrow\overline{u_{j}};\overline{y_{i}};Q\rrbracket&\triangleq&({\boldsymbol{\nu}}c)(\llbracket M\rrbracket_{c}\mid\overline{c}\langle v_{1}\rangle.(\overline{u_{1}}\langle a_{1}\rangle.[a_{1}\leftrightarrow v_{1}]\mid\dots\mid\\ &&\overline{c}\langle d_{1}\rangle.([y_{1}\leftrightarrow d_{1}]\mid\dots\mid\overline{c}\langle d_{n}\rangle.([y_{n}\leftrightarrow d_{n}]\mid\llbracket Q\rrbracket)\dots)\end{array}

Figure 7: An embedding of dependent functions into processes

The embedding is presented in Fig. 7, noting that the encoding extends straightforwardly to typing contexts, where functional contexts Ψ,x:τ\Psi,x{:}\tau are mapped to {Ψ},x:{τ}\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}. The mapping of base kinds is straightforward. Dependent kinds Πx:τ.K\Pi x{:}\tau.K rely on the monad for well-formedness and are encoded as (session) kinds of the form Πx:{τ}.K\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket. The higher-kinded types in the functional layer are translated to the corresponding type-level constructs of the process layer where all objects that must be 𝗍𝗒𝗉𝖾\mathsf{type}-kinded rely on the monad to satisfy this constraint. For instance, λx:τ.σ\lambda x{:}\tau.\sigma is mapped to the session-type abstraction λx:{τ}.σ\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket and the type-level application τM\tau\,M is translated to τ{Mc}\llbracket\tau\rrbracket\,\{\llbracket M\rrbracket_{c}\}. Given the observation above on embedding the dependent function type Πx:τ.σ\Pi x{:}\tau.\sigma, we translate it directly to x:{τ}.σ\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket, that is, functions from τ\tau to σ\sigma are mapped to sessions that input processes implementing τ\llbracket\tau\rrbracket and then behave as σ\llbracket\sigma\rrbracket accordingly. The encoding for monadic types simply realises the contextual nature of the monad by performing a sequence of inputs of the appropriate types (with the shared sessions being of !{!} type).

The mutually dependent nature of the framework requires us to extend the mapping to the process layer. Session types are mapped homomorphically (e.g. ABAB\llbracket A\multimap B\rrbracket\triangleq\llbracket A\rrbracket\multimap\llbracket B\rrbracket) with the exception of dependent inputs and outputs which rely on the monad, similarly for type-level functions and application.

The encoding of λ\lambda-terms is guided by the embedding for types: the abstraction λx:τ.M\lambda x{:}\tau.M is mapped to an input of a term of type {τ}\{\llbracket\tau\rrbracket\} with continuation Mz\llbracket M\rrbracket_{z}; application MNM\,N is mapped to the composition of the encoding of MM on a fresh name xx with the corresponding output of {Ny}\{\llbracket N\rrbracket_{y}\}, which is then forwarded to the result channel zz; monadic expressions are translated to the appropriate sequence of inputs, as dictated by the translation of the monadic type; and, the translation of variables makes use of the monadic elimination form (since the encoding enforces variables to always be of monadic type) combined with forwarding to the appropriate result channel.

The mapping for processes is mostly homomorphic, using the monad constructor as needed. The only significant exception is the encoding for monadic elimination which must provide the encoded monadic term Mc\llbracket M\rrbracket_{c} with the necessary channels. Since the session calculus does not support communication of free names this is achieved by a sequence of outputs of fresh names combined with forwarding of the appropriate channel. To account for replicated sessions we must first trigger the replication via an output which is then forwarded accordingly.

We can illustrate our encoding via a simple example of an encoded function (we omit type annotations for conciseness):

(λx.x)(λx.λy.y)z=(𝝂c)(λx.xcc{λx.λy.yw}.[cz])=(𝝂c)(c(x).yx;[yc]c{w(x).w(y).dy;[dw]}.[cz])+z(x).z(y).dy;[dz]=λx.λy.yz\begin{array}[]{l}\llbracket(\lambda x.x)\,(\lambda x.\lambda y.y)\rrbracket_{z}=({\boldsymbol{\nu}}c)(\llbracket\lambda x.x\rrbracket_{c}\mid c\langle\{\llbracket\lambda x.\lambda y.y\rrbracket_{w}\}\rangle.[c\leftrightarrow z])=\\ \qquad({\boldsymbol{\nu}}c)(c(x).y\leftarrow x;[y\leftrightarrow c]\mid c\langle\{w(x).w(y).d\leftarrow y;[d\leftrightarrow w]\}\rangle.[c\leftrightarrow z])\\ \xrightarrow{}^{+}z(x).z(y).d\leftarrow y;[d\leftrightarrow z]\ =\ \llbracket\lambda x.\lambda y.y\rrbracket_{z}\end{array}

3.2 Properties of the Embedding

We now state the key properties satisfied by our embedding, ultimately resulting in type preservation and operational correspondence. For conciseness, in the statements below we list only the cases for terms and processes, omitting those for types and kinds (see Appendix 0.C). The key property that is needed is a notion of compositionality, which unlike in the sketch above no longer falls outside of definitional equality.

Lemma 3.1 (Compositionality)
  1. 1.

    Ψ;Γ;ΔM{N/x}z=Mz{{Ny}/x}::z:A{N/x}\Psi;\Gamma;\Delta\vdash\llbracket M\{N/x\}\rrbracket_{z}=\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{y}\}/x\}::z{:}\llbracket A\{N/x\}\rrbracket

  2. 2.

    Ψ;Γ;ΔP{M/x}::z:A{M/x}\Psi;\Gamma;\Delta\vdash\llbracket P\{M/x\}\rrbracket::z{:}\llbracket A\{M/x\}\rrbracket iff Ψ;Γ;ΔP{{Mc}/x}::z:A{{Mc}/x}\Psi;\Gamma;\Delta\vdash\llbracket P\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::z{:}\llbracket A\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}

Given the dependently typed nature of the framework, establishing the key properties of the encoding must be done simultaneously (relying on some auxiliary results – see Appendix 0.C).

Theorem 3.2 (Preservation of Equality)
  1. 1.

    If ΨM=N:τ\Psi\vdash M=N:\tau then {Ψ};;Mz=Nz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}=\llbracket N\rrbracket_{z}::z{:}\llbracket\tau\rrbracket

  2. 2.

    If Ψ;Γ;ΔP=Q::z:A\Psi;\Gamma;\Delta\vdash P=Q::z{:}A then {Ψ};Γ;ΔP=Q::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket=\llbracket Q\rrbracket::z{:}\llbracket A\rrbracket

Theorem 3.3 (Preservation of Typing)
  1. 1.

    If ΨM:τ\Psi\vdash M:\tau then {Ψ};;Mz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}::z{:}\llbracket\tau\rrbracket

  2. 2.

    If Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A then {Ψ};Γ;ΔP::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket::z{:}\llbracket A\rrbracket

Theorem 3.4 (Operational Correspondence)

If Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A and ΨM:τ\Psi\vdash M:\tau then:

  1. 1.

    (a) If PPP\xrightarrow{}P^{\prime} then P+Q\llbracket P\rrbracket\xrightarrow{}^{+}Q with {Ψ};Γ;ΔQ=P::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash Q=\llbracket P^{\prime}\rrbracket::z{:}\llbracket A\rrbracket and (b) if PP\llbracket P\rrbracket\xrightarrow{}P^{\prime} then P+QP\xrightarrow{}^{+}Q with {Ψ};Γ;ΔP=Q::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash P^{\prime}=\llbracket Q\rrbracket::z{:}\llbracket A\rrbracket

  2. 2.

    (a) If MMM\xrightarrow{}M^{\prime} then Mz+N\llbracket M\rrbracket_{z}\xrightarrow{}^{+}N with {Ψ};;N=Mz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash N=\llbracket M^{\prime}\rrbracket_{z}::z{:}\llbracket\tau\rrbracket and (b) if MzP\llbracket M\rrbracket_{z}\xrightarrow{}P then MNM\xrightarrow{}N with {Ψ};;Nz=P::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket N\rrbracket_{z}=P::z{:}\llbracket\tau\rrbracket

In Theorem 3.4, (a) is commonly referred to as operational completeness, with (b) establishing soundness. As exemplified above, our encoding satisfies a very precise operational correspondence with the original λ\lambda-terms.

4 Related and Future Work

Enriching Session Types via Type Structure.

Exploiting the linear logical foundations of session types, [27] considers a form of value dependencies where session types can state properties of exchanged data values, while the work [31] introduces the contextual monad in a simply-typed setting. Our development not only subsumes these two works, but goes beyond simple value dependencies by extending to a richer type structure and integrating dependencies with the contextual monad. Recently, [1] considers a non-conservative extension of linear logic-based session types with sharing, allowing true non-determinism. Their work includes dependent quantifications with shared channels, but their type syntax does not include free type variables, so the actual type dependencies do not arise (see [1, 37:8]). Thus none of the examples in this paper can be represented in [1]. The work [17] studies gradual session types. To the best of our knowledge, the main example in [17, § 2] is statically representable in our framework as in the example of § 1, where protocol actions depend on values that are communicated (or passed as function arguments).

In the context of multiparty session types, the theory of multiparty indexed session types is studied in [7], and implemented in a protocol description language [22]. The main aim of these works is to use indexed types to represent an arbitrary number of session participants. The work [33] extends [27] to multiparty sessions in order to treat value dependency across multiple participants. Extending our framework to multiparty [16] or non-logic based session types [15] is an interesting future topic.

Combining Linear and Dependent Types.

Many works have studied the various challenges of integrating linearity in dependent functional type theories. We focus on the most closely related works. The work [6] introduced the Linear Logical Framework (LLF), integrating linearity with the LF [11] type theory, which was later extended to the Concurrent Logical Framework (CLF) [35], accounting for further linear connectives. Their theory is representable in our framework through the contextual monad (encompassing full intuitionistic linear logic), depending on linearly-typed processes that can express dependently typed functions (§ 3).

The work of [18] integrates linearity with type dependencies by extending LNL [2]. Their work is aimed at reasoning about imperative programs using a form of Hoare triples, requiring features that we do not study in this work such has proof irrelevance and computationally irrelevant quantification. Formally, their type theory is extensional which introduces significant technical differences from our intensional type theory, such as a realisability model in the style of NuPRL [10] to establish consistency.

Recently, [8] proposed an extension of LLF with first-class contexts (which may contain both linear and unrestricted hypotheses). While the contextual aspects of their theory are reminiscent of our contextual monad, their framework differs significantly from ours, since it is designed to enable higher-order abstract syntax (commonplace in the LF family of type theories), focusing on a type system for canonical LF objects with a meta-language that includes contexts and context manipulation. They do not consider additives since their integration with first-class contexts can break canonicity.

While none of the above works considers processes as primitive, their techniques should be useful for, e.g. developing algorithmic type-checking and integrating inductive and coinductive session types based on [28, 32, 19].

Dependent Types and Higher-Order π\pi-calculus.

The work [37] studies a form of dependent types where the type of processes takes the form of a mapping Δ\Delta from channels xx to channel types TT representing an interface of process PP. The dependency is specified as Π(x:T)Δ\Pi(x{:}T)\Delta, representing a channel abstraction of the environment. This notion is extended to an existential channel dependency type Σ(x:T)Δ\Sigma(x{:}T)\Delta to address fresh name creation [36, 13]. Combining our process monad with dependent types can be regarded as an “interface” which describes explicit channel usages for processes. The main differences are (1) our dependent types are more general, treating full dependent families including terms and processes in types, while [37, 36, 13] study only channel dependency to environments (i.e. neither terms nor processes appear in types, only channels); and (2) our calculus emits only fresh names, not needing to handle the complex scoping mechanism treated in [36, 13]. In this sense, the process monad provides an elegant framework to handle higher-order computations and assign non-trivial types to processes.
Acknowledgements. The authors would like to thank the anonymous reviews for their comments and suggestions. This work is partially supported by EPSRC EP/K034413/1, EP/K011715/1, EP/L00058X/1, EP/N027833/1 and EP/N028201/1.

References

  • [1] Balzer, S., Pfenning, F.: Manifest sharing with session types. PACMPL 1(ICFP), 37:1–37:29 (2017)
  • [2] Benton, N.: A mixed linear and non-linear logic: Proofs, terms and models (extended abstract). In: CSL. pp. 121–135 (1994)
  • [3] Caires, L., Pérez, J.A., Pfenning, F., Toninho, B.: Behavioral polymorphism and parametricity in session-based communication. In: ESOP 2013. pp. 330–349 (2013)
  • [4] Caires, L., Pfenning, F.: Session types as intuitionistic linear propositions. In: CONCUR 2010. pp. 222–236 (2010)
  • [5] Caires, L., Pfenning, F., Toninho, B.: Linear logic propositions as session types. Mathematical Structures in Computer Science 26(3), 367–423 (2016)
  • [6] Cervesato, I., Pfenning, F.: A linear logical framework. Inf. Comput. 179(1), 19–75 (2002)
  • [7] Deniélou, P., Yoshida, N., Bejleri, A., Hu, R.: Parameterised multiparty session types. Logical Methods in Computer Science 8(4) (2012), http://dx.doi.org/10.2168/LMCS-8(4:6)2012
  • [8] Georges, A.L., Murawska, A., Otis, S., Pientka, B.: LINCX: A linear logical framework with first-class contexts. In: ESOP. pp. 530–555 (2017)
  • [9] Girard, J.: Linear logic. Theor. Comput. Sci. 50, 1–102 (1987)
  • [10] Harper, R.: Constructing type systems over an operational semantics. Journal of Symbolic Computation 14(1), 71 – 84 (1992)
  • [11] Harper, R., Honsell, F., Plotkin, G.D.: A framework for defining logics. J. ACM 40(1), 143–184 (1993)
  • [12] Harper, R., Pfenning, F.: On equivalence and canonical forms in the LF type theory. ACM Trans. Comput. Log. 6(1), 61–101 (2005)
  • [13] Hennessy, M., Rathke, J., Yoshida, N.: safeDpi: a language for controlling mobile code. Acta Inf. 42(4-5), 227–290 (2005)
  • [14] Honda, K., Vasconcelos, V.T., Kubo, M.: Language primitives and type discipline for structured communication-based programming. In: ESOP’98. pp. 122–138 (1998)
  • [15] Honda, K., Vasconcelos, V.T., Kubo, M.: Language primitives and type disciplines for structured communication-based programming. In: ESOP’98. vol. 1381, pp. 22–138 (1998)
  • [16] Honda, K., Yoshida, N., Carbone, M.: Multiparty asynchronous session types. In: POPL’08. pp. 273–284 (2008)
  • [17] Igarashi, A., Thiemann, P., Vasconcelos, V.T., Wadler, P.: Gradual session types. PACMPL 1(ICFP), 38:1–38:28 (2017)
  • [18] Krishnaswami, N.R., Pradic, P., Benton, N.: Integrating linear and dependent types. In: POPL’15. pp. 17–30 (2015)
  • [19] Lindley, S., Morris, J.G.: Talking bananas: structural recursion for session types. In: ICFP 2016. pp. 434–447 (2016)
  • [20] McBride, C.: Elimination with a motive. In: TYPES 2000,. pp. 197–216 (2000)
  • [21] Mostrous, D., Yoshida, N.: Two session typing systems for higher-order mobile processes. In: TLCA07. pp. 321–335 (2007)
  • [22] Ng, N., Yoshida, N.: Pabble: parameterised Scribble. Service Oriented Computing and Applications 9(3-4), 269–284 (2015)
  • [23] Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Department of Computer Science and Engineering, Chalmers University of Technology (2007)
  • [24] Pérez, J.A., Caires, L., Pfenning, F., Toninho, B.: Linear logical relations for session-based concurrency. In: ESOP. pp. 539–558 (2012)
  • [25] Sangiorgi, D., Walker, D.: The pi-calculus: A theory of mobile processes. C.U.P (2001)
  • [26] Takeuchi, K., Honda, K., Kubo, M.: An interaction-based language and its typing system. In: PARLE’94. pp. 398–413 (1994)
  • [27] Toninho, B., Caires, L., Pfenning, F.: Dependent session types via intuitionistic linear type theory. In: PPDP’11. pp. 161–172 (2011)
  • [28] Toninho, B.: A Logical Foundation for Session-based Concurrent Computation. Ph.D. thesis, Carnegie Mellon University and New University of Lisbon (2015)
  • [29] Toninho, B., Caires, L., Pfenning, F.: Dependent session types via intuitionistic linear type theory. Tech. Rep. CMU-CS-11-139, School of Computer Science, Carnegie Mellon University (2011)
  • [30] Toninho, B., Caires, L., Pfenning, F.: Functions as session-typed processes. In: FOSSACS 2012. pp. 346–360 (2012)
  • [31] Toninho, B., Caires, L., Pfenning, F.: Higher-order processes, functions, and sessions: A monadic integration. In: ESOP. pp. 350–369 (2013)
  • [32] Toninho, B., Caires, L., Pfenning, F.: Corecursion and non-divergence in session-typed processes. In: TGC 2014. pp. 159–175 (2014)
  • [33] Toninho, B., Yoshida, N.: Certifying data in multiparty session types. Journal of Logical and Algebraic Methods in Programming 90(C), 61–83 (2017)
  • [34] Toninho, B., Yoshida, N.: Depending on session-typed processes. In: FoSSaCS (2018), to appear
  • [35] Watkins, K., Cervesato, I., Pfenning, F., Walker, D.: A concurrent logical framework: The propositional fragment. In: TYPES’03. pp. 355–377 (2003)
  • [36] Yoshida, N.: Channel dependent types for higher-order mobile processes. In: POPL’04. pp. 147–160 (2004)
  • [37] Yoshida, N., Hennessy, M.: Assigning types to processes. Inf. Comput. 174(2), 143–179 (2002)

Appendix 0.A Appendix – Dependently-typed Calculus

0.A.1 Complete Rules for Dependently-Typed System

We recall the meaning of the several judgments of our type theory:

ΨContext Ψ is well-formed.ΨKK is a kind in context Ψ.Ψτ::Kτ is a (functional) type of kind K in context Ψ.ΨA::KA is a session type of kind K in context Ψ.ΨM:τM has type τ in context Ψ.Ψ;Γ;ΔP::z:AP offers session z:A when composed with processes accordingto Γ and Δ in context Ψ.ΨK1=K2Kinds K1 and K2 are equal.Ψτ=σ::KTypes τ and σ are equal of kind K.ΨA=B::KSession types A and B are equal of kind K.ΨM=N:τTerms M and N are equal of type τ.Ψ;Γ;ΔP=Q::z:AProcesses P and Q are equal with typing z:A.\begin{array}[]{ll}\Psi\vdash&\mbox{Context $\Psi$ is well-formed.}\\ \Psi\vdash K&\mbox{$K$ is a kind in context $\Psi$.}\\ \Psi\vdash\tau::K&\mbox{$\tau$ is a (functional) type of kind $K$ in context $\Psi$.}\\ \Psi\vdash A::K&\mbox{$A$ is a session type of kind $K$ in context $\Psi$.}\\ \Psi\vdash M:\tau&\mbox{$M$ has type $\tau$ in context $\Psi$.}\\ \Psi;\Gamma;\Delta\vdash P::z{:}A&\mbox{$P$ offers session $z{:}A$ when composed with processes according}\\ &\mbox{to $\Gamma$ and $\Delta$ in context $\Psi$.}\\ \Psi\vdash K_{1}=K_{2}&\mbox{Kinds $K_{1}$ and $K_{2}$ are equal.}\\ \Psi\vdash\tau=\sigma::K&\mbox{Types $\tau$ and $\sigma$ are equal of kind $K$.}\\ \Psi\vdash A=B::K&\mbox{Session types $A$ and $B$ are equal of kind $K$.}\\ \Psi\vdash M=N:\tau&\mbox{Terms $M$ and $N$ are equal of type $\tau$.}\\ \Psi;\Gamma;\Delta\vdash P=Q::z{:}A&\mbox{Processes $P$ and $Q$ are equal with typing $z{:}A$.}\\ \end{array}

0.A.1.1 Well-formed Contexts

We write \cdot for the empty context. We write Ψ,x:τ\Psi,x{:}\tau for the extension of context Ψ\Psi with the binding x:τx{:}\tau. We assume that xx does not occur in Ψ\Psi. We use a similar notation for the session typing contexts Δ\Delta and Γ\Gamma.

ΨΨτ::𝗍𝗒𝗉𝖾Ψ,x:τΨΨKΨ,t::KΨΨ;ΔΨA::𝗌𝗍𝗒𝗉𝖾Ψ;Δ,x:AΨΨ;ΓΨA::𝗌𝗍𝗒𝗉𝖾Ψ;Γ,x:A\begin{array}[]{c}\cdot\vdash\quad\Psi,x{:}\tau\vdash\lx@proof@logical@and\Psi\vdash\Psi\vdash\tau::\mathsf{type}\quad\Psi,t{::}K\vdash\lx@proof@logical@and\Psi\vdash\Psi\vdash K\quad\Psi;\Delta,x{:}A\vdash\lx@proof@logical@and\Psi\vdash\Psi;\Delta\vdash\Psi\vdash A::\mathsf{stype}\\[5.0pt] \Psi;\Gamma,x{:}A\vdash\lx@proof@logical@and\Psi\vdash\Psi;\Gamma\vdash\Psi\vdash A::\mathsf{stype}\end{array}

0.A.1.2 Well-formed Kinds

ΨΨ𝗍𝗒𝗉𝖾ΨΨ𝗌𝗍𝗒𝗉𝖾Ψ,x:τKΨτ::𝗍𝗒𝗉𝖾ΨΠx:τ.KΨ,x:τKΨτ::𝗌𝗍𝗒𝗉𝖾ΨΠx:τ.KΨKΨ,t::KKΨΠt::K.K\begin{array}[]{c}\Psi\vdash\mathsf{type}\Psi\vdash\quad\Psi\vdash\mathsf{stype}\Psi\vdash\quad\Psi\vdash\Pi x{:}\tau.K\lx@proof@logical@and\Psi,x{:}\tau\vdash K\Psi\vdash\tau::\mathsf{type}\quad\Psi\vdash\Pi x{:}\tau.K\lx@proof@logical@and\Psi,x{:}\tau\vdash K\Psi\vdash\tau::\mathsf{stype}\\[5.0pt] \Psi\vdash\Pi t{::}K.K^{\prime}\Psi\vdash K\quad\Psi,t{::}K\vdash K^{\prime}\end{array}

0.A.2 Well-formed (Functional) Types

Ψτ::𝗍𝗒𝗉𝖾Ψ,x:τσ::𝗍𝗒𝗉𝖾ΨΠx:τ.σ::𝗍𝗒𝗉𝖾Ψτ::𝗍𝗒𝗉𝖾Ψ,x:τσ::KΨλx:τ.σ::Πx:τ.KΨτ::Πx:σ.KΨM:σΨτM::K{M/x}i,j.ΨAi::𝗌𝗍𝗒𝗉𝖾ΨBj::𝗌𝗍𝗒𝗉𝖾ΨA::𝗌𝗍𝗒𝗉𝖾Ψ{uj:Bj¯;di:Ai¯c:A}::𝗍𝗒𝗉𝖾ΨKΨ,t::Kσ::KΨλt::K.σ::Πt::K.KΨτ::Πt::K.KΨσ::KΨτσ::K{σ/t}t::KΨΨΨt::K\begin{array}[]{c}\Psi\vdash\Pi x{:}\tau.\sigma::\mathsf{type}\lx@proof@logical@and\Psi\vdash\tau::\mathsf{type}\Psi,x{:}\tau\vdash\sigma::\mathsf{type}\quad\Psi\vdash\lambda x{:}\tau.\sigma::\Pi x{:}\tau.K\lx@proof@logical@and\Psi\vdash\tau::\mathsf{type}\Psi,x{:}\tau\vdash\sigma::K\\[5.0pt] \Psi\vdash\tau\,M::K\{M/x\}\Psi\vdash\tau::\Pi x{:}\sigma.K\quad\Psi\vdash M:\sigma\quad\Psi\vdash\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}::\mathsf{type}\lx@proof@logical@and\forall i,j.\Psi\vdash A_{i}::\mathsf{stype}\Psi\vdash B_{j}::\mathsf{stype}\Psi\vdash A::\mathsf{stype}\\[5.0pt] \Psi\vdash\lambda t{::}K.\sigma::\Pi t{::}K.K^{\prime}\Psi\vdash K\quad\Psi,t{::}K\vdash\sigma::K^{\prime}\quad\Psi\vdash\tau\,\sigma::K^{\prime}\{\sigma/t\}\Psi\vdash\tau::\Pi t{::}K.K^{\prime}\quad\Psi\vdash\sigma::K\\[5.0pt] \Psi\vdash t::Kt{::}K\in\Psi\quad\Psi\vdash\end{array}

0.A.3 Well-formed Session Types

ΨΨ𝟏::𝗌𝗍𝗒𝗉𝖾ΨA::𝗌𝗍𝗒𝗉𝖾Ψ!A::𝗌𝗍𝗒𝗉𝖾ΨA::𝗌𝗍𝗒𝗉𝖾ΨB::𝗌𝗍𝗒𝗉𝖾ΨAB::𝗌𝗍𝗒𝗉𝖾ΨA::𝗌𝗍𝗒𝗉𝖾ΨB::𝗌𝗍𝗒𝗉𝖾ΨAB::𝗌𝗍𝗒𝗉𝖾Ψτ::𝗍𝗒𝗉𝖾Ψ,x:τA::𝗌𝗍𝗒𝗉𝖾Ψx:τ.A::𝗌𝗍𝗒𝗉𝖾Ψτ::𝗍𝗒𝗉𝖾Ψ,x:τA::𝗌𝗍𝗒𝗉𝖾Ψx:τ.A::𝗌𝗍𝗒𝗉𝖾i.ΨAi::𝗌𝗍𝗒𝗉𝖾Ψ&{li:Ai¯}::𝗌𝗍𝗒𝗉𝖾i.ΨAi::𝗌𝗍𝗒𝗉𝖾Ψ{li:Ai¯}::𝗌𝗍𝗒𝗉𝖾Ψτ::𝗍𝗒𝗉𝖾Ψ,x:τA::KΨλx:τ.A::Πx:τ.KΨA::Πx:τ.KΨM:τΨAM::K{M/x}ΨA::KΨK=KΨA::KΨ,t::KA::KΨλt::K.A::Πt::K.KΨA::Πt::K.KΨB::KΨAB::K{B/x}Ψt::KΨΨt::K\begin{array}[]{c}\Psi\vdash\mathbf{1}::\mathsf{stype}\Psi\vdash\quad\Psi\vdash{!}A::\mathsf{stype}\Psi\vdash A::\mathsf{stype}\quad\Psi\vdash A\multimap B::\mathsf{stype}\lx@proof@logical@and\Psi\vdash A::\mathsf{stype}\Psi\vdash B::\mathsf{stype}\\[5.0pt] \Psi\vdash A\otimes B::\mathsf{stype}\lx@proof@logical@and\Psi\vdash A::\mathsf{stype}\Psi\vdash B::\mathsf{stype}\quad\Psi\vdash\forall x{:}\tau.A::\mathsf{stype}\lx@proof@logical@and\Psi\vdash\tau::\mathsf{type}\Psi,x{:}\tau\vdash A::\mathsf{stype}\\[5.0pt] \quad\Psi\vdash\exists x{:}\tau.A::\mathsf{stype}\lx@proof@logical@and\Psi\vdash\tau::\mathsf{type}\Psi,x{:}\tau\vdash A::\mathsf{stype}\quad\Psi\vdash\mathbin{\binampersand}\{\overline{l_{i}:A_{i}}\}::\mathsf{stype}\forall i.\Psi\vdash A_{i}::\mathsf{stype}\\[5.0pt] \Psi\vdash\oplus\{\overline{l_{i}:A_{i}}\}::\mathsf{stype}\forall i.\Psi\vdash A_{i}::\mathsf{stype}\quad\Psi\vdash\lambda x{:}\tau.A::\Pi x{:}\tau.K\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\vdash A::K\\[5.0pt] \Psi\vdash A\,M::K\{M/x\}\lx@proof@logical@and\Psi\vdash A::\Pi x{:}\tau.K\Psi\vdash M:\tau\quad\Psi\vdash A::K^{\prime}\lx@proof@logical@and\Psi\vdash A::K\Psi\vdash K=K^{\prime}\\[5.0pt] \Psi\vdash\lambda t{::}K.A::\Pi t{::}K.K^{\prime}\Psi,t{::}K\vdash A::K^{\prime}\quad\Psi\vdash A\,B::K^{\prime}\{B/x\}\Psi\vdash A::\Pi t{::}K.K^{\prime}\quad\Psi\vdash B::K\quad\Psi\vdash t::K\Psi\vdash\quad t{::}K\in\Psi\end{array}

0.A.4 Typing for λ\lambda-Terms

(ΠI)         Ψτ::typeΨ,x:τM:σ        Ψλx:τ.M:Πx:τ.σ (ΠE)         ΨM:Πx:τ.σΨN:τ        ΨMN:σ{/Nx} (var)      Ψx:τΨ     Ψx:τ ({}I)             i,j.ΨAi,Bj::stypeΨ;¯:ujBj;¯:diAiP::c:A          Ψ{cP¯uj;¯di}:{¯:ujBj;¯:diAic:A} (Conv)         ΨM:τΨτ=σ::type     ΨM:σ \begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\Pi I)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 63.28737pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\vdash M:\sigma}$}}}\vbox{}}}\over\hbox{\hskip 51.11723pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\Pi E)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 62.68314pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\Pi x{:}\tau.\sigma\quad\Psi\vdash N:\tau}$}}}\vbox{}}}\over\hbox{\hskip 44.2631pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M\,N:\sigma\{N/x\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{var})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 32.54329pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\quad x{:}\tau\in\Psi}$}}}\vbox{}}}\over\hbox{\qquad\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash x{:}\tau}$}}}}}}$}}}\par\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\{\}I)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 89.61742pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\forall i,j.\Psi\vdash A_{i},B_{j}::\mathsf{stype}\quad\Psi;\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash P::c{:}A}$}}}\vbox{}}}\over\hbox{\hskip 71.4263pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}:A_{i}}\vdash c{:}A\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{Conv})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 60.9853pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\tau\quad\Psi\vdash\tau=\sigma::\mathsf{type}}$}}}\vbox{}}}\over\hbox{\hskip 22.14166pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\sigma}$}}}}}}$}}}\end{array}

0.A.5 Typing for Processes

(R)           ΨM:τΨ;Γ;ΔP::c:A{/Mx}           Ψ;Γ;ΔcMx:τ.A.P::c:x:τ.A (L)             Ψτ::typeΨ,x:τ;Γ;Δ,c:AQ::d:D           Ψ;Γ;Δ,c:x:τ.Ac(:xτ).Q::d:D (R)           Ψτ::typeΨ,x:τ;Γ;ΔP::c:A          Ψ;Γ;Δc(:xτ).P::c:x:τ.A (L)             ΨM:τΨ;Γ;Δ,c:A{/Mx}Q::d:D            Ψ;Γ;Δ,c:x:τ.AcMx:τ.A.Q::d:D (id)       Ψ;Γ[ΨA::stype]         Ψ;Γ;d:A[dc]::c:A (1R)    Ψ;Γ     Ψ;Γ;0::c:1 (1L)       Ψ;Γ;ΔP::d:D       Ψ;Γ;Δ,c:1P::d:D (!R)       Ψ;Γ;P::x:A       Ψ;Γ;!c(x).P::c:!A (!L)         Ψ;Γ,u:A;ΔP::d:D         Ψ;Γ;Δ,c:!AP{/cu}::d:D (copy)          Ψ;Γ,u:A;Δ,x:AP::d:D          Ψ;Γ,u:A;Δ(νx)ux.P::d:D (R)           Ψ;Γ;Δ1P1::x:AΨ;Γ;ΔP2::c:B            Ψ;Γ;Δ1,Δ2(νx)cx.(P1P2)::c:AB (L)          Ψ;Γ;Δ,x:A,c:BQ::d:D          Ψ;Γ;Δ,c:ABc(x).Q::d:D (R)         Ψ;Γ;Δ,x:AP::c:B          Ψ;Γ;Δc(x).P::c:AB (L)              Ψ;Γ;Δ1Q1::x:AΨ;Γ;Δ2,c:BQ2::d:D              Ψ;Γ;Δ1,Δ2,c:AB(νx)cx.(Q1Q2)::d:D (&R)            Ψ;Γ;ΔP1::c:A1Ψ;Γ;ΔPn::c:An         Ψ;Γ;Δc.case(¯ljPj)::c:&{¯:ljAj} (&L)         Ψ;Γ;Δ,c:AiQ::d:D         Ψ;Γ;Δ,c:&{¯:ljAj}c.li;Q::d:D (R)       Ψ;Γ;ΔP::c:Ai         Ψ;Γ;Δc.li;P::c:{¯:ljAj} (L)                Ψ;Γ;Δ,c:A1Q1::d:DΨ;Γ;Δ,c:AnQn::d:D           Ψ;Γ;Δ,c:{¯:ljAj}c.case(¯ljQj)::d:D (cut)              Ψ;Γ;Δ1P::x:AΨ;Γ;Δ2,x:AQ::d:D          Ψ;Γ;Δ1,Δ2(νx)(PQ)::d:D (cut!)             Ψ;Γ;P::x:AΨ;Γ,u:A;ΔQ::d:D          Ψ;Γ;Δ(νu)(!u(x).PQ)::d:D ({}E)                 Δ=¯:diBi¯:ujCjΓΨM:{¯:ujCj;¯:diBic:A}Ψ;Γ;Δ,x:AQ::z:C          Ψ;Γ;Δ,ΔxM¯uj;¯yi;Q::z:C (ConvR)           Ψ;Γ;ΔP::z:AΨA=B::stype       Ψ;Γ;ΔP::z:B (ConvL)            Ψ;Γ;ΔP::z:AΨ;Γ;Δ=Ψ;Γ;Δ       Ψ;Γ;ΔP::z:A \begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\exists}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 85.16693pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M{:}\tau\quad\Psi;\Gamma;\Delta\vdash P::c{:}A\{M/x\}}$}}}\vbox{}}}\over\hbox{\hskip 81.949pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash c\langle M\rangle_{\exists x{:}\tau.A}.P::c{:}\exists x{:}\tau.A}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\exists}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 94.62903pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\mathrel{;}\Gamma;\Delta,c{:}A\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 85.73376pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\mathrel{;}\Gamma;\Delta,c{:}\exists x{:}\tau.A\vdash c(x{:}\tau).Q::d{:}D}$}}}}}}$}}}\\[5.0pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\forall}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 81.31107pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}\quad\Psi,x{:}\tau\mathrel{;}\Gamma;\Delta\vdash P::c{:}A}$}}}\vbox{}}}\over\hbox{\hskip 73.2491pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash c(x{:}\tau).P::c{:}\forall x{:}\tau.A}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\forall}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 98.4849pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M{:}\tau\quad\Psi;\Gamma;\Delta,c{:}A\{M/x\}\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 95.26698pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}\forall x{:}\tau.A\vdash c\langle M\rangle_{\forall x{:}\tau.A}.Q::d{:}D}$}}}}}}$}}}\\[5.0pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{id})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 49.93048pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma\vdash\quad[\Psi\vdash A::\mathsf{stype}]}$}}}\vbox{}}}\over\hbox{\hskip 58.76823pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;d{:}A\vdash[d\leftrightarrow c]::c{:}A}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\mathbf{1}}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\qquad\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma\vdash}$}}}\vbox{}}}\over\hbox{\hskip 29.9276pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\cdot\vdash\mathbf{0}::c{:}\mathbf{1}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\mathbf{1}}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 41.96579pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 50.61566pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}\mathbf{1}\vdash P::d{:}D}$}}}}}}$}}}\\[15.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle({{{!}}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 36.69258pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\cdot\vdash P::x{:}A}$}}}\vbox{}}}\over\hbox{\hskip 49.90903pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\cdot\vdash{!}c(x).P::c{:}{!}A}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{{!}}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 54.41135pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma,u{:}A;\Delta\vdash P::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 70.40555pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}{!}A\vdash P\{c/u\}::d{:}D}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc(copy)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 67.40779pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma,u{:}A;\Delta,x{:}A\vdash P::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 75.45882pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma,u{:}A;\Delta\vdash({\boldsymbol{\nu}}x)u\langle x\rangle.P::d{:}D}$}}}}}}$}}}\\[15.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\otimes}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 90.54724pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta_{1}\vdash P_{1}::x{:}A\quad\Psi;\Gamma;\Delta\vdash P_{2}::c{:}B}$}}}\vbox{}}}\over\hbox{\hskip 95.49002pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta_{1},\Delta_{2}\vdash({\boldsymbol{\nu}}x)c\langle x\rangle.(P_{1}\mid P_{2})::c{:}A\otimes B}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\otimes}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 67.60649pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,x{:}A,c{:}B\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 75.60364pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}A\otimes B\vdash c(x).Q::d{:}D}$}}}}}}$}}}\\[15.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\multimap}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 54.28853pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,x{:}A\vdash P::c{:}B}$}}}\vbox{}}}\over\hbox{\hskip 64.50789pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash c(x).P::c{:}A\multimap B}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\multimap}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 106.15652pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta_{1}\vdash Q_{1}::x{:}A\quad\Psi;\Gamma;\Delta_{2},c{:}B\vdash Q_{2}::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 112.46732pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta_{1},\Delta_{2},c{:}A\multimap B\vdash({\boldsymbol{\nu}}x)c\langle x\rangle.(Q_{1}\mid Q_{2})::d{:}D}$}}}}}}$}}}\\[15.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\mathbin{\binampersand}}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 95.6768pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P_{1}::c{:}A_{1}\;\dots\;\Psi;\Gamma;\Delta\vdash P_{n}::c{:}A_{n}}$}}}\vbox{}}}\over\hbox{\hskip 62.0497pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash c.\mathsf{case}(\overline{l_{j}\Rightarrow P_{j}})::c{:}\mathbin{\binampersand}\{\overline{l_{j}{:}A_{j}}\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\mathbin{\binampersand}}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 54.59244pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}A_{i}\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 70.42982pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}\mathbin{\binampersand}\{\overline{l_{j}{:}A_{j}}\}\vdash c.l_{i};Q::d{:}D}$}}}}}}$}}}\\[15.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\oplus}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 42.66331pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::c{:}A_{i}}$}}}\vbox{}}}\over\hbox{\hskip 58.22295pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash c.l_{i};P::c{:}\oplus\{\overline{l_{j}{:}A_{j}}\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle({{\oplus}\mathsf{L}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 119.53503pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}A_{1}\vdash Q_{1}::d{:}D\;\dots\;\Psi;\Gamma;\Delta,c{:}A_{n}\vdash Q_{n}::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 76.4305pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,c{:}\oplus\{\overline{l_{j}{:}A_{j}}\}\vdash c.\mathsf{case}(\overline{l_{j}\Rightarrow Q_{j}})::d{:}D}$}}}}}}$}}}\\[15.00002pt] {\vbox{\hbox{\hbox{\small\sc(cut)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 104.80031pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta_{1}\vdash P::x{:}A\quad\Psi;\Gamma;\Delta_{2},x{:}A\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 71.84335pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta_{1},\Delta_{2}\vdash({\boldsymbol{\nu}}x)(P\mid Q)::d{:}D}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc(cut$\displaystyle{}^{!}$)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 96.15218pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\cdot\vdash P::x{:}A\quad\Psi;\Gamma,u{:}A;\Delta\vdash Q::d{:}D}$}}}\vbox{}}}\over\hbox{\hskip 75.58177pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash({\boldsymbol{\nu}}u)({!}u(x).P\mid Q)::d{:}D}$}}}}}}$}}}\\[5.0pt] {\vbox{\hbox{\hbox{\small\sc($\displaystyle\{\}E$)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 137.66548pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Delta^{\prime}=\overline{d_{i}:B_{i}}\quad\overline{u_{j}{:}C_{j}}\subseteq\Gamma\quad\Psi\vdash M:\{\overline{u_{j}{:}C_{j}};\overline{d_{i}{:}B_{i}}\vdash c{:}A\}\quad\Psi;\Gamma;\Delta,x{:}A\vdash Q::z{:}C}$}}}\vbox{}}}\over\hbox{\hskip 80.43236pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta^{\prime},\Delta\vdash x\leftarrow M\leftarrow\overline{u_{j}};\overline{y_{i}};Q::z{:}C}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc($\displaystyle{{\mathsf{Conv}}\mathsf{R}}$)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 85.56223pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}A\quad\Psi\vdash A=B::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 41.67345pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}B}$}}}}}}$}}}\par\quad\par{\vbox{\hbox{\hbox{\small\sc($\displaystyle{{\mathsf{Conv}}\mathsf{L}}$)}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 87.13007pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma^{\prime};\Delta^{\prime}\vdash P::z{:}A\quad\Psi;\Gamma^{\prime};\Delta^{\prime}=\Psi;\Gamma;\Delta}$}}}\vbox{}}}\over\hbox{\hskip 41.38005pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}A}$}}}}}}$}}\par}\end{array}

0.A.6 Definitional Equality for Kinds

(KEqR)     ΨK     Ψ=KK (KEqS)         Ψ=K1K2Ψ=K2K3      Ψ=K1K3 (KEqT)      Ψ=K2K1      Ψ=K1K2 (KEqΠ)            Ψτ=σ::typeΨ,x:τK1=K2         ΨΠx:τ.K1=Πx:σ.K2 (KEqKΠ)           ΨK1=K3Ψ,t::K1K2=K4          ΨΠt::K1.K2=Πt::K3.K4 \begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{KEqR})$}}\hbox{$\displaystyle\displaystyle{\hbox{\qquad\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K}$}}}\vbox{}}}\over\hbox{\hskip 25.5971pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K=K}$}}}}}}$}}}\par\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{KEqS})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 62.38878pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K_{1}=K_{2}\quad\Psi\vdash K_{2}=K_{3}}$}}}\vbox{}}}\over\hbox{\hskip 28.69438pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K_{1}=K_{3}}$}}}}}}$}}}\par\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{KEqT})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 28.69438pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K_{2}=K_{1}}$}}}\vbox{}}}\over\hbox{\hskip 28.69438pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K_{1}=K_{2}}$}}}}}}$}}}\\[5.0pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{KEq}\Pi)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 79.36375pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\sigma::\mathsf{type}\quad\Psi,x{:}\tau\vdash K_{1}=K_{2}}$}}}\vbox{}}}\over\hbox{\hskip 59.17458pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\Pi x{:}\tau.K_{1}=\Pi x{:}\sigma.K_{2}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{KEqK}\Pi)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 77.15263pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K_{1}=K_{3}\quad\Psi,t{::}K_{1}\vdash K_{2}=K_{4}}$}}}\vbox{}}}\over\hbox{\hskip 69.05537pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\Pi t::K_{1}.K_{2}=\Pi t::K_{3}.K_{4}}$}}}}}}$}}}\end{array}

0.A.7 Definitional Equality for (Functional) Types

(TEqR)     Ψτ::type      Ψτ=τ::type (TEqT)           Ψτ1=τ2::typeΨτ2=τ3::type      Ψτ1=τ3::type (TEqS)       Ψσ=τ::type       Ψτ=σ::type (TEqΠ)           Ψτ=τ::typeΨ,x:τσ=σ::type          ΨΠx:τ.σ=Πx:τ.σ::type (TEqλ)           Ψτ=τ::typeΨ,x:τσ=σ::K           Ψλx:τ.σ=λx:τ.σ::Πx:τ.K (TEqApp)            Ψτ=σ::Πx:τ.KΨM=N:τ         ΨτM=σN::K{/Mx} (TEqβ)        Ψ,x:τσ::KΨM:τ            Ψ(λx:τ.σ)M=σ{/Mx}::K{/Mx} (TEqη)          Ψσ::Πx:τ.Kxfv(σ)         Ψλx:τ.σx=σ::Πx:τ.K (TEq{})                  i,j.ΨAi=Bi::stypeΨCj=Dj::stypeΨA=B::stype           Ψ{¯:ujCj;¯:diAic:A}={¯:ujDj;¯:diBic:B}::type (TEqTλ)           ΨK1=K2Ψ,t::K1τ=σ::K3            Ψλt::K1.τ=λt::K2.σ::Πx:K1.K3 (TEqTApp)             Ψτ1=σ1::Πt::K1.K2Ψτ2=σ2:K1         Ψτ1τ2=σ1σ2::K2{/τ2t} (TEqTβ)         Ψ,t::Kτ::KΨσ::K           Ψ(λt::K.τ)σ=τ{/σt}::K{/σt} (TEqConv)         Ψτ=σ::KΨK=K      Ψτ=σ::K \begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqR})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 24.99126pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau::\mathsf{type}}$}}}\vbox{}}}\over\hbox{\hskip 33.84364pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\tau::\mathsf{type}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqT})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 76.10413pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau_{1}=\tau_{2}::\mathsf{type}\quad\Psi\vdash\tau_{2}=\tau_{3}::\mathsf{type}}$}}}\vbox{}}}\over\hbox{\hskip 35.55206pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau_{1}=\tau_{3}::\mathsf{type}}$}}}}}}$}}}\\[5.0pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqS})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 34.51494pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\sigma=\tau::\mathsf{type}}$}}}\vbox{}}}\over\hbox{\hskip 34.51494pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\sigma::\mathsf{type}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEq}\Pi)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 85.21216pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\tau^{\prime}::\mathsf{type}\quad\Psi,x{:}\tau\vdash\sigma=\sigma^{\prime}::\mathsf{type}}$}}}\vbox{}}}\over\hbox{\hskip 66.68959pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\Pi x{:}\tau.\sigma=\Pi x{:}\tau^{\prime}.\sigma^{\prime}::\mathsf{type}}$}}}}}}$}}}\\[5.0pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEq}\lambda)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 82.2885pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\tau^{\prime}::\mathsf{type}\quad\Psi,x{:}\tau\vdash\sigma=\sigma^{\prime}::K}$}}}\vbox{}}}\over\hbox{\hskip 77.00372pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.\sigma=\lambda x{:}\tau^{\prime}.\sigma^{\prime}::\Pi x{:}\tau.K}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqApp})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 87.27852pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\sigma::\Pi x{:}\tau^{\prime}.K\quad\Psi\vdash M=N:\tau^{\prime}}$}}}\vbox{}}}\over\hbox{\hskip 60.9141pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau\,M=\sigma\,N::K\{M/x\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEq}\beta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 60.36371pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi,x{:}\tau\vdash\sigma::K\quad\Psi\vdash M:\tau}$}}}\vbox{}}}\over\hbox{\hskip 91.84749pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash(\lambda x{:}\tau.\sigma)\,M=\sigma\{M/x\}::K\{M/x\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEq}\eta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 67.69713pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\sigma::\Pi x{:}\tau.K\quad x\not\in fv(\sigma)}$}}}\vbox{}}}\over\hbox{\hskip 64.92908pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.\sigma\,x=\sigma::\Pi x{:}\tau.K}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEq}\{\})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 145.96251pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\forall i,j.\quad\Psi\vdash A_{i}=B_{i}::\mathsf{stype}\quad\Psi\vdash C_{j}=D_{j}::\mathsf{stype}\quad\Psi\vdash A=B::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 81.59296pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\{\overline{u_{j}{:}C_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}=\{\overline{u_{j}{:}D_{j}};\overline{d_{i}{:}B_{i}}\vdash c{:}B\}::\mathsf{type}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqT}\lambda)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 82.29259pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K_{1}=K_{2}\quad\Psi,t{::}K_{1}\vdash\tau=\sigma::K_{3}}$}}}\vbox{}}}\over\hbox{\hskip 92.37236pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda t{::}K_{1}.\tau=\lambda t{::}K_{2}.\sigma::\Pi x{:}K_{1}.K_{3}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqTApp})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 94.87712pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau_{1}=\sigma_{1}::\Pi t{::}K_{1}.K_{2}\quad\Psi\vdash\tau_{2}=\sigma_{2}:K_{1}}$}}}\vbox{}}}\over\hbox{\hskip 61.58385pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau_{1}\,\tau_{2}=\sigma_{1}\,\sigma_{2}::K_{2}\{\tau_{2}/t\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqT}\beta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 65.11893pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi,t{::}K\vdash\tau::K^{\prime}\quad\Psi\vdash\sigma::K}$}}}\vbox{}}}\over\hbox{\hskip 85.49799pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash(\lambda t{::}K.\tau)\,\sigma=\tau\{\sigma/t\}::K^{\prime}\{\sigma/t\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TEqConv})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 63.59117pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\sigma::K\quad\Psi\vdash K=K^{\prime}}$}}}\vbox{}}}\over\hbox{\hskip 32.99405pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\sigma::K^{\prime}}$}}}}}}$}}}\end{array}

0.A.8 Definitional Equality for Session Types

(STEqR)      ΨA::stype       ΨA=A::stype (STEqS)       ΨB=A::stype       ΨA=B::stype (STEqT)           ΨA=B::stypeΨB=C::stype      ΨA=C::stype (!STEq)       ΨA=B::stype       Ψ!A=!B::stype (STEq)           ΨA=C::stypeΨB=D::stype         ΨAB=CD::stype (STEq)           ΨA=C::stypeΨB=D::stype          ΨAB=CD::stype (STEq)            Ψτ=τ::typeΨ,x:τA=B::stype         Ψx:τ.A=x:τ.B::stype (STEq)            Ψτ=τ::typeΨ,x:τA=B::stype         Ψx:τ.A=x:τ.B::stype (STEq&)        i.ΨAi=Bi::stype        Ψ&{¯:liAi}=&{¯:liBi}::stype (STEq)        i.ΨAi=Bi::stype        Ψ{¯:liAi}={¯:liBi}::stype (STEqλ)            Ψτ=τ::typeΨ,x:τA=B::K           Ψλx:τ.A=λx:τ.B::Πx:τ.K (STEqApp)            ΨA=B::Πx:τ.KΨM=N:τ         ΨAM=BN::K{/Mx} (STEqβ)         Ψ,x:τA::KΨM:τ            Ψ(λx:τ.A)M=A{/Mx}::K{/Mx} (STEqη)           ΨA::Πx:τ.Kxfv(A)          Ψλx:τ.Ax=A::Πx:τ.K (STEqTλ)           ΨK1=K2Ψ,t::K1A=B::K3            Ψλt::K1.A=λt::K2.B::Πx:K1.K3 (STEqTApp)             ΨA=C::Πt::K1.K2ΨB=D:K1         ΨAB=CD::K2{/Bt} (STEqTβ)          Ψ,t::KA::KΨB::K            Ψ(λt::K.A)B=A{/Bt}::K{/Bt} (STEqConv)          ΨA=B::KΨK=K      ΨA=B::K \begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqR})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 28.47217pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 38.88878pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=A::\mathsf{stype}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqS})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 39.18217pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash B=A::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 39.18217pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=B::\mathsf{stype}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqT})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 83.5456pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=B::\mathsf{stype}\quad\Psi\vdash B=C::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 40.88596pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=C::s\mathsf{type}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}{!})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 39.18217pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=B::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 41.95996pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash{!}A={!}B::\mathsf{stype}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\!\multimap)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 83.78067pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=C::\mathsf{stype}\quad\Psi\vdash B=D::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 64.05846pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A\multimap B=C\multimap D::\mathsf{stype}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\otimes)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 83.78067pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=C::\mathsf{stype}\quad\Psi\vdash B=D::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 59.61403pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A\otimes B=C\otimes D::\mathsf{stype}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\forall)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 89.19418pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\tau^{\prime}::\mathsf{type}\quad\Psi,x{:}\tau\vdash A=B::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 70.3938pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\forall x{:}\tau.A=\forall x{:}\tau^{\prime}.B::\mathsf{stype}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\exists)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 89.19418pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\tau^{\prime}::\mathsf{type}\quad\Psi,x{:}\tau\vdash A=B::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 70.3938pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\exists x{:}\tau.A=\exists x{:}\tau^{\prime}.B::\mathsf{stype}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\mathbin{\binampersand})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 47.28963pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\forall i.\Psi\vdash A_{i}=B_{i}::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 51.3889pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\mathbin{\binampersand}\{\overline{l_{i}{:}A_{i}}\}=\mathbin{\binampersand}\{\overline{l_{i}{:}B_{i}}\}::\mathsf{stype}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\oplus)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 47.28963pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\forall i.\Psi\vdash A_{i}=B_{i}::\mathsf{stype}}$}}}\vbox{}}}\over\hbox{\hskip 53.61107pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\oplus\{\overline{l_{i}{:}A_{i}}\}=\oplus\{\overline{l_{i}{:}B_{i}}\}::\mathsf{stype}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\lambda)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 84.35385pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\tau=\tau^{\prime}::\mathsf{type}\quad\Psi,x{:}\tau\vdash A=B::K}$}}}\vbox{}}}\over\hbox{\hskip 79.06909pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.A=\lambda x{:}\tau^{\prime}.B::\Pi x{:}\tau.K}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqApp})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 86.94577pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=B::\Pi x{:}\tau.K\quad\Psi\vdash M=N:\tau}$}}}\vbox{}}}\over\hbox{\hskip 63.66467pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A\,M=B\,N::K\{M/x\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\beta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 61.25665pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi,x{:}\tau\vdash A::K\quad\Psi\vdash M:\tau}$}}}\vbox{}}}\over\hbox{\hskip 93.63338pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash(\lambda x{:}\tau.A)\,M=A\{M/x\}::K\{M/x\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEq}\eta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 69.48302pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A::\Pi x{:}\tau.K\quad x\not\in fv(A)}$}}}\vbox{}}}\over\hbox{\hskip 66.71497pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.A\,x=A::\Pi x{:}\tau.K}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqT}\lambda)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 85.04317pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash K_{1}=K_{2}\quad\Psi,t{::}K_{1}\vdash A=B::K_{3}}$}}}\vbox{}}}\over\hbox{\hskip 95.12294pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda t{::}K_{1}.A=\lambda t{::}K_{2}.B::\Pi x{:}K_{1}.K_{3}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqTApp})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 97.37775pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=C::\Pi t{::}K_{1}.K_{2}\quad\Psi\vdash B=D:K_{1}}$}}}\vbox{}}}\over\hbox{\hskip 62.03241pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A\,B=C\,D::K_{2}\{B/t\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqT}\beta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 67.8695pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi,t{::}K\vdash A::K^{\prime}\quad\Psi\vdash B::K}$}}}\vbox{}}}\over\hbox{\hskip 92.18549pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash(\lambda t{::}K.A)\,B=A\{B/t\}::K^{\prime}\{B/t\}}$}}}}}}$}}}\quad\par\par{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{STEqConv})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 66.34175pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=B::K\quad\Psi\vdash K=K^{\prime}}$}}}\vbox{}}}\over\hbox{\hskip 35.74463pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash A=B::K^{\prime}}$}}}}}}$}}}\end{array}

0.A.9 Definitional Equality for λ\lambda-Terms

(TMEqR)     ΨM:τ      Ψ=MM:τ (TMEqS)      Ψ=NM:τ      Ψ=MN:τ (TMEqT)           Ψ=MN:τΨ=NN:τ      Ψ=MN:τ (TMEqVar)      Ψx:τΨ      Ψ=xx:τ (TMEqλ)             Ψλx:τ.M:Πx:τ.σΨλx:τ.N:Πx:τ.σΨΠx:τ.σ=Πx:τ.σ::typeΨ,x:τM=N:σ           Ψλx:τ.M=λx:τ.N:Πx:τ.σ (TMEqApp)            ΨM=M:Πx:τ.σΨN=N:τ         Ψ=MNMN:σ{/Nx} (TMEqβ)            [Ψτ::type]Ψ,x:τM:σΨN:τ            Ψ=(λx:τ.M)NM{/Nx}:σ{/Nx} (TMEqη)           ΨM:Πx:τ.σxfv(M)          Ψλx:τ.Mx=M:Πx:τ.σ (TMEq{}η)       ΨM:{¯:ujBj;¯:diAic:A}                Ψ={c(yM;¯uj;¯di;[yc])¯uj;¯di}M:{¯:ujBj;¯:diAic:A} (TMEq{})                [i,j.ΨBj::stypeΨAi::stype]Ψ;¯:ujBj;¯:diAiP=Q::c:A               Ψ={cP¯uj;¯di}{cQ¯uj;¯di}:{¯:ujBj;¯:diAic:A} (TMEqConv)          ΨM=N:τΨτ=σ::type      Ψ=MN:σ \begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEqR})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 21.47037pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\tau}$}}}\vbox{}}}\over\hbox{\hskip 33.5328pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M=M:\tau}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEqS})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 32.69946pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash N=M:\tau}$}}}\vbox{}}}\over\hbox{\hskip 32.69946pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M=N:\tau}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEqT})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 69.59344pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M=N^{\prime}:\tau\quad\Psi\vdash N^{\prime}=N:\tau}$}}}\vbox{}}}\over\hbox{\hskip 32.69946pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M=N:\tau}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEqVar})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 32.54329pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\quad x{:}\tau\in\Psi}$}}}\vbox{}}}\over\hbox{\hskip 28.45642pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash x=x:\tau}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\lambda)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 97.04874pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\begin{array}[]{c}\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma\quad\Psi\vdash\lambda x{:}\tau^{\prime}.N:\Pi x{:}\tau^{\prime}.\sigma^{\prime}\\ \Psi\vdash\Pi x{:}\tau.\sigma=\Pi x{:}\tau^{\prime}.\sigma^{\prime}::\mathsf{type}\quad\Psi,x{:}\tau\vdash M=N:\sigma\end{array}}$}}}\vbox{}}}\over\hbox{\hskip 78.09799pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.M=\lambda x{:}\tau^{\prime}.N:\Pi x{:}\tau.\sigma}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEqApp})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 86.00252pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M=M^{\prime}:\Pi x{:}\tau.\sigma\quad\Psi\vdash N=N^{\prime}:\tau}$}}}\vbox{}}}\over\hbox{\hskip 63.13805pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M\,N=M^{\prime}\,N^{\prime}:\sigma\{N/x\}}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\beta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 91.70218pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{[\Psi\vdash\tau::\mathsf{type}]\quad\Psi,x{:}\tau\vdash M:\sigma\quad\Psi\vdash N:\tau}$}}}\vbox{}}}\over\hbox{\hskip 91.0112pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash(\lambda x{:}\tau.M)\,N=M\{N/x\}:\sigma\{N/x\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\eta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 69.63867pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\Pi x{:}\tau.\sigma\quad x\not\in fv(M)}$}}}\vbox{}}}\over\hbox{\hskip 66.87062pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\lambda x{:}\tau.M\,x=M:\Pi x{:}\tau.\sigma}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\{\}\eta)$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 45.19833pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}}$}}}\vbox{}}}\over\hbox{\hskip 124.62756pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\{c\leftarrow(y\leftarrow M;\overline{u_{j}};\overline{d_{i}};[y\leftrightarrow c])\leftarrow\overline{u_{j}};\overline{d_{i}}\}=M:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEq}\{\})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 129.12569pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{[\forall i,j.\Psi\vdash B_{j}::\mathsf{stype}\quad\Psi\vdash A_{i}::\mathsf{stype}]\quad\Psi;\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash P=Q::c{:}A}$}}}\vbox{}}}\over\hbox{\hskip 109.76497pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}=\{c\leftarrow Q\leftarrow\overline{u_{j}};\overline{d_{i}}\}:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{TMEqConv})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 72.2144pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M=N:\tau\quad\Psi\vdash\tau=\sigma::\mathsf{type}}$}}}\vbox{}}}\over\hbox{\hskip 33.37076pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi\vdash M=N:\sigma}$}}}}}}$}}}\end{array}

0.A.10 Definitional Equality for Processes

(PEqRefl)       Ψ;Γ;ΔP::z:A        Ψ;Γ;ΔP=P::z:A (PEqS)        Ψ;Γ;ΔQ=P::z:A        Ψ;Γ;ΔP=Q::z:A (PEqT)              Ψ;Γ;ΔP=Q::z:AΨ;Γ;ΔQ=R::z:A        Ψ;Γ;ΔP=R::z:A   Ψ;Γ;ΔP::z:APQΨ;Γ;ΔQ::z:A   Ψ;Γ;ΔP=Q::z:A (𝖯𝖤𝗊η)   Ψ;Γ;d:x:τ.Ac(x).dx.[dc]=[dc]::c:x:τ.A (𝖯𝖤𝗊𝖢𝖢)   Ψ;Γ;ΔP::d:BΨ,x:τ;Γ;Δ,d:BQ::c:A   Ψ;Γ;Δ,Δ(νd)(Pc(x).Q)=c(x).(νd)(PQ)::c:x:τ.A (PEqR)                   Ψ;Γ;Δz(:xτ).P::z:x:τ.AΨ;Γ;Δz(:xτ).Q::z:x:τ.BΨx:τ.A=x:τ.B::stypeΨ,x:τ;Γ;ΔP=Q::z:A             Ψ;Γ;Δz(:xτ).P=z(:xτ).Q::z:x:τ.A (Other congruence, η and CC rules)\begin{array}[]{c}{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{PEqRefl})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 41.38005pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}A}$}}}\vbox{}}}\over\hbox{\hskip 51.95117pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P=P::z{:}A}$}}}}}}$}}}\quad{\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{PEqS})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 51.99944pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash Q=P::z{:}A}$}}}\vbox{}}}\over\hbox{\hskip 51.99944pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P=Q::z{:}A}$}}}}}}$}}}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{PEqT})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 108.92943pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P=Q::z{:}A\quad\Psi;\Gamma;\Delta\vdash Q=R::z{:}A}$}}}\vbox{}}}\over\hbox{\hskip 51.88173pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P=R::z{:}A}$}}}}}}$}}}\\[10.00002pt] {\hbox{$\displaystyle\displaystyle{\hbox{\hskip 103.16566pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::z{:}A\quad P\xrightarrow{}Q\quad\Psi;\Gamma;\Delta\vdash Q::z{:}A}$}}}\vbox{}}}\over\hbox{\hskip 51.99944pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P=Q::z{:}A}$}}}}}}$}}\\[10.00002pt] \raise 7.25pt\hbox{$\hbox{$\hbox{\small\sc$(\mathsf{PEq}\forall\eta)$}\,$}{\hbox{$\displaystyle\displaystyle{\hbox{}\over\hbox{\hskip 132.99133pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;d{:}\forall x{:}\tau.A\vdash c(x).d\langle x\rangle.[d\leftrightarrow c]=[d\leftrightarrow c]::c{:}\forall x{:}\tau.A}$}}}}}}$}}\hbox{}$}\\[10.00002pt] \raise 7.25pt\hbox{$\hbox{$\hbox{\small\sc$(\mathsf{PEqCC}\forall)$}\,$}{\hbox{$\displaystyle\displaystyle{\hbox{\hskip 113.36952pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash P::d{:}B\quad\Psi,x{:}\tau;\Gamma;\Delta^{\prime},d{:}B\vdash Q::c{:}A}$}}}\vbox{}}}\over\hbox{\hskip 135.27559pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta,\Delta^{\prime}\vdash({\boldsymbol{\nu}}d)(P\mid c(x).Q)=c(x).({\boldsymbol{\nu}}d)(P\mid Q)::c{:}\forall x{:}\tau.A}$}}}}}}$}}\hbox{}$}\\[10.00002pt] {\vbox{\hbox{\hbox{\small\sc$\displaystyle(\mathsf{PEq}{{\forall}\mathsf{R}})$}}\hbox{$\displaystyle\displaystyle{\hbox{\hskip 161.44868pt\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\begin{array}[]{c}\Psi;\Gamma;\Delta\vdash z(x{:}\tau).P::z{:}\forall x{:}\tau.A\quad\Psi;\Gamma;\Delta\vdash z(x{:}\tau^{\prime}).Q::z{:}\forall x{:}\tau^{\prime}.B\\ \Psi\vdash\forall x{:}\tau.A=\forall x{:}\tau^{\prime}.B::\mathsf{stype}\quad\Psi,x{:}\tau;\Gamma;\Delta\vdash P=Q::z{:}A\end{array}}$}}}\vbox{}}}\over\hbox{\hskip 103.90027pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{\Psi;\Gamma;\Delta\vdash z(x{:}\tau).P=z(x{:}\tau^{\prime}).Q::z{:}\forall x{:}\tau.A}$}}}}}}$}}}\\[10.00002pt] \mbox{(Other congruence, $\eta$ and CC rules)}\end{array}

Appendix 0.B Type Soundness

We use Ψ𝒥\Psi\vdash\mathcal{J} to signify any of the judgments ΨK\Psi\vdash K, ΨA::K\Psi\vdash A::K, Ψτ::K\Psi\vdash\tau::K and respective definitional equality judgments. We use Ψ;Γ;Δ𝒥\Psi;\Gamma;\Delta\vdash\mathcal{J} in a similar fashion.

Lemma 0.B.1 (Subderivation Properties)
  1. 1.

    Every derivation of Ψ𝒥\Psi\vdash\mathcal{J} has a proof of Ψ\Psi\vdash as a sub-proof.

  2. 2.

    Every derivation of Ψ,x:τ\Psi,x{:}\tau\vdash has a proof of Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} as a sub-proof.

  3. 3.

    Every derivation of Ψ,t::K\Psi,t{::}K\vdash has a proof of ΨK\Psi\vdash K as a sub-proof.

  4. 4.

    Every derivation of Ψ,x:K\Psi,x{:}K\vdash has a proof of ΨK\Psi\vdash K as a sub-proof.

  5. 5.

    If Ψτ::K\Psi\vdash\tau::K or ΨA::K\Psi\vdash A::K then ΨK\Psi\vdash K

  6. 6.

    If ΨM:τ\Psi\vdash M:\tau then Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}

  7. 7.

    If Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A then ΨA::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A::\mathsf{stype}

Proof

By induction on the given derivation.

Case:

Kind well-formedness

Straightforward by induction.

Case:

Functional type well-formedness

Straightforward by induction.

Case:

Session type well-formedness

Straightforward by induction.

Case:

Typing for terms

Straightforward by induction. Base-case is immediate.

Case:

Typing for processes

Straightforward by induction. Base-cases are immediate.

Case:

Kind equivalence

Straightforward, base case is reflexivity (from i.h. for well-formedness).

Case:

Type Equivalence

As above.

Case:

Session type equivalence

As above.

Lemma 0.B.2 (Weakening)

If Ψ\Psi\vdash and Ψ\Psi^{\prime}\vdash and ΨΨ\Psi\subseteq\Psi^{\prime} then:

  1. 1.

    Ψ𝒥\Psi\vdash\mathcal{J} implies Ψ𝒥\Psi^{\prime}\vdash\mathcal{J}

  2. 2.

    Ψ;Γ;Δ𝒥\Psi;\Gamma;\Delta\vdash\mathcal{J} implies Ψ;Γ;Δ𝒥\Psi^{\prime};\Gamma;\Delta\vdash\mathcal{J}

Proof

Straightforward induction on the given derivation.

See 2.1

Proof

By induction on the second given derivation. We show only some illustrative cases.

Case:

𝖳𝗒𝗉𝖾𝖠𝗉𝗉𝖶𝖥\mathsf{TypeAppWF}

Ψ,x:τ,Ψτ::Πy:σ.K\Psi,x{:}\tau,\Psi^{\prime}\vdash\tau^{\prime}::\Pi y{:}\sigma.K and Ψ,x:τ,ΨM:σ\Psi,x{:}\tau,\Psi^{\prime}\vdash M^{\prime}:\sigma by inversion
Ψ,Ψτ{M/x}::Πy:σ{M/x}.K{M/x}\Psi,\Psi^{\prime}\vdash\tau^{\prime}\{M/x\}::\Pi y{:}\sigma\{M/x\}.K\{M/x\} by i.h.
Ψ,ΨM{M/x}:σ{M/x}\Psi,\Psi^{\prime}\vdash M^{\prime}\{M/x\}:\sigma\{M/x\} by i.h.
Ψ,Ψτ{M/x}M{M/x}:K{M/y}{M/x}\Psi,\Psi^{\prime}\vdash\tau^{\prime}\{M/x\}\,M^{\prime}\{M/x\}:K\{M^{\prime}/y\}\{M/x\} by 𝖳𝗒𝗉𝖾𝖠𝗉𝗉𝖶𝖥\mathsf{TypeAppWF}
Case:

𝖪𝗂𝗇𝖽𝖢𝗈𝗇𝗏\mathsf{KindConv}

Ψ,x:τ,Ψτ::K\Psi,x{:}\tau,\Psi^{\prime}\vdash\tau::K and Ψ,x:τ,ΨK=K\Psi,x{:}\tau,\Psi^{\prime}\vdash K=K^{\prime} by inversion
Ψ,Ψτ{M/x}::K{M/x}\Psi,\Psi^{\prime}\vdash\tau\{M/x\}::K\{M/x\} by i.h.
Ψ,ΨK{M/x}=K{M/x}\Psi,\Psi^{\prime}\vdash K\{M/x\}=K^{\prime}\{M/x\} by i.h.
Ψ,Ψτ{M/x}::K{M/x}\Psi,\Psi^{\prime}\vdash\tau\{M/x\}::K^{\prime}\{M/x\} by 𝖪𝗂𝗇𝖽𝖢𝗈𝗇𝗏\mathsf{KindConv}
Case:

𝖵𝖺𝗋\mathsf{Var}

Subcase: x=yx=y
ΨM:τ\Psi\vdash M:\tau by assumption
Ψ,Ψ{M/x}M:τ\Psi,\Psi^{\prime}\{M/x\}\vdash M:\tau by weakening
Subcase: xyx\neq y
Ψ,x:τ,Ψ,y:τy:τ\Psi,x{:}\tau,\Psi^{\prime},y{:}\tau^{\prime}\vdash y{:}\tau^{\prime} by weakening and 𝖵𝖺𝗋\mathsf{Var}
Case:

𝖳𝖤𝗊β\mathsf{TEq}\beta

Ψ,x:τ,Ψ,y:τσ::K\Psi,x{:}\tau,\Psi^{\prime},y{:}\tau^{\prime}\vdash\sigma::K and Ψ,x:τ,ΨM:τ\Psi,x{:}\tau,\Psi^{\prime}\vdash M^{\prime}:\tau^{\prime} by inversion
Ψ,Ψ{M/x},y:τ{M/x}σ{M/x}::K{M/x}\Psi,\Psi^{\prime}\{M/x\},y{:}\tau^{\prime}\{M/x\}\vdash\sigma\{M/x\}::K\{M/x\} by i.h.
Ψ,Ψ{M/x}M{M/x}:τ{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash M^{\prime}\{M/x\}:\tau^{\prime}\{M/x\} by i.h.
Ψ,Ψ{M/x}(λy:τ{M/x}.σ{M/x})M{M/x}=σ{M/x}{M{M/x}/y}::K{M/x}{M{M/x}/y}\Psi,\Psi^{\prime}\{M/x\}\vdash(\lambda y{:}\tau^{\prime}\{M/x\}.\sigma\{M/x\})\,M^{\prime}\{M/x\}=\sigma\{M/x\}\{M^{\prime}\{M/x\}/y\}::K\{M^{\prime}/x\}\{M\{M/x\}/y\}
by 𝖳𝖤𝗊β\mathsf{TEq}\beta
Case:

𝖳𝖤𝗊η\mathsf{TEq}\eta

Ψ,x:τ,Ψσ::Πy:τ.K\Psi,x{:}\tau,\Psi^{\prime}\vdash\sigma::\Pi y{:}\tau^{\prime}.K and yfv(σ)y\not\in fv(\sigma) by inversion
Ψ,Ψ{M/x}σ{M/x}::Πy:τ{M/x}.K{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\sigma\{M/x\}::\Pi y{:}\tau^{\prime}\{M/x\}.K\{M/x\} by i.h
Ψ,Ψ{M/}λy:τ{M/x}.(σ{M/x}y)=σ{M/x}::Πy:τ{M/x}.K{M/x}\Psi,\Psi^{\prime}\{M/\}\vdash\lambda y{:}\tau^{\prime}\{M/x\}.(\sigma\{M/x\}\,y)=\sigma\{M/x\}::\Pi y{:}\tau^{\prime}\{M/x\}.K\{M/x\} by 𝖳𝖤𝗊η\mathsf{TEq}\eta
Case:

𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}

Ψ,x:τ,Ψ;Γ;ΔP::z:A\Psi,x{:}\tau,\Psi^{\prime};\Gamma;\Delta\vdash P::z{:}A, PQP\xrightarrow{}^{*}Q and Ψ,x:τ,Ψ;Γ;ΔQ::z:A\Psi,x{:}\tau,\Psi^{\prime};\Gamma;\Delta\vdash Q::z{:}A by inversion
Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}P{M/x}::z:A{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}::z{:}A\{M/x\} by i.h.
Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}Q{M/x}::z:A{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash Q\{M/x\}::z{:}A\{M/x\} by i.h.
P{M/x}Q{M/x}P\{M/x\}\xrightarrow{}^{*}Q\{M/x\} by compatibility of reduction with substitution
Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}P{M/x}=Q{M/x}::z:A{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=Q\{M/x\}::z{:}A\{M/x\} by 𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}
Lemma 0.B.3 (Type Substitution)
  1. 1.

    If Ψτ::K\Psi\vdash\tau::K and Ψ,t::K,Ψ𝒥\Psi,t{::}K,\Psi^{\prime}\vdash\mathcal{J} then Ψ,Ψ{τ/t}𝒥{τ/t}\Psi,\Psi^{\prime}\{\tau/t\}\vdash\mathcal{J}\{\tau/t\};

  2. 2.

    If Ψτ::K\Psi\vdash\tau::K and Ψ,t::K,Ψ;Γ;Δ𝒥\Psi,t{::}K,\Psi^{\prime};\Gamma;\Delta\vdash\mathcal{J} then Ψ,Ψ{τ/t};Γ{τ/t};Δ{τ/t}𝒥{τ/t}\Psi,\Psi^{\prime}\{\tau/t\};\Gamma\{\tau/t\};\Delta\{\tau/t\}\vdash\mathcal{J}\{\tau/t\}

  3. 3.

    If ΨA::K\Psi\vdash A::K and Ψ,t::K,Ψ𝒥\Psi,t{::}K,\Psi^{\prime}\vdash\mathcal{J} then Ψ,Ψ{A/t}𝒥{A/t}\Psi,\Psi^{\prime}\{A/t\}\vdash\mathcal{J}\{A/t\};

  4. 4.

    If ΨA::K\Psi\vdash A::K and Ψ,t::K,Ψ;Γ;Δ𝒥\Psi,t{::}K,\Psi^{\prime};\Gamma;\Delta\vdash\mathcal{J} then Ψ,Ψ{A/t};Γ{A/t};Δ{A/t}\Psi,\Psi^{\prime}\{A/t\};\Gamma\{A/t\};\Delta\{A/t\}

Lemma 0.B.4 (Context Conversion)

Let Ψ,x:τ\Psi,x{:}\tau\vdash and Ψτ::K\Psi\vdash\tau^{\prime}::K. If Ψ,x:τ𝒥\Psi,x{:}\tau\vdash\mathcal{J} and Ψτ=τ::K\Psi\vdash\tau=\tau^{\prime}::K then Ψ,x:τ𝒥\Psi,x{:}\tau^{\prime}\vdash\mathcal{J}.

Proof

Straightforward from the properties above.

Ψ,x:τx:τ\Psi,x{:}\tau^{\prime}\vdash x{:}\tau^{\prime} by variable rule
Ψτ=τ::K\Psi\vdash\tau^{\prime}=\tau::K by symmetry
Ψ,x:τx:τ\Psi,x{:}\tau^{\prime}\vdash x{:}\tau by conversion
Ψ,x:τα{x/x}\Psi,x^{\prime}{:}\tau\vdash\alpha\{x^{\prime}/x\} renaming assumption
Ψ,x:τ,x:τα{x/x}\Psi,x{:}\tau^{\prime},x^{\prime}{:}\tau\vdash\alpha\{x^{\prime}/x\} by weakening
Ψ,x:τα{x/x}{x/x}\Psi,x{:}\tau^{\prime}\vdash\alpha\{x^{\prime}/x\}\{x/x^{\prime}\} by substitution
Ψ,x:τα\Psi,x{:}\tau^{\prime}\vdash\alpha by definition
Lemma 0.B.5 (Context Conversion – Processes)

Let Ψ,x:τ;Δ\Psi,x{:}\tau;\Delta\vdash, Ψ,x:τ;Γ\Psi,x{:}\tau;\Gamma\vdash and Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}. If Ψ,x:τ;Γ;Δ𝒥\Psi,x{:}\tau;\Gamma;\Delta\vdash\mathcal{J} and Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type} then Ψ,x:τ;Γ;Δ𝒥\Psi,x{:}\tau^{\prime};\Gamma;\Delta\vdash\mathcal{J}

Proof

Straightforward by Lemma 0.B.4.

Lemma 0.B.6 (Context Conversion – Types)

Let Ψ,t::K\Psi,t{::}K\vdash and ΨK\Psi\vdash K^{\prime}. If Ψ,t::K𝒥\Psi,t{::}K\vdash\mathcal{J} and ΨK=K\Psi\vdash K=K^{\prime} then Ψ,t::K𝒥\Psi,t{::}K^{\prime}\vdash\mathcal{J}

Proof

Identical to Lemma 0.B.4

Lemma 0.B.7 (Functionality of Typing)

Assume ΨM=N:τ\Psi\vdash M=N:\tau, ΨM:τ\Psi\vdash M:\tau and ΨN:τ\Psi\vdash N:\tau:

  1. 1.

    If Ψ,x:τ,ΨM:τ\Psi,x{:}\tau,\Psi^{\prime}\vdash M^{\prime}:\tau^{\prime} then Ψ,Ψ{M/x}M{M/x}=M{N/x}:τ{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash M^{\prime}\{M/x\}=M^{\prime}\{N/x\}:\tau^{\prime}\{M/x\}

  2. 2.

    If Ψ,x:τ,Ψτ::K\Psi,x{:}\tau,\Psi^{\prime}\vdash\tau^{\prime}::K then Ψ,Ψ{M/x}τ{M/x}=τ{N/x}::K{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\tau^{\prime}\{M/x\}=\tau^{\prime}\{N/x\}::K\{M/x\}

  3. 3.

    If Ψ,x:τ,ΨA::K\Psi,x{:}\tau,\Psi^{\prime}\vdash A::K then Ψ,Ψ{M/x}A{M/x}=A{N/x}::K{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash A\{M/x\}=A\{N/x\}::K\{M/x\}

  4. 4.

    If Ψ,x:τ,Ψ;Γ;ΔP::z:A\Psi,x{:}\tau,\Psi^{\prime};\Gamma;\Delta\vdash P::z{:}A then Ψ;Ψ{M/x};Γ{M/x};Δ{M/x}P{M/x}=P{N/x}::z:A{N/x}\Psi;\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=P\{N/x\}::z{:}A\{N/x\}

  5. 5.

    If Ψ,x:τ,ΨK\Psi,x{:}\tau,\Psi^{\prime}\vdash K then Ψ,Ψ{M/x}K{M/x}=K{N/x}\Psi,\Psi^{\prime}\{M/x\}\vdash K\{M/x\}=K\{N/x\}

Proof

By induction on the given typing derivation.

Case:

Ψ,x:τ,Ψx:τ\Psi,x{:}\tau,\Psi^{\prime}\vdash x{:}\tau by variable rule

ΨM=N:τ\Psi\vdash M=N:\tau by assumption
Ψ,Ψ{M/x}M=N:τ\Psi,\Psi^{\prime}\{M/x\}\vdash M=N:\tau by weakening
Case:

Ψ,x:τ,Ψy:σ\Psi,x{:}\tau,\Psi^{\prime}\vdash y{:}\sigma with y:σΨy{:}\sigma\in\Psi or Ψ\Psi^{\prime}

y:σΨy:\sigma\in\Psi or y:σ{M/x}Ψ{M/x}y{:}\sigma\{M/x\}\in\Psi^{\prime}\{M/x\} by definition
Ψ,Ψ{M/x}y=y:σ{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash y=y:\sigma\{M/x\} by reflexivity
Case:

Ψ,x:τ,ΨM0N0:σ0{N0/y}\Psi,x{:}\tau,\Psi^{\prime}\vdash M_{0}\,N_{0}:\sigma_{0}\{N_{0}/y\} from ΠE\Pi E

Ψ,Ψ{M/x}M0{M/x}=M0{N/x}:Πy:σ1{M/x}.σ0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash M_{0}\{M/x\}=M_{0}\{N/x\}:\Pi y{:}\sigma_{1}\{M/x\}.\sigma_{0}\{M/x\} by i.h.
Ψ,Ψ{M/x}N0{M/x}=N0{N/x}:σ1{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash N_{0}\{M/x\}=N_{0}\{N/x\}:\sigma_{1}\{M/x\} by i.h.
Ψ,Ψ{M/x}M0{M/x}N0{M/x}=M0{N/x}N0{N/x}:(σ0{M/x}){(N0{M/x})/y}\Psi,\Psi^{\prime}\{M/x\}\vdash M_{0}\{M/x\}\,N_{0}\{M/x\}=M_{0}\{N/x\}\,N_{0}\{N/x\}:(\sigma_{0}\{M/x\})\{(N_{0}\{M/x\})/y\}
by 𝖳𝖬𝖤𝗊𝖠𝗉𝗉\mathsf{TMEqApp} rule
Case:

Ψ,x:τ,Ψλy:τ0.M0:Πy:τ0.τ1\Psi,x{:}\tau,\Psi^{\prime}\vdash\lambda y{:}\tau_{0}.M_{0}:\Pi y{:}\tau_{0}.\tau_{1} by ΠI\Pi I rule

Ψ,Ψ{M/x}τ0{M/x}=τ0{N/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}\{N/x\}::\mathsf{type} by i.h.
Ψ,Ψ{M/x},y:τ0{M/x}M0{M/x}=M0{N/x}:τ1{M/x}\Psi,\Psi^{\prime}\{M/x\},y{:}\tau_{0}\{M/x\}\vdash M_{0}\{M/x\}=M_{0}\{N/x\}:\tau_{1}\{M/x\} by i.h.
Ψ,Ψ{M/x}τ0{M/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}::\mathsf{type} by substitution lemma
Ψ,Ψ{M/x}τ0{M/x}=τ0{M/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}\{M/x\}::\mathsf{type} by reflexivity
Ψ,Ψ{M/x}τ0{N/x}=τ0{M/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{N/x\}=\tau_{0}\{M/x\}::\mathsf{type} by symmetry
Ψ,Ψ{M/x}λy:τ0{M/x}.M0{M/x}=λy:τ0{N/x}.M0{N/x}:Πy:τ0{M/x}.τ1{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\lambda y{:}\tau_{0}\{M/x\}.M_{0}\{M/x\}=\lambda y{:}\tau_{0}\{N/x\}.M_{0}\{N/x\}:\Pi y{:}\tau_{0}\{M/x\}.\tau_{1}\{M/x\}
by 𝖳𝖬𝖤𝗊λ\mathsf{TMEq}\lambda rule
Case:

Ψ,x:τ,Ψ{cPuj¯;di¯}:{Γ;Δc:A}\Psi,x{:}\tau,\Psi^{\prime}\vdash\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}:\{\Gamma;\Delta\vdash c{:}A\} by {}I\{\}I

Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}P{M/x}=P{N/x}::c:A{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=P\{N/x\}::c{:}A\{M/x\} by i.h.
Ψ,Ψ{M/x}Aj{M/x}¯::𝗌𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\overline{A_{j}\{M/x\}}::\mathsf{stype} by substitution lemma
Ψ,Ψ{M/x}Bi{M/x}¯::𝗌𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\overline{B_{i}\{M/x\}}::\mathsf{stype} by substitution lemma
Conclude by 𝖳𝖬𝖤𝗊{}\mathsf{TMEq}\{\} rule
Case:

Ψ,x:τ,ΨM0:τ0\Psi,x{:}\tau,\Psi^{\prime}\vdash M_{0}:\tau_{0} by conversion rule

Ψ,Ψ{M/x}M0{M/x}=M0{N/x}:τ0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash M_{0}\{M/x\}=M_{0}\{N/x\}:\tau_{0}^{\prime}\{M/x\} by i.h.
Ψ,Ψ{M/x}τ0{M/x}=τ0{M/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}^{\prime}\{M/x\}::\mathsf{type} by substitution lemma
Ψ,Ψ{M/x}M0{M/x}=M0{N/x}:τ0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash M_{0}\{M/x\}=M_{0}\{N/x\}:\tau_{0}\{M/x\} by conversion rule
Case:

Ψ,x:τ,ΨΠy:τ0.τ1::𝗍𝗒𝗉𝖾\Psi,x{:}\tau,\Psi^{\prime}\vdash\Pi y{:}\tau_{0}.\tau_{1}::\mathsf{type} by Π\Pi formation rule

Ψ,Ψ{M/x}τ0{M/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}::\mathsf{type} by substitution
Ψ,Ψ{M/x},y:τ0{M/x}τ1{M/x}=τ1{N/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\},y{:}\tau_{0}\{M/x\}\vdash\tau_{1}\{M/x\}=\tau_{1}\{N/x\}::\mathsf{type} by i.h.
Ψ,Ψ{M/x}τ0{M/x}=τ0{N/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}\{N/x\}::\mathsf{type} by i.h.
Ψ,Ψ{M/x}Πy:τ0{M/x}.τ1{M/x}=Πy:τ0{N/x}.τ1{N/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\Pi y{:}\tau_{0}\{M/x\}.\tau_{1}\{M/x\}=\Pi y{:}\tau_{0}\{N/x\}.\tau_{1}\{N/x\}::\mathsf{type}
by Π\Pi formation rule
Case:

Ψ,x:τ,Ψλy:τ0.σ::Πy:τ0.K0\Psi,x{:}\tau,\Psi^{\prime}\vdash\lambda y{:}\tau_{0}.\sigma::\Pi y{:}\tau_{0}.K_{0} by λ\lambda formation rule

Ψ,Ψ{M/x}τ0{M/x}=τ0{N/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}\{N/x\}::\mathsf{type} by i.h.
Ψ,Ψ{M/x},y:τ0{M/x}σ{M/x}=σ{N/x}::K0{M/x}\Psi,\Psi^{\prime}\{M/x\},y{:}\tau_{0}\{M/x\}\vdash\sigma\{M/x\}=\sigma\{N/x\}::K_{0}\{M/x\} by i.h.
Ψ,Ψ{M/x}λy:τ0{M/x}.σ{M/x}=λy:τ0{N/x}.σ{N/x}::Πy:τ0{M/x}.K0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\lambda y{:}\tau_{0}\{M/x\}.\sigma\{M/x\}=\lambda y{:}\tau_{0}\{N/x\}.\sigma\{N/x\}::\Pi y{:}\tau_{0}\{M/x\}.K_{0}\{M/x\}
by λ\lambda formation rule
Case:

Ψ,x:τ,Ψτ0M0::K0{M/y}\Psi,x{:}\tau,\Psi^{\prime}\vdash\tau_{0}\,M_{0}::K_{0}\{M/y\} by type application formation rule

Ψ,Ψ{M/x}τ0{M/x}=τ0{N/x}::Πy:τ1{M/x}.K0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}\{N/x\}::\Pi y{:}\tau_{1}\{M/x\}.K_{0}\{M/x\} by i.h.
Ψ,Ψ{M/x}M0{M/x}=M0{N/x}:τ1{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash M_{0}\{M/x\}=M_{0}\{N/x\}:\tau_{1}\{M/x\} by i.h.
Ψ,Ψ{M/x}τ0{M/x}M0{M/x}=τ0{M/x}M0{M/x}::K0{M0/y}{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}\,M_{0}\{M/x\}=\tau_{0}\{M/x\}\,M_{0}\{M/x\}::K_{0}\{M_{0}/y\}\{M/x\}
by type app. formation rule and def. of substitution
Case:

{}\{\} formation rule

Straightforward by i.h.
Case:

Ψ,x:τ,Ψτ0::K0\Psi,x{:}\tau,\Psi^{\prime}\vdash\tau_{0}::K_{0} by conversion rule

Ψ,Ψ{M/x}τ0{M/x}=τ0{N/x}::K1{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}\{N/x\}::K_{1}\{M/x\} by i.h.
Ψ,Ψ{M/x}K1{M/x}=K0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash K_{1}\{M/x\}=K_{0}\{M/x\} by substitution lemma
Ψ,Ψ{M/x}τ0{M/x}=τ0{N/x}::K0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash\tau_{0}\{M/x\}=\tau_{0}\{N/x\}::K_{0}\{M/x\} by conversion
Case:

Ψ,x:τ,Ψ;Γ;ΔcM0.P0::c:y:τ0.A0\Psi,x{:}\tau,\Psi^{\prime};\Gamma;\Delta\vdash c\langle M_{0}\rangle.P_{0}::c{:}\exists y{:}\tau_{0}.A_{0} by 𝖱{{\exists}\mathsf{R}}

Ψ,Ψ{M/x}M0{M/x}=M0{N/x}:τ0{M/x}\Psi,\Psi^{\prime}\{M/x\}\vdash M_{0}\{M/x\}=M_{0}\{N/x\}:\tau_{0}\{M/x\} by i.h.
Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}P0{M/x}=P0{N/x}::c:A0{M0/y}{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash P_{0}\{M/x\}=P_{0}\{N/x\}::c{:}A_{0}\{M_{0}/y\}\{M/x\}
by i.h.
Conclude by 𝖯𝖤𝗊𝖱\mathsf{PEq}{{\exists}\mathsf{R}}
Case:

Ψ,x:τ,Ψ;Γ;Δ,y:w:σ.Ay(w:σ).P0::z:C\Psi,x{:}\tau,\Psi^{\prime};\Gamma;\Delta,y{:}\exists w{:}\sigma.A\vdash y(w{:}\sigma).P_{0}::z{:}C by 𝖫{{\exists}\mathsf{L}}

Ψ,Ψ{M/x},w:σ{M/x};Γ{M/x};Δ{M/x},y:A{M/x}P0{M/x}=P0{N/x}::z:C{M/x}\Psi,\Psi^{\prime}\{M/x\},w{:}\sigma\{M/x\};\Gamma\{M/x\};\Delta\{M/x\},y{:}A\{M/x\}\vdash P_{0}\{M/x\}=P_{0}\{N/x\}::z{:}C\{M/x\}
by i.h.
Ψ,Ψ{M/x}σ{M/x}::𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash\sigma\{M/x\}::\mathsf{type} by substitution lemma
Conclude by 𝖯𝖤𝗊𝖫\mathsf{PEq}{{\exists}\mathsf{L}}
Case:

Ψ,x:τ,Ψ;Γ;ΔP::z:B\Psi,x{:}\tau,\Psi^{\prime};\Gamma;\Delta\vdash P::z{:}B by 𝖢𝗈𝗇𝗏𝖱{{\mathsf{Conv}}\mathsf{R}}

Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}P{M/x}=P{N/x}::z:A{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=P\{N/x\}::z{:}A\{M/x\} by i.h.
Ψ,Ψ{M/x}A{M/x}=B{M/x}::𝗌𝗍𝗒𝗉𝖾\Psi,\Psi^{\prime}\{M/x\}\vdash A\{M/x\}=B\{M/x\}::\mathsf{stype} by substitution lemma
Ψ,Ψ{M/x};Γ{M/x};Δ{M/x}P{M/x}=P{N/x}::z:B{M/x}\Psi,\Psi^{\prime}\{M/x\};\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=P\{N/x\}::z{:}B\{M/x\}
by conversion

Remaining cases follow similar patterns, relying on the inductive hypothesis and the substitution lemmata.

We omit the analogue functionality property for type substitution.

Lemma 0.B.8 (Inversion for Products)
  1. 1.

    If ΨΠx:τ.σ::K\Psi\vdash\Pi x{:}\tau.\sigma::K then Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma::\mathsf{type}

  2. 2.

    If ΨΠx:τ.K\Psi\vdash\Pi x{:}\tau.K then Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τK\Psi,x{:}\tau\vdash K

Proof

(1)(1) follows straightforwardly by induction on the given derivation. (2)(2) is immediate by inversion.

Lemma 0.B.9 (Inversion for \forall\exists)
  1. 1.

    If Ψx:τ.A::K\Psi\vdash\forall x{:}\tau.A::K then Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τA::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash A::\mathsf{stype}

  2. 2.

    If Ψx:τ.A:K\Psi\vdash\exists x{:}\tau.A:K then Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τA::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash A::\mathsf{stype}

Proof

Straightforwardly by induction on the given derivation.

See 2.3

Proof

By simultaneous induction on the given derivation.

Case:

𝖳𝖬𝖤𝗊𝖱\mathsf{TMEqR}

ΨM:τ\Psi\vdash M:\tau by inversion
Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} by subderivation lemma
Case:

𝖳𝖬𝖤𝗊𝖲\mathsf{TMEqS} and 𝖳𝖬𝖤𝗊𝖳\mathsf{TMEqT}

Immediate by i.h.
Case:

𝖳𝖬𝖤𝗊λ\mathsf{TMEq}\lambda

Ψλx:τ.M:Πx:τ.σ\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma, Ψλx:τ.N:Πx:τ.σ\Psi\vdash\lambda x{:}\tau^{\prime}.N:\Pi x{:}\tau^{\prime}.\sigma^{\prime}, ΨΠx:τ.σ=Πx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma=\Pi x{:}\tau^{\prime}.\sigma^{\prime}::\mathsf{type}
and Ψ,x:τM=N:σ\Psi,x{:}\tau\vdash M=N:\sigma by inversion
Ψ,x:τM:σ\Psi,x{:}\tau\vdash M:\sigma, Ψ,x:τN:σ\Psi,x{:}\tau\vdash N:\sigma and Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma::\mathsf{type} by i.h.
ΨΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma::\mathsf{type}, ΨΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau^{\prime}.\sigma^{\prime}::\mathsf{type} and Ψ𝗍𝗒𝗉𝖾\Psi\vdash\mathsf{type} by i.h.
Ψλx:τ.M:Πx:τ.σ\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma by (ΠI)(\Pi I)
Ψλx:τ.N:Πx:τ.σ\Psi\vdash\lambda x{:}\tau^{\prime}.N:\Pi x{:}\tau^{\prime}.\sigma^{\prime} by (ΠI)\Pi I)
Ψλx:τ.N:Πx:τ.σ\Psi\vdash\lambda x{:}\tau^{\prime}.N:\Pi x{:}\tau.\sigma by conversion (and symmetry)
Case:

𝖳𝖬𝖤𝗊𝖠𝗉𝗉\mathsf{TMEqApp}

ΨM=M:Πx:τ.σ\Psi\vdash M=M^{\prime}:\Pi x{:}\tau.\sigma and ΨN=N:τ\Psi\vdash N=N^{\prime}:\tau by inversion
ΨM:Πx:τ.σ\Psi\vdash M:\Pi x{:}\tau.\sigma, ΨM:Πx:τ.σ\Psi\vdash M^{\prime}:\Pi x{:}\tau.\sigma and ΨΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma::\mathsf{type} by i.h.
ΨN:τ\Psi\vdash N:\tau, ΨN:τ\Psi\vdash N^{\prime}:\tau and Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} by i.h.
Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma::\mathsf{type} by inversion for products
Ψσ{N/x}::𝗍𝗒𝗉𝖾\Psi\vdash\sigma\{N/x\}::\mathsf{type} by substitution
ΨMN:σ{N/x}\Psi\vdash M\,N:\sigma\{N/x\} by (ΠE)(\Pi E)
ΨMN:σ{N/x}\Psi\vdash M^{\prime}\,N^{\prime}:\sigma\{N^{\prime}/x\} by (ΠE)(\Pi E)
Ψσ{N/x}=σ{N/x}::𝗍𝗒𝗉𝖾\Psi\vdash\sigma\{N/x\}=\sigma\{N^{\prime}/x\}::\mathsf{type} by functionality
ΨMN:σ{N/x}\Psi\vdash M^{\prime}\,N^{\prime}:\sigma\{N/x\} by conversion (and symmetry)
Case:

𝖳𝖬𝖤𝗊β\mathsf{TMEq}\beta

Ψλx:τ.M:Πx:τ.σ\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma, ΨN:τ\Psi\vdash N:\tau and Ψ,:τM:σ\Psi,{:}\tau\vdash M:\sigma by inversion
Ψ(λx:τ.M)N:σ{N/x}\Psi\vdash(\lambda x{:}\tau.M)\,N:\sigma\{N/x\} by (ΠE)(\Pi E)
ΨΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma::\mathsf{type} by subderivation lemma
Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma::\mathsf{type} by inversion for products
Ψσ{N/x}::𝗍𝗒𝗉𝖾\Psi\vdash\sigma\{N/x\}::\mathsf{type} by substitution
ΨM{N/x}:σ{N/x}\Psi\vdash M\{N/x\}:\sigma\{N/x\} by substitution
Case:

𝖳𝖬𝖤𝗊η\mathsf{TMEq}\eta

ΨM:Πx:τ.σ\Psi\vdash M:\Pi x{:}\tau.\sigma by inversion
Ψλx:τ.(Mx):Πx:τ,σ\Psi\vdash\lambda x{:}\tau.(M\,x):\Pi x{:}\tau,\sigma by (ΠE)(\Pi E), (𝗏𝖺𝗋)(\mathsf{var}) and (ΠI)(\Pi I)
ΨΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma::\mathsf{type} by subderivation lemma
Case:

𝖳𝖬𝖤𝗊{}\mathsf{TMEq}\{\}

Ψ;Γ;ΔP=Q::c:A\Psi;\Gamma;\Delta\vdash P=Q::c{:}A by inversion
Ψ;Γ;ΔP::c:A\Psi;\Gamma;\Delta\vdash P::c{:}A, Ψ;Γ;ΔQ::c:A\Psi;\Gamma;\Delta\vdash Q::c{:}A and ΨA::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A::\mathsf{stype} by i.h.
Ψ{cP}:{Γ;Δc:A}\Psi\vdash\{c\leftarrow P\leftarrow\dots\}:\{\Gamma;\Delta\vdash c{:}A\} by {}I\{\}I
Ψ{cQ}:{Γ;Δc:A}\Psi\vdash\{c\leftarrow Q\leftarrow\dots\}:\{\Gamma;\Delta\vdash c{:}A\} by {}I\{\}I
Ψ;Γ\Psi;\Gamma\vdash and Ψ;Δ\Psi;\Delta\vdash by subderivation lemma
Ψ{Γ;Δc:A}\Psi\vdash\{\Gamma;\Delta\vdash c{:}A\} by {}\{\} well-formedness
Case:

𝖳𝖬𝖤𝗊{}η\mathsf{TMEq}\{\}\eta

ΨM:{Γ;Δc:A}\Psi\vdash M:\{\Gamma;\Delta\vdash c{:}A\} by inversion
Ψ{Γ;Δc:A}\Psi\vdash\{\Gamma;\Delta\vdash c{:}A\} by subderivation lemma
Typing follows straightforwardly
Case:

𝖳𝖤𝗊𝖱\mathsf{TEqR}

Straightforward by subderivation lemma.
Case:

𝖳𝖤𝗊𝖲\mathsf{TEqS} and 𝖳𝖤𝗊𝖳\mathsf{TEqT}

Straightforward by i.h.
Case:

𝖳𝖤𝗊Π\mathsf{TEq}\Pi

Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type} and Ψ,x:τσ=σ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma=\sigma^{\prime}::\mathsf{type} by inversion
Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}::\mathsf{type} and Ψ𝗍𝗒𝗉𝖾\Psi\vdash\mathsf{type} by i.h.
Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma::\mathsf{type}, Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma^{\prime}::\mathsf{type} and Ψ,x:τ𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\mathsf{type} by i.h.
ΨΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma::\mathsf{type} Π\Pi rule
Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau^{\prime}\vdash\sigma^{\prime}::\mathsf{type} by context conversion
ΨΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma^{\prime}::\mathsf{type} by Π\Pi rule
Case:

𝖳𝖤𝗊λ\mathsf{TEq}\lambda

Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type} and Ψ,x:τσ=σ::K\Psi,x{:}\tau\vdash\sigma=\sigma^{\prime}::K by inversion
Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}::\mathsf{type} and Ψ𝗍𝗒𝗉𝖾\Psi\vdash\mathsf{type} by i.h.
Ψ,x:τσ::K\Psi,x{:}\tau\vdash\sigma::K, Ψ,x:τσ::K\Psi,x{:}\tau\vdash\sigma^{\prime}::K and Ψ,x:τK\Psi,x{:}\tau\vdash K by i.h.
Ψλx:τ.σ::Πx:τ.K\Psi\vdash\lambda x{:}\tau.\sigma::\Pi x{:}\tau.K by λ\lambda rule
Ψ,x:τσ::K\Psi,x{:}\tau^{\prime}\vdash\sigma^{\prime}::K by context conversion
Ψλx:τ.σ::Πx:τ.K\Psi\lambda x{:}\tau^{\prime}.\sigma^{\prime}::\Pi x{:}\tau^{\prime}.K by λ\lambda rule
Ψλx:τ.σ::Πx:τ.K\Psi\vdash\lambda x{:}\tau^{\prime}.\sigma^{\prime}::\Pi x{:}\tau.K by conversion
ΨΠx:τ.K\Psi\vdash\Pi x{:}\tau.K by Π\Pi well-formedness rule
Case:

𝖳𝖤𝗊𝖠𝗉𝗉\mathsf{TEqApp}

Ψτ=σ::Πx:τ.K\Psi\vdash\tau=\sigma::\Pi x{:}\tau^{\prime}.K and ΨM=N:τ\Psi\vdash M=N:\tau^{\prime} by inversion
Ψτ::Πx:τ.K\Psi\vdash\tau::\Pi x{:}\tau^{\prime}.K, Ψσ::Πx:τ.K\Psi\vdash\sigma::\Pi x{:}\tau^{\prime}.K and ΨΠx:τ.K\Psi\vdash\Pi x{:}\tau^{\prime}.K by i.h.
ΨM:τ\Psi\vdash M:\tau^{\prime}, ΨN:τ\Psi\vdash N:\tau^{\prime} and Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}::\mathsf{type} by i.h.
ΨτM:K{M/x}\Psi\vdash\tau\,M:K\{M/x\} by app. wf rule
ΨσN:K{N/x}\Psi\vdash\sigma\,N:K\{N/x\} by app. wf rule
Ψ,x:τK\Psi,x{:}\tau^{\prime}\vdash K by inversion for products
ΨK{M/x}=K{N/x}\Psi\vdash K\{M/x\}=K\{N/x\} by functionality
ΨσN:K{M/x}\Psi\vdash\sigma\,N:K\{M/x\} by conversion
ΨK{M/x}\Psi\vdash K\{M/x\} by substitution
Case:

𝖳𝖤𝗊β\mathsf{TEq}\beta

Ψ,x:τσ::K\Psi,x{:}\tau\vdash\sigma::K and ΨM:τ\Psi\vdash M:\tau by inversion
Ψλx:τ.σ::Πx:τ.K\Psi\vdash\lambda x{:}\tau.\sigma::\Pi x{:}\tau.K by Π\Pi rule
Ψ(λx:τ.σ)M::K{M/x}\Psi\vdash(\lambda x{:}\tau.\sigma)\,M::K\{M/x\} by app. rule
Ψσ{M/x}::K{M/x}\Psi\vdash\sigma\{M/x\}::K\{M/x\} by substitution
Ψ,x:τK\Psi,x{:}\tau\vdash K by subderivation lemma
ΨK{M/x}\Psi\vdash K\{M/x\} by substitution
Case:

𝖳𝖤𝗊η\mathsf{TEq}\eta

Ψσ::Πx:τ.K\Psi\vdash\sigma::\Pi x{:}\tau.K by inversion
Ψλx:τ.(σx)::Πx:τ.K\Psi\vdash\lambda x{:}\tau.(\sigma\,x)::\Pi x{:}\tau.K by wf rules
ΨΠx:τ.K\Psi\vdash\Pi x{:}\tau.K by subderivation lemma
Case:

𝖳𝖤𝗊{}\mathsf{TEq}\{\}

Straightforward by i.h.
Case:

(3) is identical to (2), appealing to inversion for \forall\exists as needed.

Case:

𝖯𝖤𝗊𝖱𝖾𝖿𝗅\mathsf{PEqRefl}

Immediate + subderivation lemma.
Case:

𝖯𝖤𝗊𝖳\mathsf{PEqT} and 𝖯𝖤𝗊𝖲\mathsf{PEqS}

i.h.
Case:

𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}

Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A, PQP\xrightarrow{}Q and Ψ;Γ;ΔQ::z:A\Psi;\Gamma;\Delta\vdash Q::z{:}A by inversion
ΨA::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A::\mathsf{stype} by subderivation lemma
Case:

𝖯𝖤𝗊𝖱\mathsf{PEq}{{\forall}\mathsf{R}}

Straightforward by i.h.
Case:

𝖯𝖤𝗊𝖫\mathsf{PEq}{{\forall}\mathsf{L}}

ΨM0=M1:τ\Psi\vdash M_{0}=M_{1}:\tau and Ψ;Γ;Δ,x:A{M0/y}P0=Q0::z:C\Psi;\Gamma;\Delta,x{:}A\{M_{0}/y\}\vdash P_{0}=Q_{0}::z{:}C by inversion
Ψ;Γ;Δ,x:A{M0/y}P0::z:C\Psi;\Gamma;\Delta,x{:}A\{M_{0}/y\}\vdash P_{0}::z{:}C, Ψ;Γ;Δ,x:A{M0/y}Q0::z:C\Psi;\Gamma;\Delta,x{:}A\{M_{0}/y\}\vdash Q_{0}::z{:}C
and ΨC::𝗌𝗍𝗒𝗉𝖾\Psi\vdash C::\mathsf{stype} by i.h.
ΨM0:τ\Psi\vdash M_{0}:\tau, ΨM1:τ\Psi\vdash M_{1}:\tau and Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} by i.h.
Ψ;Γ;Δ,x:y:τ.AxM0.P0::z:C\Psi;\Gamma;\Delta,x{:}\forall y{:}\tau.A\vdash x\langle M_{0}\rangle.P_{0}::z{:}C by 𝖫{{\forall}\mathsf{L}}
Ψ;Δ,x:y:τ.A\Psi;\Delta,x{:}\forall y{:}\tau.A\vdash by subderivation lemma
Ψy:τ.A::𝗌𝗍𝗒𝗉𝖾\Psi\vdash\forall y{:}\tau.A::\mathsf{stype} by definition
Ψ,y:τA::𝗌𝗍𝗒𝗉𝖾\Psi,y{:}\tau\vdash A::\mathsf{stype} by inversion for \forall\exists
ΨA{M0/y}=A{M1/y}::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A\{M_{0}/y\}=A\{M_{1}/y\}::\mathsf{stype} by functionality
ΨA{M1/y}::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A\{M_{1}/y\}::\mathsf{stype} by substitution
Ψ;Γ;Δ,x:A{M1/y}Q0::z:C\Psi;\Gamma;\Delta,x{:}A\{M_{1}/y\}\vdash Q_{0}::z{:}C by context conversion rule
Ψ;Γ;Δ,x:y:τ.AxM1.Q0::z:C\Psi;\Gamma;\Delta,x{:}\forall y{:}\tau.A\vdash x\langle M_{1}\rangle.Q_{0}::z{:}C by 𝖫{{\forall}\mathsf{L}}
Case:

𝖯𝖤𝗊𝖢𝗈𝗇𝗏𝖱{{\mathsf{PEqConv}}\mathsf{R}}

Ψ;Γ;ΔP=Q::z:A\Psi;\Gamma;\Delta\vdash P=Q::z{:}A and ΨA=B::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=B::\mathsf{stype} by inversion
Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A, Ψ;Γ;ΔQ::z:A\Psi;\Gamma;\Delta\vdash Q::z{:}A,
ΨA::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A::\mathsf{stype} and ΨB::𝗌𝗍𝗒𝗉𝖾\Psi\vdash B::\mathsf{stype} by i.h.
Ψ;Γ;ΔP::z:B\Psi;\Gamma;\Delta\vdash P::z{:}B by 𝖯𝖤𝗊𝖢𝗈𝗇𝗏𝖱{{\mathsf{PEqConv}}\mathsf{R}}
Ψ;Γ;ΔQ::z:B\Psi;\Gamma;\Delta\vdash Q::z{:}B by 𝖯𝖤𝗊𝖢𝗈𝗇𝗏𝖱{{\mathsf{PEqConv}}\mathsf{R}}

Remaining cases are identical.

Theorem 0.B.10 (Functionality for Equality)

Assume ΨM=N:τ\Psi\vdash M=N:\tau:

  1. 1.

    If Ψ,x:τM0=M1:σ\Psi,x{:}\tau\vdash M_{0}=M_{1}:\sigma then ΨM0{M/x}=M1{N/x}:σ{M/x}\Psi\vdash M_{0}\{M/x\}=M_{1}\{N/x\}:\sigma\{M/x\}

  2. 2.

    If Ψ,x:τσ1=σ2::K\Psi,x{:}\tau\vdash\sigma_{1}=\sigma_{2}::K then Ψσ1{M/x}=σ2{N/x}::K{M/x}\Psi\vdash\sigma_{1}\{M/x\}=\sigma_{2}\{N/x\}::K\{M/x\}

  3. 3.

    If Ψ,x:τA=B::K\Psi,x{:}\tau\vdash A=B::K then ΨA{M/x}=B{N/x}::K{M/x}\Psi\vdash A\{M/x\}=B\{N/x\}::K\{M/x\}

  4. 4.

    If Ψ,x:τK1=K2\Psi,x{:}\tau\vdash K_{1}=K_{2} then ΨK1{M/x}=K2{N/x}\Psi\vdash K_{1}\{M/x\}=K_{2}\{N/x\}

  5. 5.

    If Ψ,x:τ;Γ;ΔP=Q::z:A\Psi,x{:}\tau;\Gamma;\Delta\vdash P=Q::z{:}A then Ψ;Γ{M/x};Δ{M/x}P{M/x}=Q{N/x}::z:A{M/x}\Psi;\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=Q\{N/x\}::z{:}A\{M/x\}

Proof

(1)

Ψ,x:τM0=M1:σ\Psi,x{:}\tau\vdash M_{0}=M_{1}:\sigma assumption
ΨM=N:τ\Psi\vdash M=N:\tau assumption
ΨM:τ\Psi\vdash M:\tau, ΨN:τ\Psi\vdash N:\tau and Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} by validity
Ψ,x:τM0:σ\Psi,x{:}\tau\vdash M_{0}:\sigma, Ψ,x:τM1:σ\Psi,x{:}\tau\vdash M_{1}:\sigma and Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma::\mathsf{type} by validity
ΨM0{M/x}=M1{M/x}:σ{M/x}\Psi\vdash M_{0}\{M/x\}=M_{1}\{M/x\}:\sigma\{M/x\} by substitution
ΨM1{M/x}=M1{N/x}:σ{M/x}\Psi\vdash M_{1}\{M/x\}=M_{1}\{N/x\}:\sigma\{M/x\} by functionality
ΨM0{M/x}=M1{N/x}:σ{M/x}\Psi\vdash M_{0}\{M/x\}=M_{1}\{N/x\}:\sigma\{M/x\} by transitivity

(2)

Ψ,x::τ;Γ;ΔP=Q::z:A\Psi,x{:}:\tau;\Gamma;\Delta\vdash P=Q::z{:}A assumption
ΨM=N:τ\Psi\vdash M=N:\tau assumption
ΨM:τ\Psi\vdash M:\tau, ΨN:τ\Psi\vdash N:\tau and Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} by validity
Ψ,x:τ;Γ;ΔP::z:A\Psi,x{:}\tau;\Gamma;\Delta\vdash P::z{:}A, Ψ,x:τ;Γ;ΔQ::z:A\Psi,x{:}\tau;\Gamma;\Delta\vdash Q::z{:}A
and Ψ,x:τA::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash A::\mathsf{stype} by validity
Ψ;Γ{M/x};Δ{M/x}P{M/x}=Q{M/x}::z:A{M/x}\Psi;\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=Q\{M/x\}::z{:}A\{M/x\} by substitutition
Ψ;Γ{M/x};Δ{M/x}Q{M/x}=Q{N/x}::z:A{M/x}\Psi;\Gamma\{M/x\};\Delta\{M/x\}\vdash Q\{M/x\}=Q\{N/x\}::z{:}A\{M/x\} by functionality
Ψ;Γ{M/x};Δ{M/x}P{M/x}=Q{N/x}::z:A{M/x}\Psi;\Gamma\{M/x\};\Delta\{M/x\}\vdash P\{M/x\}=Q\{N/x\}::z{:}A\{M/x\} by transitivity

Remaining cases are identical, appealing to validity, substitution and functionality of typing.

We omit the analogue functionality property for type substitution.

Lemma 0.B.11 (Inversion)
  1. 1.

    If Ψx:τ\Psi\vdash x{:}\tau then x:σΨx{:}\sigma\in\Psi with Ψτ=σ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\sigma::\mathsf{type}

  2. 2.

    If ΨM1M2:σ\Psi\vdash M_{1}\,M_{2}:\sigma then ΨM1:Πx:τ1.τ2\Psi\vdash M_{1}:\Pi x{:}\tau_{1}.\tau_{2}, ΨM2:τ1\Psi\vdash M_{2}:\tau_{1} and Ψσ{M2/x}=τ2::𝗍𝗒𝗉𝖾\Psi\vdash\sigma\{M_{2}/x\}=\tau_{2}::\mathsf{type}

  3. 3.

    If Ψλx:τ.M:σ\Psi\vdash\lambda x{:}\tau.M:\sigma then Ψσ=Πx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\sigma=\Pi x{:}\tau.\sigma^{\prime}::\mathsf{type}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τM:σ\Psi,x{:}\tau\vdash M:\sigma^{\prime}

  4. 4.

    If ΨΠx:τ1.τ2::K\Psi\vdash\Pi x{:}\tau_{1}.\tau_{2}::K then ΨK=𝗍𝗒𝗉𝖾\Psi\vdash K=\mathsf{type}, Ψτ1::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{1}::\mathsf{type} and Ψ,x:τ1τ2::𝗍𝗒𝗉𝖾\Psi,x{:}\tau_{1}\vdash\tau_{2}::\mathsf{type}

  5. 5.

    If Ψλx:τ.σ::K\Psi\vdash\lambda x{:}\tau.\sigma::K then ΨK=Πx:τ.K\Psi\vdash K=\Pi x{:}\tau.K^{\prime}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τσ::K\Psi,x{:}\tau\vdash\sigma::K^{\prime}

  6. 6.

    If ΨτM::K\Psi\vdash\tau\,M::K then Ψτ::Πx:τ0.K1\Psi\vdash\tau::\Pi x{:}\tau_{0}.K_{1}, ΨM:τ0\Psi\vdash M:\tau_{0} and ΨK=K1{M/x}\Psi\vdash K=K_{1}\{M/x\}

  7. 7.

    If Ψλt::K.τ::K\Psi\vdash\lambda t{::}K.\tau::K^{\prime} then ΨK=Πt::K.K′′\Psi\vdash K^{\prime}=\Pi t{::}K.K^{\prime\prime}, ΨK\Psi\vdash K and Ψ,t::Kτ::K′′\Psi,t{::}K\vdash\tau::K^{\prime\prime}

  8. 8.

    If Ψτσ::K\Psi\vdash\tau\,\sigma::K then Ψτ::Πt::K0.K1\Psi\vdash\tau::\Pi t{::}K_{0}.K_{1}, Ψσ:K0\Psi\vdash\sigma:K_{0} and ΨK=K1{σ/t}\Psi\vdash K=K_{1}\{\sigma/t\}

  9. 9.

    If ΨΠx:τ.K\Psi\vdash\Pi x{:}\tau.K then Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τK\Psi,x{:}\tau\vdash K

  10. 10.

    If ΨΠt::K1.K2\Psi\vdash\Pi t{::}K_{1}.K_{2} then ΨK1\Psi\vdash K_{1} and Ψ,t::K1K2\Psi,t{::}K_{1}\vdash K_{2}

  11. 11.

    If Ψ{Γ;Δc:A}::K\Psi\vdash\{\Gamma;\Delta\vdash c{:}A\}::K then ΨK=𝗍𝗒𝗉𝖾\Psi\vdash K=\mathsf{type}, ΨΓ::𝗌𝗍𝗒𝗉𝖾\Psi\vdash\Gamma::\mathsf{stype}, ΨΔ::𝗌𝗍𝗒𝗉𝖾\Psi\vdash\Delta::\mathsf{stype} and ΨA::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A::\mathsf{stype}

  12. 12.

    If Ψ;Γ;Δz(x:τ).P::z:A\Psi;\Gamma;\Delta\vdash z(x{:}\tau).P::z{:}A then ΨA=x:τ.A\Psi\vdash A=\forall x{:}\tau.A^{\prime} and Ψτ::𝗌𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{stype} and Ψ,x:τ;Γ;ΔP::z:A\Psi,x{:}\tau;\Gamma;\Delta\vdash P::z{:}A^{\prime}

  13. 13.

    If Ψ;Γ;Δ,x:AxMx:τ.A.P::z:C\Psi;\Gamma;\Delta,x{:}A\vdash x\langle M\rangle_{\forall x{:}\tau.A^{\prime}}.P::z{:}C then ΨA=y:τ.A::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=\forall y{:}\tau.A^{\prime}::\mathsf{stype}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}, ΨM:τ\Psi\vdash M:\tau and Ψ;Γ;Δ,x:A{M/y}P::z:C\Psi;\Gamma;\Delta,x{:}A^{\prime}\{M/y\}\vdash P::z{:}C

  14. 14.

    If Ψ;Γ;ΔzMx:τ.A.P::z:A\Psi;\Gamma;\Delta\vdash z\langle M\rangle_{\exists x{:}\tau.A^{\prime}}.P::z{:}A then ΨA=x:τ.A::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=\exists x{:}\tau.A^{\prime}::\mathsf{stype}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,y:τ;Γ;Δ,x:AP::z:C\Psi,y{:}\tau;\Gamma;\Delta,x{:}A^{\prime}\vdash P::z{:}C

  15. 15.

    If Ψx:τ.A::K\Psi\vdash\forall x{:}\tau.A::K then ΨK=𝗌𝗍𝗒𝗉𝖾\Psi\vdash K=\mathsf{stype}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}, Ψ,x:τA::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash A::\mathsf{stype}

  16. 16.

    If Ψx:τ.A::K\Psi\vdash\exists x{:}\tau.A::K then ΨK=𝗌𝗍𝗒𝗉𝖾\Psi\vdash K=\mathsf{stype}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type}, Ψ,x:τA::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash A::\mathsf{stype}

  17. 17.

    If Ψλx:τ.A::K\Psi\vdash\lambda x{:}\tau.A::K then ΨK=Πx:τ.K\Psi\vdash K=\Pi x{:}\tau.K^{\prime}, Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τA::K\Psi,x{:}\tau\vdash A::K^{\prime}

  18. 18.

    If ΨAM::K\Psi\vdash A\,M::K then ΨA::Πx:τ0.K\Psi\vdash A::\Pi x{:}\tau_{0}.K^{\prime}, ΨM:τ0\Psi\vdash M:\tau_{0} and ΨK=K{M/x}\Psi\vdash K=K^{\prime}\{M/x\}

  19. 19.

    If Ψλt::K.A::K\Psi\vdash\lambda t{::}K.A::K^{\prime} then ΨK=Πt::K.K′′\Psi\vdash K^{\prime}=\Pi t{::}K.K^{\prime\prime}, ΨK\Psi\vdash K and Ψ,t::KA::K′′\Psi,t{::}K\vdash A::K^{\prime\prime}

  20. 20.

    If ΨAB::K\Psi\vdash A\,B::K then ΨA::Πt:K0.K1\Psi\vdash A::\Pi t{:}K_{0}.K_{1}, ΨB::K0\Psi\vdash B::K_{0} and ΨK=K1{B/t}\Psi\vdash K=K_{1}\{B/t\}

Proof

By induction on the given derivation. Most cases require validity.

Theorem 0.B.12 (Equality Inversion)
  1. 1.

    If Ψτ=Πx:τ0.τ1::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\Pi x{:}\tau_{0}.\tau_{1}::\mathsf{type} then Ψτ=Πx:σ0.σ1::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\Pi x{:}\sigma_{0}.\sigma_{1}::\mathsf{type} with Ψσ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\sigma_{0}=\tau_{0}::\mathsf{type} and Ψ,x:σ0σ1=τ1::𝗍𝗒𝗉𝖾\Psi,x{:}\sigma_{0}\vdash\sigma_{1}=\tau_{1}::\mathsf{type}

  2. 2.

    If ΨK=𝗍𝗒𝗉𝖾\Psi\vdash K=\mathsf{type} then K=𝗍𝗒𝗉𝖾K=\mathsf{type}

  3. 3.

    If ΨK=Πx:τ0.K\Psi\vdash K=\Pi x{:}\tau_{0}.K^{\prime} then ΨK=Πx:σ0.K′′\Psi\vdash K=\Pi x{:}\sigma_{0}.K^{\prime\prime} with Ψσ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\sigma_{0}=\tau_{0}::\mathsf{type} and Ψ,x:σ0K′′=K\Psi,x{:}\sigma_{0}\vdash K^{\prime\prime}=K^{\prime}

  4. 4.

    If ΨK=Πt::K1.K2\Psi\vdash K=\Pi t{::}K_{1}.K_{2} then ΨK=Πt::K1.K2\Psi\vdash K=\Pi t{::}K_{1}^{\prime}.K_{2}^{\prime} with ΨK1=K1\Psi\vdash K_{1}^{\prime}=K_{1} and Ψ,t::K1K2=K2\Psi,t{::}K_{1}^{\prime}\vdash K_{2}^{\prime}=K_{2}

  5. 5.

    ΨA=x:τ0.A0::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=\forall x{:}\tau_{0}.A_{0}::\mathsf{stype} then ΨA=x:σ0.B0::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=\forall x{:}\sigma_{0}.B_{0}::\mathsf{stype} with Ψσ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\sigma_{0}=\tau_{0}::\mathsf{type} and Ψ,x:σ0B0=A0::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\sigma_{0}\vdash B_{0}=A_{0}::\mathsf{stype}

  6. 6.

    ΨA=x:τ0.A0::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=\exists x{:}\tau_{0}.A_{0}::\mathsf{stype} then ΨA=x:σ0.B0::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=\exists x{:}\sigma_{0}.B_{0}::\mathsf{stype} with Ψσ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\sigma_{0}=\tau_{0}::\mathsf{type} and Ψ,x:σ0B0=A0::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\sigma_{0}\vdash B_{0}=A_{0}::\mathsf{stype}

  7. 7.

    Ψτ=λx:τ0.σ::K\Psi\vdash\tau=\lambda x{:}\tau_{0}.\sigma::K then Ψτ=λx:τ1.σ::Πx:τ1.K0\Psi\vdash\tau=\lambda x{:}\tau_{1}.\sigma^{\prime}::\Pi x{:}\tau_{1}.K_{0} with Ψτ1=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{1}=\tau_{0}::\mathsf{type} and Ψ,x:τ1σ=σ::K0\Psi,x{:}\tau_{1}\vdash\sigma^{\prime}=\sigma::K_{0}, for some K0K_{0}

  8. 8.

    Ψτ=τ0M::K\Psi\vdash\tau=\tau_{0}\,M::K then Ψτ=τ1N::K\Psi\vdash\tau=\tau_{1}\,N::K with Ψτ1=τ0::Πx:σ.K0\Psi\vdash\tau_{1}=\tau_{0}::\Pi x{:}\sigma.K_{0}, ΨN=M:σ\Psi\vdash N=M:\sigma and K=K0{N/x}K=K_{0}\{N/x\}

  9. 9.

    Ψτ=λt::K.σ::K\Psi\vdash\tau=\lambda t{::}K.\sigma::K^{\prime} then Ψτ=λt::K0.σ::Πt::K0.K′′\Psi\vdash\tau=\lambda t{::}K_{0}.\sigma^{\prime}::\Pi t{::}K_{0}.K^{\prime\prime} with ΨK0=K\Psi\vdash K_{0}=K and Ψ,t::K0σ=σ::K′′\Psi,t{::}K_{0}\vdash\sigma^{\prime}=\sigma::K^{\prime\prime}, for some K′′K^{\prime\prime}

  10. 10.

    Ψτ=τ0σ0::K\Psi\vdash\tau=\tau_{0}\,\sigma_{0}::K then Ψτ=τ1σ1::K\Psi\vdash\tau=\tau_{1}\,\sigma_{1}::K with Ψτ1=τ0::Πt::K1.K0\Psi\vdash\tau_{1}=\tau_{0}::\Pi t{::}K_{1}.K_{0}, Ψσ1=σ0::K1\Psi\vdash\sigma_{1}=\sigma_{0}::K_{1} and K=K0{σ1/t}K=K_{0}\{\sigma_{1}/t\}

  11. 11.

    ΨA=λx:τ0.A0::K\Psi\vdash A=\lambda x{:}\tau_{0}.A_{0}::K then ΨA=λx:τ1.A0::Πx:τ1.K0\Psi\vdash A=\lambda x{:}\tau_{1}.A_{0}^{\prime}::\Pi x{:}\tau_{1}.K_{0} with Ψτ1=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{1}=\tau_{0}::\mathsf{type} and Ψ,x:τ1A0=A0::K0\Psi,x{:}\tau_{1}\vdash A_{0}^{\prime}=A_{0}::K_{0}, for some K0K_{0}

  12. 12.

    ΨA=A0M::K\Psi\vdash A=A_{0}\,M::K then ΨA=A1N\Psi\vdash A=A_{1}\,N with ΨA1=A0::Πx:σ.K0\Psi\vdash A_{1}=A_{0}::\Pi x{:}\sigma.K_{0}, ΨN=M:σ\Psi\vdash N=M:\sigma and K=K0{N/x}K=K_{0}\{N/x\}

  13. 13.

    ΨB=λt::K.A::K\Psi\vdash B=\lambda t{::}K.A::K^{\prime} then ΨB=λt::K0.A::Πt::K0.K′′\Psi\vdash B=\lambda t{::}K_{0}.A^{\prime}::\Pi t{::}K_{0}.K^{\prime\prime} with ΨK0=K\Psi\vdash K_{0}=K and Ψ,t::K0A=A::K′′\Psi,t{::}K_{0}\vdash A^{\prime}=A::K^{\prime\prime}, for some K′′K^{\prime\prime}

  14. 14.

    ΨA=A0B0::K\Psi\vdash A=A_{0}\,B_{0}::K then ΨA=A1B1::K\Psi\vdash A=A_{1}\,B_{1}::K with ΨA1=A0::Πt::K1.K0\Psi\vdash A_{1}=A_{0}::\Pi t{::}K_{1}.K_{0}, ΨB1=B0::K1\Psi\vdash B_{1}=B_{0}::K_{1} and K=K0{B1/t}K=K_{0}\{B_{1}/t\}

Proof

By induction on the given equality derivations.

(1)

Case:

𝖳𝖤𝗊𝖳\mathsf{TEqT}

Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type} and Ψτ=Πx:τ0.τ1::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}=\Pi x{:}\tau_{0}.\tau_{1}::\mathsf{type} assumption
τ=Πx:τ0.τ1\tau^{\prime}=\Pi x{:}\tau^{\prime}_{0}.\tau^{\prime}_{1} with Ψτ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}_{0}=\tau_{0}::\mathsf{type} and Ψ,x:τ0τ1=τ1::𝗍𝗒𝗉𝖾\Psi,x{:}\tau^{\prime}_{0}\vdash\tau^{\prime}_{1}=\tau_{1}::\mathsf{type} by i.h.
τ=Πx:σ0.σ1\tau=\Pi x{:}\sigma_{0}.\sigma_{1} with Ψσ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\sigma_{0}=\tau_{0}^{\prime}::\mathsf{type} and Ψ,x:σ0σ1=τ1::𝗍𝗒𝗉𝖾\Psi,x{:}\sigma_{0}\vdash\sigma_{1}=\tau^{\prime}_{1}::\mathsf{type} by i.h.
Ψσ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\sigma_{0}=\tau_{0}::\mathsf{type} by transivitity
Ψ,x:σ0τ1=τ1::𝗍𝗒𝗉𝖾\Psi,x{:}\sigma_{0}\vdash\tau_{1}^{\prime}=\tau_{1}::\mathsf{type} by context conversion
Ψ,x:σ0σ1=τ1::𝗍𝗒𝗉𝖾\Psi,x{:}\sigma_{0}\vdash\sigma_{1}=\tau_{1}::\mathsf{type} by transitivity
Case:

𝖳𝖤𝗊β\mathsf{TEq}\beta

Ψ,y:τσ::𝗍𝗒𝗉𝖾\Psi,y{:}\tau\vdash\sigma::\mathsf{type} and ΨM:τ\Psi\vdash M:\tau, K{M/y}=𝗍𝗒𝗉𝖾K\{M/y\}=\mathsf{type} and
Πx:τ0.τ1=σ{M/y}\Pi x{:}\tau_{0}.\tau_{1}=\sigma\{M/y\} by inversion
Ψ(λy:τ.σ)M=Πx:τ0.τ1::𝗍𝗒𝗉𝖾\Psi\vdash(\lambda y{:}\tau.\sigma)\,M=\Pi x{:}\tau_{0}.\tau_{1}::\mathsf{type} assumption
σ=Πx:τ.σ\sigma=\Pi x{:}\tau.\sigma by definition of substitution
Ψ,y:τΠx:τ.σ::𝗍𝗒𝗉𝖾\Psi,y{:}\tau\vdash\Pi x{:}\tau.\sigma::\mathsf{type} by def.
Ψ(λy:τ.σ)M=Πx:τ.σ{M/y}::𝗍𝗒𝗉𝖾\Psi\vdash(\lambda y{:}\tau.\sigma)\,M=\Pi x{:}\tau.\sigma\{M/y\}::\mathsf{type} by rule
Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} by validity
Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau::\mathsf{type} by reflexivity
Ψσ{M/y}::𝗍𝗒𝗉𝖾\Psi\vdash\sigma\{M/y\}::\mathsf{type} by substitution
Ψσ{M/y}=σ{M/y}::𝗍𝗒𝗉𝖾\Psi\vdash\sigma\{M/y\}=\sigma\{M/y\}::\mathsf{type} by reflexivity

The other cases follow similar patterns.

Lemma 0.B.13 (Injectivity of Products)
  1. 1.

    If ΨΠx:τ.σ=Πx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma=\Pi x{:}\tau^{\prime}.\sigma^{\prime}::\mathsf{type} then Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type} and Ψ,x:τσ=σ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma=\sigma^{\prime}::\mathsf{type}

  2. 2.

    If ΨΠx:τ1.K1=Πx:τ2.K2\Psi\vdash\Pi x{:}\tau_{1}.K_{1}=\Pi x{:}\tau_{2}.K_{2} then Ψτ1=τ2::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{1}=\tau_{2}::\mathsf{type} and Ψ,x:τ1K1=K2\Psi,x{:}\tau_{1}\vdash K_{1}=K_{2}

  3. 3.

    If Ψx:τ1.A1=x:τ2.A2::𝗌𝗍𝗒𝗉𝖾\Psi\vdash\forall x{:}\tau_{1}.A_{1}=\forall x{:}\tau_{2}.A_{2}::\mathsf{stype} then Ψτ1=τ2::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{1}=\tau_{2}::\mathsf{type} and Ψ,x:τ1A1=A2::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau_{1}\vdash A_{1}=A_{2}::\mathsf{stype}

Proof

By equality inversion.

See 2.4

Proof

By induction on the structure of the given term/type/process.

Case:

MM is λx:τ0.M\lambda x{:}\tau_{0}.M^{\prime}

Ψ,x:τ0M:σ\Psi,x{:}\tau_{0}\vdash M^{\prime}:\sigma, Ψ,x:τ0M:σ\Psi,x{:}\tau_{0}\vdash M^{\prime}:\sigma^{\prime} with Ψτ=Πx:τ0.σ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\Pi x{:}\tau_{0}.\sigma::\mathsf{type},
Ψτ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{0}::\mathsf{type} and Ψτ=Πx:τ0.σ::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}=\Pi x{:}\tau_{0}.\sigma^{\prime}::\mathsf{type} by inversion
Ψ,x:τ0σ=σ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau_{0}\vdash\sigma=\sigma^{\prime}::\mathsf{type} by i.h.
ΨΠx:τ0.σ=Πx:τ0.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau_{0}.\sigma=\Pi x{:}\tau_{0}.\sigma^{\prime}::\mathsf{type} by 𝖳𝖤𝗊Π\mathsf{TEq}\Pi rule
Case:

MM is MNM^{\prime}\,N^{\prime}

ΨMN:τ\Psi\vdash M^{\prime}N^{\prime}:\tau and ΨMN:τ\Psi\vdash M^{\prime}N^{\prime}:\tau^{\prime} assumption
ΨM:Πx:τ0.σ0\Psi\vdash M^{\prime}:\Pi x{:}\tau_{0}.\sigma_{0} and ΨM:Πx:τ0.σ0\Psi\vdash M^{\prime}:\Pi x{:}\tau_{0}^{\prime}.\sigma_{0}^{\prime} with Ψτ=σ0{N/x}::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\sigma_{0}\{N^{\prime}/x\}::\mathsf{type},
ΨN:τ0\Psi\vdash N^{\prime}:\tau_{0}, ΨN:τ0\Psi\vdash N^{\prime}:\tau_{0}^{\prime} and Ψτ=σ0{N/x}::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}=\sigma_{0}^{\prime}\{N^{\prime}/x\}::\mathsf{type} by inversion
ΨΠx:τ0.σ0=Πx:τ0.σ0::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau_{0}.\sigma_{0}=\Pi x{:}\tau_{0}^{\prime}.\sigma_{0}^{\prime}::\mathsf{type} by i.h.
Ψτ0=τ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{0}=\tau_{0}^{\prime}::\mathsf{type} by i.h.
Ψ,x:τ0σ0=σ0::𝗍𝗒𝗉𝖾\Psi,x{:}\tau_{0}\vdash\sigma_{0}=\sigma_{0}^{\prime}::\mathsf{type} by injectivity
Ψσ0{N/x}=σ0{N/x}::𝗍𝗒𝗉𝖾\Psi\vdash\sigma_{0}\{N^{\prime}/x\}=\sigma_{0}^{\prime}\{N^{\prime}/x\}::\mathsf{type} by functionality
Case:

MM is {cPuj¯;di¯}\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}

ΨM:{Γ;Δc:A}\Psi\vdash M:\{\Gamma;\Delta\vdash c{:}A\} and ΨM:{Γ;Δc:A}\Psi\vdash M:\{\Gamma;\Delta\vdash c{:}A^{\prime}\} assumption
Ψ;Γ;ΔP::c:A\Psi;\Gamma;\Delta\vdash P::c{:}A and Ψ;Γ;ΔP::c:A\Psi;\Gamma;\Delta\vdash P::c{:}A^{\prime} by inversion
ΨA=A::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=A^{\prime}::\mathsf{stype} by i.h.
Conclude by reflexivity and 𝖳𝖤𝗊{}\mathsf{TEq}\{\}
Case:

MM is xx

Direct by inversion lemma.

(2)

Case:

τ\tau is Πx:τ0.σ0\Pi x{:}\tau_{0}.\sigma_{0}

ΨΠx:τ0.σ0::K\Psi\vdash\Pi x{:}\tau_{0}.\sigma_{0}::K and ΨΠx:τ0.σ0::K\Psi\vdash\Pi x{:}\tau_{0}.\sigma_{0}::K^{\prime} assumption
Ψ,x:τ0σ0::𝗍𝗒𝗉𝖾\Psi,x{:}\tau_{0}\vdash\sigma_{0}::\mathsf{type} and Ψ,x:τ0σ0::𝗍𝗒𝗉𝖾\Psi,x{:}\tau_{0}\vdash\sigma_{0}::\mathsf{type} and K=K=𝗍𝗒𝗉𝖾K=K^{\prime}=\mathsf{type}
by inversion lemma
Case:

τ\tau is λx:τ0.σ0\lambda x{:}\tau_{0}.\sigma_{0}

Ψλx:τ0.σ0::K\Psi\vdash\lambda x{:}\tau_{0}.\sigma_{0}::K and Ψλx:τ0.σ0::K\Psi\vdash\lambda x{:}\tau_{0}.\sigma_{0}::K^{\prime} assumption
Ψ,x:τ0σ0::K0\Psi,x{:}\tau_{0}\vdash\sigma_{0}::K_{0}, Ψ,x:τ0σ0::K0\Psi,x{:}\tau_{0}\vdash\sigma_{0}::K_{0}^{\prime}, Ψτ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{0}::\mathsf{type}
with K=Πx:τ0.K0K=\Pi x{:}\tau_{0}.K_{0} and K=Πx:τ0.K0K^{\prime}=\Pi x{:}\tau_{0}.K_{0}^{\prime} by inversion lemma
Ψ,x:τ0K0=K0\Psi,x{:}\tau_{0}\vdash K_{0}=K_{0}^{\prime} by i.h.
ΨΠx:τ0.K0=Πx:τ0.K0\Psi\vdash\Pi x{:}\tau_{0}.K_{0}=\Pi x{:}\tau_{0}.K_{0}^{\prime} by rule
Case:

τ\tau is τ0M\tau_{0}\,M

Ψτ0M::K\Psi\vdash\tau_{0}\,M::K and Ψτ0M::K\Psi\vdash\tau_{0}\,M::K^{\prime} assumption
Ψτ0::Πx:σ.K0\Psi\vdash\tau_{0}::\Pi x{:}\sigma.K_{0} and Ψτ0::Πx:σ.K0\Psi\vdash\tau_{0}::\Pi x{:}\sigma^{\prime}.K_{0}^{\prime}, ΨM:σ\Psi\vdash M:\sigma and ΨM:σ\Psi\vdash M:\sigma^{\prime}
with K=K0{M/x}K=K_{0}\{M/x\} and K=K0{M/x}K^{\prime}=K_{0}^{\prime}\{M/x\} by inversion lemma
ΨΠx:σ.K0=Πx:σ.K0\Psi\vdash\Pi x{:}\sigma.K_{0}=\Pi x{:}\sigma^{\prime}.K_{0}^{\prime} by i.h.
Ψσ=σ::𝗍𝗒𝗉𝖾\Psi\vdash\sigma=\sigma^{\prime}::\mathsf{type} by i.h.
Ψ,x:σK0=K0\Psi,x{:}\sigma\vdash K_{0}=K_{0}^{\prime} by injectivity
ΨK0{M/x}=K0{M/x}\Psi\vdash K_{0}\{M/x\}=K_{0}^{\prime}\{M/x\} by substitution
Case:

τ\tau is {Γ;Δc:A}\{\Gamma;\Delta\vdash c{:}A\}

Straightforward by i.h.

(3)

Case:

PP is z(x).P0z(x).P_{0}

Ψ;Γ;Δz(x:τ0).P0::z:A\Psi;\Gamma;\Delta\vdash z(x{:}\tau_{0}).P_{0}::z{:}A and Ψ;Γ;Δz(x:τ0).P0::z:A\Psi;\Gamma;\Delta\vdash z(x{:}\tau_{0}).P_{0}::z{:}A^{\prime} assumption
A=x:τ0.A0A=\forall x{:}\tau_{0}.A_{0}, A=x:τ0.A0A^{\prime}=\forall x{:}\tau_{0}.A_{0}^{\prime}, Ψ,x:τ0;Γ;ΔP0::z:A0\Psi,x{:}\tau_{0};\Gamma;\Delta\vdash P_{0}::z{:}A_{0},
Ψ,x:τ0;Γ;ΔP0::z:A0\Psi,x{:}\tau_{0};\Gamma;\Delta\vdash P_{0}::z{:}A_{0}^{\prime}, and Ψτ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{0}::\mathsf{type} by inversion lemma
Ψ,x:τ0A0=A0\Psi,x{:}\tau_{0}\vdash A_{0}=A_{0}^{\prime} by i.h.
Ψx:τ0A0=x:τ0A0\Psi\vdash\forall x{:}\tau_{0}A_{0}=\forall x{:}\tau_{0}A_{0}^{\prime} by rule
Case:

PP is xMx:τ0.A0.P0x\langle M\rangle_{\forall x{:}\tau_{0}.A_{0}}.P_{0}

Ψ;Γ;Δ,x:AxMx:τ0.A0.P0::z:C\Psi;\Gamma;\Delta,x{:}A\vdash x\langle M\rangle_{\forall x{:}\tau_{0}.A_{0}}.P_{0}::z{:}C and
Ψ;Γ;Δ,x:AxM.P0::z:C\Psi;\Gamma;\Delta,x{:}A\vdash x\langle M\rangle.P_{0}::z{:}C assumption
A=x:τ0.A0A=\forall x{:}\tau_{0}.A_{0}, ΨM:τ0\Psi\vdash M:\tau_{0}, Ψ;Γ;Δ,x:A0{M/x}P0::z:C\Psi;\Gamma;\Delta,x{:}A_{0}\{M/x\}\vdash P_{0}::z{:}C
and Ψ;Γ;Δ,x:A0{M/x}P0::z:C\Psi;\Gamma;\Delta,x{:}A_{0}\{M/x\}\vdash P_{0}::z{:}C^{\prime} by inversion lemma
ΨC=C::𝗌𝗍𝗒𝗉𝖾\Psi\vdash C=C^{\prime}::\mathsf{stype} by i.h.
Case:

PP is zMx:τ0.A0.P0z\langle M\rangle_{\exists x{:}\tau_{0}.A_{0}}.P_{0}

Ψ;Γ;ΔzM.P0::z:A\Psi;\Gamma;\Delta\vdash z\langle M\rangle.P_{0}::z{:}A and Ψ;Γ;ΔzM.P0::z:A\Psi;\Gamma;\Delta\vdash z\langle M\rangle.P_{0}::z{:}A^{\prime} assumption
A=x:τ0.A0A=\exists x{:}\tau_{0}.A_{0}, A=x:τ0.A0A^{\prime}=\exists x{:}\tau_{0}.A_{0}, ΨM:τ0\Psi\vdash M:\tau_{0},
Ψ;Γ;ΔP0::z:A0{M/x}\Psi;\Gamma;\Delta\vdash P_{0}::z{:}A_{0}\{M/x\} and Ψ;Γ;ΔP0::z:A0{M/x}\Psi;\Gamma;\Delta\vdash P_{0}::z{:}A_{0}\{M/x\}
by inversion lemma

Remaining cases follow similarly.

Theorem 0.B.14

If ΨM:τ\Psi\vdash M:\tau and MMM\xrightarrow{}M^{\prime} then ΨM=M:τ\Psi\vdash M=M^{\prime}:\tau

Proof

By induction on \xrightarrow{} relation.

Case:
  MM   MNMN \displaystyle\displaystyle{\hbox{\qquad\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{M\xrightarrow{}M^{\prime}}$}}}\vbox{}}}\over\hbox{\hskip 25.48604pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{M\,N\xrightarrow{}M^{\prime}\,N}$}}}}}}
ΨM:Πx:τ0.σ0\Psi\vdash M:\Pi x{:}\tau_{0}.\sigma_{0}, Ψτ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{0}::\mathsf{type}, ΨN:τ0\Psi\vdash N:\tau_{0} and ΨMN:σ0{N/x}\Psi\vdash M\,N:\sigma_{0}\{N/x\}
by inversion lemma
ΨM=M:Πx:τ0.σ0\Psi\vdash M=M^{\prime}:\Pi x{:}\tau_{0}.\sigma_{0} by i.h.
ΨΠx:τ0.σ0::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau_{0}.\sigma_{0}::\mathsf{type} by validity
ΨN=N:τ0\Psi\vdash N=N:\tau_{0} by reflexivity
ΨMN=MN:σ0{N/x}\Psi\vdash M\,N=M^{\prime}\,N:\sigma_{0}\{N/x\} by 𝖳𝖬𝖤𝗊Π\mathsf{TMEq}\Pi
Case:
  NN   MNMN \displaystyle\displaystyle{\hbox{\qquad\vbox{\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{N\xrightarrow{}N^{\prime}}$}}}\vbox{}}}\over\hbox{\hskip 25.48604pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{M\,N\xrightarrow{}M\,N^{\prime}}$}}}}}}
ΨM:Πx:τ0.σ0\Psi\vdash M:\Pi x{:}\tau_{0}.\sigma_{0}, Ψτ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{0}::\mathsf{type}, ΨN:τ0\Psi\vdash N:\tau_{0} and ΨMN:σ0{N/x}\Psi\vdash M\,N:\sigma_{0}\{N/x\}
by inversion lemma
ΨN=N:τ0\Psi\vdash N=N^{\prime}:\tau_{0} by i.h.
ΨM=M:Πx:τ0.σ0\Psi\vdash M=M:\Pi x{:}\tau_{0}.\sigma_{0} by reflexivity
ΨMN=MN:σ0{N/x}\Psi\vdash M\,N=M\,N^{\prime}:\sigma_{0}\{N/x\} by 𝖳𝖬𝖤𝗊Π\mathsf{TMEq}\Pi
  (λx:τ0.M0)N0M0{/N0x} \displaystyle\displaystyle{\hbox{}\over\hbox{\hskip 64.17181pt\vbox{\vbox{}\hbox{\thinspace\hbox{\hbox{$\displaystyle\displaystyle{(\lambda x{:}\tau_{0}.M_{0})\,N_{0}\xrightarrow{}M_{0}\{N_{0}/x\}}$}}}}}}
Ψλx:τ0.M0:Πx:τ0.σ0\Psi\vdash\lambda x{:}\tau_{0}.M_{0}:\Pi x{:}\tau_{0}.\sigma_{0}, Ψτ0::𝗍𝗒𝗉𝖾\Psi\vdash\tau_{0}::\mathsf{type}, ΨN0:τ0\Psi\vdash N_{0}:\tau_{0},
Ψ(λx:τ0.M0)N0:σ0{N0/x}\Psi\vdash(\lambda x{:}\tau_{0}.M_{0})\,N_{0}:\sigma_{0}\{N_{0}/x\} by inversion lemma
Ψ,x:τ0M0:σ0\Psi,x{:}\tau_{0}\vdash M_{0}:\sigma_{0} by inversion lemma
Ψ(λx:τ0.M0)N0=M0{N0/x}:σ0{N/x}\Psi\vdash(\lambda x{:}\tau_{0}.M_{0})\,N_{0}=M_{0}\{N_{0}/x\}:\sigma_{0}\{N/x\} by 𝖳𝖬𝖤𝗊β\mathsf{TMEq}\beta

See 2.5

Proof

Immediate from Theorem 0.B.14 and validity for equality.

See 2.6

Proof

The proof follows by Theorem 0.B.14 and a series of lemmas that relate typed processes and their reducts under a cut (which now crucially rely on the inversion lemmas and validity). See [29, 28, 5].

See 2.7

Proof

By induction on typing, using the standard canonical forms-based reasoning and noting that monadic terms are values.

Appendix 0.C Appendix – Embedding

Lemma 0.C.1 (Compositionality)
  1. 1.

    ΨK{M/x}\Psi\vdash\llbracket K\{M/x\}\rrbracket iff ΨK{{Mc}/x}\Psi\vdash\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}

  2. 2.

    ΨK1{τ/t}\Psi\vdash\llbracket K_{1}\{\tau/t\}\rrbracket iff ΨK1{τ/t}\Psi\vdash\llbracket K_{1}\rrbracket\{\llbracket\tau\rrbracket/t\}

  3. 3.

    ΨK1{A/x}\Psi\vdash\llbracket K_{1}\{A/x\}\rrbracket iff ΨK1{A/x}\Psi\vdash\llbracket K_{1}\rrbracket\{\llbracket A\rrbracket/x\}

  4. 4.

    Ψτ{M/x}::K{M/x}\Psi\vdash\llbracket\tau\{M/x\}\rrbracket::\llbracket K\{M/x\}\rrbracket iff Ψτ{{Mc}/x}::K{{Mc}/x}\Psi\vdash\llbracket\tau\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}

  5. 5.

    ΨA{M/x}::K{M/x}\Psi\vdash\llbracket A\{M/x\}\rrbracket::\llbracket K\{M/x\}\rrbracket iff ΨA{{Mc}/x}::K{{Mc}/x}\Psi\vdash\llbracket A\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}

  6. 6.

    Ψ;Γ;ΔM{N/x}z=Mz{{Ny}/x}::z:A{N/x}\Psi;\Gamma;\Delta\vdash\llbracket M\{N/x\}\rrbracket_{z}=\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{y}\}/x\}::z{:}\llbracket A\{N/x\}\rrbracket

  7. 7.

    Ψ;Γ;ΔP{M/x}::z:A{M/x}\Psi;\Gamma;\Delta\vdash\llbracket P\{M/x\}\rrbracket::z{:}\llbracket A\{M/x\}\rrbracket iff Ψ;Γ;ΔP{{Mc}/x}::z:A{{Mc}/x}\Psi;\Gamma;\Delta\vdash\llbracket P\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::z{:}\llbracket A\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}

Proof

By mutual induction on the structure of the given kind/type/session type/etc.

Case:

K=𝗍𝗒𝗉𝖾K=\mathsf{type} or K=𝗌𝗍𝗒𝗉𝖾K=\mathsf{stype}

Trivial.

(1)

Case:

K=Πy:τ.KK=\Pi y{:}\tau.K^{\prime}

Subcase: \Rightarrow
Πy:τ.K{M/x}=Πy:τ{M/x}.K{M/x}=Πy:{τ{M/x}}.K{M/x}\llbracket\Pi y{:}\tau.K^{\prime}\{M/x\}\rrbracket=\llbracket\Pi y{:}\tau\{M/x\}.K^{\prime}\{M/x\}\rrbracket=\Pi y{:}\{\llbracket\tau\{M/x\}\rrbracket\}.\llbracket K^{\prime}\{M/x\}\rrbracket by definition
Πy:{τ{{Mc}/x}}.K{{Mc}/x}\Pi y{:}\{\llbracket\tau\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket K^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by i.h.(3) and i.h.(1)
=(Πy:{τ}.K){{Mc}/x}=(\Pi y{:}\{\llbracket\tau\rrbracket\}.\llbracket K^{\prime}\rrbracket)\{\{\llbracket M\rrbracket_{c}\}/x\} by definition, satisfying \Rightarrow
Subcase: \Leftarrow
Πy:τ.K{{Mc}/x}=(Πy:{τ}.K){{Mc}/x}=\llbracket\Pi y{:}\tau.K^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=(\Pi y{:}\{\llbracket\tau\rrbracket\}.\llbracket K^{\prime}\rrbracket)\{\{\llbracket M\rrbracket_{c}\}/x\}=
Πy:{τ}{{Mc}/x}.K{{Mc}/x}\Pi y{:}\{\llbracket\tau\rrbracket\}\{\{\llbracket M\rrbracket_{c}\}/x\}.\llbracket K^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition
Πy:{τ{M/x}}.K{M/x}\Pi y{:}\{\llbracket\tau\{M/x\}\rrbracket\}.\llbracket K^{\prime}\{M/x\}\rrbracket by i.h.(3) and i.h.(1)
=Πy:τ.K{M/x}=\llbracket\Pi y{:}\tau.K^{\prime}\{M/x\}\rrbracket by definition, satisfying \Leftarrow
Case:

K=Πt:K1.K2K=\Pi t{:}K_{1}.K_{2}

Same argument as above, appealing to i.h.(1)

(2)

As above, appealing to i.h.(2)

(3)

As above, appealing to i.h.(3)

(4)

Case:

τ=Πy:τ.σ\tau=\Pi y{:}\tau^{\prime}.\sigma

Subcase: \Rightarrow
Πy:τ.σ{M/x}=Πy:τ{M/x}.σ{M/x}=y:{τ{M/x}}.σ{M/x}\llbracket\Pi y{:}\tau^{\prime}.\sigma\{M/x\}\rrbracket=\llbracket\Pi y{:}\tau^{\prime}\{M/x\}.\sigma\{M/x\}\rrbracket=\forall y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}.\llbracket\sigma\{M/x\}\rrbracket by definition
y:{τ{{Mc}/x}}.σ{{Mc}/x}\forall y{:}\{\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by i.h.(3)
=(y:{τ}.σ){{Mc}/x}=(\forall y{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma\rrbracket)\{\{\llbracket M\rrbracket_{c}\}/x\} by definition, satisfying \Rightarrow
Subcase: \Leftarrow
Πy:τ.σ{{Mc}/x}=(y:{τ}.σ){{Mc}/x}=y:{τ{{Mc}/x}}.σ{{Mc}/x}\llbracket\Pi y{:}\tau^{\prime}.\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=(\forall y{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma\rrbracket)\{\{\llbracket M\rrbracket_{c}\}/x\}=\forall y{:}\{\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}
by definition
y:{τ{M/x}}.σ{M/x}\forall y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}.\llbracket\sigma\{M/x\}\rrbracket by i.h.(3)
=Πy:(τ{M/x}).(σ{M/x})=Πy:τ.σ{M/x}=\llbracket\Pi y{:}(\tau^{\prime}\{M/x\}).(\sigma\{M/x\})\rrbracket=\llbracket\Pi y{:}\tau^{\prime}.\sigma\{M/x\}\rrbracket by definition, satisfying \Leftarrow
Case:

τ=λy:τ.σ\tau=\lambda y{:}\tau^{\prime}.\sigma

As above.
Case:

τ=τM\tau=\tau^{\prime}\,M^{\prime}

τM{M/x}=τ{M/x}M{M/x}=τ{M/x}{M{M/x}c}\llbracket\tau^{\prime}\,M^{\prime}\{M/x\}\rrbracket=\llbracket\tau^{\prime}\{M/x\}\,M^{\prime}\{M/x\}\rrbracket=\llbracket\tau^{\prime}\{M/x\}\rrbracket\,\{\llbracket M^{\prime}\{M/x\}\rrbracket_{c}\} by definition
τ{{Md}/x}{Mc{{Md}/x}}\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{d}\}/x\}\,\{\llbracket M^{\prime}\rrbracket_{c}\{\{\llbracket M\rrbracket_{d}\}/x\}\} by i.h.
τM{{Md}/x}=(τ{Mc}){{Md}/x}=\llbracket\tau^{\prime}\,M^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{d}\}/x\}=(\llbracket\tau^{\prime}\rrbracket\,\{\llbracket M^{\prime}\rrbracket_{c}\})\{\{\llbracket M\rrbracket_{d}\}/x\}= τ{{Md}/x}{Mc{{Md}/x}}\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{d}\}/x\}\,\{\llbracket M^{\prime}\rrbracket_{c}\{\{\llbracket M\rrbracket_{d}\}/x\}\}
by definition
Case:

τ=λy::K.τ\tau=\lambda y::K.\tau^{\prime}

λy::K.τ{M/x}=λy::L{M/x}.τ{M/x}=λy::K{M/x}.τ{M/x}\llbracket\lambda y::K.\tau^{\prime}\{M/x\}\rrbracket=\lambda y::L\{M/x\}.\tau^{\prime}\{M/x\}\rrbracket=\lambda y::\llbracket K\{M/x\}\rrbracket.\llbracket\tau^{\prime}\{M/x\}\rrbracket by definition
λy::K.τ{{M}c/x}=λy::K{{M}c/x}.τ{{M}c/x}\llbracket\lambda y::K.\tau^{\prime}\rrbracket\{\{M\}_{c}/x\}=\lambda y::\llbracket K\rrbracket\{\{M\}_{c}/x\}.\llbracket\tau^{\prime}\rrbracket\{\{M\}_{c}/x\} by definition
=λy::K{M/x}.τ{M/x}=\lambda y::\llbracket K\{M/x\}\rrbracket.\llbracket\tau^{\prime}\{M/x\}\rrbracket by i.h.
Case:

τ=τσ\tau=\tau^{\prime}\,\sigma

Straightforward by i.h. as above.

(5)

Case:

A=𝟏A=\mathbf{1}

Trivial.

Case:

A=A1A2A=A_{1}\multimap A_{2}

A1A2{M/x}=A1{M/x}A2{M/x}\llbracket A_{1}\multimap A_{2}\{M/x\}\rrbracket=\llbracket A_{1}\{M/x\}\rrbracket\multimap\llbracket A_{2}\{M/x\}\rrbracket by definition
A1{{Mc}/x}A2{{Mc}/x}\llbracket A_{1}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\multimap\llbracket A_{2}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by i.h.
A1A2{{Mc}/x}=A1{{Mc}/x}A2{{Mc}/x}\llbracket A_{1}\multimap A_{2}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=\llbracket A_{1}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\multimap\llbracket A_{2}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition
Case:

A=A1A2A=A_{1}\otimes A_{2}

Identical to \multimap case.

Case:

A=&{li:Ai¯}A=\mathbin{\binampersand}\{\overline{l_{i}{:}A_{i}}\}

See above.

Case:

A={li:Ai¯}A=\oplus\{\overline{l_{i}{:}A_{i}}\}

See above.

Case:

A=x:τ.A0A=\forall x{:}\tau.A_{0}

x:τ.A0{M/x}=x:{τ{M/x}}.A0{M/x}\llbracket\forall x{:}\tau.A_{0}\{M/x\}\rrbracket=\forall x{:}\{\llbracket\tau\{M/x\}\rrbracket\}.\llbracket A_{0}\{M/x\}\rrbracket by definition
x:{τ{{Mc}/x}}.A0{{Mc}/x}\forall x{:}\{\llbracket\tau\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket A_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by i.h.
x:τ.A0{{Mc}/x}=x:{τ}.A0{{Mc}/x}=\llbracket\forall x{:}\tau.A_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket A_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=
x:{τ{{Mc}/x}}.A0{{Mc}/x}\forall x{:}\{\llbracket\tau\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket A_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition
Case:

A=x:τ.A0A=\exists x{:}\tau.A_{0}

As above.

Case:

A=λx:τ.A0A=\lambda x{:}\tau.A_{0}

As above.

Case:

A=A0MA=A_{0}\,M^{\prime}

A0M{M/x}=A0{M/x}{M{M/x}c}\llbracket A_{0}\,M^{\prime}\{M/x\}\rrbracket=\llbracket A_{0}\{M/x\}\rrbracket\,\{\llbracket M^{\prime}\{M/x\}\rrbracket_{c}\} by definition
(A0{{Mc}/x}){Md{{Mc}/x}}(\llbracket A_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\})\,\{\llbracket M^{\prime}\rrbracket_{d}\{\{\llbracket M\rrbracket_{c}\}/x\}\} by i.h.
A0M{{Mc}/x}=(A0{Md}){{Mc}/x}\llbracket A_{0}\,M^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=(\llbracket A_{0}\rrbracket\,\{\llbracket M^{\prime}\rrbracket_{d}\})\{\{\llbracket M\rrbracket_{c}\}/x\}
=(A0{{Mc}/x}){Md{{Mc}/x}}=(\llbracket A_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\})\,\{\llbracket M^{\prime}\rrbracket_{d}\{\{\llbracket M\rrbracket_{c}\}/x\}\} by definition
Case:

A=A0A1A=A_{0}\,A_{1}

Straightforward by i.h.

Case:

A=λt::K.A0A=\lambda t::K.A_{0}

Straightforward by i.h.

(6) Ψ;Γ;ΔM{N/x}z=Mz{{Ny}/x}::z:A{N/x}\Psi;\Gamma;\Delta\vdash\llbracket M\{N/x\}\rrbracket_{z}=\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{y}\}/x\}::z{:}\llbracket A\{N/x\}\rrbracket

Case:

M=λy:τ.M0M=\lambda y{:}\tau.M_{0}

λy:τ.M0{N/x}z::z:Πy:τ.σ{N/x}\llbracket\lambda y{:}\tau.M_{0}\{N/x\}\rrbracket_{z}::z{:}\llbracket\Pi y{:}\tau.\sigma\{N/x\}\rrbracket
λy:τ.M0{N/x}z=λy:τ{N/x}.M0{N/x}z=z(y).M0{N/x}z::z:y:{τ{N/x}}.σ{N/x}\llbracket\lambda y{:}\tau.M_{0}\{N/x\}\rrbracket_{z}=\llbracket\lambda y{:}\tau\{N/x\}.M_{0}\{N/x\}\rrbracket_{z}=z(y).\llbracket M_{0}\{N/x\}\rrbracket_{z}::z{:}\forall y{:}\{\llbracket\tau\{N/x\}\rrbracket\}.\llbracket\sigma\{N/x\}\rrbracket
by definition
z(y).M0{N/x}z=z(y).M0z{{Nc}/x}::z:y:{τ{{Nc}/x}}.σ{{Nc}/x}z(y).\llbracket M_{0}\{N/x\}\rrbracket_{z}=z(y).\llbracket M_{0}\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\}::z{:}\forall y{:}\{\llbracket\tau\rrbracket\{\{\llbracket N\rrbracket_{c}\}/x\}\}.\llbracket\sigma\rrbracket\{\{\llbracket N\rrbracket_{c}\}/x\} by i.h.
λy:τ.M0z{{Nc}/x}=z(y).M0z{{Nc}/x}\llbracket\lambda y{:}\tau.M_{0}\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\}=z(y).\llbracket M_{0}\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\} by definition
Case:

M=M1M2M=M_{1}\,M_{2}

M1M2{N/x}z::z:(σ{M2/y}){N/x}\llbracket M_{1}\,M_{2}\{N/x\}\rrbracket_{z}::z{:}\llbracket(\sigma\{M_{2}/y\})\{N/x\}\rrbracket
=(𝝂y)(M1{N/x}yy{M2{N/x}y}.[yz])=({\boldsymbol{\nu}}y)(\llbracket M_{1}\{N/x\}\rrbracket_{y}\mid y\langle\{\llbracket M_{2}\{N/x\}\rrbracket_{y}\}\rangle.[y\leftrightarrow z]) by definition
=(𝝂y)(M1y{{Nc}/x}y{M2y{{Nc}/x}}.[yz])=({\boldsymbol{\nu}}y)(\llbracket M_{1}\rrbracket_{y}\{\{\llbracket N\rrbracket_{c}\}/x\}\mid y\langle\{\llbracket M_{2}\rrbracket_{y}\{\{\llbracket N\rrbracket_{c}\}/x\}\}\rangle.[y\leftrightarrow z]) by i.h.
M1M2z{{Nc}/x}=(𝝂y)(M1yy{M2y}.[yz]){{Nc}/x}\llbracket M_{1}\,M_{2}\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\}=({\boldsymbol{\nu}}y)(\llbracket M_{1}\rrbracket_{y}\mid y\langle\{\llbracket M_{2}\rrbracket_{y}\}\rangle.[y\leftrightarrow z])\{\{\llbracket N\rrbracket_{c}\}/x\}
=(𝝂y)(M1y{{Nc}/x}y{M2y{{Nc}/x}}.[yz])=({\boldsymbol{\nu}}y)(\llbracket M_{1}\rrbracket_{y}\{\{\llbracket N\rrbracket_{c}\}/x\}\mid y\langle\{\llbracket M_{2}\rrbracket_{y}\{\{\llbracket N\rrbracket_{c}\}/x\}\}\rangle.[y\leftrightarrow z]) by definition
Case:

M={zPuj¯;di¯}M=\{z\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}

M{N/x}z=z(u0)..z(uj).z(d0)..z(dn).P{N/x}\llbracket M\{N/x\}\rrbracket_{z}=z(u_{0}).\dots.z(u_{j}).z(d_{0}).\dots.z(d_{n}).\llbracket P\{N/x\}\rrbracket by definition
z(u0)..z(uj).z(d0)..z(dn).P{{Nc}/x}z(u_{0}).\dots.z(u_{j}).z(d_{0}).\dots.z(d_{n}).\llbracket P\rrbracket\{\{\llbracket N\rrbracket_{c}\}/x\} by i.h.
Mz{{Nc}/x}=z(u0)..z(uj).z(d0)..z(dn).P{{Nc}/x}\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\}=z(u_{0}).\dots.z(u_{j}).z(d_{0}).\dots.z(d_{n}).\llbracket P\rrbracket\{\{\llbracket N\rrbracket_{c}\}/x\} by definition
Case:

M=yM=y with yxy\neq x

y{N/x}z=wy;[wz]\llbracket y\{N/x\}\rrbracket_{z}=w\leftarrow y;[w\leftrightarrow z] by definition
yz{{Nc}/x}=wy;[wz]\llbracket y\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\}=w\leftarrow y;[w\leftrightarrow z] by definition
Case:

M=yM=y with y=xy=x

x{N/x}z=Nz\llbracket x\{N/x\}\rrbracket_{z}=\llbracket N\rrbracket_{z} by definition
xz{{Nc}/x}=w{Nc};[wz]\llbracket x\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\}=w\leftarrow\{\llbracket N\rrbracket_{c}\};[w\leftrightarrow z] by definition
w{Nc};[wz]+Nzw\leftarrow\{\llbracket N\rrbracket_{c}\};[w\leftrightarrow z]\xrightarrow{}^{+}\llbracket N\rrbracket_{z} by reduction semantics
w{Nc};[wz]=Nzw\leftarrow\{\llbracket N\rrbracket_{c}\};[w\leftrightarrow z]=\llbracket N\rrbracket_{z} by 𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}

(7) Ψ;Γ;ΔP{M/x}::z:A{M/x}\Psi;\Gamma;\Delta\vdash\llbracket P\{M/x\}\rrbracket::z{:}\llbracket A\{M/x\}\rrbracket iff Ψ;Γ;ΔP{{Mc}/x}::z:A{{Mc}/x}\Psi;\Gamma;\Delta\vdash\llbracket P\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::z{:}\llbracket A\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}

Case:

P=(𝝂y)(P1P2)P=({\boldsymbol{\nu}}y)(P_{1}\mid P_{2})

(𝝂y)(P1P2){M/x}=(𝝂y)(P1{M/x}P2{M/x})\llbracket({\boldsymbol{\nu}}y)(P_{1}\mid P_{2})\{M/x\}\rrbracket=({\boldsymbol{\nu}}y)(\llbracket P_{1}\{M/x\}\rrbracket\mid\llbracket P_{2}\{M/x\}\rrbracket) by definition
(𝝂y)(P1{{Mc}/x}P2{{Mc}/x})({\boldsymbol{\nu}}y)(\llbracket P_{1}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\mid\llbracket P_{2}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}) by i.h.
(𝝂y)(P1P2){{Mc}/x}=(𝝂y)(P1{{Mc}/x}P2{{Mc}/x})\llbracket({\boldsymbol{\nu}}y)(P_{1}\mid P_{2})\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=({\boldsymbol{\nu}}y)(\llbracket P_{1}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\mid\llbracket P_{2}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}) by definition
Case:

P=zM0.P0P=z\langle M_{0}\rangle.P_{0} by 𝖱{{\exists}\mathsf{R}}

zM0.P0{M/x}=z{M0{M/x}d}.P0{M/x}\llbracket z\langle M_{0}\rangle.P_{0}\{M/x\}\rrbracket=z\langle\{\llbracket M_{0}\{M/x\}\rrbracket_{d}\}\rangle.\llbracket P_{0}\{M/x\}\rrbracket by definition
z{M0d{{Mc}/x}}.P0{{Mc}/x}z\langle\{\llbracket M_{0}\rrbracket_{d}\{\{\llbracket M\rrbracket_{c}\}/x\}\}\rangle.\llbracket P_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by i.h.
zM0.P0{{Mc}/x}=z{M0d{{Mc}/x}}.P0{{Mc}/x}\llbracket z\langle M_{0}\rangle.P_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=z\langle\{\llbracket M_{0}\rrbracket_{d}\{\{\llbracket M\rrbracket_{c}\}/x\}\}\rangle.\llbracket P_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition
Case:

P=xM0uj¯;yi¯;P0P=x\leftarrow M_{0}\leftarrow\overline{u_{j}};\overline{y_{i}};P_{0}

P{M/x}=(𝝂c)(M0{M/x}cc¯v1.(u1¯a1.[a1v1]\llbracket P\{M/x\}\rrbracket=({\boldsymbol{\nu}}c)(\llbracket M_{0}\{M/x\}\rrbracket_{c}\mid\overline{c}\langle v_{1}\rangle.(\overline{u_{1}}\langle a_{1}\rangle.[a_{1}\leftrightarrow v_{1}]\mid\dots\mid
c¯d1.([y1d1]c¯dn.([yndn]P0{M/x}))\overline{c}\langle d_{1}\rangle.([y_{1}\leftrightarrow d_{1}]\mid\dots\mid\overline{c}\langle d_{n}\rangle.([y_{n}\leftrightarrow d_{n}]\mid\llbracket P_{0}\{M/x\}\rrbracket)\dots) by definition
(𝝂c)(M0c{{Mc}/x}c¯v1.(u1¯a1.[a1v1]({\boldsymbol{\nu}}c)(\llbracket M_{0}\rrbracket_{c}\{\{\llbracket M\rrbracket_{c}\}/x\}\mid\overline{c}\langle v_{1}\rangle.(\overline{u_{1}}\langle a_{1}\rangle.[a_{1}\leftrightarrow v_{1}]\mid\dots\mid
c¯d1.([y1d1]c¯dn.([yndn]P0{{Mc}/x}))\overline{c}\langle d_{1}\rangle.([y_{1}\leftrightarrow d_{1}]\mid\dots\mid\overline{c}\langle d_{n}\rangle.([y_{n}\leftrightarrow d_{n}]\mid\llbracket P_{0}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\})\dots) by i.h.
=P{{Mc}/x}=\llbracket P\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition

Remaining process cases are straightforward by i.h.

Lemma 0.C.2 (Compositionality – Reflection in Equality)
  1. 1.

    ΨK{M/x}=K{{Mc}/x}\Psi\vdash\llbracket K\{M/x\}\rrbracket=\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}

  2. 2.

    ΨK1{τ/t}=K1{τ/t}\Psi\vdash\llbracket K_{1}\{\tau/t\}\rrbracket=\llbracket K_{1}\rrbracket\{\llbracket\tau\rrbracket/t\}

  3. 3.

    ΨK1{A/x}=K1{A/x}\Psi\vdash\llbracket K_{1}\{A/x\}\rrbracket=\llbracket K_{1}\rrbracket\{\llbracket A\rrbracket/x\}

  4. 4.

    Ψτ{M/x}=τ{{Mc}/x}::K{M/x}\Psi\vdash\llbracket\tau\{M/x\}\rrbracket=\llbracket\tau\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\{M/x\}\rrbracket

  5. 5.

    ΨA{M/x}=A{{Mc}/x}::K{M/x}\Psi\vdash\llbracket A\{M/x\}\rrbracket=\llbracket A\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\{M/x\}\rrbracket

  6. 6.

    Ψ;Γ;ΔM{N/x}z=Mz{{Ny}/x}::z:A{N/x}\Psi;\Gamma;\Delta\vdash\llbracket M\{N/x\}\rrbracket_{z}=\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{y}\}/x\}::z{:}\llbracket A\{N/x\}\rrbracket

  7. 7.

    Ψ;Γ;ΔP{M/x}=P{{Mc}/x}::z:A{M/x}\Psi;\Gamma;\Delta\vdash\llbracket P\{M/x\}\rrbracket=\llbracket P\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::z{:}\llbracket A\{M/x\}\rrbracket

Proof

(1-3) is identical to corresponding statements in Lemma 0.C.1.

(4) Ψτ{M/x}=τ{{Mc}/x}::K{M/x}\Psi\vdash\llbracket\tau\{M/x\}\rrbracket=\llbracket\tau\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\{M/x\}\rrbracket

Case:

τ=Πy:τ.σ\tau=\Pi y{:}\tau^{\prime}.\sigma

Πy:τ.σ{M/x}=Πy:τ{M/x}.σ{M/x}=y:{τ{M/x}}.σ{M/x}\llbracket\Pi y{:}\tau^{\prime}.\sigma\{M/x\}\rrbracket=\llbracket\Pi y{:}\tau^{\prime}\{M/x\}.\sigma\{M/x\}\rrbracket=\forall y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}.\llbracket\sigma\{M/x\}\rrbracket by definition
Πy:τ.σ{{Mc}/x}=(y:{τ}.σ){{Mc}/x}=y:{τ{{Mc}/x}}.σ{{Mc}/x}\llbracket\Pi y{:}\tau^{\prime}.\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=(\forall y{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma\rrbracket)\{\{\llbracket M\rrbracket_{c}\}/x\}=\forall y{:}\{\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}
by definition
Ψ{τ{M/x}}={τ{{Mc}/x}}::𝗍𝗒𝗉𝖾\Psi\vdash\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}=\{\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}::\mathsf{type} by i.h. and 𝖳𝖤𝗊{}\mathsf{TEq}\{\}
Ψ,y:{τ{M/x}}σ{M/x}=σ{{Mc}/x}::𝗌𝗍𝗒𝗉𝖾\Psi,y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}\vdash\llbracket\sigma\{M/x\}\rrbracket=\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\mathsf{stype} by i.h.
Ψy:{τ{M/x}}.σ{M/x}=y:{τ{{Mc}/x}}.σ{{Mc}/x}::𝗌𝗍𝗒𝗉𝖾\Psi\vdash\forall y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}.\llbracket\sigma\{M/x\}\rrbracket=\forall y{:}\{\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\mathsf{stype} by 𝖲𝖳𝖤𝗊\mathsf{STEq}\forall
Case:

τ=λy:τ.σ\tau=\lambda y{:}\tau^{\prime}.\sigma

λy:τ.σ{M/x}=λy:{τ{M/x}}.σ{M/x}\llbracket\lambda y{:}\tau^{\prime}.\sigma\{M/x\}\rrbracket=\lambda y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}.\llbracket\sigma\{M/x\}\rrbracket by definition
λy:τ.σ{{Mc}/x}=λy:{τ}{{Mc}/x}}.σ{{Mc}/x}\llbracket\lambda y{:}\tau^{\prime}.\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=\lambda y{:}\{\llbracket\tau^{\prime}\rrbracket\}\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition
Ψ{τ{M/x}}={τ}{{Mc}/x}}::𝗍𝗒𝗉𝖾\Psi\vdash\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}=\{\llbracket\tau^{\prime}\rrbracket\}\{\{\llbracket M\rrbracket_{c}\}/x\}\}::\mathsf{type} by i.h. and 𝖳𝖤𝗊{}\mathsf{TEq}\{\}
Ψ,y:{τ{M/x}}σ{M/x}=σ{{Mc}/x}::K{M/x}\Psi,y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}\vdash\llbracket\sigma\{M/x\}\rrbracket=\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\{M/x\}\rrbracket by i.h.
Ψλy:{τ{M/x}}.σ{M/x}=λy:{τ}{{Mc}/x}}.σ{{Mc}/x}::Πx:{τ{M/x}}.K{M/x}\Psi\vdash\lambda y{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}.\llbracket\sigma\{M/x\}\rrbracket=\lambda y{:}\{\llbracket\tau^{\prime}\rrbracket\}\{\{\llbracket M\rrbracket_{c}\}/x\}\}.\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\Pi x{:}\{\llbracket\tau^{\prime}\{M/x\}\rrbracket\}.\llbracket K\{M/x\}\rrbracket
by 𝖲𝖳𝖤𝗊λ\mathsf{STEq}\lambda
Case:

τ=τM\tau=\tau^{\prime}\,M^{\prime}

τM{M/x}=τ{M/x}{M{M/x}d}\llbracket\tau^{\prime}\,M^{\prime}\{M/x\}\rrbracket=\llbracket\tau^{\prime}\{M/x\}\rrbracket\,\{\llbracket M^{\prime}\{M/x\}\rrbracket_{d}\} by definition
τM{{Mc}/x}=(τ{{Mc}/x}){Md{{Mc}/x}}\llbracket\tau^{\prime}\,M^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=(\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\})\,\{\llbracket M^{\prime}\rrbracket_{d}\{\{\llbracket M\rrbracket_{c}\}/x\}\} by definition
Ψτ{M/x}=τ{{Mc}/x}::Πy:{τ′′{M/x}}.K{M/x}\Psi\vdash\llbracket\tau^{\prime}\{M/x\}\rrbracket=\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\Pi y{:}\{\llbracket\tau^{\prime\prime}\{M/x\}\rrbracket\}.\llbracket K\{M/x\}\rrbracket by i.h
Ψ{M{M/x}d}={Md{{Mc}/x}}:{τ′′{M/x}}\Psi\vdash\{\llbracket M^{\prime}\{M/x\}\rrbracket_{d}\}=\{\llbracket M^{\prime}\rrbracket_{d}\{\{\llbracket M\rrbracket_{c}\}/x\}\}:\{\llbracket\tau^{\prime\prime}\{M/x\}\rrbracket\} by i.h. and 𝖳𝖤𝗊{}\mathsf{TEq}\{\}
Ψτ{M/x}{M{M/x}d}=\Psi\vdash\llbracket\tau^{\prime}\{M/x\}\rrbracket\,\{\llbracket M^{\prime}\{M/x\}\rrbracket_{d}\}=
(τ{{Mc}/x}){Md{{Mc}/x}}::K{M/x}{{M{M/x}d}/y}\qquad(\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\})\,\{\llbracket M^{\prime}\rrbracket_{d}\{\{\llbracket M\rrbracket_{c}\}/x\}\}::\llbracket K\{M/x\}\rrbracket\{\{\llbracket M^{\prime}\{M/x\}\rrbracket_{d}\}/y\} by 𝖲𝖳𝖤𝗊𝖠𝗉𝗉\mathsf{STEqApp}
Case:

τ=λt::K.τ\tau=\lambda t::K^{\prime}.\tau^{\prime}

λt::K.τ{M/x}=λt::K{M/x}.τ{M/x}\llbracket\lambda t::K^{\prime}.\tau^{\prime}\{M/x\}\rrbracket=\lambda t::\llbracket K^{\prime}\{M/x\}\rrbracket.\llbracket\tau^{\prime}\{M/x\}\rrbracket by definition
λt::K.τ{{Mc}/x}=λt::K{{Mc}/x}.τ{{Mc}/x}\llbracket\lambda t::K^{\prime}.\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=\lambda t::\llbracket K^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}.\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition
ΨK{M/x}=K{{Mc}/x}\Psi\vdash\llbracket K^{\prime}\{M/x\}\rrbracket=\llbracket K^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by i.h.
Ψ,t::K{M/x}τ{M/x}=τ{{Mc}/x}::K′′{M/x}\Psi,t::\llbracket K^{\prime}\{M/x\}\rrbracket\vdash\llbracket\tau^{\prime}\{M/x\}\rrbracket=\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K^{\prime\prime}\{M/x\}\rrbracket by i.h.
Ψλt::K{M/x}.τ{M/x}=\Psi\vdash\lambda t::\llbracket K^{\prime}\{M/x\}\rrbracket.\llbracket\tau^{\prime}\{M/x\}\rrbracket=
λt::K{{Mc}/x}.τ{{Mc}/x}::Πt::K{M/x}.K′′{M/x}\qquad\lambda t::\llbracket K^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}.\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\Pi t::\llbracket K^{\prime}\{M/x\}\rrbracket.\llbracket K^{\prime\prime}\{M/x\}\rrbracket by 𝖲𝖳𝖤𝗊𝖳λ\mathsf{STEqT}\lambda
Case:

τ=τσ\tau=\tau^{\prime}\,\sigma

τσ{M/x}=τ{M/x}σ{M/x}\llbracket\tau^{\prime}\,\sigma\{M/x\}\rrbracket=\llbracket\tau^{\prime}\{M/x\}\rrbracket\,\llbracket\sigma\{M/x\}\rrbracket by definition
τσ{{Mc}/x}=τ{{Mc}/x}σ{{Mc}/x}\llbracket\tau^{\prime}\,\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}=\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}\,\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by definition
Ψτ{M/x}=τ{{Mc}/x}::Πt:K{M/x}.K{M/x}\Psi\vdash\llbracket\tau^{\prime}\{M/x\}\rrbracket=\llbracket\tau^{\prime}\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\Pi t:\llbracket K\{M/x\}\rrbracket.\llbracket K^{\prime}\{M/x\}\rrbracket by i.h.
Ψσ{M/x}=σ{{Mc}/x}::K{M/x}\Psi\vdash\llbracket\sigma\{M/x\}\rrbracket=\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\{M/x\}\rrbracket by i.h.

Remaining cases are identical.

Lemma 0.C.3 (Preservation of Equality)
  1. 1.

    If ΨK1=K2\Psi\vdash K_{1}=K_{2} then {Ψ}K1=K2\{\llbracket\Psi\rrbracket\}\vdash\llbracket K_{1}\rrbracket=\llbracket K_{2}\rrbracket

  2. 2.

    If Ψτ1=τ2::K\Psi\vdash\tau_{1}=\tau_{2}::K then {Ψ}τ1=τ2::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau_{1}\rrbracket=\llbracket\tau_{2}\rrbracket::\llbracket K\rrbracket

  3. 3.

    If ΨA=B::K\Psi\vdash A=B::K then {Ψ}A=B::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket A\rrbracket=\llbracket B\rrbracket::\llbracket K\rrbracket

  4. 4.

    If ΨM=N:τ\Psi\vdash M=N:\tau then {Ψ};;Mz=Nz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}=\llbracket N\rrbracket_{z}::z{:}\llbracket\tau\rrbracket

  5. 5.

    If Ψ;Γ;ΔP=Q::z:A\Psi;\Gamma;\Delta\vdash P=Q::z{:}A then {Ψ};Γ;ΔP=Q::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket=\llbracket Q\rrbracket::z{:}\llbracket A\rrbracket

Proof

By induction on the given judgment.

Case:

𝖪𝖤𝗊𝖱\mathsf{KEqR}, 𝖪𝖤𝗊𝖲\mathsf{KEqS}, 𝖪𝖤𝗊𝖳\mathsf{KEqT} and 𝖪𝖤𝗊Π2\mathsf{KEq}\Pi_{2}

Immediate by i.h.

Case:

𝖪𝖤𝗊Π1\mathsf{KEq}\Pi_{1}

Ψτ=σ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\sigma::\mathsf{type} and Ψ,x:τK1=K2\Psi,x{:}\tau\vdash K_{1}=K_{2} by inversion
{Ψ}τ=σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket=\llbracket\sigma\rrbracket::\mathsf{stype} by i.h.
{Ψ}{τ}={σ}::𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket\tau\rrbracket\}=\{\llbracket\sigma\rrbracket\}::\mathsf{type} by 𝖳𝖤𝗊{}\mathsf{TEq}\{\} {Ψ},x:{τ}K1=K2\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}\vdash\llbracket K_{1}\rrbracket=\llbracket K_{2}\rrbracket by i.h.
{Ψ}Πx:{τ}.K1=Πx:{σ}.K2\{\llbracket\Psi\rrbracket\}\vdash\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K_{1}\rrbracket=\Pi x{:}\{\llbracket\sigma\rrbracket\}.\llbracket K_{2}\rrbracket by 𝖪𝖤𝗊Π1\mathsf{KEq}\Pi_{1}

(2)

Case:

𝖳𝖤𝗊𝖱\mathsf{TEqR}, 𝖳𝖤𝗊𝖳\mathsf{TEqT}, 𝖳𝖤𝗊𝖲\mathsf{TEqS}

Immediate by i.h.

Case:

𝖳𝖤𝗊Π\mathsf{TEq}\Pi

Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type} and Ψ,x:τσ=σ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash\sigma=\sigma^{\prime}::\mathsf{type} by inversion
{Ψ}τ=τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket=\llbracket\tau^{\prime}\rrbracket::\mathsf{stype} by i.h. {Ψ}{τ}={τ}::𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket\tau\rrbracket\}=\{\llbracket\tau^{\prime}\rrbracket\}::\mathsf{type} by 𝖳𝖤𝗊{}\mathsf{TEq}\{\}
{Ψ},x:{τ}σ=σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}\vdash\llbracket\sigma\rrbracket=\llbracket\sigma^{\prime}\rrbracket::\mathsf{stype} by i.h.
{Ψ}x:{τ}.σ=x:{τ}.σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket=\forall x{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma^{\prime}\rrbracket::\mathsf{stype} by 𝖲𝖳𝖤𝗊\mathsf{STEq}\forall
Case:

𝖳𝖤𝗊λ\mathsf{TEq}\lambda

Ψτ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\tau=\tau^{\prime}::\mathsf{type} and Ψ,x:τσ=σ::K\Psi,x{:}\tau\vdash\sigma=\sigma^{\prime}::K by inversion
{Ψ}τ=τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket=\llbracket\tau^{\prime}\rrbracket::\mathsf{stype} by i.h.
{Ψ}{τ}={τ}::𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket\tau\rrbracket\}=\{\llbracket\tau^{\prime}\rrbracket\}::\mathsf{type} by 𝖳𝖤𝗊{}\mathsf{TEq}\{\}
{Ψ},x:{τ}σ=σ::K\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}\vdash\llbracket\sigma\rrbracket=\llbracket\sigma^{\prime}\rrbracket::\llbracket K\rrbracket by i.h.
{Ψ}λx:{τ}.σ=λx:{τ}.σ::Πx:{τ}.K\{\llbracket\Psi\rrbracket\}\vdash\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket=\lambda x{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma^{\prime}\rrbracket::\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket by 𝖲𝖳𝖤𝗊λ\mathsf{STEq}\lambda
Case:

𝖳𝖤𝗊Tλ\mathsf{TEq}T\lambda

ΨK=K\Psi\vdash K=K^{\prime} and Ψ,t::Kτ=σ::K′′\Psi,t::K\vdash\tau=\sigma::K^{\prime\prime} by inversion
{Ψ}K=K\{\llbracket\Psi\rrbracket\}\vdash\llbracket K\rrbracket=\llbracket K^{\prime}\rrbracket by i.h.
{Ψ},t::Kτ=σ::K′′\{\llbracket\Psi\rrbracket\},t::\llbracket K\rrbracket\vdash\llbracket\tau\rrbracket=\llbracket\sigma\rrbracket::\llbracket K^{\prime\prime}\rrbracket by i.h.
{Ψ}λt::K.τ=λt::K.σ::Πt::K.K′′\{\llbracket\Psi\rrbracket\}\vdash\lambda t::\llbracket K\rrbracket.\llbracket\tau\rrbracket=\lambda t::\llbracket K^{\prime}\rrbracket.\llbracket\sigma\rrbracket::\Pi t::\llbracket K\rrbracket.\llbracket K^{\prime\prime}\rrbracket by 𝖲𝖳𝖤𝗊Tλ\mathsf{STEq}T\lambda
Case:

𝖳𝖤𝗊𝖠𝗉𝗉\mathsf{TEqApp}

Ψτ=σ::Πx:τ.K\Psi\vdash\tau=\sigma::\Pi x{:}\tau^{\prime}.K and ΨM=N:τ\Psi\vdash M=N:\tau^{\prime} by inversion
{Ψ}τ=σ::Πx:{τ}.K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket=\llbracket\sigma\rrbracket::\Pi x{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket K\rrbracket by i.h.
{Ψ};;Mz=Nz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}=\llbracket N\rrbracket_{z}::z{:}\llbracket\tau^{\prime}\rrbracket by i.h.
{Ψ}{Mz}={Nz}:{τ}\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket M\rrbracket_{z}\}=\{\llbracket N\rrbracket_{z}\}:\{\llbracket\tau^{\prime}\rrbracket\} by 𝖳𝖤𝗊{}\mathsf{TEq}\{\}
{Ψ}τ{Mz}=σ{Nz}::K{{Mz}/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket\,\{\llbracket M\rrbracket_{z}\}=\llbracket\sigma\rrbracket\,\{\llbracket N\rrbracket_{z}\}::\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{z}\}/x\} by 𝖲𝖳𝖤𝗊𝖠𝗉𝗉\mathsf{STEqApp}
{Ψ}τ{Mz}=σ{Nz}::K{M/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket\,\{\llbracket M\rrbracket_{z}\}=\llbracket\sigma\rrbracket\,\{\llbracket N\rrbracket_{z}\}::\llbracket K\{M/x\}\rrbracket by compositionality and conversion
Case:

𝖳𝖤𝗊𝖳𝖠𝗉𝗉\mathsf{TEqTApp}

Ψτ=τ::Πt::K1.K2\Psi\vdash\tau=\tau^{\prime}::\Pi t::K_{1}.K_{2} and Ψσ=σ::K1\Psi\vdash\sigma=\sigma^{\prime}::K_{1} by inversion
{Ψ}τ=τ::Πt::K1.K2\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket=\llbracket\tau^{\prime}\rrbracket::\Pi t::\llbracket K_{1}\rrbracket.\llbracket K_{2}\rrbracket by i.h.
{Ψ}σ=σ::K1\{\llbracket\Psi\rrbracket\}\vdash\llbracket\sigma\rrbracket=\llbracket\sigma^{\prime}\rrbracket::\llbracket K_{1}\rrbracket by i.h.
{Ψ}τσ=τσ::K2{σ/t}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket\,\llbracket\sigma\rrbracket=\llbracket\tau^{\prime}\rrbracket\,\llbracket\sigma^{\prime}\rrbracket::\llbracket K_{2}\rrbracket\{\llbracket\sigma\rrbracket/t\} by 𝖲𝖳𝖤𝗊𝖳𝖠𝗉𝗉\mathsf{STEqTApp}
{Ψ}τσ=τσ::K2{σ/t}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket\,\llbracket\sigma\rrbracket=\llbracket\tau^{\prime}\rrbracket\,\llbracket\sigma^{\prime}\rrbracket::\llbracket K_{2}\{\sigma/t\}\rrbracket by compositionality and conversion
Case:

𝖳𝖤𝗊β\mathsf{TEq}\beta

Ψ,x:τσ::K\Psi,x{:}\tau\vdash\sigma::K and ΨM:τ\Psi\vdash M:\tau by inversion
{Ψ},x:{τ}σ::K\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}\vdash\llbracket\sigma\rrbracket::\llbracket K\rrbracket by type preservation of the encoding
{Ψ};;Mc::c:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{c}::c{:}\llbracket\tau\rrbracket by type preservation of the encoding
{Ψ}{Mc}:{τ}\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket M\rrbracket_{c}\}:\{\llbracket\tau\rrbracket\} by {}I\{\}I
{Ψ}(λx:{τ}.σ){Mc}=σ{{Mc}/x}::K{{Mc}/x}\{\llbracket\Psi\rrbracket\}\vdash(\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket)\,\{\llbracket M\rrbracket_{c}\}=\llbracket\sigma\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\}::\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by 𝖲𝖳𝖤𝗊β\mathsf{STEq}\beta
{Ψ}(λx:{τ}.σ){Mc}=σ{M/x}::K{M/x}\{\llbracket\Psi\rrbracket\}\vdash(\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket)\,\{\llbracket M\rrbracket_{c}\}=\llbracket\sigma\{M/x\}\rrbracket::\llbracket K\{M/x\}\rrbracket
by compositionality and conversion
Case:

𝖳𝖤𝗊Tβ\mathsf{TEq}T\beta

Ψσ::K\Psi\vdash\sigma::K and Ψ,t::Kτ::K\Psi,t::K\vdash\tau::K^{\prime} by inversion
{Ψ}σ::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\sigma\rrbracket::\llbracket K\rrbracket by type preservation of the encoding
{Ψ},t::Kτ::K\{\llbracket\Psi\rrbracket\},t::\llbracket K\rrbracket\vdash\llbracket\tau\rrbracket::\llbracket K^{\prime}\rrbracket by type preservation of the encoding
{Ψ}(λt::K.τ)σ=τ{σ/t}::K{σ/t}\{\llbracket\Psi\rrbracket\}\vdash(\lambda t::\llbracket K\rrbracket.\llbracket\tau\rrbracket)\,\llbracket\sigma\rrbracket=\llbracket\tau\rrbracket\{\llbracket\sigma\rrbracket/t\}::\llbracket K^{\prime}\rrbracket\{\llbracket\sigma\rrbracket/t\} by 𝖲𝖳𝖤𝗊Tβ\mathsf{STEq}T\beta
{Ψ}(λt::K.τ)σ=τ{σ/t}::K{σ/t}\{\llbracket\Psi\rrbracket\}\vdash(\lambda t::\llbracket K\rrbracket.\llbracket\tau\rrbracket)\,\llbracket\sigma\rrbracket=\llbracket\tau\{\sigma/t\}\rrbracket::\llbracket K^{\prime}\{\sigma/t\}\rrbracket by compositionality and conversion
Case:

𝖳𝖤𝗊η\mathsf{TEq}\eta

Ψσ::Πx:τ.K\Psi\vdash\sigma::\Pi x{:}\tau.K and xfv(σ)x\not\in fv(\sigma) by inversion
{Ψ}σ::Πx:{τ}.K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\sigma\rrbracket::\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket by type preservation of the encoding
{Ψ}λx:{τ}.σx=σ::Πx:{τ}.K\{\llbracket\Psi\rrbracket\}\vdash\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket\,x=\llbracket\sigma\rrbracket::\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket by 𝖲𝖳𝖤𝗊η\mathsf{STEq}\eta
{Ψ}λx:{τ}.σ{c(yx;[yc])}=σ::Πx:{τ}.K\{\llbracket\Psi\rrbracket\}\vdash\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket\,\{c\leftarrow(y\leftarrow x;[y\leftrightarrow c])\}=\llbracket\sigma\rrbracket::\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket
by 𝖲𝖳𝖤𝗊𝖳\mathsf{STEqT}, 𝖲𝖳𝖤𝗊𝖠𝗉𝗉\mathsf{STEqApp} and 𝖳𝖬𝖤𝗊{}η\mathsf{TMEq}\{\}\eta
Case:

𝖳𝖤𝗊𝖳η\mathsf{TEqT}\eta

Ψτ::Πt::K1.K2\Psi\vdash\tau::\Pi t::K_{1}.K_{2} and tfv(τ)t\not\in fv(\tau) by inversion
{Ψ}τ::Πt::K1.K2\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket::\Pi t::\llbracket K_{1}\rrbracket.\llbracket K_{2}\rrbracket by type preservation of the encoding
{Ψ}λt::K.τt=τ::Πt::K.K\{\llbracket\Psi\rrbracket\}\vdash\lambda t::\llbracket K\rrbracket.\llbracket\tau\rrbracket\,t=\llbracket\tau\rrbracket::\Pi t::\llbracket K\rrbracket.\llbracket K^{\prime}\rrbracket by 𝖲𝖳𝖤𝗊𝖳η\mathsf{STEqT}\eta
Case:

𝖳𝖤𝗊{}\mathsf{TEq}\{\}

i,j.ΨAi=Bi::𝗌𝗍𝗒𝗉𝖾\forall i,j.\Psi\vdash A_{i}=B_{i}::\mathsf{stype}, ΨCj=Dj::𝗌𝗍𝗒𝗉𝖾\Psi\vdash C_{j}=D_{j}::\mathsf{stype} and ΨA=B::𝗌𝗍𝗒𝗉𝖾\Psi\vdash A=B::\mathsf{stype} by inversion
{Ψ}Cj=Dj::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket C_{j}\rrbracket=\llbracket D_{j}\rrbracket::\mathsf{stype} by i.h.
{Ψ}Ai=Bi::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket A_{i}\rrbracket=\llbracket B_{i}\rrbracket::\mathsf{stype} by i.h.
{Ψ}A=B::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket A\rrbracket=\llbracket B\rrbracket::\mathsf{stype} by i.h.
{Ψ}!Cj¯Ai¯A=!Dj¯Bi¯B::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\overline{{!}\llbracket C_{j}\rrbracket}\multimap\overline{\llbracket A_{i}\rrbracket}\multimap\llbracket A\rrbracket=\overline{{!}\llbracket D_{j}\rrbracket}\multimap\overline{\llbracket B_{i}\rrbracket}\multimap\llbracket B\rrbracket::\mathsf{stype} by 𝖲𝖳𝖤𝗊\mathsf{STEq}\multimap and 𝖲𝖳𝖤𝗊!\mathsf{STEq}{!}

(3)

All cases are identical to those of (2).

(4)

Case:

𝖳𝖬𝖤𝗊𝖱\mathsf{TMEqR}

ΨM:τ\Psi\vdash M:\tau by inversion
{Ψ};;Mz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}::z{:}\llbracket\tau\rrbracket by type preservation of the encoding
{Ψ};;Mz=Mz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}=\llbracket M\rrbracket_{z}::z{:}\llbracket\tau\rrbracket by 𝖯𝖤𝗊𝖱\mathsf{PEqR}
Case:

𝖳𝖬𝖤𝗊𝖲\mathsf{TMEqS} 𝖳𝖬𝖤𝗊𝖳\mathsf{TMEqT}

Immediate by i.h. and the corresponding definitional equality rules for processes.

Case:

𝖳𝖬𝖤𝗊λ\mathsf{TMEq}\lambda

Ψλx:τ.M:Πx:τ.σ\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma, Ψλx:τ.N:Πx:τ.σ\Psi\vdash\lambda x{:}\tau^{\prime}.N:\Pi x{:}\tau^{\prime}.\sigma^{\prime}, ΨΠx:τ.σ=Πx:τ.σ::𝗍𝗒𝗉𝖾\Psi\vdash\Pi x{:}\tau.\sigma=\Pi x{:}\tau^{\prime}.\sigma^{\prime}::\mathsf{type}
and Ψ,x:τM=N:σ\Psi,x{:}\tau\vdash M=N:\sigma by inversion
{Ψ},x:{τ};;Mz=Nz::z:σ\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}=\llbracket N\rrbracket_{z}::z{:}\llbracket\sigma\rrbracket by i.h.
{Ψ}x:{τ}.σ=x:{τ}.σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket=\forall x{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma^{\prime}\rrbracket::\mathsf{stype} by i.h.
{Ψ}z(x).Mz=z(x).Nz::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\}\vdash z(x).\llbracket M\rrbracket_{z}=z(x^{\prime}).\llbracket N\rrbracket_{z}::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by 𝖯𝖤𝗊𝖱\mathsf{PEq}{{\forall}\mathsf{R}}
Case:

𝖳𝖬𝖤𝗊𝖠𝗉𝗉\mathsf{TMEqApp}

ΨM=M:Πx:τ.σ\Psi\vdash M=M^{\prime}:\Pi x{:}\tau.\sigma and ΨN=N:τ\Psi\vdash N=N^{\prime}:\tau by inversion
{Ψ};;Mx=Mx::x:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{x}=\llbracket M^{\prime}\rrbracket_{x}::x{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by i.h.
{Ψ};;Ny=Ny::y:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket N\rrbracket_{y}=\llbracket N^{\prime}\rrbracket_{y}::y{:}\llbracket\tau\rrbracket by i.h.
{Ψ}{Ny}={Ny}:{τ}\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket N\rrbracket_{y}\}=\{\llbracket N^{\prime}\rrbracket_{y}\}:\{\llbracket\tau\rrbracket\} by 𝖳𝖬𝖤𝗊{}\mathsf{TMEq}\{\}
{Ψ};;(𝝂x)(Mxx{Ny}.[xz])=\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}x)(\llbracket M\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{y}\}\rangle.[x\leftrightarrow z])=
(𝝂x)(Mxx{Ny}.[xz])::z:σ{{Ny}/x}\qquad({\boldsymbol{\nu}}x)(\llbracket M^{\prime}\rrbracket_{x}\mid x\langle\{\llbracket N^{\prime}\rrbracket_{y}\}\rangle.[x\leftrightarrow z])::z{:}\llbracket\sigma\rrbracket\{\{\llbracket N\rrbracket_{y}\}/x\} by 𝖯𝖤𝗊𝖼𝗎𝗍\mathsf{PEq}\mathsf{cut}, 𝖯𝖤𝗊𝖫\mathsf{PEq}{{\forall}\mathsf{L}}, 𝖯𝖤𝗊𝖨𝖣\mathsf{PEqID}
{Ψ};;(𝝂x)(Mxx{Ny}.[xz])=\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}x)(\llbracket M\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{y}\}\rangle.[x\leftrightarrow z])=
(𝝂x)(Mxx{Ny}.[xz])::z:σ{N/x}\qquad({\boldsymbol{\nu}}x)(\llbracket M^{\prime}\rrbracket_{x}\mid x\langle\{\llbracket N^{\prime}\rrbracket_{y}\}\rangle.[x\leftrightarrow z])::z{:}\llbracket\sigma\{N/x\}\rrbracket by compositionality and conversion
Case:

𝖳𝖬𝖤𝗊β\mathsf{TMEq}\beta

Ψλx:τ.M:Πx:τ.σ\Psi\vdash\lambda x{:}\tau.M:\Pi x{:}\tau.\sigma and ΨN:τ\Psi\vdash N:\tau by inversion
{Ψ};;y(x).My::y:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash y(x).\llbracket M\rrbracket_{y}::y{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by type preservation of the encoding
{Ψ};;Nw::w:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket N\rrbracket_{w}::w{:}\llbracket\tau\rrbracket by type preservation of the encoding
{Ψ}{Nw}:{τ}\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket N\rrbracket_{w}\}:\{\llbracket\tau\rrbracket\} by {}I\{\}I
To show: {Ψ};;(λx:τ.M)Nz=M{N/x}z::z:σ{N/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket(\lambda x{:}\tau.M)\,N\rrbracket_{z}=\llbracket M\{N/x\}\rrbracket_{z}::z{:}\llbracket\sigma\{N/x\}\rrbracket
S.T.S: {Ψ};;(𝝂y)(y(x).Myy{Nw}.[yz])=M{N/x}z::z:σ{N/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}y)(y(x).\llbracket M\rrbracket_{y}\mid y\langle\{\llbracket N\rrbracket_{w}\}\rangle.[y\leftrightarrow z])=\llbracket M\{N/x\}\rrbracket_{z}::z{:}\llbracket\sigma\{N/x\}\rrbracket
{Ψ};;(𝝂y)(y(x).Myy{Nw}.[yz])::z:σ{{Nw}/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}y)(y(x).\llbracket M\rrbracket_{y}\mid y\langle\{\llbracket N\rrbracket_{w}\}\rangle.[y\leftrightarrow z])::z{:}\llbracket\sigma\rrbracket\{\{\llbracket N\rrbracket_{w}\}/x\}
by above, 𝗂𝖽\mathsf{id},𝖫{{\forall}\mathsf{L}} and 𝖼𝗎𝗍\mathsf{cut}
Mz{{Nw}/x}\xrightarrow{}\xrightarrow{}\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{w}\}/x\} by operational semantics
{Ψ};;Mz{{Nw}/x}::z:σ{{Nw}/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{w}\}/x\}::z{:}\llbracket\sigma\rrbracket\{\{\llbracket N\rrbracket_{w}\}/x\} by type preservation
{Ψ};;(𝝂y)(y(x).Myy{Nw}.[yz])=M{N/x}z::z:σ{N/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}y)(y(x).\llbracket M\rrbracket_{y}\mid y\langle\{\llbracket N\rrbracket_{w}\}\rangle.[y\leftrightarrow z])=\llbracket M\{N/x\}\rrbracket_{z}::z{:}\llbracket\sigma\{N/x\}\rrbracket
by above, 𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}, compositionality and conversion
Case:

𝖳𝖬𝖤𝗊η\mathsf{TMEq}\eta

ΨM:Πx:τ.σ\Psi\vdash M:\Pi x{:}\tau.\sigma and xfv(M)x\not\in{fv}(M) by inversion
{Ψ};;My::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{y}::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by type preservation of the encoding
{Ψ};;z(x).(𝝂y)(Myyx.[yz])=\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash z(x).({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid y\langle x\rangle.[y\leftrightarrow z])=
    z(x).(𝝂y)(Myy{c(yx;[yc])}.[yz])::z:x:{τ}.σz(x).({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid y\langle\{c\leftarrow(y\leftarrow x;[y\leftrightarrow c])\leftarrow\cdot\}\rangle.[y\leftrightarrow z])::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket
by 𝖯𝖤𝗊𝖢𝗎𝗍\mathsf{PEqCut}, 𝖯𝖤𝗊𝖫\mathsf{PEq}{{\forall}\mathsf{L}}, 𝖯𝖤𝗊𝖨𝖣\mathsf{PEqID}, 𝖳𝖬𝖤𝗊{}η\mathsf{TMEq}\{\}\eta and 𝖯𝖤𝗊𝖱\mathsf{PEqR}
To show: {Ψ};;z(x).(𝝂y)(Myy{c(yx;[yc])}.[yz])=\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash z(x).({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid y\langle\{c\leftarrow(y\leftarrow x;[y\leftrightarrow c])\leftarrow\cdot\}\rangle.[y\leftrightarrow z])=
Mz::z:x:{τ}.σ\qquad\llbracket M\rrbracket_{z}::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket
{Ψ};;z(x).(𝝂y)(Myyx.[yz])=(𝝂y)(Myz(x).yx.[yz])::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash z(x).({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid y\langle x\rangle.[y\leftrightarrow z])=({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid z(x).y\langle x\rangle.[y\leftrightarrow z])::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket
by 𝖯𝖤𝗊𝖢𝖢\mathsf{PEqCC}\forall
{Ψ};;(𝝂y)(Myz(x).yx.[yz])=(𝝂y)(My[yz])::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid z(x).y\langle x\rangle.[y\leftrightarrow z])=({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid[y\leftrightarrow z])::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket
by 𝖯𝖤𝗊η\mathsf{PEq}\forall\eta
(𝝂y)(My[yz])Mz({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid[y\leftrightarrow z])\xrightarrow{}\llbracket M\rrbracket_{z} by the operational semantics
{Ψ};;Mz::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by type preservation
{Ψ};;(𝝂y)(My[yz])=Mz::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid[y\leftrightarrow z])=\llbracket M\rrbracket_{z}::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by 𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}
{Ψ};;z(x).(𝝂y)(Myy{c(yx;[yc])}.[yz])=Mz::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash z(x).({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\mid y\langle\{c\leftarrow(y\leftarrow x;[y\leftrightarrow c])\leftarrow\cdot\}\rangle.[y\leftrightarrow z])=\llbracket M\rrbracket_{z}::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket
by the above reasoning and 𝖯𝖤𝗊𝖳\mathsf{PEqT}
Case:

𝖳𝖬𝖤𝗊{}\mathsf{TMEq}\{\}

Ψ;uj:Bj¯;di:Ai¯P=Q::c:A\Psi;\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash P=Q::c{:}A by inversion
{Ψ};uj:Bj¯;di:Ai¯P=Q::c:A\{\llbracket\Psi\rrbracket\};\overline{u_{j}{:}\llbracket B_{j}\rrbracket};\overline{d_{i}{:}\llbracket A_{i}\rrbracket}\vdash\llbracket P\rrbracket=\llbracket Q\rrbracket::c{:}\llbracket A\rrbracket by i.h.
{Ψ};;c(u0).c(uj).c(d0).c(dn).P=\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash c(u_{0}).\dots c(u_{j}).c(d_{0}).\dots c(d_{n}).\llbracket P\rrbracket=
c(u0).c(uj).c(d0).c(dn).Q::c:!Bj¯Ai¯A\qquad c(u_{0}).\dots c(u_{j}).c(d_{0}).\dots c(d_{n}).\llbracket Q\rrbracket::c{:}\overline{{!}\llbracket B_{j}\rrbracket}\multimap\overline{\llbracket A_{i}\rrbracket}\multimap\llbracket A\rrbracket by 𝖯𝖤𝗊𝖱\mathsf{PEq}{{\multimap}\mathsf{R}}, 𝖯𝖤𝗊!𝖫\mathsf{PEq}{{{!}}\mathsf{L}}
Case:

𝖳𝖬𝖤𝗊{}η\mathsf{TMEq}\{\}\eta

ΨM:{uj:Bj¯;di:Ai¯c:A}\Psi\vdash M:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\} by inversion
{Ψ};;Mz::!Bj¯Ai¯A\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}::\overline{{!}\llbracket B_{j}\rrbracket}\multimap\overline{\llbracket A_{i}\rrbracket}\multimap\llbracket A\rrbracket
To show: {Ψ};;c(u0).c(uj).c(d0).c(dn).zM;uj¯;di¯;[zc]\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash c(u_{0}).\dots c(u_{j}).c(d_{0}).\dots c(d_{n}).\llbracket z\leftarrow M;\overline{u_{j}};\overline{d_{i}};[z\leftrightarrow c]\rrbracket
=Mc::c:!Bj¯Ai¯A\qquad\qquad=\llbracket M\rrbracket_{c}::c{:}\overline{{!}\llbracket B_{j}\rrbracket}\multimap\overline{\llbracket A_{i}\rrbracket}\multimap\llbracket A\rrbracket
S.T.S: {Ψ};;c(u0).c(uj).c(d0).c(dn).(𝝂z)(Mz\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash c(u_{0}).\dots c(u_{j}).c(d_{0}).\dots c(d_{n}).({\boldsymbol{\nu}}z)(\llbracket M\rrbracket_{z}\mid
z¯v1.(u1¯a1.[a1v1]z¯d1.([y1d1]z¯dn.([yndn][zc]))\qquad\overline{z}\langle v_{1}\rangle.(\overline{u_{1}}\langle a_{1}\rangle.[a_{1}\leftrightarrow v_{1}]\mid\dots\mid\overline{z}\langle d_{1}\rangle.([y_{1}\leftrightarrow d_{1}]\mid\dots\mid\overline{z}\langle d_{n}\rangle.([y_{n}\leftrightarrow d_{n}]\mid[z\leftrightarrow c])\dots)
=Mc::c:!Bj¯Ai¯A\qquad=\llbracket M\rrbracket_{c}::c{:}\overline{{!}\llbracket B_{j}\rrbracket}\multimap\overline{\llbracket A_{i}\rrbracket}\multimap\llbracket A\rrbracket
by 𝖯𝖤𝗊𝖢𝖢\mathsf{PEqCC}\multimap and 𝖯𝖤𝗊𝖢𝖢!\mathsf{PEqCC}{!} and 𝖯𝖤𝗊η\mathsf{PEq}\multimap\eta and 𝖯𝖤𝗊!η\mathsf{PEq}{!}\eta, 𝖯𝖤𝗊𝖱\mathsf{PEqR} and 𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}
Case:

𝖯𝖤𝗊𝖱\mathsf{PEqR}

Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A by inversion
{Ψ};Γ;ΔP::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket::z{:}\llbracket A\rrbracket by type preservation of the encoding
{Ψ};Γ;ΔP=P::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket=\llbracket P\rrbracket::z{:}\llbracket A\rrbracket by 𝖯𝖤𝗊𝖱\mathsf{PEqR}
Case:

𝖯𝖤𝗊𝖲\mathsf{PEqS} and 𝖯𝖤𝗊𝖳\mathsf{PEqT}

Straightforward by i.h.

Case:

𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}

Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A, PQP\xrightarrow{}^{*}Q and Ψ;Γ;ΔQ::z:A\Psi;\Gamma;\Delta\vdash Q::z{:}A by inversion
{Ψ};Γ;ΔP::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket::z{:}\llbracket A\rrbracket by type preservation of the encoding
{Ψ};Γ;ΔQ::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket Q\rrbracket::z{:}\llbracket A\rrbracket by type preservation of the encoding
PQ\llbracket P\rrbracket\xrightarrow{}^{*}\llbracket Q\rrbracket by operational correspondence
{Ψ};Γ;ΔP=Q::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket=\llbracket Q\rrbracket::z{:}\llbracket A\rrbracket by 𝖯𝖤𝗊𝖱𝖾𝖽\mathsf{PEqRed}
Case:

𝖯𝖤𝗊{}E\mathsf{PEq}\{\}E

ΨM=N:{uj:Bj¯;di:Ai¯c:A}\Psi\vdash M=N:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\}, Ψ;Γ;Δ,c:AQ=Q::z:C\Psi;\Gamma;\Delta,c{:}A\vdash Q=Q^{\prime}::z{:}C, uj:Bj¯Γ\overline{u_{j}{:}B_{j}}\subseteq\Gamma and di:Ai¯=Δ\overline{d_{i}{:}A_{i}}=\Delta^{\prime}
by inversion
{Ψ};;My=Ny::y:!Bj¯Ai¯A\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{y}=\llbracket N\rrbracket_{y}::y{:}\overline{{!}\llbracket B_{j}\rrbracket}\multimap\overline{\llbracket A_{i}\rrbracket}\multimap\llbracket A\rrbracket by i.h.
{Ψ};Γ;Δ,c:AQ=Q::z:C\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket,c{:}\llbracket A\rrbracket\vdash\llbracket Q\rrbracket=\llbracket Q^{\prime}\rrbracket::z{:}\llbracket C\rrbracket by i.h.
We conclude by 𝖯𝖤𝗊𝖢𝗎𝗍\mathsf{PEqCut}, (repeated) 𝖯𝖤𝗊𝖫\mathsf{PEq}{{\multimap}\mathsf{L}}, 𝖯𝖤𝗊!𝖫\mathsf{PEq}{{{!}}\mathsf{L}} and 𝖯𝖤𝗊𝖨𝖣\mathsf{PEqID}.

All other process cases follow fairly straightforwardly by i.h.

Lemma 0.C.4 (Preservation of Typing)
  1. 1.

    If Ψ\Psi\vdash then Ψ\llbracket\Psi\rrbracket\vdash and {Ψ}\{\llbracket\Psi\rrbracket\}\vdash.

  2. 2.

    If ΨK\Psi\vdash K then {Ψ}K\{\llbracket\Psi\rrbracket\}\vdash\llbracket K\rrbracket

  3. 3.

    If Ψτ::K\Psi\vdash\tau::K then {Ψ}τ::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket::\llbracket K\rrbracket

  4. 4.

    If ΨA::K\Psi\vdash A::K then {Ψ}A::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket A\rrbracket::\llbracket K\rrbracket

  5. 5.

    If ΨM:τ\Psi\vdash M:\tau then {Ψ};;Mz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}::z{:}\llbracket\tau\rrbracket

  6. 6.

    If Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A then {Ψ};Γ;ΔP::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P\rrbracket::z{:}\llbracket A\rrbracket

Proof

By induction on the given judgement. (1) is immediate by induction.

Case:

τ=Πx:τ.σ\tau=\Pi x{:}\tau^{\prime}.\sigma

Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}::\mathsf{type} and Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau^{\prime}\vdash\sigma::\mathsf{type} by inversion
{Ψ}τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket::\mathsf{stype} by i.h.
{Ψ},x:{τ}σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau^{\prime}\rrbracket\}\vdash\llbracket\sigma\rrbracket::\mathsf{stype} by i.h.
{Ψ}x:{τ}.σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\forall x{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma\rrbracket::\mathsf{stype} by {}\{\} and \forall rules
Case:

τ={uj:Bj¯;di:Bi¯c:A}\tau=\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}B_{i}}\vdash c{:}A\}

Straightforward by induction.

Case:

τ=λx:τ.σ\tau=\lambda x{:}\tau^{\prime}.\sigma

Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau^{\prime}::\mathsf{type} and Ψ,x:τσ::𝗍𝗒𝗉𝖾\Psi,x{:}\tau^{\prime}\vdash\sigma::\mathsf{type} by inversion
{Ψ}τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket::\mathsf{stype} by i.h.
{Ψ},x:{τ}σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau^{\prime}\rrbracket\}\vdash\llbracket\sigma\rrbracket::\mathsf{stype} by i.h.
{Ψ}λx:{τ}.σ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\lambda x{:}\{\llbracket\tau^{\prime}\rrbracket\}.\llbracket\sigma\rrbracket::\mathsf{stype} by {}\{\} and λ\lambda rules
Case:

τ=τM\tau=\tau^{\prime}\,M

Ψτ::Πx:σ.K\Psi\vdash\tau^{\prime}::\Pi x{:}\sigma.K and ΨM:σ\Psi\vdash M:\sigma by inversion
{Ψ}τ::Πx:{σ}.K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket::\Pi x{:}\{\llbracket\sigma\rrbracket\}.\llbracket K\rrbracket by i.h.
{Ψ};;Mc::c:σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{c}::c{:}\llbracket\sigma\rrbracket by i.h.
{Ψ}{Mc}::c:{σ}\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket M\rrbracket_{c}\}::c{:}\{\llbracket\sigma\rrbracket\} by {}I\{\}I
{Ψ}τ{Mc}::K{{Mc}/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket\,\{\llbracket M\rrbracket_{c}\}::\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by application well-formedness rule
{Ψ}τ{Mc}::K{M/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket\,\{\llbracket M\rrbracket_{c}\}::\llbracket K\{{M}/x\}\rrbracket by compositionality
Case:

τ=λt::K.τ\tau=\lambda t::K.\tau^{\prime}

Ψ,t::Kτ::K2\Psi,t::K\vdash\tau^{\prime}::K_{2} by inversion
{Ψ},t::Kτ::K2\{\llbracket\Psi\rrbracket\},t::\llbracket K\rrbracket\vdash\llbracket\tau^{\prime}\rrbracket::\llbracket K_{2}\rrbracket by i.h.
{Ψ}λt::K.τ::Πt::K.K\{\llbracket\Psi\rrbracket\}\vdash\lambda t::\llbracket K\rrbracket.\llbracket\tau^{\prime}\rrbracket::\Pi t::\llbracket K\rrbracket.\llbracket K^{\prime}\rrbracket by TλT\lambda well-formedness rule
Case:

τ=τσ\tau=\tau^{\prime}\,\sigma

Ψτ::Πt::K1.K2\Psi\vdash\tau^{\prime}::\Pi t{::}K_{1}.K_{2} and Ψσ::K1\Psi\vdash\sigma::K_{1} by inversion
{Ψ}τ::Πt::K1.K2\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket::\Pi t{::}\llbracket K_{1}\rrbracket.\llbracket K_{2}\rrbracket by i.h.
{Ψ}σ::K1\{\llbracket\Psi\rrbracket\}\vdash\llbracket\sigma\rrbracket::\llbracket K_{1}\rrbracket by i.h.
{Ψ}τσ::K2{K1/t}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket\,\llbracket\sigma\rrbracket::\llbracket K_{2}\rrbracket\{\llbracket K_{1}\rrbracket/t\} by TappTapp well-formedness rule
{Ψ}τσ::K2{K1/t}\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket\,\llbracket\sigma\rrbracket::\llbracket K_{2}\{K_{1}/t\}\rrbracket by compositionality
Case:

τ=τ\tau=\tau^{\prime} by conversion rule

Ψτ::K\Psi\vdash\tau^{\prime}::K by inversion
ΨK=K\Psi\vdash K=K^{\prime} by inversion
{Ψ}τ::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket::\llbracket K\rrbracket by i.h.
{Ψ}K=K\{\llbracket\Psi\rrbracket\}\vdash\llbracket K\rrbracket=\llbracket K^{\prime}\rrbracket by preservation of equality
{Ψ}τ::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau^{\prime}\rrbracket::\llbracket K^{\prime}\rrbracket by conversion rule
Case:

A=𝟏A=\mathbf{1}

Immediate from the definition.

Case:

A=!AA={!}A^{\prime}

Immediate by i.h and !{!} well-formedness rule.

Case:

A=A1A2A=A_{1}\multimap A_{2}

Immediate by i.h. and \multimap well-formedness rule.

Case:

A=A1A2A=A_{1}\otimes A_{2}

Immediate by i.h. and \otimes well-formedness rule.

Case:

A=x:τ.A0A=\forall x{:}\tau.A_{0}

Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τA0::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash A_{0}::\mathsf{stype} by inversion
{Ψ}τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket::\mathsf{stype} by i.h.
{Ψ},x:{τ}A0::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}\vdash\llbracket A_{0}\rrbracket::\mathsf{stype} by i.h.
{Ψ}x:{τ}.A0::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket A_{0}\rrbracket::\mathsf{stype} by \forall well-formedness rule
Case:

A=x:τ.A0A=\exists x{:}\tau.A_{0}

Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τA0::𝗌𝗍𝗒𝗉𝖾\Psi,x{:}\tau\vdash A_{0}::\mathsf{stype} by inversion
{Ψ}τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket::\mathsf{stype} by i.h.
{Ψ},x:{τ}A0::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}\vdash\llbracket A_{0}\rrbracket::\mathsf{stype} by i.h.
{Ψ}x:{τ}.A0::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\exists x{:}\{\llbracket\tau\rrbracket\}.\llbracket A_{0}\rrbracket::\mathsf{stype} by \exists well-formedness rule
Case:

A=&{li:Bi¯}A=\mathbin{\binampersand}\{\overline{l_{i}{:}B_{i}}\}

Immediate by i.h. and &\mathbin{\binampersand} well-formedness rule.

Case:

A={li:Bi¯}A=\oplus\{\overline{l_{i}{:}B_{i}}\}

Immediate by i.h. and \oplus well-formedness rule.

Case:

A=λx:τ.AA=\lambda x{:}\tau.A^{\prime}

Ψτ::𝗍𝗒𝗉𝖾\Psi\vdash\tau::\mathsf{type} and Ψ,x:τA::K\Psi,x{:}\tau\vdash A^{\prime}::K by inversion
{Ψ}τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\tau\rrbracket::\mathsf{stype} by i.h.
{Ψ},x:{τ}A::K\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\}\vdash\llbracket A^{\prime}\rrbracket::\llbracket K\rrbracket by i.h.
{Ψ}λx:{τ}.A::Πx:{τ}.K\{\llbracket\Psi\rrbracket\}\vdash\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket A^{\prime}\rrbracket::\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket by SλS\lambda well-formedness rule
{Ψ}λx:{τ}.A::Πx:τ.K\{\llbracket\Psi\rrbracket\}\vdash\lambda x{:}\{\llbracket\tau\rrbracket\}.\llbracket A^{\prime}\rrbracket::\llbracket\Pi x{:}\tau.K\rrbracket by compositionality
Case:

A=A0MA=A_{0}\,M

ΨA0::Πx:τ.K\Psi\vdash A_{0}::\Pi x{:}\tau.K and ΨM:τ\Psi\vdash M:\tau by inversion
{Ψ}A0::Πx:{τ}.K\{\llbracket\Psi\rrbracket\}\vdash\llbracket A_{0}\rrbracket::\Pi x{:}\{\llbracket\tau\rrbracket\}.\llbracket K\rrbracket by i.h.
{Ψ};;Mc::c:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{c}::c{:}\llbracket\tau\rrbracket by i.h.
{Ψ}{Mc}:{τ}\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket M\rrbracket_{c}\}:\{\llbracket\tau\rrbracket\} by {}\{\}
{Ψ}A0{Mc}::K{{Mc}/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket A_{0}\rrbracket\,\{\llbracket M\rrbracket_{c}\}::\llbracket K\rrbracket\{\{\llbracket M\rrbracket_{c}\}/x\} by SSapp well-formedness rule
{Ψ}A0{Mc}::K{M/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket A_{0}\rrbracket\,\{\llbracket M\rrbracket_{c}\}::\llbracket K\{M/x\}\rrbracket by compositionality
Case:

A=λt::K.AA=\lambda t::K.A^{\prime}

Ψ,t::KA::K2\Psi,t::K\vdash A^{\prime}::K_{2} and ΨK1\Psi\vdash K_{1} by inversion
{Ψ},t::KA::K2\{\llbracket\Psi\rrbracket\},t::\llbracket K\rrbracket\vdash\llbracket A^{\prime}\rrbracket::\llbracket K_{2}\rrbracket by i.h.
{Ψ}K1\{\llbracket\Psi\rrbracket\}\vdash\llbracket K_{1}\rrbracket by i.h.
{Ψ}λt::K1.A::Πt::K1.K2\{\llbracket\Psi\rrbracket\}\vdash\lambda t::\llbracket K_{1}\rrbracket.\llbracket A^{\prime}\rrbracket::\Pi t::\llbracket K_{1}\rrbracket.\llbracket K_{2}\rrbracket by SΠS\Pi well-formedness rule
{Ψ}λt::K1.A::Πt::K1.K2\{\llbracket\Psi\rrbracket\}\vdash\lambda t::\llbracket K_{1}\rrbracket.\llbracket A^{\prime}\rrbracket::\llbracket\Pi t::K_{1}.K_{2}\rrbracket by compositionality
Case:

A=ABA=A^{\prime}\,B

ΨA::Πt::K1.K2\Psi\vdash A^{\prime}::\Pi t::K_{1}.K_{2} and ΨB::K1\Psi\vdash B::K_{1} by inversion
{Ψ}A::Πt::K1.K2\{\llbracket\Psi\rrbracket\}\vdash\llbracket A^{\prime}\rrbracket::\Pi t::\llbracket K_{1}\rrbracket.\llbracket K_{2}\rrbracket by i.h.
{Ψ}B::K1\{\llbracket\Psi\rrbracket\}\vdash\llbracket B\rrbracket::\llbracket K_{1}\rrbracket by i.h.
{Ψ}AB::K2{B/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket A^{\prime}\rrbracket\,\llbracket B\rrbracket::\llbracket K_{2}\rrbracket\{\llbracket B\rrbracket/x\} by Sappapp well-formedness rule
{Ψ}AB::K2{B/x}\{\llbracket\Psi\rrbracket\}\vdash\llbracket A^{\prime}\rrbracket\,\llbracket B\rrbracket::\llbracket K_{2}\{B/x\}\rrbracket by compositionality
Case:

A=AA=A^{\prime} by conversion rule

ΨA::K\Psi\vdash A^{\prime}::K and ΨK=K\Psi\vdash K=K^{\prime} by inversion
{Ψ}A::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket A^{\prime}\rrbracket::\llbracket K\rrbracket by i.h.
{Ψ}K=K\{\llbracket\Psi\rrbracket\}\vdash\llbracket K\rrbracket=\llbracket K^{\prime}\rrbracket by preservation of equality
{Ψ}A::K\{\llbracket\Psi\rrbracket\}\vdash\llbracket A^{\prime}\rrbracket::\llbracket K^{\prime}\rrbracket by conversion rule
Case:

M=λx:τ.MM=\lambda x{:}\tau.M^{\prime}

Ψ,x:τM:σ\Psi,x{:}\tau\vdash M:\sigma by inversion
{Ψ},x:{τ};;Mz::z:σ\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}::z{:}\llbracket\sigma\rrbracket by i.h.
{Ψ};;z(x).Mz::z:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash z(x).\llbracket M\rrbracket_{z}::z{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by 𝖱{{\forall}\mathsf{R}}
Case:

M=MNM=M^{\prime}\,N

ΨM:Πx:τ.σ\Psi\vdash M^{\prime}:\Pi x{:}\tau.\sigma and ΨN:τ\Psi\vdash N:\tau by inversion
{Ψ};;Mx::x:x:{τ}.σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M^{\prime}\rrbracket_{x}::x{:}\forall x{:}\{\llbracket\tau\rrbracket\}.\llbracket\sigma\rrbracket by i.h.
{τ};;Ny::y:τ\{\llbracket\tau\rrbracket\};\cdot;\cdot\vdash\llbracket N\rrbracket_{y}::y{:}\llbracket\tau\rrbracket by i.h.
{τ}{Ny}:{τ}\{\llbracket\tau\rrbracket\}\vdash\{\llbracket N\rrbracket_{y}\}:\{\llbracket\tau\rrbracket\} by {}I\{\}I
{Ψ};;(𝝂x)(Mxx{Ny}.[xz])::z:σ{{Ny}/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}x)(\llbracket M^{\prime}\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{y}\}\rangle.[x\leftrightarrow z])::z{:}\llbracket\sigma\rrbracket\{\{\llbracket N\rrbracket_{y}\}/x\} by 𝖼𝗎𝗍\mathsf{cut}, 𝖫{{\forall}\mathsf{L}} and 𝗂𝖽\mathsf{id}
{Ψ};;(𝝂x)(Mxx{Ny}.[xz])::z:σ{N/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash({\boldsymbol{\nu}}x)(\llbracket M^{\prime}\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{y}\}\rangle.[x\leftrightarrow z])::z{:}\llbracket\sigma\{N/x\}\rrbracket by compositionality
Case:

M=xM=x

Ψ,x:τx:τ\Psi,x{:}\tau\vdash x{:}\tau by assumption
{Ψ},x:{τ};;yx;[yz]::z:τ\{\llbracket\Psi\rrbracket\},x{:}\{\llbracket\tau\rrbracket\};\cdot;\cdot\vdash y\leftarrow x;[y\leftrightarrow z]::z{:}\llbracket\tau\rrbracket by {}E\{\}E and 𝗂𝖽\mathsf{id} rules
Case:

M={cPuj¯;di¯}M=\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}

Ψ{cPuj¯;di¯}:{uj:Bj¯;di:Ai¯c:A}\Psi\vdash\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}:\{\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash c{:}A\} by assumption
Ψ;uj:Bj¯;di:Ai¯P::c:A\Psi;\overline{u_{j}{:}B_{j}};\overline{d_{i}{:}A_{i}}\vdash P::c{:}A by inversion
{Ψ};uj:Bj¯;di:Ai¯P::c:A\{\llbracket\Psi\rrbracket\};\overline{u_{j}{:}\llbracket B_{j}\rrbracket};\overline{d_{i}{:}\llbracket A_{i}\rrbracket}\vdash\llbracket P\rrbracket::c{:}\llbracket A\rrbracket by i.h.
{Ψ};;z(u0)..z(uj).z(d0)..z(dn).P::z:!Bj¯Ai¯A\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash z(u_{0}).\dots.z(u_{j}).z(d_{0}).\dots.z(d_{n}).\llbracket P\rrbracket::z{:}\overline{{!}\llbracket B_{j}\rrbracket}\multimap\overline{\llbracket A_{i}\rrbracket}\multimap\llbracket A\rrbracket
by !𝖫{{{!}}\mathsf{L}}, 𝖼𝗈𝗉𝗒\mathsf{copy} and 𝖱{{\multimap}\mathsf{R}} (repeated)
Case:

M=MM=M^{\prime} by conversion rule

ΨM:σ\Psi\vdash M^{\prime}:\sigma by inversion
Ψσ=τ::𝗍𝗒𝗉𝖾\Psi\vdash\sigma=\tau::\mathsf{type} by inversion
{Ψ};;M::z:σ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M^{\prime}\rrbracket::z{:}\llbracket\sigma\rrbracket by i.h.
{Ψ}σ=τ::𝗌𝗍𝗒𝗉𝖾\{\llbracket\Psi\rrbracket\}\vdash\llbracket\sigma\rrbracket=\llbracket\tau\rrbracket::\mathsf{stype} by preservation of equality
{Ψ};;M::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M^{\prime}\rrbracket::z{:}\llbracket\tau\rrbracket by conversion rule
Case:

P=zM.P1P=z\langle M\rangle.P_{1} by 𝖱{{\exists}\mathsf{R}}

ΨM:τ\Psi\vdash M:\tau and Ψ;Γ;ΔP1::z:A{M/x}\Psi;\Gamma;\Delta\vdash P_{1}::z{:}A\{M/x\} by inversion
{Ψ};;My::y:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{y}::y{:}\llbracket\tau\rrbracket by i.h.
{Ψ}{My}:{τ}\{\llbracket\Psi\rrbracket\}\vdash\{\llbracket M\rrbracket_{y}\}:\{\llbracket\tau\rrbracket\} by {}I\{\}I
{Ψ};Γ;ΔP1::z:A{M/x}\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P_{1}\rrbracket::z{:}\llbracket A\{M/x\}\rrbracket by i.h.
{Ψ};Γ;ΔP1::z:A{{My}/x}\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash\llbracket P_{1}\rrbracket::z{:}\llbracket A\rrbracket\{\{\llbracket M\rrbracket_{y}\}/x\} by compositionality
{Ψ};Γ;Δz{My}.P1::z:x:{τ}.A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash z\langle\{\llbracket M\rrbracket_{y}\}\rangle.\llbracket P_{1}\rrbracket::z{:}\exists x{:}\{\llbracket\tau\rrbracket\}.\llbracket A\rrbracket by 𝖱{{\exists}\mathsf{R}}

All other process cases follow straightforwardly by i.h. (and compositionality/preservation of equality when needed).

Theorem 0.C.5 (Operational Correspondence – Completeness)
  1. 1.

    Let Ψ;Γ;ΔP::z:A\Psi;\Gamma;\Delta\vdash P::z{:}A. If PPP\xrightarrow{}P^{\prime} then P+Q\llbracket P\rrbracket\xrightarrow{}^{+}Q with {Ψ};Γ;ΔQ=P::z:A\{\llbracket\Psi\rrbracket\};\llbracket\Gamma\rrbracket;\llbracket\Delta\rrbracket\vdash Q=\llbracket P^{\prime}\rrbracket::z{:}A

  2. 2.

    Let ΨM:τ\Psi\vdash M:\tau. If MMM\xrightarrow{}M^{\prime} then MzN\llbracket M\rrbracket_{z}\xrightarrow{}N with {Ψ};;N=Mz::z:τ\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash N=\llbracket M^{\prime}\rrbracket_{z}::z{:}\llbracket\tau\rrbracket

Proof

By induction on the reduction relation.

Case:

(𝝂x)(xM.Px(y).Q)(𝝂x)(PQ{M/y})({\boldsymbol{\nu}}x)(x\langle M\rangle.P\mid x(y).Q)\xrightarrow{}({\boldsymbol{\nu}}x)(P\mid Q\{M/y\})

(𝝂x)(xM.Px(y).Q)=(𝝂x)(x{Mc}.Px(y).Q)\llbracket({\boldsymbol{\nu}}x)(x\langle M\rangle.P\mid x(y).Q)\rrbracket=({\boldsymbol{\nu}}x)(x\langle\{\llbracket M_{c}\rrbracket\}\rangle.\llbracket P\rrbracket\mid x(y).\llbracket Q\rrbracket) by definition
(𝝂x)(PQ{{Mc}/y})\xrightarrow{}({\boldsymbol{\nu}}x)(\llbracket P\rrbracket\mid\llbracket Q\rrbracket\{\{\llbracket M_{c}\rrbracket\}/y\}) by operational semantics
(𝝂x)(PQ{M/y})=(𝝂x)(PQ{M/y})\llbracket({\boldsymbol{\nu}}x)(P\mid Q\{M/y\})\rrbracket=({\boldsymbol{\nu}}x)(\llbracket P\rrbracket\mid\llbracket Q\{M/y\}\rrbracket) by definition
Ψ;Γ;Δ(𝝂x)(PQ{{Mc}/y})=(𝝂x)(PQ{M/y})::z:C\Psi;\Gamma;\Delta\vdash({\boldsymbol{\nu}}x)(\llbracket P\rrbracket\mid\llbracket Q\rrbracket\{\{\llbracket M_{c}\rrbracket\}/y\})=({\boldsymbol{\nu}}x)(\llbracket P\rrbracket\mid\llbracket Q\{M/y\}\rrbracket)::z{:}C
by compositionality, type preservation and 𝖯𝖤𝗊𝖢𝗎𝗍\mathsf{PEqCut}
Case:

cMuj¯;di¯;QcMuj¯;di¯;Qc\leftarrow M\leftarrow\overline{u_{j}};\overline{d_{i}};Q\xrightarrow{}c\leftarrow M^{\prime}\leftarrow\overline{u_{j}};\overline{d_{i}};Q with MMM\xrightarrow{}M^{\prime}

Straightforward by i.h.

Case:

c{cPuj¯;di¯}uj¯;di¯;Q(𝝂c)(PQ)c\leftarrow\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}\leftarrow\overline{u_{j}};\overline{d_{i}};Q\xrightarrow{}({\boldsymbol{\nu}}c)(P\mid Q)

c{cPuj¯;di¯}uj¯;di¯;Q+(𝝂c)(PQ)\llbracket c\leftarrow\{c\leftarrow P\leftarrow\overline{u_{j}};\overline{d_{i}}\}\leftarrow\overline{u_{j}};\overline{d_{i}};Q\rrbracket\xrightarrow{}^{+}({\boldsymbol{\nu}}c)(\llbracket P\rrbracket\mid\llbracket Q\rrbracket)
by definition and operational semantics
(𝝂c)(PQ)=(𝝂c)(PQ)\llbracket({\boldsymbol{\nu}}c)(P\mid Q)\rrbracket=({\boldsymbol{\nu}}c)(\llbracket P\rrbracket\mid\llbracket Q\rrbracket) by definition
We conclude by 𝖯𝖤𝗊𝖱\mathsf{PEqR}.
Case:

(λx:τ.M)NM{N/x}(\lambda x{:}\tau.M)\,N\xrightarrow{}M\{N/x\}

(λx:τ.M)Nz=(𝝂y)(y(x).Myy{Nc}.[yz])\llbracket(\lambda x{:}\tau.M)\,N\rrbracket_{z}=({\boldsymbol{\nu}}y)(y(x).\llbracket M\rrbracket_{y}\mid y\langle\{\llbracket N\rrbracket_{c}\}\rangle.[y\leftrightarrow z]) by definition
(𝝂y)(My{{Nc}/x}[yz])Mz{{Nc}/x}\xrightarrow{}({\boldsymbol{\nu}}y)(\llbracket M\rrbracket_{y}\{\{\llbracket N\rrbracket_{c}\}/x\}\mid[y\leftrightarrow z])\xrightarrow{}\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\} by operational semantics
{Ψ};;Mz{{Nc}/x}=M{N/x}z::z:σ{N/x}\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash\llbracket M\rrbracket_{z}\{\{\llbracket N\rrbracket_{c}\}/x\}=\llbracket M\{N/x\}\rrbracket_{z}::z{:}\llbracket\sigma\{N/x\}\rrbracket
by compositionality and type preservation
Case:

MNMNM\,N\xrightarrow{}M^{\prime}\,N with MMM\xrightarrow{}M^{\prime}

MNz=(𝝂x)(Mxx{Nc}.[xz])\llbracket M\,N\rrbracket_{z}=({\boldsymbol{\nu}}x)(\llbracket M\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{c}\}\rangle.[x\leftrightarrow z]) by definition
MxM0\llbracket M\rrbracket_{x}\xrightarrow{}M_{0} with {Ψ};;M0=Mz::z:A\{\llbracket\Psi\rrbracket\};\cdot;\cdot\vdash M_{0}=\llbracket M^{\prime}\rrbracket_{z}::z{:}A by i.h.
(𝝂x)(Mxx{Nc}.[xz])(𝝂x)(M0x{Nc}.[xz])({\boldsymbol{\nu}}x)(\llbracket M\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{c}\}\rangle.[x\leftrightarrow z])\xrightarrow{}({\boldsymbol{\nu}}x)(M_{0}\mid x\langle\{\llbracket N\rrbracket_{c}\}\rangle.[x\leftrightarrow z])
by the operational semantics
=(𝝂x)(Mxx{Nc}.[xz])::z:A=({\boldsymbol{\nu}}x)(\llbracket M^{\prime}\rrbracket_{x}\mid x\langle\{\llbracket N\rrbracket_{c}\}\rangle.[x\leftrightarrow z])::z{:}A by type preservation, 𝖯𝖤𝗊𝖢𝗎𝗍\mathsf{PEqCut} and 𝖯𝖤𝗊𝖱\mathsf{PEqR}