\PassOptionsToPackage{hyphens}{url} \documentclass[12pt,a4paper]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[hmargin=30mm,vmargin=26mm]{geometry} \usepackage{amsmath,amssymb,amsthm,microtype} \usepackage{setspace} \doublespacing \usepackage[hidelinks,pdfencoding=auto]{hyperref} \urlstyle{same} \hypersetup{pdftitle={Variable-headed continuations in cut-free sequent calculi for pure type systems},pdfauthor={Francisco R. Villatoro}} \newcommand{\doi}[1]{\href{https://doi.org/#1}{\nolinkurl{#1}}} \newtheorem{theorem}{Theorem} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{corollary}[theorem]{Corollary} \newcommand{\U}{K_{\mathrm{cf}}} \newcommand{\Hc}{\widehat K_{\mathrm{cf}}} \newcommand{\ist}{\mathsf I} \newcommand{\neu}{\mathsf N} \newcommand{\conv}{=_{\beta}} \newcommand{\Rr}{\mathsf{Read}} \newcommand{\Cc}{\mathsf{Cont}} \newcommand{\J}{\mathcal J} \newcommand{\TC}{\mathsf{TC}} \newcommand{\FV}{\mathrm{FV}} \setlength{\emergencystretch}{1.1em} \title{Variable-headed continuations in cut-free sequent calculi for pure type systems} \author{Francisco R. Villatoro\\[2pt] {\small Escuela de Ingenier\'ias Industriales, Universidad de M\'alaga, 29071 M\'alaga, Spain}\\ {\small Corresponding author: \href{mailto:frvillatoro@uma.es}{frvillatoro@uma.es}\quad \href{https://orcid.org/0000-0003-4314-6213}{ORCID 0000-0003-4314-6213}}} \date{} \renewenvironment{abstract}{\par\small\begin{center}\bfseries\abstractname\end{center}\noindent}{\par\medskip} \begin{document} \begingroup\singlespacing \maketitle \endgroup \begin{abstract} The weak left rule of Guti\'errez and Ruiz substitutes a variable applied to an argument throughout a continuation and a dependent context suffix. Their structural theorem removes the suffix while leaving the continuation arbitrary. Guti\'errez later restricted the continuation to a spine headed by a fresh auxiliary variable, absent from the remaining arguments and the expected type. We prove that this further restriction preserves every cut-free typing judgment for every pure type specification. The reconstruction preserves the context, subject and expected type, and supplies cut-free proofs of every type-formation premise. A type of an application can contain an earlier prefix of the very spine being reconstructed. To handle this dependence, an intermediate derivation records a formation certificate for each neutral application. Typed substitution transports those certificates through the dependent suffix, and a continuation interpretation reads the spine in arbitrary certified target contexts. Each recursive call descends through a supplied finite derivation. The result holds for specifications with multivalued axiom and product relations and carries no global normalization assumption. It answers the reverse-inclusion question recorded in Guti\'errez's dissertation and yields admissibility of substitution by a certified neutral spine throughout a dependent continuation. It also identifies the sets of types assigned by the two cut-free calculi. Under the hypotheses of the earlier type-membership procedure, the same procedure consequently decides judgments of the unrestricted cut-free calculus. The main equivalence is formalized in Lean, both as a relation on judgments and on the original datatype of complete derivation trees. The accompanying software records the pinned dependencies and provides commands for repeating the proof and kernel checks. \end{abstract} \noindent\textbf{Keywords.} Pure type systems, sequent calculus, cut-free derivability, dependent types, proof reconstruction. \section{The restriction on the left rule} When $y$ has dependent product type and $a$ has its domain type, the weak left rule of Guti\'errez and Ruiz replaces an auxiliary hypothesis $w:S$ by $y\,a$ throughout the rest of a derivation. The variable $w$ can occur in a later declaration, several times in the subject, or in its expected type. Guti\'errez and Ruiz proved that a nonempty context suffix can already be eliminated: their auxiliary calculus $\kappa_{\mathrm{cf}}$ permits an arbitrary continuation in $\Gamma,w:S$~\cite[Lemma~11, p.~24]{gutierrez-ruiz-lopstr}. For type inference, Guti\'errez imposed a further restriction~\cite[Definition~109, p.~157]{gutierrez-thesis}. At a left step the continuation must now have the form $w\,q_1\cdots q_n:C$, where the $q_i$ and $C$ come from $\Gamma$. The auxiliary variable occurs exactly once in the subject, at the head, and is absent from its type. Even with the suffix removed, the earlier result allows continuations such as $g\,w\,w:C$. The dissertation records that it had not established the converse inclusion for the variable-headed rule~\cite[\S8.2.1, p.~159]{gutierrez-thesis}. \begin{theorem}\label{th:main} For every pure type specification and each fixed context, subject and expected type, \[ \Gamma\vdash_{\U}t:T\quad\Longleftrightarrow\quad \Gamma\vdash_{\Hc}t:T . \] Each derivation on the left yields a finite restricted derivation of the same judgment, up to $\alpha$-conversion, including all premises used to form types and contexts. \end{theorem} The proof reconstructs a restricted derivation from the application spines in a cut-free tree. A dependent type can mention the very prefix whose derivation is being reconstructed. We retain a formation proof at every application so that the recursion descends through supplied proofs even in that case. A single left step in the input may contribute to several different formation proofs in the output. \input{recent} \section{The two cut-free systems}\label{s:rules} Fix a set of sorts $\mathcal S$, an axiom relation $\mathcal A\subseteq\mathcal S^2$ and a product relation $\mathcal R\subseteq\mathcal S^3$. Terms are variables, sorts, applications, abstractions $\lambda x:A.b$ and products $\Pi x:A.B$. Contexts consist of distinct declarations ordered from oldest to newest. The type of a declaration is scoped over the preceding declarations. We identify terms up to renaming of bound variables. All substitutions avoid capture and act under binders, including in annotations. The equality $\conv$ is the full untyped $\beta$-convertibility relation. In the following common rules the judgment symbol denotes either $\vdash_{\U}$ or $\vdash_{\Hc}$, used uniformly throughout each rule. All newly declared variables are fresh. \[ \begin{gathered} \frac{(s,r)\in\mathcal A}{\varnothing\vdash s:r}\;(\mathrm{Ax}) \qquad \frac{\Gamma\vdash A:s}{\Gamma,x:A\vdash x:A}\;(\mathrm{Var}) \qquad \frac{\Gamma\vdash u:U\quad\Gamma\vdash A:s} {\Gamma,x:A\vdash u:U}\;(\mathrm{Wk}) \\[6pt] \frac{\Gamma\vdash A:s_1\quad\Gamma,x:A\vdash B:s_2} {\Gamma\vdash\Pi x:A.B:s_3}\;(\mathrm{Prod}) \qquad \frac{\Gamma\vdash\Pi x:A.B:s\quad\Gamma,x:A\vdash b:B} {\Gamma\vdash\lambda x:A.b:\Pi x:A.B}\;(\mathrm{Abs}) \\[6pt] \frac{\Gamma\vdash t:T\quad\Gamma\vdash U:s\quad T\conv U} {\Gamma\vdash t:U}\;(\mathrm{Conv}) . \end{gathered} \] In $\mathrm{Wk}$ the subject $u$ must be a variable or a sort; in $\mathrm{Prod}$ the triple $(s_1,s_2,s_3)$ belongs to $\mathcal R$. Both calculi use only these six rules and one weak left rule. The rule of $\U$ is \begin{equation}\tag{$L$}\label{eq:unres} \frac{\Gamma\vdash a:A\qquad\Gamma,w:S,\Xi\vdash c:C} {\Gamma,\Xi[y\,a/w]\vdash c[y\,a/w]:C[y\,a/w]}, \qquad y:\Pi z:A.B\in\Gamma,\quad S\conv B[a/z]. \end{equation} Substitution acts on each declaration type in $\Xi$ at its own binding depth. For $\Hc$, write $f\,\vec q$ for left-associated application to a possibly empty list and require $w\notin\FV(C)\cup\bigcup_i\FV(q_i)$. Its rule is \begin{equation}\tag{$\widehat L$}\label{eq:res} \frac{\Gamma\vdash a:A\qquad\Gamma,w:S\vdash w\,\vec q:C} {\Gamma\vdash y\,a\,\vec q:C}, \qquad y:\Pi z:A.B\in\Gamma,\quad S\conv B[a/z], \end{equation} In particular, $C$ may mention $y\,a$. Membership $y:\Pi z:A.B\in\Gamma$ refers to the type as declared, up to bound names. A complete proof recursively contains both premises of $\mathrm{Conv}$ and of $\mathrm{Abs}$, as well as both typing premises of the left rule. The $\beta$-conversion guard is a side condition in each system. For an example with a nonempty suffix, take a specification supporting ordinary dependent types and let \[ \Gamma=(A:*,\ a:A,\ y:\Pi u:A.A,\ P:\Pi u:A.*). \] From $\Gamma\vdash a:A$ and $\Gamma,w:A,z:P\,w\vdash z:P\,w$, rule~\eqref{eq:unres} yields $\Gamma,z:P(y\,a)\vdash z:P(y\,a)$. A restricted proof of the conclusion can end in $\mathrm{Var}$. The work involving $y\,a$ must then be done in its premise, the formation of $P(y\,a)$ in $\Gamma$. \section{Retaining the result type of a neutral application}\label{s:extract} A neutral is a variable applied to a list of arguments. We use mutually inductive judgments $\ist_\Gamma(t:T)$ for terms and $\neu_\Gamma(f:F)$ for neutrals. The following clauses define both relations in raw, well-scoped contexts. \begin{enumerate} \item An axiom $(s,r)\in\mathcal A$ gives $\ist_\Gamma(s:r)$ for any $\Gamma$. A neutral proof $\neu_\Gamma(f:F)$ gives $\ist_\Gamma(f:F)$. \item Product formation and conversion have the same premises and side conditions as the common rules, with $\ist$ in place of $\vdash$. For abstraction take the three premises \[ \ist_\Gamma(A:r),\quad \ist_\Gamma(\Pi x:A.B:s),\quad \ist_{\Gamma,x:A}(b:B) \] and conclude $\ist_\Gamma(\lambda x:A.b:\Pi x:A.B)$. \item A declaration $x:T\in\Gamma$ gives $\neu_\Gamma(x:T)$. The only other neutral rule is \begin{equation}\tag{$N$}\label{eq:neutral} \frac{\neu_\Gamma(f:\Pi z:A.B)\quad\ist_\Gamma(a:A)\quad \ist_\Gamma(V:s)\quad V\conv B[a/z]} {\neu_\Gamma(f\,a:V)}. \end{equation} \end{enumerate} The third premise of~\eqref{eq:neutral} stores a proof for the chosen representative $V$. A context is \emph{$\ist$-certified} if each declaration type has an $\ist$-derivation at some sort in its original prefix. Define a \emph{restricted-certified} context by using $\vdash_{\Hc}$ in the same definition. Certification pertains to the declarations actually present, so it imposes no classifier requirement on a sort used only as the type of an axiom. \begin{lemma}\label{l:sub} Both intermediate judgments are preserved by lookup-preserving renamings and by typed neutral substitutions. If $\Gamma$ and $\Gamma,w:S,\Xi$ are $\ist$-certified and $\neu_\Gamma(p:S)$, then $\Gamma,\Xi[p/w]$ is $\ist$-certified. Substituting $p$ for $w$ carries any intermediate judgment in the former extended context into the latter one. \end{lemma} \begin{proof} A renaming $\rho:\Gamma\to\Delta$ preserves lookup if each $x:T\in\Gamma$ maps to a declared $\rho x:\rho T$ in $\Delta$. First prove the renaming assertion by mutual induction. The variable case uses lookup, and each binder lifts the renaming by sending its bound variable to the new variable. At~\eqref{eq:neutral} the argument proof and the formation proof for $V$ are both renamed. Its guard is preserved since renaming commutes with instantiation. A sort axiom can be placed in any raw context. For a typed neutral substitution $\sigma:\Gamma\to\Delta$, each declared $x:T$ has a proof $\neu_\Delta(\sigma x:T[\sigma])$. Under a binder of type $A$, extend $\Delta$ by $x:A[\sigma]$. The fresh variable maps to itself, and the older neutral images weaken by the renaming assertion. Mutual induction now gives substitution. Lookup uses the specified neutral image. Products and abstractions use the lifted substitution, and conversion uses stability of $\conv$. For~\eqref{eq:neutral} take the three substituted proofs and use \[ (B[a/z])[\sigma]=(B[\sigma^+])[a[\sigma]/z], \] where $\sigma^+$ is the lifted substitution. This capture-avoiding substitution identity follows by induction on $B$. To remove $w:S$, first fix each variable of $\Gamma$ and send $w$ to $p$. This is a typed neutral substitution into $\Gamma$. Extend it from left to right along $\Xi$. At $v:V$ the source context certificate supplies a proof of $V:r$ in the prefix already treated. Substituting gives the certificate for $v:V[p/w]$. Lift the substitution under this new declaration and continue. This gives a certified target context and the claimed judgments. \end{proof} \begin{lemma}\label{l:extract} A complete derivation of $\Gamma\vdash_{\U}t:T$ yields an $\ist$-certificate for $\Gamma$ and an intermediate derivation $\ist_\Gamma(t:T)$. \end{lemma} \begin{proof} Induct on the complete tree. An axiom uses the empty context. For $\mathrm{Var}$ append the extracted certificate for its declaration and use lookup. For $\mathrm{Wk}$ append the certificate from the second premise and rename the first proof into the extended context. For $\mathrm{Prod}$ and $\mathrm{Conv}$ take the extracted premises and the original side condition. For $\mathrm{Abs}$ the product and body come from its two premises. The context certificate extracted along with the body contains the additional proof $\ist_\Gamma(A:r)$ for its domain. At~\eqref{eq:unres} extract $\ist_\Gamma(a:A)$ and $\ist_{\Gamma,w:S,\Xi}(c:C)$, with certificates for both contexts. In the second certificate the entry for $w:S$ gives $\ist_\Gamma(S:s)$, regardless of the length of $\Xi$. Lookup of $y$ and rule~\eqref{eq:neutral} give $\neu_\Gamma(y\,a:S)$ using precisely the original guard $S\conv B[a/z]$. Lemma~\ref{l:sub} now gives the substituted judgment and the certificate for $\Gamma,\Xi[y\,a/w]$. \end{proof} \section{Reading a spine against a continuation}\label{s:reading} For each lookup-preserving renaming $\rho:\Gamma\to\Delta$ into a restricted-certified context, two facts hold. Every declared variable in $\Delta$ is derivable at its declared type by $\mathrm{Var}$ followed by atomic weakenings. Every axiom judgment is derivable in $\Delta$ by weakening from the empty context. In both constructions, the premises for weakening are supplied by the context certificate. Write $\Rr_\Gamma(t:T)$ to mean that $\Delta\vdash_{\Hc}\rho t:\rho T$ for every such $\rho,\Delta$. For a type $F$, a tail $\vec q$ and a result type $C$ scoped over $\Gamma$, define the continuation property $\Cc_\Gamma(F,\vec q,C)$ by requiring \[ \Delta\vdash_{\Hc}z\,(\rho\vec q):\rho C \] for every such $\rho,\Delta$ and every $z:\rho F\in\Delta$. The quantifier over target contexts permits the argument below to extend a context by the type of the next application. \begin{lemma}\label{l:cons} Suppose $\Rr_\Gamma(a:A)$, $\Rr_\Gamma(V:s)$, and $V\conv B[a/z]$. Then $\Cc_\Gamma(V,\vec q,C)$ implies $\Cc_\Gamma(\Pi z:A.B,a::\vec q,C)$. \end{lemma} \begin{proof} Choose $\rho:\Gamma\to\Delta$ as above and a variable $f:\rho(\Pi z:A.B)$ in $\Delta$. Read the argument $\rho a:\rho A$ and the type $\rho V:s$ in $\Delta$. The latter proof certifies $\Delta,w:\rho V$ for a fresh $w$. Compose $\rho$ with the inclusion into this extension. Applying the given continuation to the composed map and its newest variable gives \[ \Delta,w:\rho V\vdash_{\Hc}w\,(\rho\vec q):\rho C . \] The terms in $\rho\vec q$ and $\rho C$ have been weakened from $\Delta$, so $w$ is fresh for them. Renaming gives $\rho V\conv(\rho^+ B)[\rho a/z]$. Rule~\eqref{eq:res} with head $f$ now yields $\Delta\vdash_{\Hc}f\,(\rho a)\,(\rho\vec q):\rho C$. \end{proof} \begin{lemma}\label{l:read} The following assertions hold simultaneously. \begin{align*} \ist_\Gamma(t:T)&\ \Longrightarrow\ \Rr_\Gamma(t:T),\\ \neu_\Gamma(f:F)&\ \Longrightarrow\ \bigl(\Cc_\Gamma(F,\vec q,C)\Longrightarrow\Rr_\Gamma(f\,\vec q:C)\bigr) \quad\text{for all }\vec q,C . \end{align*} \end{lemma} \begin{proof} Use mutual induction on the two intermediate proofs. Read a sort axiom by atomic weakening. To read an included neutral, take the empty tail and $C=F$. The required continuation holds since each declared variable is derivable at its declared type. At a product the domain proof certifies the extended target; lift $\rho$ to read the codomain there and form the product with its recorded triple. At an abstraction the separate domain proof likewise certifies the extension, where the body is read. Read the product proof in the original target and apply $\mathrm{Abs}$. Conversion reads both premises and renames the guard. For a neutral variable $x$, apply the supplied continuation to $\rho x$, whose declared type is $\rho F$ by lookup preservation. For a neutral $f\,a:V$ as in~\eqref{eq:neutral}, fix $\vec q,C$ and a continuation for $V$. The term induction hypotheses on $a:A$ and $V:s$ give the readings in Lemma~\ref{l:cons}. Its conclusion is a continuation for the product with tail $a::\vec q$. Apply the neutral induction hypothesis on $f$ to this tail. This gives the required reading of $(f\,a)\,\vec q:C$. The induction has used only proper premises of the given application proof. \end{proof} \begin{proof}[Proof of Theorem~\ref{th:main}] A restricted derivation embeds in $\U$ by induction. At~\eqref{eq:res} take $\Xi$ empty in~\eqref{eq:unres}. Substitution then changes only the head of the continuation. Conversely, use Lemma~\ref{l:extract} on the unrestricted tree. Read the resulting context certificate by induction from the empty prefix: once a prefix is restricted-certified, apply the term part of Lemma~\ref{l:read} with its identity renaming to obtain the formation proof for the next declaration. The resulting certificate for $\Gamma$ now permits the same identity renaming to read $\ist_\Gamma(t:T)$. This gives a complete restricted derivation of $\Gamma\vdash t:T$. No sort or product output has been chosen beyond those already present in the input certificates. \end{proof} \begin{corollary}[Substitution of a certified spine]\label{c:spine} Let $p=y\,a_1\cdots a_n$ and $y:V_0\in\Gamma$. For $1\le i\le n$ suppose $V_{i-1}=\Pi z_i:A_i.B_i$ as a term, that $\Gamma\vdash_{\Hc}a_i:A_i$ and $\Gamma\vdash_{\Hc}V_i:s_i$, and that $V_i\conv B_i[a_i/z_i]$. Then \[ \Gamma,w:V_n,\Xi\vdash_{\Hc}c:C \quad\Longrightarrow\quad \Gamma,\Xi[p/w]\vdash_{\Hc}c[p/w]:C[p/w] . \] \end{corollary} \begin{proof} Embed the premises in $\U$ and apply Lemma~\ref{l:extract}. Starting with lookup of $y$, use~\eqref{eq:neutral} successively to obtain $\neu_\Gamma(p:V_n)$. The extracted context certificate of the continuation contains the certificate for $\Gamma$ as a prefix. Apply Lemma~\ref{l:sub} with $p$; read the substituted context certificate and the substituted term proof as in the proof of Theorem~\ref{th:main}. \end{proof} \section{Dependent result types and type checking}\label{s:application} An example in the Calculus of Constructions illustrates the scope of freshness in~\eqref{eq:res}. Let $A:*$ and $a:A$, define $P_0=\Pi u:A.*$ and $R=\Pi C:P_0.C\,a$, and take declarations $H:R\to *$ and $y:\Pi u:A.R$. Put $p=y\,a$, so $p:R$. Applying $p$ to $C_0=\lambda u:A.H\,p$ gives $p\,C_0:H\,p$ because $C_0\,a\conv H\,p$. The expected type contains the very prefix $p$ of the subject. In Lemma~\ref{l:cons} this type is weakened from the old context. Its occurrence of $p$ survives, and the new head $w$ is fresh. For a calculus $J$ and fixed $\Gamma,t$, write $\TC_J(\Gamma,t)=\{T\mid\Gamma\vdash_J t:T\}$. This is the set of types used for the restricted calculus in Guti\'errez's type-checking problem~\cite[\S8.2.2]{gutierrez-thesis}. \begin{corollary}\label{c:tc} For every pure type specification, $\TC_{\U}(\Gamma,t)=\TC_{\Hc}(\Gamma,t)$. Any procedure that decides membership for the restricted calculus therefore decides the unrestricted cut-free judgment on the same inputs. \end{corollary} \begin{proof} Fix a candidate type $T$ and apply Theorem~\ref{th:main} to the triple $(\Gamma,t,T)$. The decision procedure receives this very triple. \end{proof} For a concrete use, assume an effectively given finite specification, the normalization hypothesis of~\cite[Ch.~8]{gutierrez-thesis}, and its weak cut-elimination property for $\U$. Guti\'errez and Ruiz establish weak cut elimination for a class of systems~\cite{gutierrez-ruiz-ce}. The property says that when $\Gamma,t$ are $\beta$-normal and the ordinary PTS derives $\Gamma\vdash t:T$, the cut-free calculus derives $\Gamma\vdash t:T_\beta$, with $T_\beta$ the normal form of $T$. By Theorem~\ref{th:main} the same statement holds for $\Hc$. This discharges the restricted cut-elimination hypothesis in Guti\'errez's membership algorithm~\cite[Theorem~120, pp.~163--165]{gutierrez-thesis}. Its effective tests on axiom outputs and product sorts, listed on p.~160, are available by finite search. Consequently that algorithm also decides $\Gamma\vdash_{\U}t:T$ under these assumptions. The equality of type sets in Corollary~\ref{c:tc} holds without them. \input{artifact} \section*{Funding} \begingroup\exhyphenpenalty=10000\emergencystretch=1em This work was supported by the Universidad de M\'alaga, Spain, through project PRO-B4-2026-011 of its Plan Propio de Investigaci\'on, Transferencia y Divulgaci\'on Cient\'ifica. \par\endgroup \section*{Acknowledgements} OpenAI's ChatGPT and Codex assisted in developing and checking the mathematical arguments, working on the Lean formalization, and drafting and revising the manuscript. \input{bibliography} \end{document}