diff --git a/supplement.tex b/supplement.tex index 8ef0952..5a11240 100644 --- a/supplement.tex +++ b/supplement.tex @@ -1,13 +1,9 @@ \documentclass[dvipsnames]{article} -\usepackage[dvipsnames]{xcolor} -\usepackage{amssymb} +\hbadness=99999 +\usepackage{silence} -\input{preamble} -\input{symbols} -\input{macros} - -\usepackage[margin=1in]{geometry} +% font \usepackage{iftex} \ifPDFTeX \usepackage{libertinust1math} @@ -17,17 +13,98 @@ \fi \usepackage[scaled=0.8]{FiraMono} +% geometry +\usepackage[margin=1in]{geometry} + +% math and symbols +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{amsfonts} +\usepackage{amsthm} +\usepackage{thmtools} +\usepackage{mathtools} +\usepackage{mathpartir} +\usepackage{stmaryrd} +\WarningFilter{latexfont}{Font shape `U/stmry/b/n' undefined} +\WarningFilter{latexfont}{Some font shapes were not available} + +\usepackage{bm} +\usepackage{relsize} +\usepackage{centernot} + +% hyperlinks +\usepackage[colorlinks=true, linkcolor=purple]{hyperref} +\usepackage[capitalise, noabbrev]{cleveref} + +% enumeration +\usepackage{enumitem} + +% colors +\usepackage{scalerel} +\usepackage[dvipsnames]{xcolor} +\usepackage[most]{tcolorbox} + +% theorem types \declaretheorem[name=Theorem, parent=section]{theorem} \declaretheorem[name=Lemma, parent=theorem]{lemma} +\declaretheorem[name=Lemma, sibling=theorem]{lemma*} \declaretheorem[name=Definition, parent=section, style=definition]{definition} +% toc +\makeatletter +\renewcommand\tableofcontents{% + \@starttoc{toc}% +} +\makeatother +\setcounter{tocdepth}{2} + +\input{symbols} +\input{macros} + +\newtcolorbox{mybox}[2][] +{ + on line, + hbox, + boxsep=0pt, + left=1pt, + right=1pt, + top=1pt, + bottom=1pt, + colframe=white, + colback=#2 + #1, +} +\newcommand\goodcolor[2]{% + \protect\leavevmode + \begingroup + \color{#1}% + #2% + \endgroup +} + +\usepackage{subfiles} + \begin{document} +\tableofcontents +\newpage + \renewcommand{\thesection}{\Alph{section}} -\input{supplement/marking} -\input{supplement/constraintRules} -% \input{supplement/unionFindPTS} -% \input{supplement/extendedPTS} -% \input{supplement/inferenceFormalism} +\subfile{supplement/marked} +\newpage + +\subfile{supplement/patterned} +\newpage + +\subfile{supplement/polymorphism} +\newpage + +\subfile{supplement/untyped} +\newpage + +\subfile{supplement/typed} +\newpage + +\subfile{supplement/constraintRules} \end{document} diff --git a/supplement/constraintRules.tex b/supplement/constraintRules.tex index 690f234..b09bc7c 100644 --- a/supplement/constraintRules.tex +++ b/supplement/constraintRules.tex @@ -1,8 +1,15 @@ -\newpage -\section{Constraint Generating Bidirectional Typing Rules} -\judgbox{\ensuremath{\ctxSynType{\ctx}{\ECMV}{\TMV} ~|~ C}} +\documentclass[formalism.tex]{subfiles} + +\begin{document} +\section{Constraint generation} +\judgbox{\ensuremath{\synConstraint{\ctx}{\ECMV}{\TMV}{C}}} $\ECMV$ synthesizes type $\TMV$ and generates constraints $C$ +% \begin{mathpar} - \judgment{ + \judgment{ }{ + \synConstraint{\ctx}{\EEHole^u}{\TUnknown^{exp(u)}}{\{ \TUnknown^{exp(u)} \approx \mathtt{etc} \}} + }{MSEHole-C}\\ + + \judgment{ \inCtx{\ctx}{x}{\TMV} }{ \synConstraint{\ctx}{x}{\TMV}{\{\}} @@ -11,33 +18,51 @@ \section{Constraint Generating Bidirectional Typing Rules} \judgment{ \notInCtx{\ctx}{x} }{ - \synConstraint{\ctx}{\ECUnboundId{x}{u}}{\TUnknown^{exp(u)}}{\{ \TUnknown^{exp(u)} \approx \mathtt{etc} \}} - }{MSUnbound-C}\\ + \synConstraint{\ctx}{\ECFreeId{x}{u}}{\TUnknown^{exp(u)}}{\{ \TUnknown^{exp(u)} \approx \mathtt{etc} \}} + }{MSFree-C} - \judgment{ }{ - \synConstraint{\ctx}{\ECTrue}{\TBool}{\{\}} - }{MSTrue-C} + \judgment{ + \synConstraint{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TMV_2}{C} + }{ + \synConstraint{\ctx}{\ECLam{x}{\TMV_1}{\ECMV}}{\TArrow{\TMV_1}{\TMV_2}}{C} + }{MSLam-C} - \judgment{ }{ - \synConstraint{\ctx}{\ECFalse}{\TBool}{\{\}} - }{MSFalse-C} \\ + \judgment{ + \synConstraint{\ctx}{\ECMV_1}{\TMV}{C_1} \\ + \matchedArrowConstraint{\TMV}{\TMV_1}{\TMV_2}{C_2} \\ + \anaConstraint{\ctx}{\ECMV_2}{\TMV_1}{C_3} + }{ + \synConstraint{\ctx}{\ECAp{\ECMV_1}{\ECMV_2}}{\TMV_2}{C_1 \cup C_2 \cup C_3} + }{MSAp1-C} + + \judgment{ + \synConstraint{\ctx}{\ECMV_1}{\TMV}{C_1} \\ + \notMatchedArrow{\TMV} \\ + \anaConstraint{\ctx}{\ECMV_2}{\TUnknown^{\rightarrow_{L}(exp(u))}}{C_2} + }{ + \synConstraint{\ctx}{\ECApSynNonMatchedArrowId{\ECMV_1}{u}{\ECMV_2}}{\TUnknown^{\rightarrow_{R}(exp(u))}}{C_1 \cup C_2 \cup \{ \TUnknown^{exp(u)} \approx \tarr{\TUnknown^{\rightarrow_L(exp(u))}}{\TUnknown^{\rightarrow_R(exp(u))}}\}} + }{MSAp2-C} \judgment{ }{ \synConstraint{\ctx}{\ECNumMV}{\TNum}{\{\}} }{MSNum-C} - \judgment{ }{ - \synConstraint{\ctx}{\EEHole^u}{\TUnknown^{exp(u)}}{\{ \TUnknown^{exp(u)} \approx \mathtt{etc} \}} - }{MSEHole-C}\\ - \judgment{ \anaConstraint{\ctx}{\ECMV_1}{\TNum}{C_1}\\ \anaConstraint{\ctx}{\ECMV_2}{\TNum}{C_2} }{ \synConstraint{\ctx}{\ECPlus{\ECMV_1}{\ECMV_2}}{\TNum}{C_1 \cup C_2} }{MSPlus-C} - \judgment{ - \anaConstraint{\ctx}{\ECMV_1}{\TBool}{C_1}\\ + \judgment{ }{ + \synConstraint{\ctx}{\ECTrue}{\TBool}{\{\}} + }{MSTrue-C} + + \judgment{ }{ + \synConstraint{\ctx}{\ECFalse}{\TBool}{\{\}} + }{MSFalse-C} + + \judgment{ + \anaConstraint{\ctx}{\ECMV_1}{\TBool}{C_1} \\ \synConstraint{\ctx}{\ECMV_2}{\TMV_1}{C_2} \\ \synConstraint{\ctx}{\ECMV_3}{\TMV_2}{C_3} }{ @@ -53,28 +78,6 @@ \section{Constraint Generating Bidirectional Typing Rules} \synConstraint{\ctx}{\ECInconBrId{\ECMV_1}{\ECMV_2}{\ECMV_3}{u}}{\TUnknown^{exp(u)}}{C_1 \cup C_2 \cup C_3 \cup \{ \TMV_1 \approx \TMV_2, \TUnknown^{exp(u)} \approx \mathtt{etc} \}} }{MSInconsistentBranches-C} - \judgment{ - \synConstraint{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TMV_2}{C} - }{ - \synConstraint{\ctx}{\ECLam{x}{\TMV_1}{\ECMV}}{\TArrow{\TMV_1}{\TMV_2}}{C} - }{MSLam-C} - - \judgment{ - \synConstraint{\ctx}{\ECMV_1}{\TMV}{C_1} \\ - \matchedArrowConstraint{\TMV}{\TMV_1}{\TMV_2}{C_2} \\ - \anaConstraint{\ctx}{\ECMV_2}{\TMV_1}{C_3} - }{ - \synConstraint{\ctx}{\ECAp{\ECMV_1}{\ECMV_2}}{\TMV_2}{C_1 \cup C_2 \cup C_3} - }{MSAp1-C} - - \judgment{ - \synConstraint{\ctx}{\ECMV_1}{\TMV}{C_1} \\ - \notMatchedArrow{\TMV} \\ - \anaConstraint{\ctx}{\ECMV_2}{\TUnknown^{\rightarrow_{L}(exp(u))}}{C_2} - }{ - \synConstraint{\ctx}{\ECApSynNonMatchedArrowId{\ECMV_1}{u}{\ECMV_2}}{\TUnknown^{\rightarrow_{R}(exp(u))}}{C_1 \cup C_2 \cup \{ \TUnknown^{exp(u)} \approx \tarr{\TUnknown^{\rightarrow_L(exp(u))}}{\TUnknown^{\rightarrow_R(exp(u))}}\}} - }{MSAp2-C} - \judgment{ \synConstraint{\ctx}{\ECMV_1}{\TMV_1}{C_1}\\ \synConstraint{\ctx}{\ECMV_2}{\TMV_2}{C_2} @@ -111,32 +114,9 @@ \section{Constraint Generating Bidirectional Typing Rules} }{MSProjR2-C} \end{mathpar} -\judgbox{\ensuremath{\ctxAnaType{\ctx}{\ECMV}{\TMV} ~|~ C}} +\judgbox{\ensuremath{\anaConstraint{\ctx}{\ECMV}{\TMV}{C}}} $\ECMV$ analyzes against type $\TMV$ and generates constraints $C$ +% \begin{mathpar} - \judgment{ - \synConstraint{\ctx}{\ECMV}{\TMV'}{C} \\ - \consistent{\TMV}{\TMV'} \\ - \subsumable{\ECMV} - }{ - \anaConstraint{\ctx}{\ECMV}{\TMV}{C \cup \{ \TMV \approx \TMV' \}} - }{MASubsume-C} - - \judgment{ - \synConstraint{\ctx}{\ECMV}{\TMV'}{C} \\ - \inconsistent{\TMV}{\TMV'} \\ - \subsumable{\ECMV} - }{ - \anaConstraint{\ctx}{\ECInconTypeId{\ECMV}{u}}{\TMV}{C \cup \{ \TMV \approx \TUnknown^{exp(u)} \}} - }{MAInconsistentTypes-C} - - \judgment{ - \anaConstraint{\ctx}{\ECMV_1}{\TBool}{C_1} \\ - \anaConstraint{\ctx}{\ECMV_1}{\TMV}{C_2} \\ - \anaConstraint{\ctx}{\ECMV_2}{\TMV}{C_3} - }{ - \anaConstraint{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV}{C_1 \cup C_2 \cup C_3} - }{MAIf} - \judgment{ \matchedArrowConstraint{\TMV_3}{\TMV_1}{\TMV_2}{C_1}\\ \consistent{\TMV}{\TMV_1} \\ @@ -160,6 +140,14 @@ \section{Constraint Generating Bidirectional Typing Rules} \anaConstraint{\ctx}{\ECInconTypeId{\ECLam{x}{\TMV}{\ECMV}}{u}}{\TMV_3} {C_1 \cup C_2 \cup \{ \TUnknown^{exp(u)} \approx \TMV_3 \}} }{MALam3-C} + \judgment{ + \anaConstraint{\ctx}{\ECMV_1}{\TBool}{C_1} \\ + \anaConstraint{\ctx}{\ECMV_1}{\TMV}{C_2} \\ + \anaConstraint{\ctx}{\ECMV_2}{\TMV}{C_3} + }{ + \anaConstraint{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV}{C_1 \cup C_2 \cup C_3} + }{MAIf} + \judgment{ \matchedProdConstraint{\TMV}{\TMV_1}{\TMV_2}{C_1} \\ \anaConstraint{\ctx}{\ECMV_1}{\TMV_1}{C_2} \\ @@ -168,21 +156,48 @@ \section{Constraint Generating Bidirectional Typing Rules} \anaConstraint{\ctx}{\ECPair{\ECMV_1}{\ECMV_2}}{\TMV}{C_1 \cup C_2 \cup C_3} }{MAPair1-C} - \judgment{ + \judgment{ \notMatchedProd{\TMV} \\ \anaConstraint{\ctx}{\ECMV_1}{\TUnknown^{anon}}{C_1} \\ \anaConstraint{\ctx}{\ECMV_2}{\TUnknown^{anon}}{C_2} }{ \anaConstraint{\ctx}{ - \ECPairAnaNonMatchedProdId{\ECMV_1}{\ECMV_2}{u} + \ECPairAnaNonMatchedProdId{\ECMV_1}{\ECMV_2}{u} }{\TMV}{C_1 \cup C_2 \cup \{\TUnknown^{exp(u)} \approx \tau\}} }{MAPair2-C} + + \judgment{ + \synConstraint{\ctx}{\ECMV}{\TMV'}{C} \\ + \inconsistent{\TMV}{\TMV'} \\ + \subsumable{\ECMV} + }{ + \anaConstraint{\ctx}{\ECInconTypeId{\ECMV}{u}}{\TMV}{C \cup \{ \TMV \approx \TUnknown^{exp(u)} \}} + }{MAInconsistentTypes-C} + + \judgment{ + \synConstraint{\ctx}{\ECMV}{\TMV'}{C} \\ + \consistent{\TMV}{\TMV'} \\ + \subsumable{\ECMV} + }{ + \anaConstraint{\ctx}{\ECMV}{\TMV}{C \cup \{ \TMV \approx \TMV' \}} + }{MASubsume-C} \end{mathpar} \begin{figure}[htb] -\raggedright - \judgbox{\ensuremath{\matchedProdConstraint{\TMV}{\TMV_1}{\TMV_2}{C}}} - \begin{mathpar} + \raggedright + \judgbox{\ensuremath{\matchedArrowConstraint{\TMV}{\TMV_1}{\TMV_2}{C}}} $\TMV$ has matched arrow type $\TArrow{\TMV_1}{\TMV_2}$ and generates constraints $C$ + \begin{mathpar} + \judgment{ }{ + \matchedArrowConstraint{\TUnknown^p}{\TUnknown^{\rightarrow_L(p)}}{\TUnknown^{\rightarrow_R(p)}}{\{ \TUnknown^p \approx \tarr{\TUnknown^{\rightarrow_L(p)}}{\TUnknown^{\rightarrow_R(p)}} \}} + }{TMAHole-C} + + \judgment{ }{ + \matchedArrowConstraint{\TArrow{\TMV_1}{\TMV_2}}{\TMV_1}{\TMV_2}{\{\}} + }{TMAArr-C} + \end{mathpar} + + \judgbox{\ensuremath{\matchedProdConstraint{\TMV}{\TMV_1}{\TMV_2}{C}}} $\TMV$ has matched binary product type $\TProd{\TMV_1}{\TMV_2}$ and generates constraints $C$ + \begin{mathpar} \judgment{ }{ \matchedProdConstraint{\TUnknown^p}{\TUnknown}{\TUnknown}{\{ \TUnknown^p \approx \TProd{\TUnknown^{\times_{L}(p)}}{\TUnknown^{\times_{R}(p)}} \}} }{TMPHole-C} @@ -190,17 +205,8 @@ \section{Constraint Generating Bidirectional Typing Rules} \judgment{ }{ \matchedProdConstraint{\TProd{\TMV_1}{\TMV_2}}{\TMV_1}{\TMV_2}{\{\}} }{TMPProd-C} -\end{mathpar} + \end{mathpar} + \label{fig:Matched Rules} +\end{figure} -\judgbox{\ensuremath{\matchedArrowConstraint{\TMV}{\TMV_1}{\TMV_2}{C}}} -\begin{mathpar} - \judgment{ }{ - \matchedArrowConstraint{\TUnknown^p}{\TUnknown^{\rightarrow_L(p)}}{\TUnknown^{\rightarrow_R(p)}}{\{ \TUnknown^p \approx \tarr{\TUnknown^{\rightarrow_L(p)}}{\TUnknown^{\rightarrow_R(p)}} \}} -}{TMAHole-C} - - \judgment{ }{ - \matchedArrowConstraint{\TArrow{\TMV_1}{\TMV_2}}{\TMV_1}{\TMV_2}{\{\}} - }{TMAArr-C} -\end{mathpar} - \label{fig:Matched Rules} -\end{figure} \ No newline at end of file +\end{document} diff --git a/supplement/formalism.tex b/supplement/formalism.tex new file mode 100644 index 0000000..0e2f57b --- /dev/null +++ b/supplement/formalism.tex @@ -0,0 +1,29 @@ +\documentclass{article} + +\input{preamble/preamble} +\usepackage{subfiles} + +\begin{document} +\tableofcontents +\newpage + +\renewcommand{\thesection}{\Alph{section}} + +\subfile{preface} +\newpage + +\subfile{marked} +\newpage + +\subfile{patterned} +\newpage + +\subfile{polymorphism} +\newpage + +\subfile{untyped} +\newpage + +\subfile{typed} + +\end{document} diff --git a/supplement/marked.tex b/supplement/marked.tex new file mode 100644 index 0000000..d39edaa --- /dev/null +++ b/supplement/marked.tex @@ -0,0 +1,985 @@ +\documentclass[supplement.tex]{subfiles} + +\begin{document} + +\section{Marked lambda calculus} +\label{sec:marked} + +The \emph{marked lambda calculus} is a judgmental framework for bidirectional type error +localization and recovery. Here, we demonstrate it on a gradually typed lambda calculus with +numbers, booleans, and product types. Typed holes (written $\EEHole$) are included to model +incomplete editor states \`a la Hazelnut but are not essential. + +\subsection{Syntax} +\label{sec:marked-syntax} +\[\begin{array}{rrcl} + \TMName & \TMV & \Coloneqq & \TUnknown \mid \TNum \mid \TBool \mid \TArrow{\TMV}{\TMV} \mid \TProd{\TMV}{\TMV} \\ + \EMName & \EMV & \Coloneqq & x \mid \ELam{x}{\TMV}{\EMV} \mid \EAp{\EMV}{\EMV} \mid \ELet{x}{\EMV}{\EMV} + \mid \ENumMV \mid \EPlus{\EMV}{\EMV} \\ + & & \mid & \ETrue \mid \EFalse \mid \EIf{\EMV}{\EMV}{\EMV} + \mid \EPair{\EMV}{\EMV} + \mid \EProjL{\EMV} \mid \EProjR{\EMV} + \mid \EEHole \\ + \ECMName & \ECMV & \Coloneqq & x \mid \ECLam{x}{\TMV}{\ECMV} \mid \ECAp{\ECMV}{\ECMV} \mid \ECLet{x}{\ECMV}{\ECMV} + \mid \ECNumMV \mid \ECPlus{\ECMV}{\ECMV} \\ + & & \mid & \ECTrue \mid \ECFalse \mid \ECIf{\ECMV}{\ECMV}{\ECMV} + \mid \ECPair{\ECMV}{\ECMV} \mid \ECProjL{\ECMV} \mid \ECProjR{\ECMV} + \mid \ECEHole \\ + & & \mid & \ECFree{x} \mid \ECInconType{\ECMV} \\ + & & \mid & \ECLamInconAsc{x}{\TMV}{\ECMV} \mid \ECLamAnaNonMatchedArrow{x}{\TMV}{\ECMV} \mid \ECApSynNonMatchedArrow{\ECMV}{\ECMV} \\ + & & \mid & \ECInconBr{\ECMV}{\ECMV}{\ECMV} \\ + & & \mid & \ECPairAnaNonMatchedProd{\ECMV}{\ECMV} \mid \ECProjLSynNonMatchedProd{\ECMV} \mid \ECProjRSynNonMatchedProd{\ECMV} +\end{array}\] + +\subsection{Types} +\label{sec:marked-types} +\judgbox{\ensuremath{\consistent{\TMV_1}{\TMV_2}}} $\TMV_1$ is consistent with $\TMV_2$ +% +\begin{mathpar} + \inferrule[TCUnknown1]{ }{ + \consistent{\TUnknown}{\TMV} + } + + \inferrule[TCUnknown2]{ }{ + \consistent{\TMV}{\TUnknown} + } + + \inferrule[TCRefl]{ }{ + \consistent{\TMV}{\TMV} + } + + \inferrule[TCArr]{ + \consistent{\TMV_1}{\TMV_1'} \\ + \consistent{\TMV_2}{\TMV_2'} \\ + }{ + \consistent{\TArrow{\TMV_1}{\TMV_2}}{\TArrow{\TMV_1'}{\TMV_2'}} + } + + \inferrule[TCProd]{ + \consistent{\TMV_1}{\TMV_1'} \\ + \consistent{\TMV_2}{\TMV_2'} \\ + }{ + \consistent{\TProd{\TMV_1}{\TMV_2}}{\TProd{\TMV_1'}{\TMV_2'}} + } +\end{mathpar} \\ + +\judgbox{\ensuremath{\matchedArrow{\TMV}{\TMV_1}{\TMV_2}}} $\TMV$ has matched arrow type $\TArrow{\TMV_1}{\TMV_2}$ +% +\begin{mathpar} + \inferrule[TMAUnknown]{ }{ + \matchedArrow{\TUnknown}{\TUnknown}{\TUnknown} + } + + \inferrule[TMAArr]{ }{ + \matchedArrow{\TArrow{\TMV_1}{\TMV_2}}{\TMV_1}{\TMV_2} + } +\end{mathpar} \\ + +\judgbox{\ensuremath{\matchedProd{\TMV}{\TMV_1}{\TMV_2}}} $\TMV$ has matched binary product type $\TProd{\TMV_1}{\TMV_2}$ +% +\begin{mathpar} + \inferrule[TMPUnknown]{ }{ + \matchedProd{\TUnknown}{\TUnknown}{\TUnknown} + } + + \inferrule[TMPProd]{ }{ + \matchedProd{\TProd{\TMV_1}{\TMV_2}}{\TMV_1}{\TMV_2} + } +\end{mathpar} \\ + +\judgbox{\ensuremath{\TMeet{\TMV_1}{\TMV_2}}} is a \emph{partial} metafunction defined as follows: +% +\newcommand{\meetsToRow}[3]{\ensuremath{\TMeet{#1}{#2} & = & #3}} +\[\begin{array}{rcl} + \meetsToRow{\TUnknown}{\TMV}{\TMV} \\ + \meetsToRow{\TMV}{\TUnknown}{\TMV} \\ + \meetsToRow{\TNum}{\TNum}{\TNum} \\ + \meetsToRow{\TBool}{\TBool}{\TBool} \\ + \meetsToRow{(\TArrow{\TMV_1}{\TMV_2})}{(\TArrow{\TMV_1'}{\TMV_2'})}{\TArrow{(\TMeet{\TMV_1}{\TMV_1'})}{(\TMeet{\TMV_2}{\TMV_2'})}} \\ + \meetsToRow{(\TProd{\TMV_1}{\TMV_2})}{(\TProd{\TMV_1'}{\TMV_2'})}{\TProd{(\TMeet{\TMV_1}{\TMV_1'})}{(\TMeet{\TMV_2}{\TMV_2'})}} +\end{array}\] \\ + +\judgbox{\ensuremath{\base{\TMV}}} $\TMV$ is a base type +% +\begin{mathpar} + \inferrule[TBNum]{ }{ + \base{\TNum} + } + + \inferrule[TBBool]{ }{ + \base{\TBool} + } +\end{mathpar} + +\subsection{Unmarked expressions} +\label{sec:marked-unmarked-expressions} +\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[USHole]{ }{ + \ctxSynTypeU{\ctx}{\EEHole}{\TUnknown} + } + + \inferrule[USVar]{ + \inCtx{\ctx}{x}{\TMV} + }{ + \ctxSynTypeU{\ctx}{x}{\TMV} + } + + \inferrule[USLam]{ + \ctxSynTypeU{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\TMV_2} + }{ + \ctxSynTypeU{\ctx}{\ELam{x}{\TMV_1}{\EMV}}{\TArrow{\TMV_1}{\TMV_2}} + } + + \inferrule[USAp]{ + \ctxSynTypeU{\ctx}{\EMV_1}{\TMV} \\ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV_1} + }{ + \ctxSynTypeU{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\TMV_2} + } + + \inferrule[USLet]{ + \ctxSynTypeU{\ctx}{\EMV_1}{\TMV_1} \\ + \ctxSynTypeU{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\TMV_2} + }{ + \ctxSynTypeU{\ctx}{\ELet{x}{\EMV_1}{\EMV_2}}{\TMV_2} + } + + \inferrule[USNum]{ }{ + \ctxSynTypeU{\ctx}{\ENumMV}{\TNum} + } + + \inferrule[USPlus]{ + \ctxAnaTypeU{\ctx}{\EMV_1}{\TNum} \\ + \ctxAnaTypeU{\ctx}{\EMV_2}{\TNum} + }{ + \ctxSynTypeU{\ctx}{\EPlus{\EMV_1}{\EMV_2}}{\TNum} + } + + \inferrule[USTrue]{ }{ + \ctxSynTypeU{\ctx}{\ETrue}{\TBool} + } + + \inferrule[USFalse]{ }{ + \ctxSynTypeU{\ctx}{\EFalse}{\TBool} + } + + \inferrule[USIf]{ + \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ + \ctxSynTypeU{\ctx}{\EMV_2}{\TMV_1} \\ + \ctxSynTypeU{\ctx}{\EMV_3}{\TMV_2} + }{ + \ctxSynTypeU{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TMeet{\TMV_1}{\TMV_2}} + } + + \inferrule[USPair]{ + \ctxSynTypeU{\ctx}{\EMV_1}{\TMV_1} \\ + \ctxSynTypeU{\ctx}{\EMV_2}{\TMV_2} + }{ + \ctxSynTypeU{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\TProd{\TMV_1}{\TMV_2}} + } + + \inferrule[USProjL]{ + \ctxSynTypeU{\ctx}{\EMV}{\TMV} \\ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} + }{ + \ctxSynTypeU{\ctx}{\EProjL{\EMV}}{\TMV_1} + } + + \inferrule[USProjR]{ + \ctxSynTypeU{\ctx}{\EMV}{\TMV} \\ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} + }{ + \ctxSynTypeU{\ctx}{\EProjR{\EMV}}{\TMV_2} + } +\end{mathpar} \\ + +\judgbox{\ctxAnaTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ analyzes against type $\TMV$ +% +\begin{mathpar} + \inferrule[UALam]{ + \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ + \consistent{\TMV}{\TMV_1} \\ + \ctxAnaTypeU{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\TMV_2} + }{ + \ctxAnaTypeU{\ctx}{\ECLam{x}{\TMV}{\EMV}}{\TMV_3} + } + + \inferrule[UALet]{ + \ctxSynTypeU{\ctx}{\EMV_1}{\TMV_1} \\ + \ctxAnaTypeU{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\TMV_2} + }{ + \ctxAnaTypeU{\ctx}{\ELet{x}{\EMV_1}{\EMV_2}}{\TMV_2} + } + + \inferrule[UAIf]{ + \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ + \ctxAnaTypeU{\ctx}{\EMV_1}{\TMV} \\ + \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV} + }{ + \ctxAnaTypeU{\ctx}{\ECIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TMV} + } + + \inferrule[UAPair]{ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaTypeU{\ctx}{\EMV_1}{\TMV_1} \\ + \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV_2} + }{ + \ctxAnaTypeU{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\TMV} + } + + \inferrule[UASubsume]{ + \ctxSynTypeU{\ctx}{\EMV}{\TMV'} \\ + \consistent{\TMV}{\TMV'} \\ + \subsumable{\EMV} + }{ + \ctxAnaTypeU{\ctx}{\EMV}{\TMV} + } +\end{mathpar} \\ + +\judgbox{\subsumable{\EMV}} $\EMV$ is subsumable +% +\begin{mathpar} + \inferrule[USuHole]{ }{ + \subsumable{\EEHole} + } + + \inferrule[USuVar]{ }{ + \subsumable{x} + } + + \inferrule[USuAp]{ }{ + \subsumable{\EAp{\EMV_1}{\EMV_2}} + } + + \inferrule[USuNum]{ }{ + \subsumable{\ENumMV} + } + + \inferrule[USuPlus]{ }{ + \subsumable{\EPlus{\EMV_1}{\EMV_2}} + } + + \inferrule[USuTrue]{ }{ + \subsumable{\ETrue} + } + + \inferrule[USuFalse]{ }{ + \subsumable{\EFalse} + } + + \inferrule[USuProjL]{ }{ + \subsumable{\EProjL{\EMV}} + } + + \inferrule[USuProjR]{ }{ + \subsumable{\EProjR{\EMV}} + } +\end{mathpar} + +\subsection{Marking} +\label{sec:marked-marking} +\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MKSHole]{ }{ + \ctxSynFixedInto{\ctx}{\EEHole}{\ECEHole}{\TUnknown} + } + + \inferrule[MKSVar]{ + \inCtx{\ctx}{x}{\TMV} + }{ + \ctxSynFixedInto{\ctx}{x}{x}{\TMV} + } + + \inferrule[MKSFree]{ + \notInCtx{\ctx}{x} + }{ + \ctxSynFixedInto{\ctx}{x}{\ECFree{x}}{\TUnknown} + } + + \inferrule[MKSLam]{ + \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV}{\ECMV}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\ELam{x}{\TMV_1}{\EMV}}{\ELam{x}{\TMV_1}{\ECMV}}{\TArrow{\TMV_1}{\TMV_2}} + } + + \inferrule[MKSAp1]{ + \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_1} \\ + }{ + \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECAp{\ECMV_1}{\ECMV_2}}{\TMV_2} + } + + % \inferrule[MKSAp2]{ + % \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ + % \notMatchedArrow{\TMV} \\ + % \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} + % }{ + % \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECApNonMatched{\ECMV_1}{\ECMV_2}}{\TUnknown} + % } + + % \inferrule[MKSAp2]{ + % \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ + % \notMatchedArrow{\TMV} \\ + % \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} + % }{ + % \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECApNonMatchedAlt{\ECMV_1}{\ECMV_2}}{\TUnknown} + % } + + \inferrule[MKSAp2]{ + \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ + \notMatchedArrow{\TMV} \\ + \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} + }{ + \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECApSynNonMatchedArrow{\ECMV_1}{\ECMV_2}}{\TUnknown} + } + + \inferrule[MKSLet]{ + \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ + \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\ECMV_2}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\ECLet{x}{\EMV_1}{\EMV_2}}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} + } + + \inferrule[MKSNum]{ }{ + \ctxSynFixedInto{\ctx}{\ENumMV}{\ECNumMV}{\TNum} + } + + \inferrule[MKSPlus]{ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TNum} \\ + \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TNum} + }{ + \ctxSynFixedInto{\ctx}{\EPlus{\EMV_1}{\EMV_2}}{\ECPlus{\ECMV_1}{\ECMV_2}}{\TNum} + } + + \inferrule[MKSTrue]{ }{ + \ctxSynFixedInto{\ctx}{\ETrue}{\ECTrue}{\TBool} + } + + \inferrule[MKSFalse]{ }{ + \ctxSynFixedInto{\ctx}{\EFalse}{\ECFalse}{\TBool} + } + + \inferrule[MKSIf]{ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ + \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_1} \\ + \ctxSynFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMeet{\TMV_1}{\TMV_2}} + } + + \inferrule[MKSInconsistentBranches]{ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ + \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_1} \\ + \ctxSynFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV_2} \\ + \inconsistent{\TMV_1}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TUnknown} + } + + \inferrule[MKSPair]{ + \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ + \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\ECPair{\ECMV_1}{\ECMV_2}}{\TProd{\TMV_1}{\TMV_2}} + } + + \inferrule[MKSProjL1]{ + \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\EProjL{\EMV}}{\ECProjL{\ECMV}}{\TMV_1} + } + + \inferrule[MKSProjL2]{ + \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ + \notMatchedProd{\TMV} + }{ + \ctxSynFixedInto{\ctx}{\EProjL{\EMV}}{\ECProjLSynNonMatchedProd{\ECMV}}{\TMV_1} + } + + \inferrule[MKSProjR1]{ + \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\EProjR{\EMV}}{\ECProjR{\ECMV}}{\TMV_2} + } + + \inferrule[MKSProjR2]{ + \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ + \notMatchedProd{\TMV} + }{ + \ctxSynFixedInto{\ctx}{\EProjR{\EMV}}{\ECProjRSynNonMatchedProd{\ECMV}}{\TMV_2} + } +\end{mathpar} \\ + +\judgbox{\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and analyzes against type $\TMV$ +% +\begin{mathpar} + \inferrule[MKALam1]{ + \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ + \consistent{\TMV}{\TMV_1} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\ECMV}{\TMV_2} + }{ + \ctxAnaFixedInto{\ctx}{\ELam{x}{\TMV}{\EMV}}{\ECLam{x}{\TMV}{\ECMV}}{\TMV_3} + } + + \inferrule[MKALam2]{ + \notMatchedArrow{\TMV_3} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\ECMV}{\TUnknown} + }{ + \ctxAnaFixedInto{\ctx}{\ELam{x}{\TMV}{\EMV}}{\ECLamAnaNonMatchedArrow{x}{\TMV}{\ECMV}}{\TMV_3} + } + + \inferrule[MKALam3]{ + \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ + \inconsistent{\TMV}{\TMV_1} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV}{\ECMV}{\TMV_2} + }{ + \ctxAnaFixedInto{\ctx}{\ELam{x}{\TMV}{\EMV}}{\ECLamInconAsc{x}{\TMV}{\ECMV}}{\TMV_3} + } + + \inferrule[MKALet]{ + \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\ECMV_2}{\TMV_2} + }{ + \ctxAnaFixedInto{\ctx}{\ECLet{x}{\EMV_1}{\EMV_2}}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} + } + + \inferrule[MKAIf]{ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ + \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV} \\ + \ctxAnaFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV} \\ + }{ + \ctxAnaFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} + } + + \inferrule[MKAPair1]{ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ + \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_2} + }{ + \ctxAnaFixedInto{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\ECPair{\ECMV_1}{\ECMV_2}}{\TMV} + } + + \inferrule[MKAPair2]{ + \notMatchedProd{\TMV} \\ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TUnknown} \\ + \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} + }{ + \ctxAnaFixedInto{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\ECPairAnaNonMatchedProd{\ECMV_1}{\ECMV_2}}{\TMV} + } + + \inferrule[MKAInconsistentTypes]{ + \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'} \\ + \inconsistent{\TMV}{\TMV'} \\ + \subsumable{\EMV} + }{ + \ctxAnaFixedInto{\ctx}{\EMV}{\ECInconType{\ECMV}}{\TMV} + } + + \inferrule[MKASubsume]{ + \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'} \\ + \consistent{\TMV}{\TMV'} \\ + \subsumable{\EMV} + }{ + \ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} + } +\end{mathpar} + +\subsection{Marked expressions} +\label{sec:marked-marked-expressions} +\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MSHole]{ }{ + \ctxSynTypeM{\ctx}{\ECEHole}{\TUnknown} + } + + \inferrule[MSVar]{ + \inCtx{\ctx}{x}{\TMV} + }{ + \ctxSynTypeM{\ctx}{x}{\TMV} + } + + \inferrule[MSFree]{ + \notInCtx{\ctx}{x} + }{ + \ctxSynTypeM{\ctx}{\ECFree{x}}{\TUnknown} + } + + \inferrule[MSLam]{ + \ctxSynTypeM{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ECLam{x}{\TMV_1}{\ECMV}}{\TArrow{\TMV_1}{\TMV_2}} + } + + \inferrule[MSAp1]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV_1} + }{ + \ctxSynTypeM{\ctx}{\ECAp{\ECMV_1}{\ECMV_2}}{\TMV_2} + } + + % \inferrule[MSAp2]{ + % \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ + % \notMatchedArrow{\TMV} \\ + % \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} + % }{ + % \ctxSynTypeM{\ctx}{\ECApNonMatched{\ECMV_1}{\ECMV_2}}{\TUnknown} + % } + + % \inferrule[MSAp2]{ + % \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ + % \notMatchedArrow{\TMV} \\ + % \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} + % }{ + % \ctxSynTypeM{\ctx}{\ECApNonMatchedAlt{\ECMV}{\ECMV}}{\TUnknown} + % } + + \inferrule[MSAp2]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ + \notMatchedArrow{\TMV} \\ + \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} + }{ + \ctxSynTypeM{\ctx}{\ECApSynNonMatchedArrow{\ECMV}{\ECMV}}{\TUnknown} + } + + \inferrule[MSLet]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \ctxSynTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV_2}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} + } + + \inferrule[MSNum]{ }{ + \ctxSynTypeM{\ctx}{\ECNumMV}{\TNum} + } + + \inferrule[MSPlus]{ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TNum} \\ + \ctxAnaTypeM{\ctx}{\ECMV_2}{\TNum} + }{ + \ctxSynTypeM{\ctx}{\ECPlus{\ECMV_1}{\ECMV_2}}{\TNum} + } + + \inferrule[MSTrue]{ }{ + \ctxSynTypeM{\ctx}{\ECTrue}{\TBool} + } + + \inferrule[MSFalse]{ }{ + \ctxSynTypeM{\ctx}{\ECFalse}{\TBool} + } + + \inferrule[MSIf]{ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ + \ctxSynTypeM{\ctx}{\ECMV_3}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMeet{\TMV_1}{\TMV_2}} + } + + \inferrule[MSInconsistentBranches]{ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ + \ctxSynTypeM{\ctx}{\ECMV_3}{\TMV_2} \\ + \inconsistent{\TMV_1}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TUnknown} + } + + \inferrule[MSPair]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ECPair{\ECMV_1}{\ECMV_2}}{\TProd{\TMV_1}{\TMV_2}} + } + + \inferrule[MSProjL1]{ + \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ECProjL{\ECMV}}{\TMV_1} + } + + \inferrule[MSProjL2]{ + \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ + \notMatchedProd{\TMV} + }{ + \ctxSynTypeM{\ctx}{\ECProjLSynNonMatchedProd{\ECMV}}{\TUnknown} + } + + \inferrule[MSProjR1]{ + \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ECProjR{\ECMV}}{\TMV_2} + } + + \inferrule[MSProjR2]{ + \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ + \notMatchedProd{\TMV} + }{ + \ctxSynTypeM{\ctx}{\ECProjRSynNonMatchedProd{\ECMV}}{\TUnknown} + } +\end{mathpar} \\ + +\judgbox{\ctxAnaTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ analyzes against type $\TMV$ +% +\begin{mathpar} + \inferrule[MALam1]{ + \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ + \consistent{\TMV}{\TMV_1} \\ + \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TMV_2} + }{ + \ctxAnaTypeM{\ctx}{\ECLam{x}{\TMV}{\ECMV}}{\TMV_3} + } + + \inferrule[MALam2]{ + \notMatchedArrow{\TMV_3} \\ + \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TUnknown} + }{ + \ctxAnaTypeM{\ctx}{\ECLamAnaNonMatchedArrow{x}{\TMV}{\ECMV}}{\TMV_3} + } + + \inferrule[MALam3]{ + \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ + \inconsistent{\TMV}{\TMV_1} \\ + \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV}{\TMV_2} + }{ + \ctxAnaTypeM{\ctx}{\ECLamInconAsc{x}{\TMV}{\ECMV}}{\TMV_3} + } + + \inferrule[MALet]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV_2}{\TMV_2} + }{ + \ctxAnaTypeM{\ctx}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} + } + + \inferrule[MAIf]{ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TMV} \\ + \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV} + }{ + \ctxAnaTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} + } + + \inferrule[MAPair1]{ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV_2} + }{ + \ctxAnaTypeM{\ctx}{\ECPair{\ECMV_1}{\ECMV_2}}{\TMV} + } + + \inferrule[MAPair2]{ + \notMatchedProd{\TMV} \\ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TUnknown} \\ + \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} + }{ + \ctxAnaTypeM{\ctx}{\ECPairAnaNonMatchedProd{\ECMV_1}{\ECMV_2}}{\TMV} + } + + \inferrule[MAInconsistentTypes]{ + \ctxSynTypeM{\ctx}{\ECMV}{\TMV'} \\ + \inconsistent{\TMV}{\TMV'} \\ + \subsumable{\ECMV} + }{ + \ctxAnaTypeM{\ctx}{\ECInconType{\ECMV}}{\TMV} + } + + \inferrule[MASubsume]{ + \ctxSynTypeM{\ctx}{\ECMV}{\TMV'} \\ + \consistent{\TMV}{\TMV'} \\ + \subsumable{\ECMV} + }{ + \ctxAnaTypeM{\ctx}{\ECMV}{\TMV} + } +\end{mathpar} \\ + +\judgbox{\subsumable{\ECMV}} $\ECMV$ is subsumable +% +\begin{mathpar} + \inferrule[MSuHole]{ }{ + \subsumable{\ECEHole} + } + + \inferrule[MSuVar]{ }{ + \subsumable{x} + } + + \inferrule[MSuFree]{ }{ + \subsumable{\ECFree{x}} + } + + \inferrule[MSuAp1]{ }{ + \subsumable{\ECAp{\ECMV_1}{\ECMV_2}} + } + + \inferrule[MSuAp2]{ }{ + \subsumable{\ECApSynNonMatchedArrow{\ECMV_1}{\ECMV_2}} + } + + \inferrule[MSuNum]{ }{ + \subsumable{\ECNumMV} + } + + \inferrule[MSuPlus]{ }{ + \subsumable{\ECPlus{\ECMV_1}{\ECMV_2}} + } + + \inferrule[MSuTrue]{ }{ + \subsumable{\ECTrue} + } + + \inferrule[MSuFalse]{ }{ + \subsumable{\ECFalse} + } + + \inferrule[MSuInconsistentBranches]{ }{ + \subsumable{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } + + \inferrule[MSuProjL1]{ }{ + \subsumable{\ECProjL{\ECMV}} + } + + \inferrule[MSuProjL2]{ }{ + \subsumable{\ECProjLSynNonMatchedProd{\ECMV}} + } + + \inferrule[MSuProjR1]{ }{ + \subsumable{\ECProjR{\ECMV}} + } + + \inferrule[MSuProjR2]{ }{ + \subsumable{\ECProjRSynNonMatchedProd{\ECMV}} + } +\end{mathpar} \\ + +\judgbox{\markless{\ECMV}} $\ECMV$ has no marks +% +\begin{mathpar} + \inferrule[MLHole]{ }{ + \markless{\ECEHole} + } + + \inferrule[MLVar]{ }{ + \markless{x} + } + + \inferrule[MLLam]{ + \markless{\ECMV} + }{ + \markless{\ECLam{x}{\TMV}{\ECMV}} + } + + \inferrule[MLAp]{ + \markless{\ECMV_1} \\ + \markless{\ECMV_2} + }{ + \markless{\ECAp{\ECMV_1}{\ECMV_2}} + } + + \inferrule[MLNum]{ }{ + \markless{\ECNumMV} + } + + \inferrule[MLPlus]{ + \markless{\ECMV_1} \\ + \markless{\ECMV_2} + }{ + \markless{\ECPlus{\ECMV_1}{\ECMV_2}} + } + + \inferrule[MLTrue]{ }{ + \markless{\ECTrue} + } + + \inferrule[MLFalse]{ }{ + \markless{\ECFalse} + } + + \inferrule[MLIf]{ + \markless{\ECMV_1} \\ + \markless{\ECMV_2} \\ + \markless{\ECMV_3} + }{ + \markless{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } +\end{mathpar} + +\subsection{Mark erasure} +\label{sec:marked-mark-erasure} +$\judgbox{\erase{\ECMV}}$ is a metafunction defined as follows: +% +\newcommand{\erasesToRow}[2]{\erase{#1} & = & #2} +\[\begin{array}{rcl} + \erasesToRow{\ECEHole}{\EEHole} \\ + \erasesToRow{x}{x} \\ + \erasesToRow{\ECFree{x}}{x} \\ + \erasesToRow{(\ECLam{x}{\TMV}{\ECMV})}{\ELam{x}{\TMV}{(\erase{\ECMV})}} \\ + \erasesToRow{\ECLamInconAsc{x}{\TMV}{\ECMV}}{\ELam{x}{\TMV}{(\erase{\ECMV})}} \\ + \erasesToRow{\ECLamAnaNonMatchedArrow{x}{\TMV}{\ECMV}}{\ECLam{x}{\TMV}{(\erase{\ECMV})}} \\ + \erasesToRow{(\ECAp{\ECMV_1}{\ECMV_2})}{\EAp{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} \\ + \erasesToRow{(\ECApSynNonMatchedArrow{\ECMV_1}{\ECMV_2})}{\ECAp{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} \\ + \erasesToRow{(\ECLet{x}{\ECMV_1}{\ECMV_2})}{\ELet{x}{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} \\ + \erasesToRow{\ECNumMV}{\ENumMV} \\ + \erasesToRow{(\ECPlus{\ECMV_1}{\ECMV_2})}{\EPlus{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} \\ + \erasesToRow{\ECTrue}{\ETrue} \\ + \erasesToRow{\ECFalse}{\EFalse} \\ + \erasesToRow{(\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3})}{\EIf{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}{(\erase{\ECMV_3})}} \\ + \erasesToRow{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\EIf{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}{(\erase{\ECMV_3})}} \\ + \erasesToRow{\ECPair{\ECMV_1}{\ECMV_2}}{\ECPair{\erase{\ECMV_1}}{\erase{\ECMV_2}}} \\ + \erasesToRow{\ECPairAnaNonMatchedProd{\ECMV_1}{\ECMV_2}}{\ECPair{\erase{\ECMV_1}}{\erase{\ECMV_2}}} \\ + \erasesToRow{(\ECProjL{\ECMV})}{\ECProjL{(\erase{\ECMV})}} \\ + \erasesToRow{(\ECProjLSynNonMatchedProd{\ECMV})}{\ECProjL{(\erase{\ECMV})}} \\ + \erasesToRow{(\ECProjR{\ECMV})}{\ECProjR{(\erase{\ECMV})}} \\ + \erasesToRow{(\ECProjRSynNonMatchedProd{\ECMV})}{\ECProjR{(\erase{\ECMV})}} \\ + \erasesToRow{\ECInconType{\ECMV}}{\erase{\ECMV}} \\ +\end{array}\] + +\subsection{Metatheorems} +\label{sec:marked-metatheorems} +\begin{theorem}[name=Marking Totality] \ + \begin{enumerate} + \item For all $\ctx$ and $\EMV$, there exist $\ECMV$ and $\TMV$ such that + $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$. + \item For all $\ctx$, $\EMV$, and $\TMV$, there exists $\ECMV$ such that + $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Marking Well-Formedness] \ + \begin{enumerate} + \item If $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, then $\ctxSynTypeM{\ctx}{\ECMV}{\TMV}$ and + $\erasesTo{\ECMV}{\EMV}$. + \item If $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, then $\ctxAnaTypeM{\ctx}{\ECMV}{\TMV}$ and + $\erasesTo{\ECMV}{\EMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Marking of Well-Typed/Ill-Typed Expressions] \ + \begin{enumerate} + \item \begin{enumerate} + \item If $\ctxSynTypeU{\ctx}{\EMV}{\TMV}$ and $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, + then $\markless{\ECMV}$. + \item If $\ctxAnaTypeU{\ctx}{\EMV}{\TMV}$ and $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, + then $\markless{\ECMV}$. + \end{enumerate} + + \item \begin{enumerate} + \item If there does not exist $\TMV$ such that $\ctxSynTypeU{\ctx}{\EMV}{\TMV}$, then for + all $\ECMV$ and $\TMV'$ such that $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'}$, it is not + the case that $\markless{\ECMV}$. + \item If there does not exist $\TMV$ such that $\ctxAnaTypeU{\ctx}{\EMV}{\TMV}$, then for + all $\ECMV$ and $\TMV'$ such that $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'}$, it is not + the case that $\markless{\ECMV}$. + \end{enumerate} + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Marking Unicity] \ + \begin{enumerate} + \item If $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV_1}{\TMV_1}$ and + $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV_2}{\TMV_2}$, then $\ECMV_1 = \ECMV_2$ and $\TMV_1 = + \TMV_2$. + \item If $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV_1}{\TMV}$ and + $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV_2}{\TMV}$, then $\ECMV_1 = \ECMV_2$. + \end{enumerate} +\end{theorem} + +\subsection{Alternative conditional rules} +\label{sec:marked-alternative-conditionals} +There are alternative ways to formulate error localization in conditionals. Below, we provide two +alternatives to the rules above. + +\subsubsection{Localize to second} +\label{sec:marked-alternative-conditionals-localize-second} +In this formulation, we always select the first branch as ``correct'' and localize errors to the +second. \\ + +\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[USIf']{ + \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ + \ctxSynTypeU{\ctx}{\EMV_2}{\TMV} \\ + \ctxAnaTypeU{\ctx}{\EMV_3}{\TMV} + }{ + \ctxSynTypeU{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TMV} + } +\end{mathpar} + +\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MKSIf']{ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ + \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV} \\ + \ctxAnaFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV} + }{ + \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} + } +\end{mathpar} + +\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MSIf']{ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV} \\ + \ctxAnaTypeM{\ctx}{\ECMV_3}{\TMV} + }{ + \ctxSynTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} + } +\end{mathpar} + +\subsubsection{Localize to first} +\label{sec:marked-alternative-conditionals-localize-first} +In this formulation, we always select the second branch as ``correct'' and localize errors to the +first. \\ + +\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[USIf'']{ + \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ + \ctxSynTypeU{\ctx}{\EMV_3}{\TMV} \\ + \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV} + }{ + \ctxSynTypeU{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TMV} + } +\end{mathpar} + +\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MKSIf'']{ + \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ + \ctxSynFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV} \\ + \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV} + }{ + \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} + } +\end{mathpar} + +\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MSIf'']{ + \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ + \ctxSynTypeM{\ctx}{\ECMV_3}{\TMV} \\ + \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV} + }{ + \ctxSynTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} + } +\end{mathpar} + +\end{document} diff --git a/supplement/marking.tex b/supplement/marking.tex deleted file mode 100644 index 209853c..0000000 --- a/supplement/marking.tex +++ /dev/null @@ -1,2890 +0,0 @@ -\section{Marked Lambda Calculus} -The \emph{marked lambda calculus} is a judgmental framework for bidirectional type error -localization and recovery. Below is the complete formalization of the calculus on a gradually typed -lambda calculus, with rules organized by judgment form. - -\subsection{Syntax} -\[\begin{array}{rrcl} - \TMName & \TMV & \Coloneqq & \TUnknown \mid \TNum \mid \TBool \mid \TArrow{\TMV}{\TMV} \mid \TProd{\TMV}{\TMV} \\ - \EMName & \EMV & \Coloneqq & x \mid \ELam{x}{\TMV}{\EMV} \mid \EAp{\EMV}{\EMV} \mid \ELet{x}{\EMV}{\EMV} - \mid \ENumMV \mid \EPlus{\EMV}{\EMV} \\ - & & \mid & \ETrue \mid \EFalse \mid \EIf{\EMV}{\EMV}{\EMV} - \mid \EPair{\EMV}{\EMV} - \mid \EProjL{\EMV} \mid \EProjR{\EMV} - \mid \EEHole \\ - \ECMName & \ECMV & \Coloneqq & x \mid \ECLam{x}{\TMV}{\ECMV} \mid \ECAp{\ECMV}{\ECMV} \mid \ECLet{x}{\ECMV}{\ECMV} - \mid \ECNumMV \mid \ECPlus{\ECMV}{\ECMV} \\ - & & \mid & \ECTrue \mid \ECFalse \mid \ECIf{\ECMV}{\ECMV}{\ECMV} - \mid \ECPair{\ECMV}{\ECMV} \mid \ECProjL{\ECMV} \mid \ECProjR{\ECMV} - \mid \ECEHole \\ - & & \mid & \ECUnbound{x} \mid \ECInconType{\ECMV} \mid \ECInconBr{\ECMV}{\ECMV}{\ECMV} \mid \ECLamInconAsc{x}{\TMV}{\ECMV} \\ - & & \mid & \ECSynNonMatchedArrow{\ECMV} \mid \ECAnaNonMatchedArrow{\ECMV} - \mid \ECSynNonMatchedProd{\ECMV} \mid \ECAnaNonMatchedProd{\ECMV} -\end{array}\] - -\subsection{Types} -\judgbox{\ensuremath{\consistent{\TMV_1}{\TMV_2}}} $\TMV_1$ is consistent with $\TMV_2$ -% -\begin{mathpar} - \judgment{ }{ - \consistent{\TUnknown}{\TMV} - }{TCUnknown1} - - \judgment{ }{ - \consistent{\TMV}{\TUnknown} - }{TCUnknown2} - - \judgment{ }{ - \consistent{\TMV}{\TMV} - }{TCRefl} - - \judgment{ - \consistent{\TMV_1}{\TMV_1'} \\ - \consistent{\TMV_2}{\TMV_2'} \\ - }{ - \consistent{\TArrow{\TMV_1}{\TMV_2}}{\TArrow{\TMV_1'}{\TMV_2'}} - }{TCArr} - - \judgment{ - \consistent{\TMV_1}{\TMV_1'} \\ - \consistent{\TMV_2}{\TMV_2'} \\ - }{ - \consistent{\TProd{\TMV_1}{\TMV_2}}{\TProd{\TMV_1'}{\TMV_2'}} - }{TCProd} -\end{mathpar} \\ - -\judgbox{\ensuremath{\matchedArrow{\TMV}{\TMV_1}{\TMV_2}}} $\TMV$ has matched arrow type $\TArrow{\TMV_1}{\TMV_2}$ -% -\begin{mathpar} - \judgment{ }{ - \matchedArrow{\TUnknown}{\TUnknown}{\TUnknown} - }{TMAUnknown} - - \judgment{ }{ - \matchedArrow{\TArrow{\TMV_1}{\TMV_2}}{\TMV_1}{\TMV_2} - }{TMAArr} -\end{mathpar} \\ - -\judgbox{\ensuremath{\matchedProd{\TMV}{\TMV_1}{\TMV_2}}} $\TMV$ has matched binary product type $\TProd{\TMV_1}{\TMV_2}$ -% -\begin{mathpar} - \judgment{ }{ - \matchedProd{\TUnknown}{\TUnknown}{\TUnknown} - }{TMPUnknown} - - \judgment{ }{ - \matchedProd{\TProd{\TMV_1}{\TMV_2}}{\TMV_1}{\TMV_2} - }{TMPProd} -\end{mathpar} \\ - -\judgbox{\ensuremath{\TJoin{\TMV_1}{\TMV_2}}} is a \emph{partial} metafunction defined as follows: -% -\newcommand{\joinsTo}[3]{\ensuremath{\TJoin{#1}{#2} & = & #3}} -\[\begin{array}{rcl} - \joinsTo{\TUnknown}{\TMV}{\TMV} \\ - \joinsTo{\TMV}{\TUnknown}{\TMV} \\ - \joinsTo{\TNum}{\TNum}{\TNum} \\ - \joinsTo{\TBool}{\TBool}{\TBool} \\ - \joinsTo{(\TArrow{\TMV_1}{\TMV_2})}{(\TArrow{\TMV_1'}{\TMV_2'})}{\TArrow{(\TJoin{\TMV_1}{\TMV_1'})}{(\TJoin{\TMV_2}{\TMV_2'})}} \\ - \joinsTo{(\TProd{\TMV_1}{\TMV_2})}{(\TProd{\TMV_1'}{\TMV_2'})}{\TProd{(\TJoin{\TMV_1}{\TMV_1'})}{(\TJoin{\TMV_2}{\TMV_2'})}} -\end{array}\] \\ - -\judgbox{\ensuremath{\base{\TMV}}} $\TMV$ is a base type -% -\begin{mathpar} - \judgment{ }{ - \base{\TNum} - }{TBNum} - - \judgment{ }{ - \base{\TBool} - }{TBBool} -\end{mathpar} - -\subsection{Unmarked Expressions} -\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ }{ - \ctxSynTypeU{\ctx}{\EEHole}{\TUnknown} - }{USHole} - - \judgment{ - \inCtx{\ctx}{x}{\TMV} - }{ - \ctxSynTypeU{\ctx}{x}{\TMV} - }{USVar} - - \judgment{ - \ctxSynTypeU{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\TMV_2} - }{ - \ctxSynTypeU{\ctx}{\ELam{x}{\TMV_1}{\EMV}}{\TArrow{\TMV_1}{\TMV_2}} - }{USLam} - - \judgment{ - \ctxSynTypeU{\ctx}{\EMV_1}{\TMV} \\ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV_1} - }{ - \ctxSynTypeU{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\TMV_2} - }{USAp} - - \judgment{ - \ctxSynTypeU{\ctx}{\EMV_1}{\TMV_1} \\ - \ctxSynTypeU{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\TMV_2} - }{ - \ctxSynTypeU{\ctx}{\ELet{x}{\EMV_1}{\EMV_2}}{\TMV_2} - }{USLet} - - \judgment{ }{ - \ctxSynTypeU{\ctx}{\ENumMV}{\TNum} - }{USNum} - - \judgment{ - \ctxAnaTypeU{\ctx}{\EMV_1}{\TNum} \\ - \ctxAnaTypeU{\ctx}{\EMV_2}{\TNum} - }{ - \ctxSynTypeU{\ctx}{\EPlus{\EMV_1}{\EMV_2}}{\TNum} - }{USPlus} - - \judgment{ }{ - \ctxSynTypeU{\ctx}{\ETrue}{\TBool} - }{USTrue} - - \judgment{ }{ - \ctxSynTypeU{\ctx}{\EFalse}{\TBool} - }{USFalse} - - \judgment{ - \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ - \ctxSynTypeU{\ctx}{\EMV_2}{\TMV_1} \\ - \ctxSynTypeU{\ctx}{\EMV_3}{\TMV_2} - }{ - \ctxSynTypeU{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TJoin{\TMV_1}{\TMV_2}} - }{USIf} - - \judgment{ - \ctxSynTypeU{\ctx}{\EMV_1}{\TMV_1} \\ - \ctxSynTypeU{\ctx}{\EMV_2}{\TMV_2} - }{ - \ctxSynTypeU{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\TProd{\TMV_1}{\TMV_2}} - }{USPair} - - \judgment{ - \ctxSynTypeU{\ctx}{\EMV}{\TMV} \\ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} - }{ - \ctxSynTypeU{\ctx}{\EProjL{\EMV}}{\TMV_1} - }{USProjL} - - \judgment{ - \ctxSynTypeU{\ctx}{\EMV}{\TMV} \\ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} - }{ - \ctxSynTypeU{\ctx}{\EProjR{\EMV}}{\TMV_2} - }{USProjR} -\end{mathpar} \\ - -\judgbox{\ctxAnaTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ analyzes against type $\TMV$ -% -\begin{mathpar} - \judgment{ - \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ - \consistent{\TMV}{\TMV_1} \\ - \ctxAnaTypeU{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\TMV_2} - }{ - \ctxAnaTypeU{\ctx}{\ECLam{x}{\TMV}{\EMV}}{\TMV_3} - }{UALam} - - \judgment{ - \ctxSynTypeU{\ctx}{\EMV_1}{\TMV_1} \\ - \ctxAnaTypeU{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\TMV_2} - }{ - \ctxAnaTypeU{\ctx}{\ELet{x}{\EMV_1}{\EMV_2}}{\TMV_2} - }{UALet} - - \judgment{ - \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ - \ctxAnaTypeU{\ctx}{\EMV_1}{\TMV} \\ - \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV} - }{ - \ctxAnaTypeU{\ctx}{\ECIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TMV} - }{UAIf} - - \judgment{ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaTypeU{\ctx}{\EMV_1}{\TMV_1} \\ - \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV_2} - }{ - \ctxAnaTypeU{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\TMV} - }{UAPair} - - \judgment{ - \ctxSynTypeU{\ctx}{\EMV}{\TMV'} \\ - \consistent{\TMV}{\TMV'} \\ - \subsumable{\EMV} - }{ - \ctxAnaTypeU{\ctx}{\EMV}{\TMV} - }{UASubsume} -\end{mathpar} \\ - -\judgbox{\subsumable{\EMV}} $\EMV$ is subsumable -% -\begin{mathpar} - \judgment{ }{ - \subsumable{\EEHole} - }{USuHole} - - \judgment{ }{ - \subsumable{x} - }{USuVar} - - \judgment{ }{ - \subsumable{\EAp{\EMV_1}{\EMV_2}} - }{USuAp} - - \judgment{ }{ - \subsumable{\ENumMV} - }{USuNum} - - \judgment{ }{ - \subsumable{\EPlus{\EMV_1}{\EMV_2}} - }{USuPlus} - - \judgment{ }{ - \subsumable{\ETrue} - }{USuTrue} - - \judgment{ }{ - \subsumable{\EFalse} - }{USuFalse} - - \judgment{ }{ - \subsumable{\EProjL{\EMV}} - }{USuProjL} - - \judgment{ }{ - \subsumable{\EProjR{\EMV}} - }{USuProjR} -\end{mathpar} - -\subsection{Marking} -\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ }{ - \ctxSynFixedInto{\ctx}{\EEHole}{\ECEHole}{\TUnknown} - }{MKSHole} - - \judgment{ - \inCtx{\ctx}{x}{\TMV} - }{ - \ctxSynFixedInto{\ctx}{x}{x}{\TMV} - }{MKSVar} - - \judgment{ - \notInCtx{\ctx}{x} - }{ - \ctxSynFixedInto{\ctx}{x}{\ECUnbound{x}}{\TUnknown} - }{MKSUnbound} - - \judgment{ - \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV}{\ECMV}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\ELam{x}{\TMV_1}{\EMV}}{\ELam{x}{\TMV_1}{\ECMV}}{\TArrow{\TMV_1}{\TMV_2}} - }{MKSLam} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_1} \\ - }{ - \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECAp{\ECMV_1}{\ECMV_2}}{\TMV_2} - }{MKSAp1} - - % \judgment{ - % \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ - % \notMatchedArrow{\TMV} \\ - % \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} - % }{ - % \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECApNonMatched{\ECMV_1}{\ECMV_2}}{\TUnknown} - % }{MKSAp2} - - % \judgment{ - % \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ - % \notMatchedArrow{\TMV} \\ - % \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} - % }{ - % \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECApNonMatchedAlt{\ECMV_1}{\ECMV_2}}{\TUnknown} - % }{MKSAp2} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV} \\ - \notMatchedArrow{\TMV} \\ - \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} - }{ - \ctxSynFixedInto{\ctx}{\EAp{\EMV_1}{\EMV_2}}{\ECApSynNonMatchedArrow{\ECMV_1}{\ECMV_2}}{\TUnknown} - }{MKSAp2} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ - \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\ECMV_2}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\ECLet{x}{\EMV_1}{\EMV_2}}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} - }{MKSLet} - - \judgment{ - }{ - \ctxSynFixedInto{\ctx}{\ENumMV}{\ECNumMV}{\TNum} - }{MKSNum} - - \judgment{ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TNum} \\ - \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TNum} - }{ - \ctxSynFixedInto{\ctx}{\EPlus{\EMV_1}{\EMV_2}}{\ECPlus{\ECMV_1}{\ECMV_2}}{\TNum} - }{MKSPlus} - - \judgment{ - }{ - \ctxSynFixedInto{\ctx}{\ETrue}{\ECTrue}{\TBool} - }{MKSTrue} - - \judgment{ - }{ - \ctxSynFixedInto{\ctx}{\EFalse}{\ECFalse}{\TBool} - }{MKSFalse} - - \judgment{ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ - \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_1} \\ - \ctxSynFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TJoin{\TMV_1}{\TMV_2}} - }{MKSIf} - - \judgment{ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ - \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_1} \\ - \ctxSynFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV_2} \\ - \inconsistent{\TMV_1}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TUnknown} - }{MKSInconsistentBranches} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ - \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\ECPair{\ECMV_1}{\ECMV_2}}{\TProd{\TMV_1}{\TMV_2}} - }{MKSPair} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\EProjL{\EMV}}{\ECProjL{\ECMV}}{\TMV_1} - }{MKSProjL1} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ - \notMatchedProd{\TMV} - }{ - \ctxSynFixedInto{\ctx}{\EProjL{\EMV}}{\ECProjLSynNonMatchedProd{\ECMV}}{\TMV_1} - }{MKSProjL2} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\EProjR{\EMV}}{\ECProjR{\ECMV}}{\TMV_2} - }{MKSProjR1} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} \\ - \notMatchedProd{\TMV} - }{ - \ctxSynFixedInto{\ctx}{\EProjR{\EMV}}{\ECProjRSynNonMatchedProd{\ECMV}}{\TMV_2} - }{MKSProjR2} -\end{mathpar} \\ - -\judgbox{\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and analyzes against type $\TMV$ -% -\begin{mathpar} - \judgment{ - \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ - \consistent{\TMV}{\TMV_1} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\ECMV}{\TMV_2} - }{ - \ctxAnaFixedInto{\ctx}{\ELam{x}{\TMV}{\EMV}}{\ECLam{x}{\TMV}{\ECMV}}{\TMV_3} - }{MKALam1} - - \judgment{ - \notMatchedArrow{\TMV_3} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV}}{\EMV}{\ECMV}{\TUnknown} - }{ - \ctxAnaFixedInto{\ctx}{\ELam{x}{\TMV}{\EMV}}{\ECLamAnaNonMatchedArrow{x}{\TMV}{\ECMV}}{\TMV_3} - }{MKALam2} - - \judgment{ - \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ - \inconsistent{\TMV}{\TMV_1} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV}{\ECMV}{\TMV_2} - }{ - \ctxAnaFixedInto{\ctx}{\ELam{x}{\TMV}{\EMV}}{\ECLamInconAsc{x}{\TMV}{\ECMV}}{\TMV_3} - }{MKALam3} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\EMV_2}{\ECMV_2}{\TMV_2} - }{ - \ctxAnaFixedInto{\ctx}{\ECLet{x}{\EMV_1}{\EMV_2}}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} - }{MKALet} - - \judgment{ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ - \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV} \\ - \ctxAnaFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV} \\ - }{ - \ctxAnaFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} - }{MKAIf} - - \judgment{ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TMV_1} \\ - \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV_2} - }{ - \ctxAnaFixedInto{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\ECPair{\ECMV_1}{\ECMV_2}}{\TMV} - }{MKAPair1} - - \judgment{ - \notMatchedProd{\TMV} \\ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TUnknown} \\ - \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TUnknown} - }{ - \ctxAnaFixedInto{\ctx}{\EPair{\EMV_1}{\EMV_2}}{\ECPairAnaNonMatchedProd{\ECMV_1}{\ECMV_2}}{\TMV} - }{MKAPair2} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'} \\ - \inconsistent{\TMV}{\TMV'} \\ - \subsumable{\EMV} - }{ - \ctxAnaFixedInto{\ctx}{\EMV}{\ECInconType{\ECMV}}{\TMV} - }{MKAInconsistentTypes} - - \judgment{ - \ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'} \\ - \consistent{\TMV}{\TMV'} \\ - \subsumable{\EMV} - }{ - \ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV} - }{MKASubsume} -\end{mathpar} - -\subsection{Marked Expressions} -\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ }{ - \ctxSynTypeM{\ctx}{\ECEHole}{\TUnknown} - }{MSHole} - - \judgment{ - \inCtx{\ctx}{x}{\TMV} - }{ - \ctxSynTypeM{\ctx}{x}{\TMV} - }{MSVar} - - \judgment{ - \notInCtx{\ctx}{x} - }{ - \ctxSynTypeM{\ctx}{\ECUnbound{x}}{\TUnknown} - }{MSUnbound} - - \judgment{ - \ctxSynTypeM{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ECLam{x}{\TMV_1}{\ECMV}}{\TArrow{\TMV_1}{\TMV_2}} - }{MSLam} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV_1} - }{ - \ctxSynTypeM{\ctx}{\ECAp{\ECMV_1}{\ECMV_2}}{\TMV_2} - }{MSAp1} - - % \judgment{ - % \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ - % \notMatchedArrow{\TMV} \\ - % \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} - % }{ - % \ctxSynTypeM{\ctx}{\ECApNonMatched{\ECMV_1}{\ECMV_2}}{\TUnknown} - % }{MSAp2} - - % \judgment{ - % \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ - % \notMatchedArrow{\TMV} \\ - % \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} - % }{ - % \ctxSynTypeM{\ctx}{\ECApNonMatchedAlt{\ECMV}{\ECMV}}{\TUnknown} - % }{MSAp2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV} \\ - \notMatchedArrow{\TMV} \\ - \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} - }{ - \ctxSynTypeM{\ctx}{\ECApSynNonMatchedArrow{\ECMV}{\ECMV}}{\TUnknown} - }{MSAp2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \ctxSynTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV_2}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} - }{MSLet} - - \judgment{ }{ - \ctxSynTypeM{\ctx}{\ECNumMV}{\TNum} - }{MSNum} - - \judgment{ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TNum} \\ - \ctxAnaTypeM{\ctx}{\ECMV_2}{\TNum} - }{ - \ctxSynTypeM{\ctx}{\ECPlus{\ECMV_1}{\ECMV_2}}{\TNum} - }{MSPlus} - - \judgment{ }{ - \ctxSynTypeM{\ctx}{\ECTrue}{\TBool} - }{MSTrue} - - \judgment{ }{ - \ctxSynTypeM{\ctx}{\ECFalse}{\TBool} - }{MSFalse} - - \judgment{ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ - \ctxSynTypeM{\ctx}{\ECMV_3}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TJoin{\TMV_1}{\TMV_2}} - }{MSIf} - - \judgment{ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ - \ctxSynTypeM{\ctx}{\ECMV_3}{\TMV_2} \\ - \inconsistent{\TMV_1}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TUnknown} - }{MSInconsistentBranches} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ECPair{\ECMV_1}{\ECMV_2}}{\TProd{\TMV_1}{\TMV_2}} - }{MSPair} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ECProjL{\ECMV}}{\TMV_1} - }{MSProjL1} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ - \notMatchedProd{\TMV} - }{ - \ctxSynTypeM{\ctx}{\ECProjLSynNonMatchedProd{\ECMV}}{\TUnknown} - }{MSProjL2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ECProjR{\ECMV}}{\TMV_2} - }{MSProjR1} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV}{\TMV} \\ - \notMatchedProd{\TMV} - }{ - \ctxSynTypeM{\ctx}{\ECProjRSynNonMatchedProd{\ECMV}}{\TUnknown} - }{MSProjR2} -\end{mathpar} \\ - -\judgbox{\ctxAnaTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ analyzes against type $\TMV$ -% -\begin{mathpar} - \judgment{ - \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ - \consistent{\TMV}{\TMV_1} \\ - \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TMV_2} - }{ - \ctxAnaTypeM{\ctx}{\ECLam{x}{\TMV}{\ECMV}}{\TMV_3} - }{MALam1} - - \judgment{ - \notMatchedArrow{\TMV_3} \\ - \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV}}{\ECMV}{\TUnknown} - }{ - \ctxAnaTypeM{\ctx}{\ECLamAnaNonMatchedArrow{x}{\TMV}{\ECMV}}{\TMV_3} - }{MALam2} - - \judgment{ - \matchedArrow{\TMV_3}{\TMV_1}{\TMV_2} \\ - \inconsistent{\TMV}{\TMV_1} \\ - \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV}{\TMV_2} - }{ - \ctxAnaTypeM{\ctx}{\ECLamInconAsc{x}{\TMV}{\ECMV}}{\TMV_3} - }{MALam3} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \ctxAnaTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV_2}{\TMV_2} - }{ - \ctxAnaTypeM{\ctx}{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\TMV_2} - }{MALet} - - \judgment{ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TMV} \\ - \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV} - }{ - \ctxAnaTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} - }{MAIf} - - \judgment{ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV_2} - }{ - \ctxAnaTypeM{\ctx}{\ECPair{\ECMV_1}{\ECMV_2}}{\TMV} - }{MAPair1} - - \judgment{ - \notMatchedProd{\TMV} \\ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TUnknown} \\ - \ctxAnaTypeM{\ctx}{\ECMV_2}{\TUnknown} - }{ - \ctxAnaTypeM{\ctx}{\ECPairAnaNonMatchedProd{\ECMV_1}{\ECMV_2}}{\TMV} - }{MAPair2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV}{\TMV'} \\ - \inconsistent{\TMV}{\TMV'} \\ - \subsumable{\ECMV} - }{ - \ctxAnaTypeM{\ctx}{\ECInconType{\ECMV}}{\TMV} - }{MAInconsistentTypes} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV}{\TMV'} \\ - \consistent{\TMV}{\TMV'} \\ - \subsumable{\ECMV} - }{ - \ctxAnaTypeM{\ctx}{\ECMV}{\TMV} - }{MASubsume} -\end{mathpar} \\ - -\judgbox{\subsumable{\ECMV}} $\ECMV$ is subsumable -% -\begin{mathpar} - \judgment{ }{ - \subsumable{\ECEHole} - }{MSuHole} - - \judgment{ }{ - \subsumable{x} - }{MSuVar} - - \judgment{ }{ - \subsumable{\ECUnbound{x}} - }{MSuUnbound} - - \judgment{ }{ - \subsumable{\ECAp{\ECMV_1}{\ECMV_2}} - }{MSuAp} - - \judgment{ }{ - \subsumable{\ECNumMV} - }{MSuNum} - - \judgment{ }{ - \subsumable{\ECPlus{\ECMV_1}{\ECMV_2}} - }{MSuPlus} - - \judgment{ }{ - \subsumable{\ECTrue} - }{MSuTrue} - - \judgment{ }{ - \subsumable{\ECFalse} - }{MSuFalse} - - \judgment{ }{ - \subsumable{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}} - }{MSuInconsistentBranches} - - \judgment{ }{ - \subsumable{\ECProjL{\ECMV}} - }{MSuProjL} - - \judgment{ }{ - \subsumable{\ECProjR{\ECMV}} - }{MSuProjR} -\end{mathpar} \\ - -\judgbox{\markless{\ECMV}} $\ECMV$ has no marks -% -\begin{mathpar} - \judgment{ }{ - \markless{\ECEHole} - }{MLHole} - - \judgment{ }{ - \markless{x} - }{MLVar} - - \judgment{ - \markless{\ECMV} - }{ - \markless{\ECLam{x}{\TMV}{\ECMV}} - }{MLLam} - - \judgment{ - \markless{\ECMV_1} \\ - \markless{\ECMV_2} - }{ - \markless{\ECAp{\ECMV_1}{\ECMV_2}} - }{MLAp} - - \judgment{ }{ - \markless{\ECNumMV} - }{MLNum} - - \judgment{ - \markless{\ECMV_1} \\ - \markless{\ECMV_2} - }{ - \markless{\ECPlus{\ECMV_1}{\ECMV_2}} - }{MLPlus} - - \judgment{ }{ - \markless{\ECTrue} - }{MLTrue} - - \judgment{ }{ - \markless{\ECFalse} - }{MLFalse} - - \judgment{ - \markless{\ECMV_1} \\ - \markless{\ECMV_2} \\ - \markless{\ECMV_3} - }{ - \markless{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}} - }{MLIf} -\end{mathpar} - -\subsection{Mark Erasure} -$\judgbox{\erase{\ECMV}}$ is a metafunction defined as follows: -% -\newcommand{\erasesToRow}[2]{\erase{#1} & = & #2} -\[\begin{array}{rcl} - \erasesToRow{\ECEHole}{\EEHole} \\ - \erasesToRow{x}{x} \\ - \erasesToRow{(\ECLam{x}{\TMV}{\ECMV})}{\ELam{x}{\TMV}{(\erase{\ECMV})}} \\ - \erasesToRow{(\ECAp{\ECMV_1}{\ECMV_2})}{\EAp{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} \\ - \erasesToRow{(\ECLet{x}{\ECMV_1}{\ECMV_2})}{\ELet{x}{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} \\ - \erasesToRow{\ECNumMV}{\ENumMV} \\ - \erasesToRow{(\ECPlus{\ECMV_1}{\ECMV_2})}{\EPlus{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} \\ - \erasesToRow{\ECTrue}{\ETrue} \\ - \erasesToRow{\ECFalse}{\EFalse} \\ - \erasesToRow{(\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3})}{\EIf{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}{(\erase{\ECMV_3})}} \\ - \erasesToRow{\ECUnbound{x}}{x} \\ - \erasesToRow{\ECInconType{\ECMV}}{\erase{\ECMV}} \\ - \erasesToRow{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\EIf{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}{(\erase{\ECMV_3})}} \\ - \erasesToRow{\ECLamInconAsc{x}{\TMV}{\ECMV}}{\ELam{x}{\TMV}{(\erase{\ECMV})}} \\ - \erasesToRow{\ECSynNonMatchedArrow{\ECMV}}{\erase{\ECMV}} \\ - \erasesToRow{\ECSynNonMatchedProd{\ECMV}}{\erase{\ECMV}} \\ - \erasesToRow{\ECAnaNonMatchedArrow{\ECMV}}{\erase{\ECMV}} \\ - \erasesToRow{\ECAnaNonMatchedProd{\ECMV}}{\erase{\ECMV}} \\ -\end{array}\] - -\subsection{Metatheorems} -\begin{theorem}[name=Marking Totality] \ - \begin{enumerate} - \item For all $\ctx$ and $\EMV$, there exist $\ECMV$ and $\TMV$ such that - $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$. - \item For all $\ctx$, $\EMV$, and $\TMV$, there exists $\ECMV$ such that - $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$. - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Marking Well-Formedness] \ - \begin{enumerate} - \item If $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, then $\ctxSynTypeM{\ctx}{\ECMV}{\TMV}$ and - $\erasesTo{\ECMV}{\EMV}$. - \item If $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, then $\ctxAnaTypeM{\ctx}{\ECMV}{\TMV}$ and - $\erasesTo{\ECMV}{\EMV}$. - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Marking of Well-Typed/Ill-Typed Expressions] \ - \begin{enumerate} - \item \begin{enumerate} - \item If $\ctxSynTypeU{\ctx}{\EMV}{\TMV}$ and $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, - then $\markless{\ECMV}$. - \item If $\ctxAnaTypeU{\ctx}{\EMV}{\TMV}$ and $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}$, - then $\markless{\ECMV}$. - \end{enumerate} - - \item \begin{enumerate} - \item If there does not exist $\TMV$ such that $\ctxSynTypeU{\ctx}{\EMV}{\TMV}$, then for - all $\ECMV$ and $\TMV'$ such that $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'}$, it is not - the case that $\markless{\ECMV}$. - \item If there does not exist $\TMV$ such that $\ctxAnaTypeU{\ctx}{\EMV}{\TMV}$, then for - all $\ECMV$ and $\TMV'$ such that $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV'}$, it is not - the case that $\markless{\ECMV}$. - \end{enumerate} - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Marking Unicity] \ - \begin{enumerate} - \item If $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV_1}{\TMV_1}$ and - $\ctxSynFixedInto{\ctx}{\EMV}{\ECMV_2}{\TMV_2}$, then $\ECMV_1 = \ECMV_2$ and $\TMV_1 = - \TMV_2$. - \item If $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV_1}{\TMV}$ and - $\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV_2}{\TMV}$, then $\ECMV_1 = \ECMV_2$. - \end{enumerate} -\end{theorem} - -\subsection{Alternative Conditional Rules} -There are alternative ways to formulate error localization in conditionals. Below, we provide two -alternatives to the rules above. - -\subsubsection{Localize to Second} -In this formulation, we always select the first branch as ``correct'' and localize errors to the -second. \\ - -\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ - \ctxSynTypeU{\ctx}{\EMV_2}{\TMV} \\ - \ctxAnaTypeU{\ctx}{\EMV_3}{\TMV} - }{ - \ctxSynTypeU{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TMV} - }{USIf'} -\end{mathpar} - -\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ - \ctxSynFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV} \\ - \ctxAnaFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV} - }{ - \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} - }{MKSIf'} -\end{mathpar} - -\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV} \\ - \ctxAnaTypeM{\ctx}{\ECMV_3}{\TMV} - }{ - \ctxSynTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} - }{MSIf'} -\end{mathpar} - -\subsubsection{Localize to First} -In this formulation, we always select the second branch as ``correct'' and localize errors to the -first. \\ - -\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxAnaTypeU{\ctx}{\EMV_1}{\TBool} \\ - \ctxSynTypeU{\ctx}{\EMV_3}{\TMV} \\ - \ctxAnaTypeU{\ctx}{\EMV_2}{\TMV} - }{ - \ctxSynTypeU{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\TMV} - }{USIf''} -\end{mathpar} - -\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxAnaFixedInto{\ctx}{\EMV_1}{\ECMV_1}{\TBool} \\ - \ctxSynFixedInto{\ctx}{\EMV_3}{\ECMV_3}{\TMV} \\ - \ctxAnaFixedInto{\ctx}{\EMV_2}{\ECMV_2}{\TMV} - }{ - \ctxSynFixedInto{\ctx}{\EIf{\EMV_1}{\EMV_2}{\EMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} - }{MKSIf''} -\end{mathpar} - -\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxAnaTypeM{\ctx}{\ECMV_1}{\TBool} \\ - \ctxSynTypeM{\ctx}{\ECMV_3}{\TMV} \\ - \ctxAnaTypeM{\ctx}{\ECMV_2}{\TMV} - }{ - \ctxSynTypeM{\ctx}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\TMV} - }{MSIf''} -\end{mathpar} - -\subsection{Patterned Let Expressions} -\subsubsection{Syntax} -\[\begin{array}{rrcl} - \TMName & \TMV & \Coloneqq & \cdots \mid \TUnknownSwitch \\ - \EMName & \EMV & \Coloneqq & \cdots \mid \ELet{\PMV}{\EMV}{\EMV} \\ - \ECMName & \ECMV & \Coloneqq & \cdots \mid \ECLet{\PMV}{\ECMV}{\ECMV} \\ - \PMName & \PMV & \Coloneqq & \PWild \mid \PVar{x} \mid \PPair{\PMV}{\PMV} \mid \PAsc{\PMV}{\TMV} \\ - \PCMName & \PCMV & \Coloneqq & \PCWild \mid \PCVar{x} \mid \PCPair{\PCMV}{\PCMV} \mid \PCAsc{\PCMV}{\TMV} - \mid \PCInconType{\PCMV} \mid \PCAnaNonMatchedProd{\PCMV} -\end{array}\] - -\subsubsection{Unmarked Expressions} -\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxSynPatU{\ctx}{\PMV}{\TMV_p} \\ - \ctxAnaTypeU{\ctx}{\EMV_{1}}{\TMV_p} \\ - \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\\\ - \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ - \ctxSynTypeU{\ctx'}{\EMV_{2}}{\TMV_2} - }{ - \ctxSynTypeU{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\TMV_2} - }{USLetPat} -\end{mathpar} - -\judgbox{\ctxAnaTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ analyzes against type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxSynTypeU{\ctx}{\EMV}{\ctx'} - }{ - \ctxAnaTypeU{\ctx}{\EMV}{\TUnknownSwitch} - }{UASynSwitch} - - \judgment{ - \ctxSynPatU{\ctx}{\PMV}{\TMV_p} \\ - \ctxAnaTypeU{\ctx}{\EMV_{1}}{\TMV_p} \\ - \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\\\ - \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ - \ctxAnaTypeU{\ctx'}{\EMV_{2}}{\TMV_2} - }{ - \ctxAnaTypeU{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\TMV_2} - }{UALetPat} -\end{mathpar} - -\subsubsection{Marking} -\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxSynFixedInto{\ctx}{\PMV}{\PCMV}{\TMV_p} \\ - \ctxAnaFixedInto{\ctx}{\EMV_{1}}{\ECMV_{1}}{\TMV_{p}} \\\\ - \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\ - \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ - \ctxSynFixedInto{\ctx'}{\EMV_{2}}{\ECMV_{2}}{\TMV_2} - }{ - \ctxSynFixedInto{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} - }{ISLetPat} -\end{mathpar} \\ - -\judgbox{\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and analyzes against type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxSynFixedInto{\ctx}{\PMV}{\PCMV}{\TMV_p} \\ - \ctxAnaFixedInto{\ctx}{\EMV_{1}}{\ECMV_{1}}{\TMV_{p}} \\\\ - \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\ - \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ - \ctxAnaFixedInto{\ctx'}{\EMV_{2}}{\ECMV_{2}}{\TMV_2} - }{ - \ctxAnaFixedInto{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} - }{IALetPat} -\end{mathpar} - -\subsubsection{Marked Expressions} -\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxSynPatM{\ctx}{\PCMV}{\TMV_p} \\ - \ctxAnaTypeM{\ctx}{\ECMV_{1}}{\TMV_p} \\ - \ctxSynTypeM{\ctx}{\ECMV_{1}}{\TMV_{1}} \\\\ - \ctxAnaPatM{\ctx}{\PCMV}{\TMV_{1}}{\ctx'} \\ - \ctxSynTypeM{\ctx'}{\ECMV_{2}}{\TMV_2} - }{ - \ctxSynTypeM{\ctx}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} - }{MSLetPat} -\end{mathpar} - -\judgbox{\ctxAnaTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ analyzes against type $\TMV$ -% -\begin{mathpar} - \judgment{ - \ctxSynPatM{\ctx}{\PCMV}{\TMV_p} \\ - \ctxAnaTypeM{\ctx}{\ECMV_{1}}{\TMV_p} \\ - \ctxSynTypeM{\ctx}{\ECMV_{1}}{\TMV_{1}} \\\\ - \ctxAnaPatM{\ctx}{\PCMV}{\TMV_{1}}{\ctx'} \\ - \ctxAnaTypeM{\ctx'}{\ECMV_{2}}{\TMV_2} - }{ - \ctxAnaTypeM{\ctx}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} - }{MALetPat} -\end{mathpar} - -\subsubsection{Unmarked Patterns} -\judgbox{\ensuremath{\ctxSynPatU{\ctx}{\PMV}{\TMV}}} $\PMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ }{ - \ctxSynPatU{\ctx}{\PWild}{\TUnknownSwitch} - }{USPWild} - - \judgment{ }{ - \ctxSynPatU{\ctx}{\PVar{x}}{\TUnknownSwitch} - }{USPVar} - - \judgment{ - \ctxSynPatU{\ctx}{\PMV_1}{\TMV_1} \\ - \ctxSynPatU{\ctx}{\PMV_2}{\TMV_2} - }{ - \ctxSynPatU{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\TProd{\TMV_1}{\TMV_2}} - }{USPPair} - - \judgment{ - \ctxAnaPatU{\ctx}{\PMV}{\TMV}{\ctx'} - }{ - \ctxSynPatU{\ctx}{\PAsc{\PMV}{\TMV}}{\TMV} - }{USPAnn} -\end{mathpar} - -\judgbox{\ensuremath{\ctxAnaPatU{\ctx_1}{\PMV}{\TMV}{\ctx_2}}} $\PMV$ analyzes against type $\TMV$ producing context $\ctx_2$ -% -\begin{mathpar} - \judgment{ }{ - \ctxAnaPatU{\ctx}{\PWild}{\TMV}{\ctx} - }{UAPWild} - - \judgment{ }{ - \ctxAnaPatU{\ctx}{\PVar{x}}{\TMV}{\extendCtx{\ctx}{x}{\TMV}} - }{UAPVar} - - \judgment{ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaPatU{\ctx}{\PMV_1}{\TMV_1}{\ctx_1} \\ - \ctxAnaPatU{\ctx_1}{\PMV_2}{\TMV_2}{\ctx_2} - }{ - \ctxAnaPatU{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\TMV}{\ctx_2} - }{UAPPair} - - \judgment{ - \ctxAnaPatU{\ctx}{\PMV}{\TMV'}{\ctx'} \\ - \consistent{\TMV}{\TMV'} - }{ - \ctxAnaPatU{\ctx}{\PAsc{\PMV}{\TMV'}}{\TMV}{\ctx'} - }{UAPAnn} -\end{mathpar} - -\subsubsection{Pattern Marking} -\judgbox{\ensuremath{\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}}} $\PMV$ is marked into $\PCMV$ and synthesizes $\TMV$ - % -\begin{mathpar} - \judgment{ }{ - \ctxSynFixedIntoPat{\ctx}{\PWild}{\PCWild}{\TUnknownSwitch} - }{ISPWild} - - \judgment{ }{ - \ctxSynFixedIntoPat{\ctx}{\PVar{x}}{\PCVar{x}}{\TUnknownSwitch} - }{ISPVar} - - \judgment{ - \ctxSynFixedIntoPat{\ctx}{\PMV_1}{\PCMV_1}{\TMV_1} \\\\ - \ctxSynFixedIntoPat{\ctx}{\PMV_2}{\PCMV_2}{\TMV_2} - }{ - \ctxSynFixedIntoPat{\ctx}{\EPair{\PMV_1}{\PMV_2}}{\ECPair{\PCMV_1}{\PCMV_2}}{\TProd{\TMV_1}{\TMV_2}} - }{ISPPair} - - \judgment{ - \ctxAnaPatU{\ctx}{\PMV{}}{\TMV}{\ctx'} \\ - \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}{\ctx''} - }{ - \ctxSynFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV}}{\PCAsc{\PCMV}{\TMV}}{\tau} - }{ISPAnn1} - - \judgment{ - \ctxNotAnaPatU{\ctx}{\PMV{}}{\TMV}{\ctx'} \\ - \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TUnknown}{\ctx''} - }{ - \ctxSynFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV}}{\PCAsc{\PCInconType{\PCMV}}{\TMV}}{\TMV} - }{ISPAnn2} -\end{mathpar} - -\judgbox{\ensuremath{\ctxAnaFixedIntoPat{\ctx_1}{\PMV}{\PCMV}{\TMV}{\ctx_2}}} $\PMV$ is marked into $\PCMV$ and analyzes against $\TMV$ producing $\ctx_2$ -% -\begin{mathpar} - \judgment{ }{ - \ctxAnaFixedIntoPat{\ctx}{\PWild}{\PCWild}{\TMV}{\ctx} - }{IAPWild} - - \judgment{ }{ - \ctxAnaFixedIntoPat{\ctx}{\PVar{x}}{\PCVar{x}}{\TMV}{\extendCtx{\ctx}{x}{\TMV}} - }{IAPVar} - - \judgment{ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaFixedIntoPat{\ctx}{\PMV_1}{\PCMV_1}{\TMV_1}{\ctx_1} \\\\ - \ctxAnaFixedIntoPat{\ctx_1}{\PMV_2}{\PCMV_2}{\TMV_2}{\ctx_2} - }{ - \ctxAnaFixedIntoPat{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\PCPair{\PCMV_1}{\PCMV_2}}{\TMV}{\ctx_2} - }{IAPPair1} - - \judgment{ - \notMatchedProd{\TMV} \\ - \ctxAnaFixedIntoPat{\ctx}{\PMV_1}{\PCMV_1}{\TUnknown}{\ctx_1} \\\\ - \ctxAnaFixedIntoPat{\ctx_1}{\PMV_2}{\PCMV_2}{\TUnknown}{\ctx_2} - }{ - \ctxAnaFixedIntoPat{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\PCAnaNonMatchedProd{\PCPair{\PCMV_1}{\PCMV_2}}}{\TMV}{\ctx_2} - }{IAPPair2} - - \judgment{ - \consistent{\TMV}{\TMV'} \\ - \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV'}{\ctx'} - }{ - \ctxAnaFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV'}}{\PCAsc{\PCMV}{\TMV'}}{\TMV}{\ctx'} - }{IAPAnn1} - - \judgment{ - \inconsistent{\TMV}{\TMV'} \\ - \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV'}{\ctx'} - }{ - \ctxAnaFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV'}}{\PCInconType{\PCAsc{\PCMV}{\TMV'}}}{\TMV}{\ctx'} - }{IAPAnn2} -\end{mathpar} - -\subsubsection{Marked Patterns} -\judgbox{\ensuremath{\ctxSynPatM{\ctx}{\PCMV}{\TMV}}} $\PCMV$ synthesizes type $\TMV$ -% -\begin{mathpar} - \judgment{ }{ - \ctxSynPatM{\ctx}{\PCWild}{\TUnknownSwitch} - }{MSPWild} - - \judgment{ }{ - \ctxSynPatM{\ctx}{\PCVar{x}}{\TUnknownSwitch} - }{MSPVar} - - \judgment{ - \ctxSynPatM{\ctx}{\PCMV_1}{\TMV_1} \\ - \ctxSynPatM{\ctx}{\PCMV_2}{\TMV_2} - }{ - \ctxSynPatM{\ctx}{\PCPair{\PCMV_1}{\PCMV_2}}{\TProd{\TMV_1}{\TMV_2}} - }{MSPPair} - - \judgment{ - \ctxAnaPatM{\ctx}{\PCMV}{\TMV}{\ctx'} - }{ - \ctxSynPatM{\ctx}{\PCAsc{\PCMV}{\TMV}}{\TMV} - }{MSPAnn} -\end{mathpar} - -\judgbox{\ensuremath{\ctxAnaPatM{\ctx_1}{\PCMV}{\TMV}{\ctx_2}}} $\PCMV$ analyzes against type $\TMV$ producing context $\ctx_2$ -% -\begin{mathpar} - \judgment{ }{ - \ctxAnaPatM{\ctx}{\PCWild}{\TMV}{\ctx} - }{MAPWild} - - \judgment{ }{ - \ctxAnaPatM{\ctx}{\PCVar{x}}{\TMV}{\extendCtx{\ctx}{x}{\TMV}} - }{MAPVar} - - \judgment{ - \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaPatM{\ctx}{\PCMV_1}{\TMV_1}{\ctx_1} \\\\ - \ctxAnaPatM{\ctx_1}{\PCMV_2}{\TMV_2}{\ctx_2} - }{ - \ctxAnaPatM{\ctx}{\PCPair{\PCMV_1}{\PCMV_2}}{\TMV}{\ctx_2} - }{MAPPair1} - - \judgment{ - \notMatchedProd{\TMV} \\ - \ctxAnaPatM{\ctx}{\PCMV_1}{\TUnknown}{\ctx_1} \\\\ - \ctxAnaPatM{\ctx_1}{\PCMV_2}{\TUnknown}{\ctx_2} - }{ - \ctxAnaPatM{\ctx}{\PCAnaNonMatchedProd{\PCPair{\PCMV_1}{\PCMV_2}}}{\TMV}{\ctx_2} - }{MAPPair2} - - \judgment{ - \consistent{\TMV}{\TMV'} \\ - \ctxAnaPatM{\ctx}{\PCMV}{\TMV'}{\ctx'} - }{ - \ctxAnaPatM{\ctx}{\PCAsc{\PCMV}{\TMV'}}{\TMV}{\ctx'} - }{MAPAnn1} - - \judgment{ - \inconsistent{\TMV}{\TMV'} \\ - \ctxAnaPatM{\ctx}{\PCMV}{\TMV'}{\ctx'} - }{ - \ctxAnaPatM{\ctx}{\PCInconType{\PCAsc{\PCMV}{\TMV'}}}{\TMV}{\ctx'} - }{MAPAnn2} -\end{mathpar} - -\newpage -\section{Untyped Hazelnut} - -\subsection{Syntax} -\[\begin{array}{rrcl} - \ZTMName & \ZTMV & \Coloneqq & \ZTCursor{\TMV} \mid \ZTArrowL{\ZTMV}{\TMV} \mid \ZTArrowR{\TMV}{\ZTMV} \mid \ZTProdL{\ZTMV}{\TMV} \mid \ZTProdR{\TMV}{\ZTMV} \\ - \ZMName & \ZMV & \Coloneqq & \ZCursor{\EMV} \mid \ZLamT{x}{\ZTMV}{\EMV} \mid \ZLamE{x}{\TMV}{\ZMV} \mid \ZApL{\ZMV}{\EMV} \mid \ZApR{\EMV}{\ZMV} \\ - & & \mid & \ZLetL{x}{\ZMV}{\EMV} \mid \ZLetR{x}{\EMV}{\ZMV} \\ - & & \mid & \ZPlusL{\ZMV}{\EMV} \mid \ZPlusR{\EMV}{\ZMV} \\ - & & \mid & \ZIfC{\ZMV}{\EMV}{\EMV} \mid \ZIfL{\EMV}{\ZMV}{\EMV} \mid \ZIfR{\EMV}{\EMV}{\ZMV} \\ - & & \mid & \ZPairL{\ZMV}{\EMV} \mid \ZPairR{\EMV}{\ZMV} \mid \ZProjL{\ZMV} \mid \ZProjR{\ZMV} \\ -\end{array}\] - -\subsection{Cursor Erasure} -\subsubsection{Type Cursor Erasure} -\judgbox{\ensuremath{\cursorErase{\ZTMV}}} is a metafunction defined as follows: -% -\newcommand{\cursorErasesToRow}[2]{\ensuremath{\cursorErase{#1} & = & #2}} -\[\begin{array}{rcl} - \cursorErasesToRow{\ZTCursor{\TMV}}{\TMV} \\ - \cursorErasesToRow{(\ZTArrowL{\ZTMV}{\TMV})}{\TArrow{\cursorErase{\ZTMV}}{\TMV}} \\ - \cursorErasesToRow{(\ZTArrowR{\TMV}{\ZTMV})}{\TArrow{\TMV}{\cursorErase{\ZTMV}}} \\ - \cursorErasesToRow{(\ZTProdL{\ZTMV}{\TMV})}{\TProd{\cursorErase{\ZTMV}}{\TMV}} \\ - \cursorErasesToRow{(\ZTProdR{\TMV}{\ZTMV})}{\TProd{\TMV}{\cursorErase{\ZTMV}}} \\ -\end{array}\] - -\subsubsection{Expression Cursor Erasure} -\judgbox{\ensuremath{\cursorErase{\ZMV}}} is a metafunction defined as follows: -% -\[\begin{array}{rcl} - \cursorErasesToRow{\ZCursor{\EMV}}{\EMV} \\ - \cursorErasesToRow{(\ZLamT{x}{\ZTMV}{\EMV})}{\ELam{x}{\cursorErase{\ZTMV}}{\EMV}} \\ - \cursorErasesToRow{(\ZLamE{x}{\TMV}{\ZMV})}{\ELam{x}{\TMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZApL{\ZMV}{\EMV})}{\EAp{\cursorErase{\ZMV}}{\EMV}} \\ - \cursorErasesToRow{(\ZApR{\EMV}{\ZMV})}{\EAp{\EMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZLetL{x}{\ZMV}{\EMV})}{\ELet{x}{\cursorErase{\ZMV}}{\EMV}} \\ - \cursorErasesToRow{(\ZLetR{x}{\EMV}{\ZMV})}{\ELet{x}{\EMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZPlusL{\ZMV}{\EMV})}{\EPlus{\cursorErase{\ZMV}}{\EMV}} \\ - \cursorErasesToRow{(\ZPlusR{\EMV}{\ZMV})}{\EPlus{\EMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZIfC{\ZMV}{\EMV_1}{\EMV_2})}{\EIf{\cursorErase{\ZMV}}{\EMV_1}{\EMV_2}} \\ - \cursorErasesToRow{(\ZIfL{\EMV_1}{\ZMV}{\EMV_2})}{\EIf{\EMV_1}{\cursorErase{\ZMV}}{\EMV_2}} \\ - \cursorErasesToRow{(\ZIfL{\EMV_1}{\EMV_2}{\ZMV})}{\EIf{\EMV_1}{\EMV_2}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZPairL{\ZMV}{\EMV})}{\EPair{\cursorErase{\ZMV}}{\EMV}} \\ - \cursorErasesToRow{(\ZPairR{\EMV}{\ZMV})}{\EPair{\EMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZProjL{\ZMV})}{\EProjL{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZProjR{\ZMV})}{\EProjR{\cursorErase{\ZMV}}} \\ -\end{array}\] - -\subsection{Action Model} -\[\begin{array}{rrcl} - \AMName & \AMV & \Coloneqq & \AMove{\MMV} \mid \ACon{\SMV} \mid \ADel \\ - \AIMName & \AIMV & \Coloneqq & \AINil \mid \AICons{\AMV}{\AIMV} \\ - \MMName & \MMV & \Coloneqq & \MChild{\MChildNMV} \mid \MParent \\ - \SMName & \SMV & \Coloneqq & \STArrowL \mid \STArrowR \mid \STProdL \mid \STProdR \mid \STNum \mid \STBool \\ - & & \mid & \SVar{x} \mid \SLam{x} \mid \SApL \mid \SApR \\ - & & \mid & \SLetL{x} \mid \SLetR{x} \\ - & & \mid & \SLit{n} \mid \SPlusL \mid \SPlusR \\ - & & \mid & \STrue \mid \SFalse \mid \SIfC \mid \SIfL \mid \SIfR \\ - & & \mid & \SPairL \mid \SPairR \mid \SProjL \mid \SProjR -\end{array}\] - -\subsubsection{Shape Sort} -\judgbox{\ensuremath{\tshape{\SMV}}} $\SMV$ is a shape on types -% -\begin{mathpar} - \judgment{ }{ - \tshape{\STArrowL} - }{ASortArrow1} - - \judgment{ }{ - \tshape{\STArrowR} - }{ASortArrow2} - - \judgment{ }{ - \tshape{\STProdL} - }{ASortProd1} - - \judgment{ }{ - \tshape{\STProdR} - }{ASortProd2} - - \judgment{ }{ - \tshape{\STNum} - }{ASortNum} - - \judgment{ }{ - \tshape{\STBool} - }{ASortBool} -\end{mathpar} - -\judgbox{\ensuremath{\eshape{\SMV}}} $\SMV$ is a shape on expressions -% -\begin{mathpar} - \judgment{ }{ - \eshape{\SVar{x}} - }{ASortVar} - - \judgment{ }{ - \eshape{\SLam{x}} - }{ASortLam} - - \judgment{ }{ - \eshape{\SApL} - }{ASortAp1} - - \judgment{ }{ - \eshape{\SApR} - }{ASortAp2} - - \judgment{ }{ - \eshape{\SLetL{x}} - }{ASortLet1} - - \judgment{ }{ - \eshape{\SLetR{x}} - }{ASortLet2} - - \judgment{ }{ - \eshape{\SLit{n}} - }{ASortLit} - - \judgment{ }{ - \eshape{\SPlusL} - }{ASortPlus1} - - \judgment{ }{ - \eshape{\SPlusR} - }{ASortPlus2} - - \judgment{ }{ - \eshape{\STrue} - }{ASortTrue} - - \judgment{ }{ - \eshape{\SFalse} - }{ASortFalse} - - \judgment{ }{ - \eshape{\SIfC} - }{ASortIf1} - - \judgment{ }{ - \eshape{\SIfL} - }{ASortIf2} - - \judgment{ }{ - \eshape{\SIfR} - }{ASortIf3} - - \judgment{ }{ - \eshape{\SPairL} - }{ASortPairL} - - \judgment{ }{ - \eshape{\SPairR} - }{ASortPairR} - - \judgment{ }{ - \eshape{\SProjL} - }{ASortProjL} - - \judgment{ }{ - \eshape{\SProjR} - }{ASortProjR} -\end{mathpar} - -\subsubsection{Type Actions} -\judgbox{\ensuremath{\AUTAction{\ZTMV}{\ZTMV'}{\AMV}}} - -\paragraph{Movement} -\begin{mathpar} - \judgment{ }{ - \AUTMArrowChildL{\TMV_1}{\TMV_2} - }{ATMArrChild1} - - \judgment{ }{ - \AUTMArrowChildR{\TMV_1}{\TMV_2} - }{ATMArrChild2} - - \judgment{ }{ - \AUTMArrowParentL{\TMV_1}{\TMV_2} - }{ATMArrParent1} - - \judgment{ }{ - \AUTMArrowParentR{\TMV_1}{\TMV_2} - }{ATMArrParent2} - - \judgment{ }{ - \AUTMProdChildL{\TMV_1}{\TMV_2} - }{ATMProdChild1} - - \judgment{ }{ - \AUTMProdChildR{\TMV_1}{\TMV_2} - }{ATMProdChild2} - - \judgment{ }{ - \AUTMProdParentL{\TMV_1}{\TMV_2} - }{ATMProdParent1} - - \judgment{ }{ - \AUTMProdParentR{\TMV_1}{\TMV_2} - }{ATMProdParent2} -\end{mathpar} - -\paragraph{Deletion} -\begin{mathpar} - \judgment{ }{ - \AUTDel{\TMV} - }{ATDel} -\end{mathpar} - -\paragraph{Construction} -\begin{mathpar} - \judgment{ }{ - \AUTConArrowL{\TMV} - }{ATConArrow1} - - \judgment{ }{ - \AUTConArrowR{\TMV} - }{ATConArrow2} - - \judgment{ }{ - \AUTConProdL{\TMV} - }{ATConProd1} - - \judgment{ }{ - \AUTConProdR{\TMV} - }{ATConProd2} - - \judgment{ }{ - \AUTConNum - }{ATConNum} - - \judgment{ }{ - \AUTConBool - }{ATConBool} -\end{mathpar} - -\paragraph{Zipper Cases} -\begin{mathpar} - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} - }{ - \AUTAction{\ZTArrowL{\ZTMV}{\TMV}}{\ZTArrowL{\ZTMV'}{\TMV}}{\AMV} - }{ATZipArr1} - - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} - }{ - \AUTAction{\ZTArrowR{\TMV}{\ZTMV}}{\ZTArrowR{\TMV}{\ZTMV'}}{\AMV} - }{ATZipArr2} - - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} - }{ - \AUTAction{\ZTProdL{\ZTMV}{\TMV}}{\ZTProdL{\ZTMV'}{\TMV}}{\AMV} - }{ATZipProd1} - - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} - }{ - \AUTAction{\ZTProdR{\TMV}{\ZTMV}}{\ZTProdR{\TMV}{\ZTMV'}}{\AMV} - }{ATZipProd2} -\end{mathpar} - -\subsubsection{Expression Movement} -\judgbox{\ensuremath{\AUEMove{\ZMV}{\ZMV'}{\MMV}}} -% -\begin{mathpar} - \judgment{ }{ - \AUEMLamChildT{x}{\TMV}{\EMV} - }{AEMLamChild1} - - \judgment{ }{ - \AUEMLamChildE{x}{\TMV}{\EMV} - }{AEMLamChild2} \\ - - \judgment{ }{ - \AUEMLamParentT{x}{\TMV}{\EMV} - }{AEMLamParent1} - - \judgment{ }{ - \AUEMLamParentE{x}{\TMV}{\EMV} - }{AEMLamParent2} \\ - - \judgment{ }{ - \AUEMApChildL{\EMV_1}{\EMV_2} - }{AEMApChild1} - - \judgment{ }{ - \AUEMApChildR{\EMV_1}{\EMV_2} - }{AEMApChild2} \\ - - \judgment{ }{ - \AUEMApParentL{\EMV_1}{\EMV_2} - }{AEMApParent1} - - \judgment{ }{ - \AUEMApParentR{\EMV_1}{\EMV_2} - }{AEMApParent2} \\ - - \judgment{ }{ - \AUEMLetChildL{x}{\EMV_1}{\EMV_2} - }{AEMLetChild1} - - \judgment{ }{ - \AUEMLetChildR{x}{\EMV_1}{\EMV_2} - }{AEMLetChild2} \\ - - \judgment{ }{ - \AUEMLetParentL{x}{\EMV_1}{\EMV_2} - }{AEMLetParent1} - - \judgment{ }{ - \AUEMLetParentR{x}{\EMV_1}{\EMV_2} - }{AEMLetParent2} \\ - - \judgment{ }{ - \AUEMPlusChildL{\EMV_1}{\EMV_2} - }{AEMPlusChild1} - - \judgment{ }{ - \AUEMPlusChildR{\EMV_1}{\EMV_2} - }{AEMPlusChild2} \\ - - \judgment{ }{ - \AUEMPlusParentL{\EMV_1}{\EMV_2} - }{AEMPlusParent1} - - \judgment{ }{ - \AUEMPlusParentR{\EMV_1}{\EMV_2} - }{AEMPlusParent2} \\ - - \judgment{ }{ - \AUEMIfChildC{\EMV_1}{\EMV_2}{\EMV_3} - }{AEMIfChild1} - - \judgment{ }{ - \AUEMIfChildL{\EMV_1}{\EMV_2}{\EMV_3} - }{AEMIfChild2} - - \judgment{ }{ - \AUEMIfChildR{\EMV_1}{\EMV_2}{\EMV_3} - }{AEMIfChild3} - - \judgment{ }{ - \AUEMIfParentC{\EMV_1}{\EMV_2}{\EMV_3} - }{AEMIfParent1} - - \judgment{ }{ - \AUEMIfParentL{\EMV_1}{\EMV_2}{\EMV_3} - }{AEMIfParent2} - - \judgment{ }{ - \AUEMIfParentR{\EMV_1}{\EMV_2}{\EMV_3} - }{AEMIfParent3} \\ - - \judgment{ }{ - \AUEMPairChildL{\EMV_1}{\EMV_2} - }{AEMPairChild1} - - \judgment{ }{ - \AUEMPairChildR{\EMV_1}{\EMV_2} - }{AEMPairChild2} \\ - - \judgment{ }{ - \AUEMPairParentL{\EMV_1}{\EMV_2} - }{AEMPairParent1} - - \judgment{ }{ - \AUEMPairParentR{\EMV_1}{\EMV_2} - }{AEMPairParent2} - - \judgment{ }{ - \AUEMProjLChild{\EMV_1} - }{AEMProjLChild} - - \judgment{ }{ - \AUEMProjLParent{\EMV_1} - }{AEMProjLParent} - - \judgment{ }{ - \AUEMProjRChild{\EMV_1} - }{AEMProjRChild} - - \judgment{ }{ - \AUEMProjRParent{\EMV_1} - }{AEMProjRParent} -\end{mathpar} - -\subsubsection{Expression Actions} -\judgbox{\ensuremath{\AUEAction{\ZMV}{\ZMV'}{\AMV}}} - -\paragraph{Movement} -\begin{mathpar} - \judgment{ - \AUEMove{\ZMV}{\ZMV'}{\MMV} - }{ - \AUEMove{\ZMV}{\ZMV'}{\MMV} - }{AEMove} -\end{mathpar} - -\paragraph{Deletion} -\begin{mathpar} - \judgment{ }{ - \AUEDel{\EMV} - }{AEDel} -\end{mathpar} - -\paragraph{Construction} -\begin{mathpar} - \judgment{ }{ - \AUEConVar{x} - }{AEConVar} \\ - - \judgment{ }{ - \AUEConLam{x}{\EMV} - }{AEConLam} \\ - - \judgment{ }{ - \AUEConApL{\EMV} - }{AEConAp1} - - \judgment{ }{ - \AUEConApR{\EMV} - }{AEConAp2} \\ - - \judgment{ }{ - \AUEConLetL{x}{\EMV} - }{AEConLet1} - - \judgment{ }{ - \AUEConLetR{x}{\EMV} - }{AEConLet2} \\ - - \judgment{ }{ - \AUEConNum{\ENumMV} - }{AEConNum} - - \judgment{ }{ - \AUEConPlusL{\EMV} - }{AEConPlus1} - - \judgment{ }{ - \AUEConPlusR{\EMV} - }{AEConPlus2} \\ - - \judgment{ }{ - \AUEConTrue - }{AEConTrue} - - \judgment{ }{ - \AUEConFalse - }{AEConFalse} \\ - - \judgment{ }{ - \AUEConIfC{\EMV} - }{AEConIf1} - - \judgment{ }{ - \AUEConIfL{\EMV} - }{AEConIf2} - - \judgment{ }{ - \AUEConIfR{\EMV} - }{AEConIf3} \\ - - \judgment{ }{ - \AUEConPairL{\EMV} - }{AEConPair1} - - \judgment{ }{ - \AUEConPairR{\EMV} - }{AEConPair2} \\ - - \judgment{ }{ - \AUEConProjL{\EMV} - }{AEConProjL} - - \judgment{ }{ - \AUEConProjR{\EMV} - }{AEConProjR} -\end{mathpar} - -\paragraph{Zipper Cases} -\begin{mathpar} - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} - }{ - \AUEAction{\ZLamT{x}{\ZTMV}{\EMV}}{\ZLamT{x}{\ZTMV'}{\EMV}}{\AMV} - }{AEZipLam1} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZLamE{x}{\TMV}{\ZMV}}{\ZLamE{x}{\TMV}{\ZMV'}}{\AMV} - }{AEZipLam2} \\ - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZApL{\ZMV}{\EMV}}{\ZApL{\ZMV'}{\EMV}}{\AMV} - }{AEZipAp1} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZApR{\EMV}{\ZMV}}{\ZApR{\EMV}{\ZMV'}}{\AMV} - }{AEZipAp2} \\ - - \judgment{ - \AUTAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZLetL{x}{\ZMV}{\EMV}}{\ZLetL{x}{\ZMV'}{\EMV}}{\AMV} - }{AEZipLet1} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZLetR{x}{\EMV}{\ZMV}}{\ZLetR{x}{\EMV}{\ZMV'}}{\AMV} - }{AEZipLet2} \\ - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZPlusL{\ZMV}{\EMV}}{\ZPlusL{\ZMV'}{\EMV}}{\AMV} - }{AEZipPlus1} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZPlusR{\EMV}{\ZMV}}{\ZPlusR{\EMV}{\ZMV'}}{\AMV} - }{AEZipPlus2} \\ - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZIfC{\ZMV}{\EMV_1}{\EMV_2}}{\ZIfC{\ZMV'}{\EMV_1}{\EMV_2}}{\AMV} - }{AEZipIf1} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZIfL{\EMV_1}{\ZMV}{\EMV_2}}{\ZIfL{\EMV_1}{\ZMV'}{\EMV_2}}{\AMV} - }{AEZipIf2} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZIfR{\EMV_1}{\EMV_2}{\ZMV}}{\ZIfR{\EMV_1}{\EMV_2}{\ZMV'}}{\AMV} - }{AEZipIf3} \\ - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZPairL{\ZMV}{\EMV}}{\ZPairL{\ZMV'}{\EMV}}{\AMV} - }{AEZipPair1} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZPairR{\EMV}{\ZMV}}{\ZPairR{\EMV}{\ZMV'}}{\AMV} - }{AEZipPair2} \\ - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZProjL{\ZMV}{\EMV}}{\ZProjL{\ZMV'}{\EMV}}{\AMV} - }{AEZipProjL} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} - }{ - \AUEAction{\ZProjR{\EMV}{\ZMV}}{\ZProjR{\EMV}{\ZMV'}}{\AMV} - }{AEZipProjR} -\end{mathpar} - -\subsubsection{Iterated Actions} -\judgbox{\ensuremath{\AUTActionIter{\ZTMV}{\ZTMV'}{\AIMV}}} -% -\begin{mathpar} - \judgment{ }{ - \AUTActionIter{\ZTMV}{\ZTMV}{\AINil} - }{ATIRefl} - - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ - \AUTActionIter{\ZTMV'}{\ZTMV''}{\AIMV} - }{ - \AUTActionIter{\ZTMV}{\ZTMV''}{\AICons{\AMV}{\AIMV}} - }{ATITyp} -\end{mathpar} - -\judgbox{\ensuremath{\AUEActionIter{\ZMV}{\ZMV'}{\AIMV}}} -% -\begin{mathpar} - \judgment{ }{ - \AUEActionIter{\ZMV}{\ZMV}{\AINil} - }{AEIRefl} - - \judgment{ - \AUEAction{\ZMV}{\ZMV'}{\AMV} \\ - \AUEActionIter{\ZMV'}{\ZMV''}{\AIMV} - }{ - \AUEActionIter{\ZMV}{\ZMV''}{\AICons{\AMV}{\AIMV}} - }{AEIExp} -\end{mathpar} - -\judgbox{\ensuremath{\movements{\AIMV}}} -% -\begin{mathpar} - \judgment{ }{ - \movements{\AINil} - }{AMINil} - - \judgment{ - \movements{\AIMV} - }{ - \movements{\AICons{\AMove{\MMV}}{\AIMV}} - }{AMICons} -\end{mathpar} - -\subsubsection{Metatheorems} -\begin{theorem}[name=Sensibility] -\end{theorem} - -\begin{theorem}[name=Movement Erasure Invariance] \ - \begin{enumerate} - \item If $\AUTAction{\ZTMV}{\ZTMV'}{\AMove{\MMV}}$, then $\cursorErase{\ZTMV} = - \cursorErase{\ZTMV'}$. - - \item If $\AUEAction{\ZMV}{\ZMV'}{\AMove{\MMV}}$, then $\cursorErase{\ZMV} = - \cursorErase{\ZMV'}$. - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Reachability] \ - \begin{enumerate} - \item If $\cursorErase{\ZTMV} = \cursorErase{\ZTMV'}$, then there exists $\AIMV$ such that - $\movements{\AIMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV'}{\AIMV}$. - - \item If $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$, then there exists $\AIMV$ such that - $\movements{\AIMV}$ and $\AUEActionIter{\ZMV}{\ZMV'}{\AIMV}$. - \end{enumerate} -\end{theorem} - -\begin{lemma}[name=Reach Up] \ - \begin{enumerate} - \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ - and $\AUTActionIter{\ZTMV}{\ZTCursor{\TMV}}{\AIMV}$. - - \item If $\cursorErase{\ZMV} = \EMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ - and $\AUEActionIter{\ZMV}{\ZTCursor{\EMV}}{\AIMV}$. - \end{enumerate} -\end{lemma} - -\begin{lemma}[name=Reach Down] \ - \begin{enumerate} - \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ - and $\AUTActionIter{\ZTCursor{\TMV}}{\ZTMV}{\AIMV}$. - - \item If $\cursorErase{\ZMV} = \EMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ - and $\AUEActionIter{\ZTCursor{\EMV}}{\ZMV}{\AIMV}$. - \end{enumerate} -\end{lemma} - -\begin{theorem}[name=Constructability] \ - \begin{enumerate} - \item For every $\TMV$, there exists $\AIMV$ such that - $\AUTActionIter{\ZTCursor{\TUnknown}}{\ZTCursor{\TMV}}{\AIMV}$. - - \item For every $\EMV$, there exists $\AIMV$ such that - $\AUEActionIter{\ZCursor{\EEHole}}{\ZCursor{\EMV}}{\AIMV}$. - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Determinism] \ - \begin{enumerate} - \item If $\AUTActionIter{\ZTMV}{\ZTMV'}{\AMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV''}{\AMV}$, then - $\ZTMV' = \ZTMV''$. - - \item If $\AUEActionIter{\ZMV}{\ZMV'}{\AMV}$ and $\AUEActionIter{\ZMV}{\ZMV''}{\AMV}$, then - $\ZMV' = \ZMV''$. - \end{enumerate} -\end{theorem} - -% \begin{theorem}[name=Actionability] \ - % \begin{enumerate} - % \item For every $\TMV$ and $\AMV$, there exists $\ZTMV$ such that - % $\AUTAction{\ZTCursor{\TMV}}{\ZTMV}{\AMV}$. - - % \item For every $\EMV$ and $\AMV$, there exists $\ZMV$ such that - % $\AUEAction{\ZCursor{\EMV}}{\ZMV}{\AMV}$. - % \end{enumerate} -% \end{theorem} - -\newpage -\section{Typed Hazelnut} - -\subsection{Syntax} -Zippered types are the same as in the untyped model. - -\[\begin{array}{rrcl} - \ZMName & \ZMV & \Coloneqq & \ZCursor{\ECMV} \mid \ZLamT{x}{\ZTMV}{\ECMV} \mid \ZLamE{x}{\TMV}{\ZMV} \mid \ZApL{\ZMV}{\ECMV} \mid \ZApR{\ECMV}{\ZMV} \\ - & & \mid & \ZLetL{x}{\ZMV}{\ECMV} \mid \ZLetR{x}{\ECMV}{\ZMV} \\ - & & \mid & \ZPlusL{\ZMV}{\ECMV} \mid \ZPlusR{\ECMV}{\ZMV} \\ - & & \mid & \ZIfC{\ZMV}{\ECMV}{\ECMV} \mid \ZIfL{\ECMV}{\ZMV}{\ECMV} \mid \ZIfR{\ECMV}{\ECMV}{\ZMV} \\ - & & \mid & \ZInconType{\ZMV} \mid \ZInconBrC{\ZMV}{\ECMV}{\ECMV} \mid \ZInconBrL{\ECMV}{\ZMV}{\ECMV} \mid \ZInconBrR{\ECMV}{\ECMV}{\ZMV} \\ -\end{array}\] - -\subsubsection{Well-Formedness} -\judgbox{\ensuremath{\zWellFormed{\ZMV}}} $\ZMV$ is well-formed -% -\begin{mathpar} - \judgment{ }{ - \zWellFormed{\ZCursor{\ECMV}} - }{WFCursor} - - \judgment{ }{ - \zWellFormed{\ZLamT{x}{\ZTMV}{\ECMV}} - }{WFLamT} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZLamE{x}{\TMV}{\ZMV}} - }{WFLamE} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZApL{\ZMV}{\ECMV}} - }{WFApL} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZApR{\ECMV}{\ZMV}} - }{WFApR} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZLetL{x}{\ZMV}{\ECMV}} - }{WFLetL} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZLetR{x}{\ECMV}{\ZMV}} - }{WFLetR} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZPlusL{\ZMV}{\ECMV}} - }{WFPlusL} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZPlusR{\ECMV}{\ZMV}} - }{WFPlusR} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2}} - }{WFIfC} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}} - }{WFIfL} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZIfL{\ZMV}{\ECMV_1}{\ECMV_2}} - }{WFIfC} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZInconBrC{\ZMV}{\ECMV_1}{\ECMV_2}} - }{WFInconsistentBranchesC} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}} - }{WFInconsistentBranchesL} - - \judgment{ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZInconBrL{\ZMV}{\ECMV_1}{\ECMV_2}} - }{WFInconsistentBranchesR} - - \judgment{ - \notEqual{\ZMV}{\ZCursor{\ECMV}} \\ - \zWellFormed{\ZMV} - }{ - \zWellFormed{\ZInconType{\ZMV}} - }{WFInconsistentTypes} -\end{mathpar} - -\subsection{Cursor Erasure} -\subsubsection{Type Cursor Erasure} -Type cursor erasure is the same as in the untyped model. - -\subsubsection{Expression Cursor Erasure} -\judgbox{\ensuremath{\cursorErase{\ZMV}}} is a metafunction defined as follows: -% -\[\begin{array}{rcl} - \cursorErasesToRow{\ZCursor{\ECMV}}{\ECMV} \\ - \cursorErasesToRow{(\ZLamT{x}{\ZTMV}{\ECMV})}{\ECLam{x}{\cursorErase{\ZTMV}}{\ECMV}} \\ - \cursorErasesToRow{(\ZLamE{x}{\TMV}{\ZMV})}{\ECLam{x}{\TMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZApL{\ZMV}{\ECMV})}{\ECAp{\cursorErase{\ZMV}}{\ECMV}} \\ - \cursorErasesToRow{(\ZApR{\ECMV}{\ZMV})}{\ECAp{\ECMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZLetL{x}{\ZMV}{\ECMV})}{\ECLet{x}{\cursorErase{\ZMV}}{\ECMV}} \\ - \cursorErasesToRow{(\ZLetR{x}{\ECMV}{\ZMV})}{\ECLet{x}{\ECMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZPlusL{\ZMV}{\ECMV})}{\ECPlus{\cursorErase{\ZMV}}{\ECMV}} \\ - \cursorErasesToRow{(\ZPlusR{\ECMV}{\ZMV})}{\ECPlus{\ECMV}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{(\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2})}{\ECIf{\cursorErase{\ZMV}}{\ECMV_1}{\ECMV_2}} \\ - \cursorErasesToRow{(\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2})}{\ECIf{\ECMV_1}{\cursorErase{\ZMV}}{\ECMV_2}} \\ - \cursorErasesToRow{(\ZIfL{\ECMV_1}{\ECMV_2}{\ZMV})}{\ECIf{\ECMV_1}{\ECMV_2}{\cursorErase{\ZMV}}} \\ - \cursorErasesToRow{\ZInconType{\ZMV}}{\cursorErase{\ZMV}} \\ - \cursorErasesToRow{\ZInconBrC{\ZMV}{\ECMV_1}{\ECMV_2}}{\ECIf{\cursorErase{\ZMV}}{\ECMV_1}{\ECMV_2}} \\ - \cursorErasesToRow{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}}{\ECIf{\ECMV_1}{\cursorErase{\ZMV}}{\ECMV_2}} \\ - \cursorErasesToRow{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV}}{\ECIf{\ECMV_1}{\ECMV_2}{\cursorErase{\ZMV}}} \\ -\end{array}\] - -\subsection{Action Model} -The action syntax is the same in the untyped model. - -\subsubsection{Shape Sort} -The shape sort judgments are the same as in the untyped model. - -\subsubsection{Type Actions} -Type actions are the same as in the untyped model. - -\subsubsection{Expression Movement} -\judgbox{\ensuremath{\AUEMove{\ZMV}{\ZMV'}{\MMV}}} -% -\begin{mathpar} - \judgment{ }{ - \ASEMLamChildT{x}{\TMV}{\ECMV} - }{AEMLamChild1} - - \judgment{ }{ - \ASEMLamChildE{x}{\TMV}{\ECMV} - }{AEMLamChild2} \\ - - \judgment{ }{ - \ASEMLamParentT{x}{\TMV}{\ECMV} - }{AEMLamParent1} - - \judgment{ }{ - \ASEMLamParentE{x}{\TMV}{\ECMV} - }{AEMLamParent2} -\end{mathpar} - -\begin{mathpar} - \judgment{ }{ - \ASEMApChildL{\ECMV_1}{\ECMV_2} - }{AEMApChild1} - - \judgment{ }{ - \ASEMApChildR{\ECMV_1}{\ECMV_2} - }{AEMApChild2} \\ - - \judgment{ }{ - \ASEMApParentL{\ECMV_1}{\ECMV_2} - }{AEMApParent1} - - \judgment{ }{ - \ASEMApParentR{\ECMV_1}{\ECMV_2} - }{AEMApParent2} -\end{mathpar} - -\begin{mathpar} - \judgment{ }{ - \ASEMLetChildL{x}{\ECMV_1}{\ECMV_2} - }{AEMLetChild1} - - \judgment{ }{ - \ASEMLetChildR{x}{\ECMV_1}{\ECMV_2} - }{AEMLetChild2} \\ - - \judgment{ }{ - \ASEMLetParentL{x}{\ECMV_1}{\ECMV_2} - }{AEMLetParent1} - - \judgment{ }{ - \ASEMLetParentR{x}{\ECMV_1}{\ECMV_2} - }{AEMLetParent2} -\end{mathpar} - -\begin{mathpar} - \judgment{ }{ - \ASEMPlusChildL{\ECMV_1}{\ECMV_2} - }{AEMPlusChild1} - - \judgment{ }{ - \ASEMPlusChildR{\ECMV_1}{\ECMV_2} - }{AEMPlusChild2} \\ - - \judgment{ }{ - \ASEMPlusParentL{\ECMV_1}{\ECMV_2} - }{AEMPlusParent1} - - \judgment{ }{ - \ASEMPlusParentR{\ECMV_1}{\ECMV_2} - }{AEMPlusParent2} -\end{mathpar} - -\begin{mathpar} - \judgment{ }{ - \ASEMIfChildC{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMIfChild1} - - \judgment{ }{ - \ASEMIfChildL{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMIfChild2} - - \judgment{ }{ - \ASEMIfChildR{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMIfChild3} \\ - - \judgment{ }{ - \ASEMIfParentC{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMIfParent1} - - \judgment{ }{ - \ASEMIfParentL{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMIfParent2} - - \judgment{ }{ - \ASEMIfParentR{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMIfParent3} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \ASEMChild{\ZMV}{\ZMV'}{\MChildNMV} - }{ - \ASEMInconTypeChild{\ZMV}{\ZMV'}{\MChildNMV} - }{AEMInconsistentTypesChild} - - \judgment{ - \ASEMParent{\ZMV}{\ZMV'} - }{ - \ASEMInconTypeParent{\ZMV}{\ZMV'} - }{AEMInconsistentTypesParent} -\end{mathpar} - -\begin{mathpar} - \judgment{ }{ - \ASEMInconBrChildC{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMInconsistentBranchesChild1} - - \judgment{ }{ - \ASEMInconBrChildL{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMInconsistentBranchesChild2} - - \judgment{ }{ - \ASEMInconBrChildR{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMInconsistentBranchesChild3} \\ - - \judgment{ }{ - \ASEMInconBrParentC{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMInconsistentBranchesParent1} - - \judgment{ }{ - \ASEMInconBrParentL{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMInconsistentBranchesParent2} - - \judgment{ }{ - \ASEMInconBrParentR{\ECMV_1}{\ECMV_2}{\ECMV_3} - }{AEMInconsistentBranchesParent3} -\end{mathpar} - -\subsubsection{Synthetic Expression Actions} -\judgbox{\ensuremath{\ASAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV}}} - -\paragraph{Movement} -\begin{mathpar} - \judgment{ - \ASEMove{\ZMV}{\ZMV'}{\MMV} - }{ - \ASMove{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV}{\MMV} - }{ASEMove} -\end{mathpar} - -\paragraph{Deletion} -\begin{mathpar} - \judgment{ }{ - \ASEDel{\ctx}{\ECMV}{\TMV} - }{ASEDel} -\end{mathpar} - -\paragraph{Construction} -\begin{mathpar} - \judgment{ - \inCtx{\ctx}{x}{\TMV} - }{ - \ASEConBoundVar{\ctx}{x}{\TMV} - }{ASEConVar} - - \judgment{ - \notInCtx{\ctx}{x} - }{ - \ASEConUnboundVar{\ctx}{x} - }{ASEConUnbound} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\erase{\ECMV}}{\ECMV'}{\TMV'} - }{ - \ASEConLam{\ctx}{\ECMV}{\TMV}{\ECMV'}{\TMV'}{x} - }{ASEConLam} - - \judgment{ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} - }{ - \ASEConApL{\ctx}{\ECMV}{\TMV}{\ECMV}{\TMV_2} - }{ASEConApL1} - - \judgment{ - \notMatchedArrow{\TMV} - }{ - \ASEConApL{\ctx}{\ECMV}{\TMV}{\ECInconType{\ECMV}}{\TUnknown} - }{ASEConApL2} - - \judgment{ - }{ - \ASEConApR{\ctx}{\ECMV}{\TMV}{\ECMV}{\TUnknown} - }{ASEConApR} -\end{mathpar} - -\begin{mathpar} - \judgment{ - }{ - \ASEConLetL{\ctx}{\ECMV}{\TMV}{\ECMV}{x} - }{ASEConLet1} - - \judgment{ - \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\erase{\ECMV}}{\ECMV'}{\TMV'} - }{ - \ASEConLetR{\ctx}{\ECMV}{\TMV}{\ECMV'}{\TMV'}{x} - }{ASEConLet2} -\end{mathpar} - -\begin{mathpar} - \judgment{ }{ - \ASEConNum{\ctx}{\ENumMV} - }{ASEConNum} - - \judgment{ - \consistent{\TMV}{\TNum} - }{ - \ASEConPlusL{\ctx}{\ECMV}{\TMV}{\ECMV} - }{ASEConPlusL1} - - \judgment{ - \inconsistent{\TMV}{\TNum} - }{ - \ASEConPlusL{\ctx}{\ECMV}{\TMV}{\ECInconType{\ECMV}} - }{ASEConPlusL2} \\ - - \judgment{ - \consistent{\TMV}{\TNum} - }{ - \ASEConPlusR{\ctx}{\ECMV}{\TMV}{\ECMV} - }{ASEConPlusR1} - - \judgment{ - \inconsistent{\TMV}{\TNum} - }{ - \ASEConPlusR{\ctx}{\ECMV}{\TMV}{\ECInconType{\ECMV}} - }{ASEConPlusR2} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \consistent{\TMV}{\TBool} - }{ - \ASEConIfC{\ctx}{\ECMV}{\TMV}{\ECMV} - }{ASEConIfC1} - - \judgment{ - \inconsistent{\TMV}{\TBool} - }{ - \ASEConIfC{\ctx}{\ECMV}{\TMV}{\ECInconType{\ECMV}} - }{ASEConIfC2} - - \judgment{ }{ - \ASEConIfL{\ctx}{\ECMV}{\TMV}{\ECMV}{\TMV} - }{ASEConIfL} - - \judgment{ }{ - \ASEConIfR{\ctx}{\ECMV}{\TMV}{\ECMV}{\TMV} - }{ASEConIfR} -\end{mathpar} - -\paragraph{Zipper Cases} -\begin{mathpar} - \judgment{ - \AUTAction{\ZTMV_1}{\ZTMV_1'}{\AMV} \\ - \equal{\cursorErase{\ZTMV_1}}{\cursorErase{\ZTMV_1'}} - }{ - \ASEAction{\ctx}{\ZLamT{x}{\ZTMV_1}{\ECMV}}{\TArrow{\cursorErase{\ZTMV_1}}{\TMV_2}}{\ZLamT{x}{\ZTMV_1'}{\ECMV}}{\TArrow{\cursorErase{\ZTMV_1}}{\TMV_2}}{\AMV} - }{ASEZipLamT1} - - \judgment{ - \AUTAction{\ZTMV_1}{\ZTMV_1'}{\AMV} \\ - \notEqual{\cursorErase{\ZTMV_1}}{\cursorErase{\ZTMV_1'}} \\ - \ctxSynFixedInto{\extendCtx{\ctx}{x}{\cursorErase{\ZTMV_1'}}}{\erase{\ECMV}}{\ECMV'}{\TMV_2'} - }{ - \ASEAction{\ctx}{\ZLamT{x}{\ZTMV_1}{\ECMV}}{\TArrow{\cursorErase{\ZTMV_1}}{\TMV_2}}{\ZLamT{x}{\ZTMV_1'}{\ECMV'}}{\TArrow{\cursorErase{\ZTMV_1'}}{\TMV_2'}}{\AMV} - }{ASEZipLamT2} - - \judgment{ - \ASEAction{\extendCtx{\ctx}{x}{\TMV_1}}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} - }{ - \ASEAction{\ctx}{\ZLamE{x}{\TMV_1}{\ZMV}}{\TArrow{\TMV_1}{\TMV_2}}{\ZLamE{x}{\TMV_1}{\ZMV'}}{\TArrow{\ZTMV_1}{\TMV_2'}}{\AMV} - }{ASEZipLamE} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ - \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ - \ctxAnaType{\ctx}{\ECMV_2}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZApL{\ZMV_1}{\ECMV_2}}{\TMV}{\ZApL{\ZMV_1'}{\ECMV_2}}{\TMV_3}{\AMV} - }{ASEZipApL1} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ - \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ - \ctxNotAnaType{\ctx}{\ECMV_2}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZApL{\ZMV_1}{\ECMV_2}}{\TMV}{\ZApL{\ZMV_1'}{\ECInconType{\ECMV_2}}}{\TMV_3}{\AMV} - }{ASEZipApL2} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\\\ - \notMatchedArrow{\TMV_1'} - }{ - \ASEAction{\ctx}{\ZApL{\ZMV_1}{\ECMV_2}}{\TMV}{\ZApL{\ECInconType{\ZMV_1'}}{\ECMV_2}}{\TUnknown}{\AMV} - }{ASEZipApL3} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ - \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ - \ctxAnaType{\ctx}{\ECMV_2}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZApL{\ECInconType{\ZMV_1}}{\ECMV_2}}{\TUnknown}{\ZApL{\ZMV_1'}{\ECMV_2}}{\TMV_3}{\AMV} - }{ASEZipApL4} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ - \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ - \ctxNotAnaType{\ctx}{\ECMV_2}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZApL{\ECInconType{\ZMV_1}}{\ECMV_2}}{\TUnknown}{\ZApL{\ZMV_1'}{\ECInconType{\ECMV_2}}}{\TMV_3}{\AMV} - }{ASEZipApL5} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ - \notMatchedArrow{\TMV_1'} - }{ - \ASEAction{\ctx}{\ZApL{\ECInconType{\ZMV_1}}{\ECMV_2}}{\TUnknown}{\ZApL{\ECInconType{\ZMV_1'}}{\ECMV_2}}{\TUnknown}{\AMV} - }{ASEZipApL6} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \matchedArrow{\TMV_1}{\TMV_2}{\TMV_3} \\ - \AAEAction{\ctx}{\ZMV_2}{\ZMV_2'}{\TMV_2}{\AMV} - }{ - \ASEAction{\ctx}{\ZApR{\ECMV_1}{\ZMV_2}}{\TMV}{\ZApR{\ECMV_1}{\ZMV_2'}}{\TMV_3}{\AMV} - }{ASEZipApR} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\ - \consistent{\TMV_1}{\TMV_1'} - }{ - \ASEAction{\ctx}{\ZLetL{x}{\ZMV_1}{\ECMV_2}}{\TMV_2}{\ZLetL{x}{\ZMV_1'}{\ECMV_2}}{\TMV_2}{\AMV} - }{ASEZipLetL1} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ - \inconsistent{\TMV_1}{\TMV_1'} \\ - \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TMV_1'}}{\erase{\ECMV_2}}{\ECMV_2'}{\TMV_2'} - }{ - \ASEAction{\ctx}{\ZLetL{x}{\ZMV_1}{\ECMV_2}}{\TMV_2}{\ZLetL{x}{\ZMV_1'}{\ECMV_2'}}{\TMV_2'}{\AMV} - }{ASEZipLetL2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \ctxSynTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\cursorErase{\ZMV_2}}{\TMV_2} \\\\ - \ASEAction{\extendCtx{\ctx}{x}{\TMV_1}}{\ZMV_2}{\TMV_2}{\ZMV_2'}{\TMV_2'}{\AMV} - }{ - \ASEAction{\ctx}{\ZLetR{x}{\ECMV_1}{\ZMV_2}}{\TMV_2}{\ZLetR{x}{\ECMV_1}{\ZMV_2'}}{\TMV_2'}{\AMV} - }{ASEZipLetR} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TNum}{\AMV} - }{ - \ASEAction{\ctx}{\ZPlusL{\ZMV}{\ECMV}}{\TNum}{\ZPlusL{\ZMV'}{\ECMV}}{\TNum}{\AMV} - }{ASEZipPlusL} - - \judgment{ - \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TNum}{\AMV} - }{ - \ASEAction{\ctx}{\ZPlusR{\ECMV}{\ZMV}}{\TNum}{\ZPlusR{\ECMV}{\ZMV'}}{\TNum}{\AMV} - }{ASEZipPlusR} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TBool}{\AMV} - }{ - \ASEAction{\ctx}{\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2}}{\TMV}{\ZIfC{\ZMV'}{\ECMV_1}{\ECMV_2}}{\TMV}{\AMV} - }{ASEZipIfC} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\\\ - \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ - \consistent{\TMV_1'}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZIfL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TJoin{\TMV_1'}{\TMV_2}}{\AMV} - }{ASEZipIfL1} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\\\ - \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ - \inconsistent{\TMV_1'}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZInconBrL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TUnknown}{\AMV} - }{ASEZipIfL2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_2} \\\\ - \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ - \consistent{\TMV_1}{\TMV_2'} - }{ - \ASEAction{\ctx}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TJoin{\TMV_1}{\TMV_2'}}{\AMV} - }{ASEZipIfR1} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_2} \\\\ - \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ - \inconsistent{\TMV_1}{\TMV_2'} - }{ - \ASEAction{\ctx}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TUnknown}{\AMV} - }{ASEZipIfR2} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TBool}{\AMV} - }{ - \ASEAction{\ctx}{\ZInconBrC{\ZMV}{\ECMV_1}{\ECMV_2}}{\TMV}{\ZInconBrC{\ZMV'}{\ECMV_1}{\ECMV_2}}{\TMV}{\AMV} - }{ASEZipInconsistentBranchesC} - - \judgment{ - \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\ - \consistent{\TMV_1'}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZIfL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TJoin{\TMV_1'}{\TMV_2}}{\AMV} - }{ASEZipInconsistentBranchesL1} - - \judgment{ - \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\ - \inconsistent{\TMV_1'}{\TMV_2} - }{ - \ASEAction{\ctx}{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZInconBrL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TUnknown}{\AMV} - }{ASEZipInconsistentBranchesL2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ - \consistent{\TMV_1}{\TMV_2'} - }{ - \ASEAction{\ctx}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZIfL{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TJoin{\TMV_1}{\TMV_2'}}{\AMV} - }{ASEZipInconsistentBranchesR1} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ - \inconsistent{\TMV_1}{\TMV_2'} - }{ - \ASEAction{\ctx}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TUnknown}{\AMV} - }{ASEZipInconsistentBranchesR2} -\end{mathpar} - -\subsubsection{Analytic Expression Actions} -\judgbox{\ensuremath{\AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV'}{\AMV}}} - -\paragraph{Subsumption} -\begin{mathpar} - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ - \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ - \consistent{\TMV}{\TMV''} \\ - \subsumable{\cursorErase{\ZMV}} - }{ - \AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV} - }{AAESubsume1} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ - \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ - \inconsistent{\TMV}{\TMV''} \\ - \subsumable{\cursorErase{\ZMV}} - }{ - \AAAction{\ctx}{\ZMV}{\ZInconType{\ZMV'}}{\TMV}{\AMV} - }{AAESubsume2} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ - \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ - \inconsistent{\TMV}{\TMV''} \\ - \subsumable{\cursorErase{\ZMV}} - }{ - \AAAction{\ctx}{\ZInconType{\ZMV}}{\ZInconType{\ZMV'}}{\TMV}{\AMV} - }{AAEInconsistentTypes1} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ - \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ - \consistent{\TMV}{\TMV''} \\ - \subsumable{\cursorErase{\ZMV}} - }{ - \AAAction{\ctx}{\ZInconType{\ZMV}}{\ZMV'}{\TMV}{\AMV} - }{AAEInconsistentTypes2} -\end{mathpar} - -\paragraph{Movement} -\begin{mathpar} - \judgment{ - \ASEMove{\ZMV}{\ZMV'}{\MMV} - }{ - \AAMove{\ctx}{\ZMV}{\ZMV'}{\TMV}{\MMV} - }{AAEMove} -\end{mathpar} - -\paragraph{Deletion} -\begin{mathpar} - \judgment{ }{ - \AAEDel{\ctx}{\ECMV}{\TMV} - }{AAEDel} -\end{mathpar} - -\paragraph{Construction} -\begin{mathpar} - \judgment{ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV}{\ECMV'}{\TMV_2} - }{ - \AACon{\ctx}{\ZCursor{\ECMV}}{\ZLamT{x}{\ZTCursor{\TMV_1}}{\ECMV'}}{\TMV}{\SLam{x}} - }{AAEConLam1} - - \judgment{ - \notMatchedArrow{\TMV} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\ECMV}{\ECMV'}{\TUnknown} - }{ - \AACon{\ctx}{\ZCursor{\ECMV}}{\ZInconType{\ZLamT{x}{\ZTCursor{\TUnknown}}{\ECMV'}}}{\TMV}{\SLam{x}} - }{AAEConLam2} -\end{mathpar} - -\begin{mathpar} - \judgment{ - }{ - \AACon{\ctx}{\ZCursor{\ECMV}}{\ZLetL{x}{\ECMV}{\ZCursor{\ECEHole}}}{\TMV}{\SLetL{x}} - }{AAEConLetL} - - \judgment{ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\erase{\ECMV}}{\ECMV'}{\TMV} - }{ - \AACon{\ctx}{\ZCursor{\ECMV}}{\ZLetR{x}{\ZCursor{\ECEHole}}{\ECMV'}}{\TMV}{\SLetR{x}} - }{AAEConLetR} -\end{mathpar} - -\begin{mathpar} - \judgment{ }{ - \AACon{\ctx}{\ZCursor{\ECMV}}{\ZIfC{\ZCursor{\ECEHole}}{\ECMV}{\ECEHole}}{\TMV}{\SIfL} - }{AAEConIfL} - - \judgment{ - }{ - \AACon{\ctx}{\ZCursor{\ECMV}}{\ZIfC{\ZCursor{\ECEHole}}{\ECEHole}{\ECMV}}{\TMV}{\SIfR} - }{AAEConIfR} -\end{mathpar} - -\paragraph{Zipper Cases} -\begin{mathpar} - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ - \consistent{\cursorErase{\ZTMV}}{\cursorErase{\ZTMV'}} - }{ - \AAAction{\ctx}{\ZLamT{x}{\ZTMV}{\ECMV}}{\ZLamT{x}{\ZTMV'}{\ECMV}}{\TMV}{\AMV} - }{AAEZipLamT1} - - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ - \inconsistent{\cursorErase{\ZTMV}}{\cursorErase{\ZTMV'}} \\ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\\\ - \consistent{\cursorErase{\ZTMV'}}{\TMV_1} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\cursorErase{\ZTMV'}}}{\erase{\ECMV}}{\ECMV'}{\TMV_2} - }{ - \AAAction{\ctx}{\ZLamT{x}{\ZTMV}{\ECMV}}{\ZLamT{x}{\ZTMV'}{\ECMV'}}{\TMV}{\AMV} - }{AAEZipLamT2} - - \judgment{ - \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ - \inconsistent{\cursorErase{\ZTMV}}{\cursorErase{\ZTMV'}} \\ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\\\ - \inconsistent{\cursorErase{\ZTMV'}}{\TMV_1} \\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\erase{\ECMV}}{\ECMV'}{\TMV_2} - }{ - \AAAction{\ctx}{\ZLamT{x}{\ZTMV}{\ECMV}}{\ZInconType{\ZLamT{x}{\ZTMV'}{\ECMV'}}}{\TMV}{\AMV} - }{AAEZipLamT3} - - \judgment{ - \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ - \AAAction{\extendCtx{\ctx}{x}{\TMV_3}}{\ZMV}{\ZMV'}{\TMV_2}{\AMV} - }{ - \AAAction{\ctx}{\ZLamE{x}{\TMV_3}{\ZMV}}{\ZLamE{x}{\TMV_3}{\ZMV'}}{\TMV}{\AMV} - }{AAEZipLamE} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ - \consistent{\TMV_1}{\TMV_1'} - }{ - \AAAction{\ctx}{\ZLetL{x}{\ZMV}{\ECMV}}{\ZLetL{x}{\ZMV'}{\ECMV}}{\TMV}{\AMV} - }{AAEZipLetL1} - - \judgment{ - \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ - \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\\\ - \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1'}}{\erase{\ECMV}}{\ECMV'}{\TMV} - }{ - \AAAction{\ctx}{\ZLetL{x}{\ZMV}{\ECMV}}{\ZLetL{x}{\ZMV'}{\ECMV'}}{\TMV}{\AMV} - }{AAEZipLetL2} - - \judgment{ - \ctxSynTypeM{\ctx}{\ECMV}{\TMV'} \\ - \AAAction{\extendCtx{\ctx}{x}{\TMV'}}{\ZMV}{\ZMV'}{\TMV}{\AMV} - }{ - \AAAction{\ctx}{\ZLetR{x}{\ECMV}{\ZMV}}{\ZLetL{x}{\ECMV}{\ZMV'}}{\TMV}{\AMV} - }{AAEZipLetR} -\end{mathpar} - -\begin{mathpar} - \judgment{ - \AAAction{\ctx}{\ZMV}{\ZMV'}{\TBool}{\AMV} - }{ - \AAAction{\ctx}{\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2}}{\ZIfC{\ZMV'}{\ECMV_1}{\ECMV_2}}{\TMV}{\AMV} - }{AAEZipIfC} - - \judgment{ - \AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV} - }{ - \AAAction{\ctx}{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}}{\ZIfL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TMV}{\AMV} - }{AAEZipIfL} - - \judgment{ - \AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV} - }{ - \AAAction{\ctx}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV}}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TMV}{\AMV} - }{AAEZipIfR} -\end{mathpar} - -\subsubsection{Iterated Actions} -The iterated type action and movements judgments are the same as in the untyped model. \\ - -\judgbox{\ensuremath{\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AIMV}}} -% -\begin{mathpar} - \judgment{ }{ - \ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV}{\TMV}{\AINil} - }{ASEIRefl} - - \judgment{ - \ASEAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV} \\ - \ASEActionIter{\ctx}{\ZMV'}{\TMV'}{\ZMV''}{\TMV''}{\AIMV} - }{ - \ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV''}{\TMV''}{\AICons{\AMV}{\AIMV}} - }{ASEIExp} -\end{mathpar} - -\judgbox{\ensuremath{\AAEActionIter{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AIMV}}} -% -\begin{mathpar} - \judgment{ }{ - \AAEActionIter{\ctx}{\ZMV}{\ZMV}{\TMV}{\AINil} - }{AAEIRefl} - - \judgment{ - \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TMV'}{\AMV} \\ - \AAEActionIter{\ctx}{\ZMV'}{\ZMV''}{\TMV''}{\AIMV} - }{ - \AAEActionIter{\ctx}{\ZMV}{\ZMV''}{\TMV''}{\AICons{\AMV}{\AIMV}} - }{AAEIExp} -\end{mathpar} - -\subsubsection{Metatheorems} -\begin{theorem}[name=Sensibility] \ - \begin{enumerate} - \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\ASEAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV}$, then $\zWellFormed{\ZMV'}$ and - $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV'}}{\TMV'}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\AAEAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV}$, then $\zWellFormed{\ZMV'}$ and - $\ctxAnaType{\ctx}{\cursorErase{\ZMV'}}{\TMV}$. - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Movement Erasure Invariance] \ - \begin{enumerate} - \item If $\AUTAction{\ZTMV}{\ZTMV'}{\AMove{\MMV}}$, then $\cursorErase{\ZTMV} = - \cursorErase{\ZTMV'}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\ASEAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMove{\MMV}}$, then $\zWellFormed{\ZMV'}$ and - $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$ and $\equal{\TMV}{\TMV'}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\AAEAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMove{\MMV}}$, then $\zWellFormed{\ZMV'}$ and - $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$. - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Reachability] \ - \begin{enumerate} - \item If $\cursorErase{\ZTMV} = \cursorErase{\ZTMV'}$, then there exists $\AIMV$ such that - $\movements{\AIMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV'}{\AIMV}$. - - \item If $\zWellFormed{\ZMV}$ and $\zWellFormed{\ZMV'}$ and - $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$, - then there exists $\AIMV$ such that $\movements{\AIMV}$ and - $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV}{\AIMV}$. - - \item If $\zWellFormed{\ZMV}$ and $\zWellFormed{\ZMV'}$ and - $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$, - then there exists $\AIMV$ such that $\movements{\AIMV}$ and - $\AAEActionIter{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AIMV}$. - \end{enumerate} -\end{theorem} - -\begin{lemma}[name=Reach Up] \ - \begin{enumerate} - \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ - and $\AUTActionIter{\ZTMV}{\ZTCursor{\TMV}}{\AIMV}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and - $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZTCursor{\ECMV}}{\TMV}{\AIMV}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and - $\AAEActionIter{\ctx}{\ZMV}{\ZTCursor{\ECMV}}{\TMV}{\AIMV}$. - \end{enumerate} -\end{lemma} - -\begin{lemma}[name=Reach Down] \ - \begin{enumerate} - \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ - and $\AUTActionIter{\ZTCursor{\TMV}}{\ZTMV}{\AIMV}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and - $\ASEActionIter{\ctx}{\ZTCursor{\ECMV}}{\TMV}{\ZMV}{\TMV}{\AIMV}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and - $\AAEActionIter{\ctx}{\ZTCursor{\ECMV}}{\ZMV}{\TMV}{\AIMV}$. - \end{enumerate} -\end{lemma} - -\begin{theorem}[name=Constructability] \ - \begin{enumerate} - \item For every $\TMV$, there exists $\AIMV$ such that - $\AUTActionIter{\ZTCursor{\TUnknown}}{\ZTCursor{\TMV}}{\AIMV}$. - - \item If $\ctxSynTypeM{\ctx}{\ECMV}{\TMV}$, then there exists $\AIMV$ such that - $\ASEActionIter{\ctx}{\ZCursor{\EEHole}}{\TUnknown}{\ZCursor{\ECMV}}{\TMV}{\AIMV}$. - - \item If $\ctxAnaType{\ctx}{\ECMV}{\TMV}$, then there exists $\AIMV$ such that - $\AAEActionIter{\ctx}{\ZCursor{\EEHole}}{\ZCursor{\ECMV}}{\TMV}{\AIMV}$. - \end{enumerate} -\end{theorem} - -\begin{theorem}[name=Determinism] \ - \begin{enumerate} - \item If $\AUTActionIter{\ZTMV}{\ZTMV'}{\AMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV''}{\AMV}$, then - $\ZTMV' = \ZTMV''$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV}$ and - $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV''}{\TMV''}{\AMV}$, then $\ZMV' = \ZMV''$ and - $\equal{\TMV'}{\TMV''}$. - - \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and - $\AAEActionIter{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV}$ and - $\AAEActionIter{\ctx}{\ZMV}{\ZMV''}{\TMV}{\AMV}$, then $\ZMV' = \ZMV''$. - \end{enumerate} -\end{theorem} diff --git a/supplement/patterned.tex b/supplement/patterned.tex new file mode 100644 index 0000000..0fd3481 --- /dev/null +++ b/supplement/patterned.tex @@ -0,0 +1,500 @@ +\documentclass[supplement.tex]{subfiles} + +\begin{document} + +\section{Extension: patterned let expressions} +\label{sec:patterned} + +\subsection{Syntax} +\label{sec:patterned-syntax} +\[\begin{array}{rrcl} + \TMName & \TMV & \Coloneqq & \cdots \mid \TUnknownSwitch \\ + \EMName & \EMV & \Coloneqq & \cdots \mid \ELet{\PMV}{\EMV}{\EMV} \\ + \ECMName & \ECMV & \Coloneqq & \cdots \mid \ECLet{\PMV}{\ECMV}{\ECMV} \\ + \PMName & \PMV & \Coloneqq & \PWild \mid \PVar{x} \mid \PPair{\PMV}{\PMV} \mid \PAsc{\PMV}{\TMV} \\ + \PCMName & \PCMV & \Coloneqq & \PCWild \mid \PCVar{x} \mid \PCPair{\PCMV}{\PCMV} \mid \PCAsc{\PCMV}{\TMV} \\ + & & \mid & \PCInconType{\PCMV} \mid \PCPairAnaNonMatchedProd{\PCMV}{\PCMV} +\end{array}\] + +\subsection{Types} +\label{sec:patterned-types} +\judgbox{\ensuremath{\consistent{\TMV_1}{\TMV_2}}} $\TMV_1$ is consistent with $\TMV_2$ +% +\begin{mathpar} + \inferrule[TCUnknownSwitch1]{ }{ + \consistent{\TUnknownSwitch}{\TMV} + } + + \inferrule[TCUnknownSwitch2]{ }{ + \consistent{\TMV}{\TUnknownSwitch} + } +\end{mathpar} + +\judgbox{\ensuremath{\matchedArrow{\TMV}{\TMV_1}{\TMV_2}}} $\TMV$ has matched arrow type $\TArrow{\TMV_1}{\TMV_2}$ +% +\begin{mathpar} + \inferrule[TMAUnknownSwitch]{ }{ + \matchedArrow{\TUnknownSwitch}{\TUnknownSwitch}{\TUnknownSwitch} + } +\end{mathpar} + +\judgbox{\ensuremath{\matchedProd{\TMV}{\TMV_1}{\TMV_2}}} $\TMV$ has matched binary product type $\TProd{\TMV_1}{\TMV_2}$ +% +\begin{mathpar} + \inferrule[TMPUnknownSwitch]{ }{ + \matchedProd{\TUnknownSwitch}{\TUnknownSwitch}{\TUnknownSwitch} + } +\end{mathpar} + +\judgbox{\ensuremath{\TMeet{\TMV_1}{\TMV_2}}} is a \emph{partial} metafunction defined as follows: +% +\newcommand{\meetsToRow}[3]{\ensuremath{\TMeet{#1}{#2} & = & #3}} +\[\begin{array}{rcl} + & \vdots & \\ + \meetsToRow{\TUnknownSwitch}{\TMV}{\TUnknownSwitch} \\ + \meetsToRow{\TMV}{\TUnknownSwitch}{\TUnknownSwitch} +\end{array}\] + +\subsection{Unmarked patterns} +\label{sec:patterned-unmarked-patterns} +\judgbox{\ensuremath{\ctxSynPatU{\ctx}{\PMV}{\TMV}}} $\PMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[USPWild]{ }{ + \ctxSynPatU{\ctx}{\PWild}{\TUnknownSwitch} + } + + \inferrule[USPVar]{ }{ + \ctxSynPatU{\ctx}{\PVar{x}}{\TUnknownSwitch} + } + + \inferrule[USPPair]{ + \ctxSynPatU{\ctx}{\PMV_1}{\TMV_1} \\ + \ctxSynPatU{\ctx}{\PMV_2}{\TMV_2} + }{ + \ctxSynPatU{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\TProd{\TMV_1}{\TMV_2}} + } + + \inferrule[USPAnn]{ + \ctxAnaPatU{\ctx}{\PMV}{\TMV}{\ctx'} + }{ + \ctxSynPatU{\ctx}{\PAsc{\PMV}{\TMV}}{\TMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\ctxAnaPatU{\ctx_1}{\PMV}{\TMV}{\ctx_2}}} $\PMV$ analyzes against type $\TMV$ producing context $\ctx_2$ +% +\begin{mathpar} + \inferrule[UAPWild]{ }{ + \ctxAnaPatU{\ctx}{\PWild}{\TMV}{\ctx} + } + + \inferrule[UAPVar]{ }{ + \ctxAnaPatU{\ctx}{\PVar{x}}{\TMV}{\extendCtx{\ctx}{x}{\TMV}} + } + + \inferrule[UAPPair]{ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaPatU{\ctx}{\PMV_1}{\TMV_1}{\ctx_1} \\ + \ctxAnaPatU{\ctx_1}{\PMV_2}{\TMV_2}{\ctx_2} + }{ + \ctxAnaPatU{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\TMV}{\ctx_2} + } + + \inferrule[UAPAnn]{ + \ctxAnaPatU{\ctx}{\PMV}{\TMV'}{\ctx'} \\ + \consistent{\TMV}{\TMV'} + }{ + \ctxAnaPatU{\ctx}{\PAsc{\PMV}{\TMV'}}{\TMV}{\ctx'} + } +\end{mathpar} + +\subsection{Pattern marking} +\label{sec:patterned-pattern-marking} +\judgbox{\ensuremath{\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}}} $\PMV$ is marked into $\PCMV$ and synthesizes $\TMV$ + % +\begin{mathpar} + \inferrule[ISPWild]{ }{ + \ctxSynFixedIntoPat{\ctx}{\PWild}{\PCWild}{\TUnknownSwitch} + } + + \inferrule[ISPVar]{ }{ + \ctxSynFixedIntoPat{\ctx}{\PVar{x}}{\PCVar{x}}{\TUnknownSwitch} + } + + \inferrule[ISPPair]{ + \ctxSynFixedIntoPat{\ctx}{\PMV_1}{\PCMV_1}{\TMV_1} \\\\ + \ctxSynFixedIntoPat{\ctx}{\PMV_2}{\PCMV_2}{\TMV_2} + }{ + \ctxSynFixedIntoPat{\ctx}{\EPair{\PMV_1}{\PMV_2}}{\ECPair{\PCMV_1}{\PCMV_2}}{\TProd{\TMV_1}{\TMV_2}} + } + + \inferrule[ISPAnn1]{ + \ctxAnaPatU{\ctx}{\PMV{}}{\TMV}{\ctx'} \\ + \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}{\ctx''} + }{ + \ctxSynFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV}}{\PCAsc{\PCMV}{\TMV}}{\tau} + } + + \inferrule[ISPAnn2]{ + \ctxNotAnaPatU{\ctx}{\PMV{}}{\TMV}{\ctx'} \\ + \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TUnknown}{\ctx''} + }{ + \ctxSynFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV}}{\PCAsc{\PCInconType{\PCMV}}{\TMV}}{\TMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\ctxAnaFixedIntoPat{\ctx_1}{\PMV}{\PCMV}{\TMV}{\ctx_2}}} $\PMV$ is marked into $\PCMV$ and analyzes against $\TMV$ producing $\ctx_2$ +% +\begin{mathpar} + \inferrule[IAPWild]{ }{ + \ctxAnaFixedIntoPat{\ctx}{\PWild}{\PCWild}{\TMV}{\ctx} + } + + \inferrule[IAPVar]{ }{ + \ctxAnaFixedIntoPat{\ctx}{\PVar{x}}{\PCVar{x}}{\TMV}{\extendCtx{\ctx}{x}{\TMV}} + } + + \inferrule[IAPPair1]{ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaFixedIntoPat{\ctx}{\PMV_1}{\PCMV_1}{\TMV_1}{\ctx_1} \\\\ + \ctxAnaFixedIntoPat{\ctx_1}{\PMV_2}{\PCMV_2}{\TMV_2}{\ctx_2} + }{ + \ctxAnaFixedIntoPat{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\PCPair{\PCMV_1}{\PCMV_2}}{\TMV}{\ctx_2} + } + + \inferrule[IAPPair2]{ + \notMatchedProd{\TMV} \\ + \ctxAnaFixedIntoPat{\ctx}{\PMV_1}{\PCMV_1}{\TUnknown}{\ctx_1} \\\\ + \ctxAnaFixedIntoPat{\ctx_1}{\PMV_2}{\PCMV_2}{\TUnknown}{\ctx_2} + }{ + \ctxAnaFixedIntoPat{\ctx}{\PPair{\PMV_1}{\PMV_2}}{\PCPairAnaNonMatchedProd{\PCMV_1}{\PCMV_2}}{\TMV}{\ctx_2} + } + + \inferrule[IAPAnn1]{ + \consistent{\TMV}{\TMV'} \\ + \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV'}{\ctx'} + }{ + \ctxAnaFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV'}}{\PCAsc{\PCMV}{\TMV'}}{\TMV}{\ctx'} + } + + \inferrule[IAPAnn2]{ + \inconsistent{\TMV}{\TMV'} \\ + \ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV'}{\ctx'} + }{ + \ctxAnaFixedIntoPat{\ctx}{\PAsc{\PMV}{\TMV'}}{\PCInconType{\PCAsc{\PCMV}{\TMV'}}}{\TMV}{\ctx'} + } +\end{mathpar} + +\subsection{Marked patterns} +\label{sec:patterned-marked-patterns} +\judgbox{\ensuremath{\ctxSynPatM{\ctx}{\PCMV}{\TMV}}} $\PCMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MSPWild]{ }{ + \ctxSynPatM{\ctx}{\PCWild}{\TUnknownSwitch} + } + + \inferrule[MSPVar]{ }{ + \ctxSynPatM{\ctx}{\PCVar{x}}{\TUnknownSwitch} + } + + \inferrule[MSPPair]{ + \ctxSynPatM{\ctx}{\PCMV_1}{\TMV_1} \\ + \ctxSynPatM{\ctx}{\PCMV_2}{\TMV_2} + }{ + \ctxSynPatM{\ctx}{\PCPair{\PCMV_1}{\PCMV_2}}{\TProd{\TMV_1}{\TMV_2}} + } + + \inferrule[MSPAnn]{ + \ctxAnaPatM{\ctx}{\PCMV}{\TMV}{\ctx'} + }{ + \ctxSynPatM{\ctx}{\PCAsc{\PCMV}{\TMV}}{\TMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\ctxAnaPatM{\ctx_1}{\PCMV}{\TMV}{\ctx_2}}} $\PCMV$ analyzes against type $\TMV$ producing context $\ctx_2$ +% +\begin{mathpar} + \inferrule[MAPWild]{ }{ + \ctxAnaPatM{\ctx}{\PCWild}{\TMV}{\ctx} + } + + \inferrule[MAPVar]{ }{ + \ctxAnaPatM{\ctx}{\PCVar{x}}{\TMV}{\extendCtx{\ctx}{x}{\TMV}} + } + + \inferrule[MAPPair1]{ + \matchedProd{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaPatM{\ctx}{\PCMV_1}{\TMV_1}{\ctx_1} \\\\ + \ctxAnaPatM{\ctx_1}{\PCMV_2}{\TMV_2}{\ctx_2} + }{ + \ctxAnaPatM{\ctx}{\PCPair{\PCMV_1}{\PCMV_2}}{\TMV}{\ctx_2} + } + + \inferrule[MAPPair2]{ + \notMatchedProd{\TMV} \\ + \ctxAnaPatM{\ctx}{\PCMV_1}{\TUnknown}{\ctx_1} \\\\ + \ctxAnaPatM{\ctx_1}{\PCMV_2}{\TUnknown}{\ctx_2} + }{ + \ctxAnaPatM{\ctx}{\PCPairAnaNonMatchedProd{\PCMV_1}{\PCMV_2}}{\TMV}{\ctx_2} + } + + \inferrule[MAPAnn1]{ + \consistent{\TMV}{\TMV'} \\ + \ctxAnaPatM{\ctx}{\PCMV}{\TMV'}{\ctx'} + }{ + \ctxAnaPatM{\ctx}{\PCAsc{\PCMV}{\TMV'}}{\TMV}{\ctx'} + } + + \inferrule[MAPAnn2]{ + \inconsistent{\TMV}{\TMV'} \\ + \ctxAnaPatM{\ctx}{\PCMV}{\TMV'}{\ctx'} + }{ + \ctxAnaPatM{\ctx}{\PCInconType{\PCAsc{\PCMV}{\TMV'}}}{\TMV}{\ctx'} + } +\end{mathpar} + +\judgbox{\markless{\PCMV}} $\PCMV$ has no marks +% +\begin{mathpar} + \inferrule[MLPWild]{ }{ + \markless{\PCWild} + } + + \inferrule[MLPVar]{ }{ + \markless{\PCVar{x}} + } + + \inferrule[MLPPair]{ + \markless{\PCMV_1} \\ + \markless{\PCMV_2} + }{ + \markless{\PCPair{\PCMV_1}{\PCMV_2}} + } + + \inferrule[MLPAnn]{ + \markless{\PCMV} + }{ + \markless{\PCAsc{\PCMV}{\TMV}} + } +\end{mathpar} + +\subsection{Pattern mark erasure} +\label{sec:patterned-pattern-mark-erasure} +$\judgbox{\erase{\PCMV}}$ is a metafunction defined as follows: +% +\newcommand{\erasesToRow}[2]{\erase{#1} & = & #2} +\[\begin{array}{rcl} + & \vdots & \\ + \erasesToRow{\PCWild}{\PWild} \\ + \erasesToRow{\PCVar{x}}{\PVar{x}} \\ + \erasesToRow{\PCPair{\PCMV_1}{\PCMV_2}}{\PPair{\erase{\PCMV_1}}{\erase{\PCMV_2}}} \\ + \erasesToRow{\PCPairAnaNonMatchedProd{\PCMV_1}{\PCMV_2}}{\PPair{\erase{\PCMV_1}}{\erase{\PCMV_2}}} \\ + \erasesToRow{(\PCAsc{\PCMV}{\TMV})}{\PAsc{(\erase{\PCMV})}{\TMV}} \\ + \erasesToRow{\PCInconType{\PCAsc{\PCMV}{\TMV}}}{\PAsc{(\erase{\PCMV})}{\TMV}} +\end{array}\] + +\subsection{Unmarked expressions} +\label{sec:patterned-unmarked-expressions} +\judgbox{\ctxSynTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[USLetPat]{ + \ctxSynPatU{\ctx}{\PMV}{\TMV_p} \\ + \ctxAnaTypeU{\ctx}{\EMV_{1}}{\TMV_p} \\ + \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\\\ + \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ + \ctxSynTypeU{\ctx'}{\EMV_{2}}{\TMV_2} + }{ + \ctxSynTypeU{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\TMV_2} + } +\end{mathpar} + +\judgbox{\ctxAnaTypeU{\ctx}{\EMV}{\TMV}} $\EMV$ analyzes against type $\TMV$ +% +\begin{mathpar} + \inferrule[UASynSwitch]{ + \ctxSynTypeU{\ctx}{\EMV}{\TMV} + }{ + \ctxAnaTypeU{\ctx}{\EMV}{\TUnknownSwitch} + } + + \inferrule[UALetPat]{ + \ctxSynPatU{\ctx}{\PMV}{\TMV_p} \\ + \ctxAnaTypeU{\ctx}{\EMV_{1}}{\TMV_p} \\ + \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\\\ + \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ + \ctxAnaTypeU{\ctx'}{\EMV_{2}}{\TMV_2} + }{ + \ctxAnaTypeU{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\TMV_2} + } +\end{mathpar} + +\judgbox{\subsumable{\EMV}} $\EMV$ is subsumable +% +\begin{mathpar} + \inferrule[USuLetPat]{ }{ + \subsumable{\ELet{\PMV}{\EMV_1}{\EMV_2}} + } +\end{mathpar} + +\subsection{Marking} +\label{sec:patterned-marking} +\judgbox{\ctxSynFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[ISLetPat]{ + \ctxSynFixedInto{\ctx}{\PMV}{\PCMV}{\TMV_p} \\ + \ctxAnaFixedInto{\ctx}{\EMV_{1}}{\ECMV_{1}}{\TMV_{p}} \\\\ + \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\ + \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ + \ctxSynFixedInto{\ctx'}{\EMV_{2}}{\ECMV_{2}}{\TMV_2} + }{ + \ctxSynFixedInto{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} + } +\end{mathpar} \\ + +\judgbox{\ctxAnaFixedInto{\ctx}{\EMV}{\ECMV}{\TMV}} $\EMV$ is marked into $\ECMV$ and analyzes against type $\TMV$ +% +\begin{mathpar} + \inferrule[IALetPat]{ + \ctxSynFixedInto{\ctx}{\PMV}{\PCMV}{\TMV_p} \\ + \ctxAnaFixedInto{\ctx}{\EMV_{1}}{\ECMV_{1}}{\TMV_{p}} \\\\ + \ctxSynTypeU{\ctx}{\EMV_{1}}{\TMV_{1}} \\ + \ctxAnaPatU{\ctx}{\PMV}{\TMV_{1}}{\ctx'} \\ + \ctxAnaFixedInto{\ctx'}{\EMV_{2}}{\ECMV_{2}}{\TMV_2} + }{ + \ctxAnaFixedInto{\ctx}{\ELet{\PMV}{\EMV_{1}}{\EMV_{2}}}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} + } +\end{mathpar} + +\subsection{Marked expressions} +\label{sec:patterned-marked-expressions} +\judgbox{\ctxSynTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \inferrule[MSLetPat]{ + \ctxSynPatM{\ctx}{\PCMV}{\TMV_p} \\ + \ctxAnaTypeM{\ctx}{\ECMV_{1}}{\TMV_p} \\ + \ctxSynTypeM{\ctx}{\ECMV_{1}}{\TMV_{1}} \\\\ + \ctxAnaPatM{\ctx}{\PCMV}{\TMV_{1}}{\ctx'} \\ + \ctxSynTypeM{\ctx'}{\ECMV_{2}}{\TMV_2} + }{ + \ctxSynTypeM{\ctx}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} + } +\end{mathpar} + +\judgbox{\ctxAnaTypeM{\ctx}{\ECMV}{\TMV}} $\ECMV$ analyzes against type $\TMV$ +% +\begin{mathpar} + \inferrule[MALetPat]{ + \ctxSynPatM{\ctx}{\PCMV}{\TMV_p} \\ + \ctxAnaTypeM{\ctx}{\ECMV_{1}}{\TMV_p} \\ + \ctxSynTypeM{\ctx}{\ECMV_{1}}{\TMV_{1}} \\\\ + \ctxAnaPatM{\ctx}{\PCMV}{\TMV_{1}}{\ctx'} \\ + \ctxAnaTypeM{\ctx'}{\ECMV_{2}}{\TMV_2} + }{ + \ctxAnaTypeM{\ctx}{\ELet{\PCMV}{\ECMV_{1}}{\ECMV_{2}}}{\TMV_2} + } +\end{mathpar} + +\judgbox{\subsumable{\ECMV}} $\ECMV$ is subsumable +% +\begin{mathpar} + \inferrule[MSuLetPat]{ }{ + \subsumable{\ECLet{\PMV}{\ECMV_1}{\ECMV_2}} + } +\end{mathpar} + +\judgbox{\markless{\ECMV}} $\ECMV$ has no marks +% +\begin{mathpar} + \inferrule[MLLetPat]{ + \markless{\PCMV} \\ + \markless{\ECMV_1} \\ + \markless{\ECMV_2} + }{ + \markless{\ECLet{\PCMV}{\ECMV_1}{\ECMV_2}} + } +\end{mathpar} + +\subsection{Mark erasure} +\label{sec:patterned-mark-erasure} +$\judgbox{\erase{\ECMV}}$ is a metafunction defined as follows: +% +\[\begin{array}{rcl} + & \vdots & \\ + \erasesToRow{(\ECLet{\PCMV}{\ECMV_1}{\ECMV_2})}{\ELet{(\erase{\PCMV})}{(\erase{\ECMV_1})}{(\erase{\ECMV_2})}} +\end{array}\] + +\subsection{Metatheorems} +\label{sec:patterned-metatheorems} +In addition to the original metatheorems above (see \cref{sec:marked-metatheorems}), the following +ones governing patterns additionally hold. + +\begin{theorem}[name=Pattern Marking Totality] \ + \begin{enumerate} + \item For all $\ctx$ and $\PMV$, + there exist $\PCMV$ and $\TMV$ + such that $\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}$. + + \item For all $\ctx$, $\PMV$, and $\TMV$, + there exists $\PCMV$ and $\ctx'$ + such that $\ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}{\ctx'}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Pattern Marking Well-Formedness] \ + \begin{enumerate} + \item If $\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}$, + then $\ctxSynPatM{\ctx}{\PCMV}{\TMV}$ + and $\erasesTo{\PCMV}{\PMV}$. + + \item If $\ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}{\ctx'}$, + then $\ctxAnaPatM{\ctx}{\PCMV}{\TMV}{\ctx'}$ + and $\erasesTo{\PCMV}{\PMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Pattern Marking of Well-Typed/Ill-Typed Patterns] \ + \begin{enumerate} + \item \begin{enumerate} + \item If $\ctxSynPatU{\ctx}{\PMV}{\TMV}$ + and $\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}$, + then $\markless{\PCMV}$. + + \item If $\ctxAnaPatU{\ctx}{\PMV}{\TMV}{\ctx'}$ + and $\ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV}{\ctx'}$, + then $\markless{\PCMV}$. + \end{enumerate} + + \item \begin{enumerate} + \item If there does not exist $\TMV$ + such that $\ctxSynPatU{\ctx}{\PMV}{\TMV}$, + then for all $\PCMV$ and $\TMV'$ + such that $\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV'}$, + it is not the case that $\markless{\PCMV}$. + + \item If there does not exist $\TMV$ and $\ctx'$ such that $\ctxAnaPatU{\ctx}{\PMV}{\TMV}{\ctx'}$, + then for all $\PCMV$, $\TMV'$, and $\ctx'$ + such that $\ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV}{\TMV'}{\ctx'}$, + it is not the case that $\markless{\PCMV}$. + \end{enumerate} + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Pattern Marking Unicity] \ + \begin{enumerate} + \item If $\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV_1}{\TMV_1}$ + and $\ctxSynFixedIntoPat{\ctx}{\PMV}{\PCMV_2}{\TMV_2}$, + then $\PCMV_1 = \PCMV_2$ + and $\TMV_1 = \TMV_2$. + + \item If $\ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV_1}{\TMV}{\ctx_1}$ + and $\ctxAnaFixedIntoPat{\ctx}{\PMV}{\PCMV_2}{\TMV}{\ctx_2}$, + then $\PCMV_1 = \PCMV_2$ and $\ctx_1 = \ctx_2$. + \end{enumerate} +\end{theorem} + +\end{document} diff --git a/supplement/polymorphism.tex b/supplement/polymorphism.tex new file mode 100644 index 0000000..c32fcdc --- /dev/null +++ b/supplement/polymorphism.tex @@ -0,0 +1,653 @@ +\documentclass[supplement.tex]{subfiles} + +\begin{document} + +\section{Extension: System F-style polymorphism} +\label{sec:polymorphism} +In this section, we describe an extension of the marked lambda calculus for System F-style +parametric polymorphism. + +Chiefly, the introduction of type variables and the possibility of free ones requires the +distinction between unmarked and marked types. These are each governed by well-formedness judgments +(alongside extensions of the original consistency, etc. judgments) and linked by a marking +operation. + +\subsection{Syntax} +\label{sec:polymorphism-syntax} +The syntax of unmarked types is exactly that of the original types alongside additional forms for +forall types and type variables. In marked types, we additionally have free type variables. +Within unmarked expressions, there may be type abstractions and type applications. In marked +expressions, marks corresponding to those of ordinary lambda abstractions are present. + +\[\begin{array}{rrcl} + \TMName & \TMV & \Coloneqq & \cdots \mid \TForall{\TVarMV}{\TMV} \mid \TVarMV \\ + \MTMName & \MTMV & \Coloneqq & \cdots + % \MTUnknown \mid \MTNum \mid \MTBool + % \mid \MTArrow{\MTMV}{\MTMV} \mid \MTProd{\MTMV}{\MTMV} + \mid \MTForall{\MTVarMV}{\MTMV} \mid \MTVarMV \mid \MTFree{\MTVarMV} \\ + \EMName & \EMV & \Coloneqq & \cdots \mid \ETypeLam{\TVarMV}{\EMV} \mid \ETypeAp{\EMV}{\TMV} \\ + \ECMName & \ECMV & \Coloneqq & \cdots \mid \ECTypeLam{\MTVarMV}{\ECMV} \mid \ECTypeAp{\ECMV}{\MTMV} \\ + & & \mid & \ECTypeLamAnaNonMatchedForall{\MTVarMV}{\ECMV} \mid \ECTypeApSynNonMatchedForall{\ECMV}{\MTMV} +\end{array}\] + +\subsection{Unmarked types} +\label{sec:polymorphism-unmarked-types} +Type consistency is now parametrized by the type variable context $\tvarCtx$. Here (and similarly +the extension of other judgments), we omit the rules for the old syntactic constructs, which may be +straightforwardly derived from the original rules. \\ + +\judgbox{\ensuremath{\tvarCtxConsistentU{\tvarCtx}{\TMV_1}{\TMV_2}}} $\TMV_1$ and $\TMV_2$ are consistent +% +\begin{mathpar} + \cdots + + \inferrule[TCForall]{ + \tvarCtxConsistentU{\extendTvarCtx{\tvarCtx}{\TVarMV}}{\TMV}{\TMV'} + }{ + \tvarCtxConsistentU{\tvarCtx}{\TForall{\TVarMV}{\TMV}}{\TForall{\TVarMV}{\TMV'}} + } + + \inferrule[TCVar]{ + \inTvarCtx{\tvarCtx}{\TVarMV} + }{ + \tvarCtxConsistentU{\tvarCtx}{\TVarMV}{\TVarMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\tvarCtxWFU{\tvarCtx}{\TMV}}} $\TMV$ is well-formed +% +\begin{mathpar} + \inferrule[TWFUnknown]{ }{ + \tvarCtxWFU{\tvarCtx}{\MTUnknown} + } + + \inferrule[TWFNum]{ }{ + \tvarCtxWFU{\tvarCtx}{\MTNum} + } + + \inferrule[TWFBool]{ }{ + \tvarCtxWFU{\tvarCtx}{\MTBool} + } + + \inferrule[TWFArr]{ + \tvarCtxWFU{\tvarCtx}{\MTMV_1} \\ + \tvarCtxWFU{\tvarCtx}{\MTMV_2} + }{ + \tvarCtxWFU{\tvarCtx}{\TArrow{\MTMV_1}{\MTMV_2}} + } + + \inferrule[TWFProd]{ + \tvarCtxWFU{\tvarCtx}{\MTMV_1} \\ + \tvarCtxWFU{\tvarCtx}{\MTMV_2} + }{ + \tvarCtxWFU{\tvarCtx}{\TProd{\MTMV_1}{\MTMV_2}} + } + + \inferrule[TWFForall]{ + \tvarCtxWFU{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\MTMV} + }{ + \tvarCtxWFU{\tvarCtx}{\MTForall{\MTVarMV}{\MTMV}} + } + + \inferrule[TWFVar]{ + \inTvarCtx{\tvarCtx}{\MTVarMV} + }{ + \tvarCtxWFU{\tvarCtx}{\MTVarMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\matchedForall{\TMV}{\TVarMV}{\TMV'}}} $\TMV$ has matched forall type $\TForall{\TVarMV}{\TMV'}$ +% +\begin{mathpar} + \inferrule[TMFUnknown]{ }{ + \matchedForall{\TUnknown}{\TVarMV}{\TUnknown} + } + + \inferrule[TMFForall]{ }{ + \matchedForall{\TForall{\TVarMV}{\TMV}}{\TVarMV}{\TMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\TMeet{\TMV_1}{\TMV_2}}} is a \emph{partial} metafunction defined as follows: +% +\newcommand{\meetsToRow}[3]{\ensuremath{\TMeet{#1}{#2} & = & #3}} +\[\begin{array}{rcl} + & \vdots & \\ + \meetsToRow{(\TForall{\TVarMV}{\TMV})}{(\TForall{\TVarMV}{\TMV'})}{\TForall{\TVarMV}{(\TMeet{\TMV}{\TMV'})}} \\ + \meetsToRow{\TVarMV}{\TVarMV}{\TVarMV} \\ +\end{array}\] + +\judgbox{\ensuremath{\subst{\TMV_1}{\TMV_2}{\TVarMV}}} is a metafunction defined as follows: +% +\newcommand{\substToRow}[4]{\ensuremath{\subst{#1}{#2}{#3} & = & #4}} +\[\begin{array}{rcll} + \substToRow{\TUnknown}{\TMV}{\TVarMV}{\TUnknown} \\ + \substToRow{\TNum}{\TMV}{\TVarMV}{\TNum} \\ + \substToRow{\TBool}{\TMV}{\TVarMV}{\TBool} \\ + \substToRow{(\TArrow{\TMV_1}{\TMV_2})}{\TMV}{\TVarMV}{\TArrow{(\subst{\TMV_1}{\TMV}{\TVarMV})}{(\subst{\TMV_2}{\TMV}{\TVarMV})}} \\ + \substToRow{(\TProd{\TMV_1}{\TMV_2})}{\TMV}{\TVarMV}{\TProd{(\subst{\TMV_1}{\TMV}{\TVarMV})}{(\subst{\TMV_2}{\TMV}{\TVarMV})}} \\ + \substToRow{(\TForall{\TVarMV'}{\TMV'})}{\TMV}{\TVarMV}{\TForall{\TVarMV'}{\TMV'}} & \equal{\TVarMV}{\TVarMV'} \\ + \substToRow{(\TForall{\TVarMV'}{\TMV'})}{\TMV}{\TVarMV}{\TForall{\TVarMV'}{(\subst{\TMV'}{\TMV}{\TVarMV})}} & \notEqual{\TVarMV}{\TVarMV'} \\ + \substToRow{\TVarMV'}{\TMV}{\TVarMV}{\TMV} & \equal{\TVarMV}{\TVarMV'} \\ + \substToRow{\TVarMV'}{\TMV}{\TVarMV}{\TVarMV'} & \notEqual{\TVarMV}{\TVarMV'} +\end{array}\] + +\subsection{Type marking} +\label{sec:polymorphism-type-marking} +\judgbox{\ensuremath{\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV}}} $\TMV$ is marked into $\MTMV$ +% +\begin{mathpar} + \inferrule[MKTUnknown]{ }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TUnknown}{\MTUnknown} + } + + \inferrule[MKTNum]{ }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TNum}{\MTNum} + } + + \inferrule[MKTBool]{ }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TBool}{\MTBool} + } + + \inferrule[MKTArr]{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TMV_1}{\MTMV_1} \\ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TMV_2}{\MTMV_2} + }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TArrow{\TMV_1}{\TMV_2}}{\MTArrow{\MTMV_1}{\MTMV_2}} + } + + \inferrule[MKTProd]{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TMV_1}{\MTMV_1} \\ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TMV_2}{\MTMV_2} + }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TProd{\TMV_1}{\TMV_2}}{\MTProd{\MTMV_1}{\MTMV_2}} + } + + \inferrule[MKTForall]{ + \tvarCtxTypeMarkedInto{\extendTvarCtx{\tvarCtx}{\TVarMV}}{\TMV}{\MTMV} + }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TForall{\TVarMV}{\TMV}}{\MTForall{\MTVarMV}{\MTMV}} + } + + \inferrule[MKTVar]{ + \inTvarCtx{\tvarCtx}{\TVarMV} + }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TVarMV}{\MTVarMV} + } + + \inferrule[MKTFree]{ + \notInTvarCtx{\tvarCtx}{\TVarMV} + }{ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TVarMV}{\MTFree{\MTVarMV}} + } +\end{mathpar} + +\subsection{Marked types} +\label{sec:polymorphism-marked-types} +\judgbox{\ensuremath{\tvarCtxConsistentM{\tvarCtx}{\MTMV_1}{\MTMV_2}}} $\MTMV_1$ and $\MTMV_2$ are consistent +% +\begin{mathpar} + \cdots + + \inferrule[MTCForall]{ + \tvarCtxConsistentM{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\MTMV}{\MTMV'} + }{ + \tvarCtxConsistentM{\tvarCtx}{\TForall{\MTVarMV}{\MTMV}}{\TForall{\MTVarMV}{\MTMV'}} + } + + \inferrule[MTCVar]{ + \inTvarCtx{\tvarCtx}{\MTVarMV} + }{ + \tvarCtxConsistentM{\tvarCtx}{\MTVarMV}{\MTVarMV} + } + + \inferrule[MTCFree1]{ + \notInTvarCtx{\tvarCtx}{\MTVarMV} + }{ + \tvarCtxConsistentM{\tvarCtx}{\MTFree{\MTVarMV}}{\MTMV} + } + + \inferrule[MTCFree2]{ + \notInTvarCtx{\tvarCtx}{\MTVarMV} + }{ + \tvarCtxConsistentM{\tvarCtx}{\MTMV}{\MTFree{\MTVarMV}} + } +\end{mathpar} + +\judgbox{\ensuremath{\tvarCtxWFM{\tvarCtx}{\MTMV}}} $\MTMV$ is well-formed +% +\begin{mathpar} + \inferrule[MTWFUnknown]{ }{ + \tvarCtxWFM{\tvarCtx}{\TUnknown} + } + + \inferrule[MTWFNum]{ }{ + \tvarCtxWFM{\tvarCtx}{\TNum} + } + + \inferrule[MTWFBool]{ }{ + \tvarCtxWFM{\tvarCtx}{\TBool} + } + + \inferrule[MTWFArr]{ + \tvarCtxWFM{\tvarCtx}{\MTMV_1} \\ + \tvarCtxWFM{\tvarCtx}{\MTMV_2} + }{ + \tvarCtxWFM{\tvarCtx}{\TArrow{\MTMV_1}{\MTMV_2}} + } + + \inferrule[MTWFProd]{ + \tvarCtxWFM{\tvarCtx}{\MTMV_1} \\ + \tvarCtxWFM{\tvarCtx}{\MTMV_2} + }{ + \tvarCtxWFM{\tvarCtx}{\TProd{\MTMV_1}{\MTMV_2}} + } + + \inferrule[MTWFForall]{ + \tvarCtxWFM{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\MTMV} + }{ + \tvarCtxWFM{\tvarCtx}{\TForall{\MTVarMV}{\MTMV}} + } + + \inferrule[MTWFVar]{ + \inTvarCtx{\tvarCtx}{\MTVarMV} + }{ + \tvarCtxWFM{\tvarCtx}{\MTVarMV} + } + + \inferrule[MTWFFree]{ + \notInTvarCtx{\tvarCtx}{\MTVarMV} + }{ + \tvarCtxWFM{\tvarCtx}{\MTFree{\MTVarMV}} + } +\end{mathpar} + +\judgbox{\ensuremath{\matchedForall{\MTMV}{\MTVarMV}{\MTMV'}}} $\MTMV$ has matched forall type $\MTForall{\MTVarMV}{\MTMV'}$ +% +\begin{mathpar} + \inferrule[MTMFUnknown]{ }{ + \matchedForall{\MTUnknown}{\MTVarMV}{\MTUnknown} + } + + \inferrule[MTMFForall]{ }{ + \matchedForall{\MTForall{\MTVarMV}{\MTMV}}{\MTVarMV}{\MTMV} + } + + \inferrule[MTMFFree]{ }{ + \matchedForall{\MTFree{\MTVarMV}}{\MTVarMV}{\MTUnknown} + } +\end{mathpar} + +\judgbox{\ensuremath{\MTMeet{\MTMV_1}{\MTMV_2}}} is a \emph{partial} metafunction defined as follows: +% +\[\begin{array}{rcl} + & \vdots & \\ + \meetsToRow{(\MTForall{\MTVarMV}{\MTMV})}{(\MTForall{\MTVarMV}{\MTMV'})}{\MTForall{\MTVarMV}{(\MTMeet{\MTMV}{\MTMV'})}} \\ + \meetsToRow{\MTVarMV}{\MTVarMV}{\MTVarMV} \\ + \meetsToRow{\MTFree{\MTVarMV}}{\MTMV}{\MTMV} \\ + \meetsToRow{\MTMV}{\MTFree{\MTVarMV}}{\MTMV} \\ +\end{array}\] + +\judgbox{\ensuremath{\subst{\MTMV_1}{\MTMV_2}{\MTVarMV}}} is a metafunction defined as follows: +% +\[\begin{array}{rcll} + \substToRow{\MTUnknown}{\MTMV}{\MTVarMV}{\MTUnknown} \\ + \substToRow{\MTNum}{\MTMV}{\MTVarMV}{\MTNum} \\ + \substToRow{\MTBool}{\MTMV}{\MTVarMV}{\MTBool} \\ + \substToRow{(\MTArrow{\MTMV_1}{\MTMV_2})}{\MTMV}{\MTVarMV}{\MTArrow{(\subst{\MTMV_1}{\MTMV}{\MTVarMV})}{(\subst{\MTMV_2}{\MTMV}{\MTVarMV})}} \\ + \substToRow{(\MTProd{\MTMV_1}{\MTMV_2})}{\MTMV}{\MTVarMV}{\MTProd{(\subst{\MTMV_1}{\MTMV}{\MTVarMV})}{(\subst{\MTMV_2}{\MTMV}{\MTVarMV})}} \\ + \substToRow{(\MTForall{\MTVarMV'}{\MTMV'})}{\MTMV}{\MTVarMV}{\MTForall{\MTVarMV'}{\MTMV'}} & \equal{\MTVarMV}{\MTVarMV'} \\ + \substToRow{(\MTForall{\MTVarMV'}{\MTMV'})}{\MTMV}{\MTVarMV}{\MTForall{\MTVarMV'}{(\subst{\MTMV'}{\MTMV}{\MTVarMV})}} & \notEqual{\MTVarMV}{\MTVarMV'} \\ + \substToRow{\MTVarMV'}{\MTMV}{\MTVarMV}{\MTMV} & \equal{\MTVarMV}{\MTVarMV'} \\ + \substToRow{\MTVarMV'}{\MTMV}{\MTVarMV}{\MTVarMV'} & \notEqual{\MTVarMV}{\MTVarMV'} \\ + \substToRow{\MTFree{\MTVarMV'}}{\MTMV}{\MTVarMV}{\MTFree{\MTVarMV'}} +\end{array}\] + +\judgbox{\ensuremath{\markless{\MTMV}}} $\MTMV$ has no marks +% +\begin{mathpar} + \inferrule[MLTUnknown]{ }{ + \markless{\MTUnknown} + } + + \inferrule[MLTNum]{ }{ + \markless{\MTNum} + } + + \inferrule[MLTBool]{ }{ + \markless{\MTBool} + } + + \inferrule[MLTArr]{ + \markless{\MTMV_1} \\ + \markless{\MTMV_2} + }{ + \markless{\MTArrow{\MTMV_1}{\MTMV_2}} + } + + \inferrule[MLTProd]{ + \markless{\MTMV_1} \\ + \markless{\MTMV_2} + }{ + \markless{\MTProd{\MTMV_1}{\MTMV_2}} + } + + \inferrule[MLTForall]{ + \markless{\MTMV} \\ + }{ + \markless{\MTForall{\MTVarMV}{\MTMV}} + } + + \inferrule[MLTVar]{ }{ + \markless{\MTVarMV} + } +\end{mathpar} + +\subsection{Type mark erasure} +\label{sec:polymorphism-type-mark-erasure} +\judgbox{\ensuremath{\erase{\MTMV}}} is a metafunction defined as follows: +% +\newcommand{\erasesToRow}[2]{\erase{#1} & = & #2} +\[\begin{array}{rcl} + \erasesToRow{\MTUnknown}{\TUnknown} \\ + \erasesToRow{\MTNum}{\TNum} \\ + \erasesToRow{\MTBool}{\TBool} \\ + \erasesToRow{(\MTArrow{\MTMV_1}{\MTMV_2})}{\MTArrow{(\erase{\MTMV_1})}{(\erase{\MTMV_2})}} \\ + \erasesToRow{(\MTProd{\MTMV_1}{\MTMV_2})}{\MTProd{(\erase{\MTMV_1})}{(\erase{\MTMV_2})}} \\ + \erasesToRow{(\MTForall{\MTVarMV}{\MTMV})}{\TForall{\TVarMV}{(\erase{\MTMV})}} \\ + \erasesToRow{\MTVarMV}{\TVarMV} \\ + \erasesToRow{\MTFree{\MTVarMV}}{\TVarMV} +\end{array}\] + +\subsection{Unmarked expressions} +\label{sec:polymorphism-unmarked-expressions} +\judgbox{\ensuremath{\bothCtxSynTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV}}} $\EMV$ synthesizes type $\TMV$ +% +\begin{mathpar} + \cdots + + \inferrule[USTypeLam]{ + \bothCtxSynTypeU{\extendTvarCtx{\tvarCtx}{\TVarMV}}{\ctx}{\EMV}{\TMV} + }{ + \bothCtxSynTypeU{\tvarCtx}{\ctx}{\ETypeLam{\TVarMV}{\EMV}}{\TForall{\TVarMV}{\TMV}} + } + + \inferrule[USTypeAp]{ + \bothCtxSynTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV} \\ + \tvarCtxWFU{\tvarCtx}{\TMV_2} \\ + \matchedForall{\TMV}{\TVarMV}{\TMV_1} + }{ + \bothCtxSynTypeU{\tvarCtx}{\ctx}{\ETypeAp{\EMV}{\TMV_2}}{\subst{\TMV_1}{\TMV_2}{\TVarMV}} + } +\end{mathpar} + +\judgbox{\ensuremath{\bothCtxAnaTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV}}} $\EMV$ analyzes against type $\TMV$ +% +\begin{mathpar} + \cdots + + \inferrule[UATypeLam]{ + \matchedForall{\TMV}{\TVarMV}{\TMV'} \\ + \bothCtxAnaTypeU{\extendTvarCtx{\tvarCtx}{\TVarMV}}{\ctx}{\EMV}{\TMV'} + }{ + \bothCtxAnaTypeU{\tvarCtx}{\ctx}{\ETypeLam{\TVarMV}{\EMV}}{\TMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\subsumable{\EMV}}} $\EMV$ is subsumable +% +\begin{mathpar} + \cdots + + \inferrule[USuTypeAp]{ }{ + \subsumable{\ETypeAp{\EMV}{\TMV}} + } +\end{mathpar} + +\subsection{Marking} +\label{sec:polymorphism-marking} +\judgbox{\bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}} $\EMV$ is marked into $\ECMV$ and synthesizes type $\MTMV$ +% +\begin{mathpar} + \cdots + + \inferrule[MKSTypeLam]{ + \bothCtxSynFixedInto{\extendTvarCtx{\tvarCtx}{\TVarMV}}{\ctx}{\EMV}{\ECMV}{\MTMV} + }{ + \bothCtxSynFixedInto{\tvarCtx}{\ctx}{\ETypeLam{\TVarMV}{\EMV}}{\ECTypeLam{\MTVarMV}{\ECMV}}{\MTForall{\MTVarMV}{\MTMV}} + } + + \inferrule[MKSTypeAp1]{ + \bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV} \\ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TMV_2}{\MTMV_2} \\ + \matchedForall{\MTMV}{\MTVarMV}{\MTMV_1} + }{ + \bothCtxSynFixedInto{\tvarCtx}{\ctx}{\ETypeAp{\EMV}{\TMV_2}}{\ECTypeAp{\ECMV}{\MTMV_2}}{\subst{\MTMV_1}{\MTMV_2}{\MTVarMV}} + } + + \inferrule[MKSTypeAp2]{ + \bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV} \\ + \tvarCtxTypeMarkedInto{\tvarCtx}{\TMV_2}{\MTMV_2} \\ + \notMatchedForall{\MTMV} + }{ + \bothCtxSynFixedInto{\tvarCtx}{\ctx}{\ETypeAp{\EMV}{\TMV_2}}{\ECTypeAp{\ECMV}{\MTMV_2}}{\MTUnknown} + } +\end{mathpar} + +\judgbox{\bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}} $\EMV$ is marked into $\ECMV$ and analyzes against type $\MTMV$ +% +\begin{mathpar} + \cdots + + \inferrule[MKATypeLam1]{ + \matchedForall{\MTMV}{\MTVarMV}{\MTMV'} \\ + \bothCtxAnaFixedInto{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\ctx}{\EMV}{\ECMV}{\MTMV'} + }{ + \bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\ETypeLam{\TVarMV}{\EMV}}{\ECTypeLam{\MTVarMV}{\ECMV}}{\MTMV} + } + + \inferrule[MKATypeLam2]{ + \notMatchedForall{\MTMV} \\ + \bothCtxAnaFixedInto{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\ctx}{\EMV}{\ECMV}{\MTUnknown} + }{ + \bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\ETypeLam{\TVarMV}{\EMV}}{\ECTypeLamAnaNonMatchedForall{\MTVarMV}{\ECMV}}{\MTMV} + } +\end{mathpar} + +\subsection{Marked expressions} +\label{sec:polymorphism-marked-expressions} +\judgbox{\ensuremath{\bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECMV}{\MTMV}}} $\ECMV$ synthesizes type $\MTMV$ +% +\begin{mathpar} + \cdots + + \inferrule[MSTypeLam]{ + \bothCtxSynTypeM{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\ctx}{\ECMV}{\MTMV} + }{ + \bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECTypeLam{\MTVarMV}{\ECMV}}{\MTForall{\MTVarMV}{\MTMV}} + } + + \inferrule[MSTypeAp1]{ + \bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECMV}{\MTMV} \\ + \tvarCtxWFM{\tvarCtx}{\MTMV_2} \\ + \matchedForall{\MTMV}{\MTVarMV}{\MTMV_1} + }{ + \bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECTypeAp{\ECMV}{\MTMV_2}}{\subst{\MTMV_1}{\MTMV_2}{\MTVarMV}} + } + + \inferrule[MSTypeAp2]{ + \bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECMV}{\MTMV} \\ + \tvarCtxWFM{\tvarCtx}{\MTMV_2} \\ + \notMatchedForall{\MTMV} + }{ + \bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECTypeApSynNonMatchedForall{\ECMV}{\MTMV_2}}{\MTUnknown} + } +\end{mathpar} + +\judgbox{\ensuremath{\bothCtxAnaTypeM{\tvarCtx}{\ctx}{\ECMV}{\MTMV}}} $\ECMV$ analyzes against type $\MTMV$ +% +\begin{mathpar} + \cdots + + \inferrule[MATypeLam1]{ + \matchedForall{\MTMV}{\MTVarMV}{\MTMV'} \\ + \bothCtxAnaTypeM{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\ctx}{\ECMV}{\MTMV'} + }{ + \bothCtxAnaTypeM{\tvarCtx}{\ctx}{\ECTypeLam{\MTVarMV}{\ECMV}}{\MTMV} + } + + \inferrule[MATypeLam2]{ + \notMatchedForall{\MTMV} \\ + \bothCtxAnaTypeM{\extendTvarCtx{\tvarCtx}{\MTVarMV}}{\ctx}{\ECMV}{\MTUnknown} + }{ + \bothCtxAnaTypeM{\tvarCtx}{\ctx}{\ECTypeLamAnaNonMatchedForall{\MTVarMV}{\ECMV}}{\MTMV} + } +\end{mathpar} + +\judgbox{\ensuremath{\subsumable{\ECMV}}} $\ECMV$ is subsumable +% +\begin{mathpar} + \cdots + + \inferrule[MSuTypeAp1]{ }{ + \subsumable{\ECTypeAp{\ECMV}{\MTMV}} + } + + \inferrule[MSuTypeAp2]{ }{ + \subsumable{\ECTypeApSynNonMatchedForall{\ECMV}{\MTMV}} + } +\end{mathpar} + +\judgbox{\ensuremath{\markless{\ECMV}}} $\ECMV$ has no marks +% +\begin{mathpar} + \cdots + + \inferrule[MLTypeLam]{ + \markless{\ECMV} + }{ + \markless{\ECTypeLam{\MTVarMV}{\ECMV}} + } + + \inferrule[MLTypeAp]{ + \markless{\ECMV} \\ + \markless{\MTMV} \\ + }{ + \markless{\ECTypeAp{\ECMV}{\MTMV}} + } +\end{mathpar} + +\subsection{Mark erasure} +\label{sec:polymorphism-mark-erasure} +\judgbox{\ensuremath{\erase{\ECMV}}} is a metafunction defined as follows: +% +\[\begin{array}{rcl} + & \vdots & \\ + \erasesToRow{(\ECTypeLam{\MTVarMV}{\ECMV})}{\ETypeLam{\MTVarMV}{(\erase{\ECMV})}} \\ + \erasesToRow{\ECTypeLamAnaNonMatchedForall{\MTVarMV}{\ECMV}}{\ETypeLam{\MTVarMV}{(\erase{\ECMV})}} \\ + \erasesToRow{(\ECTypeAp{\ECMV}{\MTMV})}{\ETypeAp{\erase{\ECMV}}{\erase{\MTMV}}} \\ + \erasesToRow{(\ECTypeApSynNonMatchedForall{\ECMV}{\MTMV})}{\ETypeAp{\erase{\ECMV}}{\erase{\MTMV}}} \\ +\end{array}\] + +\subsection{Metatheorems} +\label{sec:polymorphism-metatheorems} +With polymorphism, we have the following modified metatheorems which additionally account for type +well-formedness and marking. + +\begin{lemma*}[name=Unmarked Synthesis] + If $\bothCtxSynTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV}$, then $\tvarCtxWFU{\tvarCtx}{\TMV}$. +\end{lemma*} + +\begin{lemma*}[name=Marked Synthesis] + If $\bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECMV}{\MTMV}$, then $\tvarCtxWFM{\tvarCtx}{\MTMV}$. +\end{lemma*} + +\begin{theorem}[name=Marking Totality] \ + \begin{enumerate} + \item For all $\tvarCtx$ and $\TMV$, + there exists $\MTMV$ such that $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV}$. + + \item For all $\tvarCtx$, $\ctx$, and $\EMV$, + there exist $\ECMV$ and $\MTMV$ such that $\bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$. + + \item For all $\tvarCtx$, $\ctx$, $\EMV$, and $\MTMV$ + such that $\tvarCtxWFM{\tvarCtx}{\MTMV}$, + there exists $\ECMV$ + such that $\bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Marking Well-Formedness] \ + \begin{enumerate} + \item If $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV}$, + then $\tvarCtxWFM{\tvarCtx}{\MTMV}$ + and $\erasesTo{\MTMV}{\TMV}$. + + \item If $\bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$, + then $\tvarCtxWFM{\tvarCtx}{\MTMV}$ + and $\bothCtxSynTypeM{\tvarCtx}{\ctx}{\ECMV}{\MTMV}$ + and $\erasesTo{\ECMV}{\EMV}$. + + \item If $\bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$ + and $\tvarCtxWFM{\tvarCtx}{\MTMV}$, + then $\bothCtxAnaTypeM{\tvarCtx}{\ctx}{\ECMV}{\MTMV}$ + and $\erasesTo{\ECMV}{\EMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Marking of Well-Typed/Ill-Typed Expressions] \ + \begin{enumerate} + \item \begin{enumerate} + \item If $\tvarCtxWFU{\tvarCtx}{\TMV}$ + and $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV}$, + then $\markless{\MTMV}$. + + \item If $\bothCtxSynTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV}$ + and $\bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$, + then $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV}$ + and $\markless{\ECMV}$. + + \item If $\bothCtxAnaTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV}$ + and $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV}$ + and $\bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$, + then $\markless{\ECMV}$. + \end{enumerate} + + \item \begin{enumerate} + \item If it is not the case that $\tvarCtxWFU{\tvarCtx}{\TMV}$, + then for all $\MTMV$ + such that $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV}$, + it is not the case that $\markless{\MTMV}$. + + \item If there does not exist $\TMV$ + such that $\bothCtxSynTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV}$, + then for all $\ECMV$ and $\MTMV$ + such that $\bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$, + it is not the case that $\markless{\ECMV}$. + + \item If there does not exist $\TMV$ + such that $\bothCtxAnaTypeU{\tvarCtx}{\ctx}{\EMV}{\TMV}$, + then for all $\ECMV$ and $\MTMV$ + such that $\bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV}{\MTMV}$, + it is not the case that $\markless{\ECMV}$. + \end{enumerate} + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Marking Unicity] \ + \begin{enumerate} + \item If $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV_1}$, + and $\tvarCtxTypeMarkedInto{\tvarCtx}{\TMV}{\MTMV_2}$, + then $\equal{\MTMV_1}{\MTMV_2}$. + + \item If $\bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV_1}{\MTMV_1}$ + and $\bothCtxSynFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV_2}{\MTMV_2}$, + then $\equal{\ECMV_1}{\ECMV_2}$ and $\equal{\MTMV_1}{\MTMV_2}$. + + \item If $\bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV_1}{\MTMV}$ + and $\bothCtxAnaFixedInto{\tvarCtx}{\ctx}{\EMV}{\ECMV_2}{\MTMV}$, + then $\equal{\ECMV_1}{\ECMV_2}$. + \end{enumerate} +\end{theorem} + +\end{document} diff --git a/supplement/preface.tex b/supplement/preface.tex new file mode 100644 index 0000000..fdf63ea --- /dev/null +++ b/supplement/preface.tex @@ -0,0 +1,39 @@ +\documentclass[supplement.tex]{subfiles} + +\begin{document} +\section{Preface} +\label{sec:preface} +This is a formalism demonstrating the \emph{marked lambda calculus}, a judgmental framework for +precise bidirectional error localization and recovery that employs gradual typing. + +\subsection{Organization} +Though more is said in each individual section, the overall structure of the document is as follows: +% +\begin{itemize} + \item \cref{sec:marked} employs the framework on a gradually typed lambda calculus. + + \item \cref{sec:patterned} extends the demonstration with patterned let expressions. + + \item \cref{sec:polymorphism} extends the demonstration with System F-style parametric + polymorphism. + + \item \cref{sec:untyped} gives a version of the Hazelnut structure editor calculus that uses the + marked lambda calculus to solve Hazelnut's deficiency with regards to non-local hole fixing. + + \item \cref{sec:typed} is similar, except that it employs the marking procedure in a roughly + incremental fashion. +\end{itemize} +% +Note that each of the following sections after \cref{sec:marked} build upon the same core language. + +\subsection{Mechanization} +Not all parts of the formalism are mechanized in Agda. In particular, the core of the marked lambda +calculus (\cref{sec:marked}) and the untyped Hazelnut calculus that employs marking +(\cref{sec:untyped}) \emph{are} mechanized, while all others \emph{are not}. Crucially, the +metatheorems of the aforementioned sections are verified, whereas those of all other sections are +not. + +As possible, the names of judgments and rules that appear in the mechanization have been made to +follow those in this formalism. Refer also to the mechanization's README for more details. + +\end{document} diff --git a/supplement/typed.tex b/supplement/typed.tex new file mode 100644 index 0000000..2bd0b83 --- /dev/null +++ b/supplement/typed.tex @@ -0,0 +1,958 @@ +\documentclass[supplement.tex]{subfiles} + +\begin{document} + +\section{Typed hazelnut} +\label{sec:typed} + +\subsection{Syntax} +\label{sec:typed-syntax} +Zippered types are the same as in the untyped model. + +\[\begin{array}{rrcl} + \ZMName & \ZMV & \Coloneqq & \ZCursor{\ECMV} \mid \ZLamT{x}{\ZTMV}{\ECMV} \mid \ZLamE{x}{\TMV}{\ZMV} \mid \ZApL{\ZMV}{\ECMV} \mid \ZApR{\ECMV}{\ZMV} \\ + & & \mid & \ZLetL{x}{\ZMV}{\ECMV} \mid \ZLetR{x}{\ECMV}{\ZMV} \\ + & & \mid & \ZPlusL{\ZMV}{\ECMV} \mid \ZPlusR{\ECMV}{\ZMV} \\ + & & \mid & \ZIfC{\ZMV}{\ECMV}{\ECMV} \mid \ZIfL{\ECMV}{\ZMV}{\ECMV} \mid \ZIfR{\ECMV}{\ECMV}{\ZMV} \\ + & & \mid & \ZInconType{\ZMV} \mid \ZInconBrC{\ZMV}{\ECMV}{\ECMV} \mid \ZInconBrL{\ECMV}{\ZMV}{\ECMV} \mid \ZInconBrR{\ECMV}{\ECMV}{\ZMV} \\ +\end{array}\] + +\subsubsection{Well-formedness} +\label{sec:typed-well-formedness} +\judgbox{\ensuremath{\zWellFormed{\ZMV}}} $\ZMV$ is well-formed +% +\begin{mathpar} + \inferrule[WFCursor]{ }{ + \zWellFormed{\ZCursor{\ECMV}} + } + + \inferrule[WFLamT]{ }{ + \zWellFormed{\ZLamT{x}{\ZTMV}{\ECMV}} + } + + \inferrule[WFLamE]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZLamE{x}{\TMV}{\ZMV}} + } + + \inferrule[WFApL]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZApL{\ZMV}{\ECMV}} + } + + \inferrule[WFApR]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZApR{\ECMV}{\ZMV}} + } + + \inferrule[WFLetL]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZLetL{x}{\ZMV}{\ECMV}} + } + + \inferrule[WFLetR]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZLetR{x}{\ECMV}{\ZMV}} + } + + \inferrule[WFPlusL]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZPlusL{\ZMV}{\ECMV}} + } + + \inferrule[WFPlusR]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZPlusR{\ECMV}{\ZMV}} + } + + \inferrule[WFIfC]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2}} + } + + \inferrule[WFIfL]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}} + } + + \inferrule[WFIfC]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZIfL{\ZMV}{\ECMV_1}{\ECMV_2}} + } + + \inferrule[WFInconsistentBranchesC]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZInconBrC{\ZMV}{\ECMV_1}{\ECMV_2}} + } + + \inferrule[WFInconsistentBranchesL]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}} + } + + \inferrule[WFInconsistentBranchesR]{ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZInconBrL{\ZMV}{\ECMV_1}{\ECMV_2}} + } + + \inferrule[WFInconsistentTypes]{ + \notEqual{\ZMV}{\ZCursor{\ECMV}} \\ + \zWellFormed{\ZMV} + }{ + \zWellFormed{\ZInconType{\ZMV}} + } +\end{mathpar} + +\subsection{Cursor erasure} +\label{sec:typed-cursor-erasure} + +\subsubsection{Type cursor erasure} +\label{sec:typed-type-cursor-erasure} +Type cursor erasure is the same as in the untyped model. + +\subsubsection{Expression cursor erasure} +\label{sec:typed-expression-cursor-erasure} +\judgbox{\ensuremath{\cursorErase{\ZMV}}} is a metafunction defined as follows: +% +\newcommand{\cursorErasesToRow}[2]{\ensuremath{\cursorErase{#1} & = & #2}} +\[\begin{array}{rcl} + \cursorErasesToRow{\ZCursor{\ECMV}}{\ECMV} \\ + \cursorErasesToRow{(\ZLamT{x}{\ZTMV}{\ECMV})}{\ECLam{x}{\cursorErase{\ZTMV}}{\ECMV}} \\ + \cursorErasesToRow{(\ZLamE{x}{\TMV}{\ZMV})}{\ECLam{x}{\TMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZApL{\ZMV}{\ECMV})}{\ECAp{\cursorErase{\ZMV}}{\ECMV}} \\ + \cursorErasesToRow{(\ZApR{\ECMV}{\ZMV})}{\ECAp{\ECMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZLetL{x}{\ZMV}{\ECMV})}{\ECLet{x}{\cursorErase{\ZMV}}{\ECMV}} \\ + \cursorErasesToRow{(\ZLetR{x}{\ECMV}{\ZMV})}{\ECLet{x}{\ECMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZPlusL{\ZMV}{\ECMV})}{\ECPlus{\cursorErase{\ZMV}}{\ECMV}} \\ + \cursorErasesToRow{(\ZPlusR{\ECMV}{\ZMV})}{\ECPlus{\ECMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2})}{\ECIf{\cursorErase{\ZMV}}{\ECMV_1}{\ECMV_2}} \\ + \cursorErasesToRow{(\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2})}{\ECIf{\ECMV_1}{\cursorErase{\ZMV}}{\ECMV_2}} \\ + \cursorErasesToRow{(\ZIfL{\ECMV_1}{\ECMV_2}{\ZMV})}{\ECIf{\ECMV_1}{\ECMV_2}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{\ZInconType{\ZMV}}{\cursorErase{\ZMV}} \\ + \cursorErasesToRow{\ZInconBrC{\ZMV}{\ECMV_1}{\ECMV_2}}{\ECIf{\cursorErase{\ZMV}}{\ECMV_1}{\ECMV_2}} \\ + \cursorErasesToRow{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}}{\ECIf{\ECMV_1}{\cursorErase{\ZMV}}{\ECMV_2}} \\ + \cursorErasesToRow{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV}}{\ECIf{\ECMV_1}{\ECMV_2}{\cursorErase{\ZMV}}} \\ +\end{array}\] + +\subsection{Action model} +\label{sec:typed-action-model} +The action syntax is the same in the untyped model. + +\subsubsection{Shape sort} +\label{sec:typed-shape-sort} +The shape sort judgments are the same as in the untyped model. + +\subsubsection{Type actions} +\label{sec:typed-type-actions} +Type actions are the same as in the untyped model. + +\subsubsection{Expression movement} +\label{sec:typed-expression-movement} +\judgbox{\ensuremath{\AUEMove{\ZMV}{\ZMV'}{\MMV}}} +% +\begin{mathpar} + \inferrule[AEMLamChild1]{ }{ + \ASEMChild{\ECLam{x}{\TMV}{\ECMV}}{\ZLamT{x}{\ZTCursor{\TMV}}{\ECMV}}{1} + } + + \inferrule[AEMLamChild2]{ }{ + \ASEMChild{\ECLam{x}{\TMV}{\ECMV}}{\ZLamE{x}{\TMV}{\ZCursor{\ECMV}}}{2} + } \\ + + \inferrule[AEMLamParent1]{ }{ + \ASEMParent{\ZLamT{x}{\ZTCursor{\TMV}}{\ECMV}}{\ECLam{x}{\TMV}{\ECMV}} + } + + \inferrule[AEMLamParent2]{ }{ + \ASEMParent{\ZLamE{x}{\TMV}{\ZCursor{\ECMV}}}{\ECLam{x}{\TMV}{\ECMV}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AEMApChild1]{ }{ + \ASEMChild{\ECAp{\ECMV_1}{\ECMV_2}}{\ZApL{\ZCursor{\ECMV_1}}{\ECMV_2}}{1} + } + + \inferrule[AEMApChild2]{ }{ + \ASEMChild{\ECAp{\ECMV_1}{\ECMV_2}}{\ZApR{\ECMV_1}{\ZCursor{\ECMV_2}}}{2} + } \\ + + \inferrule[AEMApParent1]{ }{ + \ASEMParent{\ZApL{\ZCursor{\ECMV_1}}{\ECMV_2}}{\ECAp{\ECMV_1}{\ECMV_2}} + } + + \inferrule[AEMApParent2]{ }{ + \ASEMParent{\ZApR{\ECMV_1}{\ZCursor{\ECMV_2}}}{\ECAp{\ECMV_1}{\ECMV_2}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AEMLetChild1]{ }{ + \ASEMChild{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\ZLetL{x}{\ZCursor{\ECMV_1}}{\ECMV_2}}{1} + } + + \inferrule[AEMLetChild2]{ }{ + \ASEMChild{\ECLet{x}{\ECMV_1}{\ECMV_2}}{\ZLetR{x}{\ECMV_1}{\ZCursor{\ECMV_2}}}{2} + } \\ + + \inferrule[AEMLetParent1]{ }{ + \ASEMParent{\ZLetL{x}{\ZCursor{\ECMV_1}}{\ECMV_2}}{\ECLet{x}{\ECMV_1}{\ECMV_2}} + } + + \inferrule[AEMLetParent2]{ }{ + \ASEMParent{\ZLetR{x}{\ECMV_1}{\ZCursor{\ECMV_2}}}{\ECLet{x}{\ECMV_1}{\ECMV_2}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AEMPlusChild1]{ }{ + \ASEMChild{\ECPlus{\ECMV_1}{\ECMV_2}}{\ZPlusL{\ZCursor{\ECMV_1}}{\ECMV_2}}{1} + } + + \inferrule[AEMPlusChild2]{ }{ + \ASEMChild{\ECPlus{\ECMV_1}{\ECMV_2}}{\ZPlusR{\ECMV_1}{\ZCursor{\ECMV_2}}}{2} + } \\ + + \inferrule[AEMPlusParent1]{ }{ + \ASEMParent{\ZPlusL{\ZCursor{\ECMV_1}}{\ECMV_2}}{\ECPlus{\ECMV_1}{\ECMV_2}} + } + + \inferrule[AEMPlusParent2]{ }{ + \ASEMParent{\ZPlusR{\ECMV_1}{\ZCursor{\ECMV_2}}}{\ECPlus{\ECMV_1}{\ECMV_2}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AEMIfChild1]{ }{ + \ASEMChild{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\ZIfC{\ZCursor{\ECMV_1}}{\ECMV_2}{\ECMV_3}}{1} + } + + \inferrule[AEMIfChild2]{ }{ + \ASEMChild{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\ZIfL{\ECMV_1}{\ZCursor{\ECMV_2}}{\ECMV_3}}{2} + } + + \inferrule[AEMIfChild3]{ }{ + \ASEMChild{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZCursor{\ECMV_3}}}{3} + } \\ + + \inferrule[AEMIfParent1]{ }{ + \ASEMParent{\ZIfC{\ZCursor{\ECMV_1}}{\ECMV_2}{\ECMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } + + \inferrule[AEMIfParent2]{ }{ + \ASEMParent{\ZIfL{\ECMV_1}{\ZCursor{\ECMV_2}}{\ECMV_3}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } + + \inferrule[AEMIfParent3]{ }{ + \ASEMParent{\ZIfR{\ECMV_1}{\ECMV_2}{\ZCursor{\ECMV_3}}}{\ECIf{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AEMInconsistentTypesChild]{ + \ASEMChild{\ZMV}{\ZMV'}{\MChildNMV} + }{ + \ASEMChild{\ZInconType{\ZMV}}{\ZInconType{\ZMV'}}{\MChildNMV} + } + + \inferrule[AEMInconsistentTypesParent]{ + \ASEMParent{\ZMV}{\ZMV'} + }{ + \ASEMParent{\ZInconType{\ZMV}}{\ZInconType{\ZMV'}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AEMInconsistentBranchesChild1]{ }{ + \ASEMChild{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\ZInconBrC{\ZCursor{\ECMV_1}}{\ECMV_2}{\ECMV_3}}{1} + } + + \inferrule[AEMInconsistentBranchesChild2]{ }{ + \ASEMChild{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\ZInconBrL{\ECMV_1}{\ZCursor{\ECMV_2}}{\ECMV_3}}{2} + } + + \inferrule[AEMInconsistentBranchesChild3]{ }{ + \ASEMChild{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZCursor{\ECMV_3}}}{3} + } \\ + + \inferrule[AEMInconsistentBranchesParent1]{ }{ + \ASEMParent{\ZInconBrC{\ZCursor{\ECMV_1}}{\ECMV_2}{\ECMV_3}}{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } + + \inferrule[AEMInconsistentBranchesParent2]{ }{ + \ASEMParent{\ZInconBrC{\ECMV_1}{\ZCursor{\ECMV_2}}{\ECMV_3}}{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } + + \inferrule[AEMInconsistentBranchesParent3]{ }{ + \ASEMParent{\ZInconBrC{\ECMV_1}{\ECMV_2}{\ZCursor{\ECMV_3}}}{\ECInconBr{\ECMV_1}{\ECMV_2}{\ECMV_3}} + } +\end{mathpar} + +\subsubsection{Synthetic expression actions} +\label{sec:typed-synthetic-expression-actions} +\judgbox{\ensuremath{\ASAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV}}} + +\paragraph{Movement} +\begin{mathpar} + \inferrule[ASEMove]{ + \ASEMove{\ZMV}{\ZMV'}{\MMV} + }{ + \ASMove{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV}{\MMV} + } +\end{mathpar} + +\paragraph{Deletion} +\begin{mathpar} + \inferrule[ASEDel]{ }{ + \ASEDel{\ctx}{\ECMV}{\TMV} + } +\end{mathpar} + +\paragraph{Construction} +\begin{mathpar} + \inferrule[ASEConVar]{ + \inCtx{\ctx}{x}{\TMV} + }{ + \ASCon{\ctx}{\ZCursor{\ECEHole}}{\TUnknown}{\ZCursor{x}}{\TMV}{\SVar{x}} + } + + \inferrule[ASEConFree]{ + \notInCtx{\ctx}{x} + }{ + \ASCon{\ctx}{\ZCursor{\ECEHole}}{\TUnknown}{\ZCursor{\ZFree{x}}}{\TUnknown}{\SVar{x}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEConLam]{ + \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\erase{\ECMV}}{\ECMV'}{\TMV'} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZLamT{x}{\ZTCursor{\TUnknown}}{\ECMV'}}{\TArrow{\TUnknown}{\TMV'}}{\SLam{x}} + } + + \inferrule[ASEConApL1]{ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZApL{\ECInconType{\ECMV}}{\ZCursor{\ECEHole}}}{\TMV_2}{\SApL} + } + + \inferrule[ASEConApL2]{ + \notMatchedArrow{\TMV} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZApL{\ECInconType{\ECMV}}{\ZCursor{\ECEHole}}}{\TUnknown}{\SApL} + } + + \inferrule[ASEConApR]{ }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZApR{\ZCursor{\ECEHole}}{\ECMV}}{\TUnknown}{\SApR} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEConLet1]{ }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZLetL{x}{\ECMV}{\ZCursor{\ECEHole}}}{\TUnknown}{\SLetL{x}} + } + + \inferrule[ASEConLet2]{ + \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\erase{\ECMV}}{\ECMV'}{\TMV'} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZLetR{x}{\ZCursor{\ECEHole}}{\ECMV'}}{\TMV'}{\SLetL{x}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEConNum]{ }{ + \ASCon{\ctx}{\ZCursor{\ECEHole}}{\TUnknown}{\ZCursor{\ENumMV}}{\TNum}{\SLit{\ENumMV}} + } + + \inferrule[ASEConPlusL1]{ + \consistent{\TMV}{\TNum} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZPlusR{\ECMV}{\ZCursor{\ECEHole}}}{\TNum}{\SPlusL} + } + + \inferrule[ASEConPlusL2]{ + \inconsistent{\TMV}{\TNum} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZPlusR{\ECInconType{\ECMV}}{\ZCursor{\ECEHole}}}{\TNum}{\SPlusL} + } \\ + + \inferrule[ASEConPlusR1]{ + \consistent{\TMV}{\TNum} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZPlusL{\ZCursor{\ECEHole}}{\ECMV}}{\TNum}{\SPlusR} + } + + \inferrule[ASEConPlusR2]{ + \inconsistent{\TMV}{\TNum} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZPlusL{\ZCursor{\ECEHole}}{\ECInconType{\ECMV}}}{\TNum}{\SPlusR} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEConIfC1]{ + \consistent{\TMV}{\TBool} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZIfL{\ECMV}{\ZCursor{\ECEHole}}{\ECEHole}}{\TUnknown}{\SIfC} + } + + \inferrule[ASEConIfC2]{ + \inconsistent{\TMV}{\TBool} + }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZIfL{\ECInconType{\ECMV}}{\ZCursor{\ECEHole}}{\ECEHole}}{\TUnknown}{\SIfC} + } + + \inferrule[ASEConIfL]{ }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZIfC{\ZCursor{\ECEHole}}{\ECMV}{\ECEHole}}{\TMV}{\SIfL} + } + + \inferrule[ASEConIfR]{ }{ + \ASCon{\ctx}{\ZCursor{\ECMV}}{\TMV}{\ZIfC{\ZCursor{\ECEHole}}{\ECEHole}{\ECMV}}{\TMV}{\SIfR} + } +\end{mathpar} + +\paragraph{Zipper Cases} +\begin{mathpar} + \inferrule[ASEZipLamT1]{ + \AUTAction{\ZTMV_1}{\ZTMV_1'}{\AMV} \\ + \equal{\cursorErase{\ZTMV_1}}{\cursorErase{\ZTMV_1'}} + }{ + \ASEAction{\ctx}{\ZLamT{x}{\ZTMV_1}{\ECMV}}{\TArrow{\cursorErase{\ZTMV_1}}{\TMV_2}}{\ZLamT{x}{\ZTMV_1'}{\ECMV}}{\TArrow{\cursorErase{\ZTMV_1}}{\TMV_2}}{\AMV} + } + + \inferrule[ASEZipLamT2]{ + \AUTAction{\ZTMV_1}{\ZTMV_1'}{\AMV} \\ + \notEqual{\cursorErase{\ZTMV_1}}{\cursorErase{\ZTMV_1'}} \\ + \ctxSynFixedInto{\extendCtx{\ctx}{x}{\cursorErase{\ZTMV_1'}}}{\erase{\ECMV}}{\ECMV'}{\TMV_2'} + }{ + \ASEAction{\ctx}{\ZLamT{x}{\ZTMV_1}{\ECMV}}{\TArrow{\cursorErase{\ZTMV_1}}{\TMV_2}}{\ZLamT{x}{\ZTMV_1'}{\ECMV'}}{\TArrow{\cursorErase{\ZTMV_1'}}{\TMV_2'}}{\AMV} + } + + \inferrule[ASEZipLamE]{ + \ASEAction{\extendCtx{\ctx}{x}{\TMV_1}}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} + }{ + \ASEAction{\ctx}{\ZLamE{x}{\TMV_1}{\ZMV}}{\TArrow{\TMV_1}{\TMV_2}}{\ZLamE{x}{\TMV_1}{\ZMV'}}{\TArrow{\ZTMV_1}{\TMV_2'}}{\AMV} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEZipApL1]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ + \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ + \ctxAnaType{\ctx}{\ECMV_2}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZApL{\ZMV_1}{\ECMV_2}}{\TMV}{\ZApL{\ZMV_1'}{\ECMV_2}}{\TMV_3}{\AMV} + } + + \inferrule[ASEZipApL2]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ + \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ + \ctxNotAnaType{\ctx}{\ECMV_2}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZApL{\ZMV_1}{\ECMV_2}}{\TMV}{\ZApL{\ZMV_1'}{\ECInconType{\ECMV_2}}}{\TMV_3}{\AMV} + } + + \inferrule[ASEZipApL3]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\\\ + \notMatchedArrow{\TMV_1'} + }{ + \ASEAction{\ctx}{\ZApL{\ZMV_1}{\ECMV_2}}{\TMV}{\ZApL{\ECInconType{\ZMV_1'}}{\ECMV_2}}{\TUnknown}{\AMV} + } + + \inferrule[ASEZipApL4]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ + \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ + \ctxAnaType{\ctx}{\ECMV_2}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZApL{\ECInconType{\ZMV_1}}{\ECMV_2}}{\TUnknown}{\ZApL{\ZMV_1'}{\ECMV_2}}{\TMV_3}{\AMV} + } + + \inferrule[ASEZipApL5]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ + \matchedArrow{\TMV_1'}{\TMV_2}{\TMV_3} \\ + \ctxNotAnaType{\ctx}{\ECMV_2}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZApL{\ECInconType{\ZMV_1}}{\ECMV_2}}{\TUnknown}{\ZApL{\ZMV_1'}{\ECInconType{\ECMV_2}}}{\TMV_3}{\AMV} + } + + \inferrule[ASEZipApL6]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ + \notMatchedArrow{\TMV_1'} + }{ + \ASEAction{\ctx}{\ZApL{\ECInconType{\ZMV_1}}{\ECMV_2}}{\TUnknown}{\ZApL{\ECInconType{\ZMV_1'}}{\ECMV_2}}{\TUnknown}{\AMV} + } + + \inferrule[ASEZipApR]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \matchedArrow{\TMV_1}{\TMV_2}{\TMV_3} \\ + \AAEAction{\ctx}{\ZMV_2}{\ZMV_2'}{\TMV_2}{\AMV} + }{ + \ASEAction{\ctx}{\ZApR{\ECMV_1}{\ZMV_2}}{\TMV}{\ZApR{\ECMV_1}{\ZMV_2'}}{\TMV_3}{\AMV} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEZipLetL1]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\ + \consistent{\TMV_1}{\TMV_1'} + }{ + \ASEAction{\ctx}{\ZLetL{x}{\ZMV_1}{\ECMV_2}}{\TMV_2}{\ZLetL{x}{\ZMV_1'}{\ECMV_2}}{\TMV_2}{\AMV} + } + + \inferrule[ASEZipLetL2]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV_1}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV_1}{\TMV_1}{\ZMV_1'}{\TMV_1'}{\AMV} \\\\ + \inconsistent{\TMV_1}{\TMV_1'} \\ + \ctxSynFixedInto{\extendCtx{\ctx}{x}{\TMV_1'}}{\erase{\ECMV_2}}{\ECMV_2'}{\TMV_2'} + }{ + \ASEAction{\ctx}{\ZLetL{x}{\ZMV_1}{\ECMV_2}}{\TMV_2}{\ZLetL{x}{\ZMV_1'}{\ECMV_2'}}{\TMV_2'}{\AMV} + } + + \inferrule[ASEZipLetR]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \ctxSynTypeM{\extendCtx{\ctx}{x}{\TMV_1}}{\cursorErase{\ZMV_2}}{\TMV_2} \\\\ + \ASEAction{\extendCtx{\ctx}{x}{\TMV_1}}{\ZMV_2}{\TMV_2}{\ZMV_2'}{\TMV_2'}{\AMV} + }{ + \ASEAction{\ctx}{\ZLetR{x}{\ECMV_1}{\ZMV_2}}{\TMV_2}{\ZLetR{x}{\ECMV_1}{\ZMV_2'}}{\TMV_2'}{\AMV} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEZipPlusL]{ + \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TNum}{\AMV} + }{ + \ASEAction{\ctx}{\ZPlusL{\ZMV}{\ECMV}}{\TNum}{\ZPlusL{\ZMV'}{\ECMV}}{\TNum}{\AMV} + } + + \inferrule[ASEZipPlusR]{ + \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TNum}{\AMV} + }{ + \ASEAction{\ctx}{\ZPlusR{\ECMV}{\ZMV}}{\TNum}{\ZPlusR{\ECMV}{\ZMV'}}{\TNum}{\AMV} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEZipIfC]{ + \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TBool}{\AMV} + }{ + \ASEAction{\ctx}{\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2}}{\TMV}{\ZIfC{\ZMV'}{\ECMV_1}{\ECMV_2}}{\TMV}{\AMV} + } + + \inferrule[ASEZipIfL1]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\\\ + \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ + \consistent{\TMV_1'}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZIfL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TMeet{\TMV_1'}{\TMV_2}}{\AMV} + } + + \inferrule[ASEZipIfL2]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\\\ + \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ + \inconsistent{\TMV_1'}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZInconBrL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TUnknown}{\AMV} + } + + \inferrule[ASEZipIfR1]{ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_2} \\\\ + \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ + \consistent{\TMV_1}{\TMV_2'} + }{ + \ASEAction{\ctx}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TMeet{\TMV_1}{\TMV_2'}}{\AMV} + } + + \inferrule[ASEZipIfR2]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_2} \\\\ + \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ + \inconsistent{\TMV_1}{\TMV_2'} + }{ + \ASEAction{\ctx}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TUnknown}{\AMV} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[ASEZipInconsistentBranchesC]{ + \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TBool}{\AMV} + }{ + \ASEAction{\ctx}{\ZInconBrC{\ZMV}{\ECMV_1}{\ECMV_2}}{\TMV}{\ZInconBrC{\ZMV'}{\ECMV_1}{\ECMV_2}}{\TMV}{\AMV} + } + + \inferrule[ASEZipInconsistentBranchesL1]{ + \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\ + \consistent{\TMV_1'}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZIfL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TMeet{\TMV_1'}{\TMV_2}}{\AMV} + } + + \inferrule[ASEZipInconsistentBranchesL2]{ + \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_2} \\ + \inconsistent{\TMV_1'}{\TMV_2} + }{ + \ASEAction{\ctx}{\ZInconBrL{\ECMV_1}{\ZMV}{\ECMV_2}}{\TMV}{\ZInconBrL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TUnknown}{\AMV} + } + + \inferrule[ASEZipInconsistentBranchesR1]{ + \ctxSynTypeM{\ctx}{\ECMV_1}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ + \consistent{\TMV_1}{\TMV_2'} + }{ + \ASEAction{\ctx}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZIfL{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TMeet{\TMV_1}{\TMV_2'}}{\AMV} + } + + \inferrule[ASEZipInconsistentBranchesR2]{ + \ctxSynTypeM{\ctx}{\ECMV_2}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV}{\TMV_2}{\ZMV'}{\TMV_2'}{\AMV} \\ + \inconsistent{\TMV_1}{\TMV_2'} + }{ + \ASEAction{\ctx}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV}}{\TMV}{\ZInconBrR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TUnknown}{\AMV} + } +\end{mathpar} + +\subsubsection{Analytic expression actions} +\label{sec:typed-analytic-expression-actions} +\judgbox{\ensuremath{\AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV'}{\AMV}}} + +\paragraph{Subsumption} +\begin{mathpar} + \inferrule[AAESubsume1]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ + \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ + \consistent{\TMV}{\TMV''} \\ + \subsumable{\cursorErase{\ZMV}} + }{ + \AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV} + } + + \inferrule[AAESubsume2]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ + \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ + \inconsistent{\TMV}{\TMV''} \\ + \subsumable{\cursorErase{\ZMV}} + }{ + \AAAction{\ctx}{\ZMV}{\ZInconType{\ZMV'}}{\TMV}{\AMV} + } + + \inferrule[AAEInconsistentTypes1]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ + \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ + \inconsistent{\TMV}{\TMV''} \\ + \subsumable{\cursorErase{\ZMV}} + }{ + \AAAction{\ctx}{\ZInconType{\ZMV}}{\ZInconType{\ZMV'}}{\TMV}{\AMV} + } + + \inferrule[AAEInconsistentTypes2]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV'} \\ + \ASAction{\ctx}{\ZMV}{\TMV'}{\ZMV'}{\TMV''}{\AMV} \\\\ + \consistent{\TMV}{\TMV''} \\ + \subsumable{\cursorErase{\ZMV}} + }{ + \AAAction{\ctx}{\ZInconType{\ZMV}}{\ZMV'}{\TMV}{\AMV} + } +\end{mathpar} + +\paragraph{Movement} +\begin{mathpar} + \inferrule[AAEMove]{ + \ASEMove{\ZMV}{\ZMV'}{\MMV} + }{ + \AAMove{\ctx}{\ZMV}{\ZMV'}{\TMV}{\MMV} + } +\end{mathpar} + +\paragraph{Deletion} +\begin{mathpar} + \inferrule[AAEDel]{ }{ + \AAEDel{\ctx}{\ECMV}{\TMV} + } +\end{mathpar} + +\paragraph{Construction} +\begin{mathpar} + \inferrule[AAEConLam1]{ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\ECMV}{\ECMV'}{\TMV_2} + }{ + \AACon{\ctx}{\ZCursor{\ECMV}}{\ZLamT{x}{\ZTCursor{\TMV_1}}{\ECMV'}}{\TMV}{\SLam{x}} + } + + \inferrule[AAEConLam2]{ + \notMatchedArrow{\TMV} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\ECMV}{\ECMV'}{\TUnknown} + }{ + \AACon{\ctx}{\ZCursor{\ECMV}}{\ZInconType{\ZLamT{x}{\ZTCursor{\TUnknown}}{\ECMV'}}}{\TMV}{\SLam{x}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AAEConLetL]{ }{ + \AACon{\ctx}{\ZCursor{\ECMV}}{\ZLetL{x}{\ECMV}{\ZCursor{\ECEHole}}}{\TMV}{\SLetL{x}} + } + + \inferrule[AAEConLetR]{ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TUnknown}}{\erase{\ECMV}}{\ECMV'}{\TMV} + }{ + \AACon{\ctx}{\ZCursor{\ECMV}}{\ZLetR{x}{\ZCursor{\ECEHole}}{\ECMV'}}{\TMV}{\SLetR{x}} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AAEConIfL]{ }{ + \AACon{\ctx}{\ZCursor{\ECMV}}{\ZIfC{\ZCursor{\ECEHole}}{\ECMV}{\ECEHole}}{\TMV}{\SIfL} + } + + \inferrule[AAEConIfR]{ + }{ + \AACon{\ctx}{\ZCursor{\ECMV}}{\ZIfC{\ZCursor{\ECEHole}}{\ECEHole}{\ECMV}}{\TMV}{\SIfR} + } +\end{mathpar} + +\paragraph{Zipper Cases} +\begin{mathpar} + \inferrule[AAEZipLamT1]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ + \consistent{\cursorErase{\ZTMV}}{\cursorErase{\ZTMV'}} + }{ + \AAAction{\ctx}{\ZLamT{x}{\ZTMV}{\ECMV}}{\ZLamT{x}{\ZTMV'}{\ECMV}}{\TMV}{\AMV} + } + + \inferrule[AAEZipLamT2]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ + \inconsistent{\cursorErase{\ZTMV}}{\cursorErase{\ZTMV'}} \\ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\\\ + \consistent{\cursorErase{\ZTMV'}}{\TMV_1} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\cursorErase{\ZTMV'}}}{\erase{\ECMV}}{\ECMV'}{\TMV_2} + }{ + \AAAction{\ctx}{\ZLamT{x}{\ZTMV}{\ECMV}}{\ZLamT{x}{\ZTMV'}{\ECMV'}}{\TMV}{\AMV} + } + + \inferrule[AAEZipLamT3]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ + \inconsistent{\cursorErase{\ZTMV}}{\cursorErase{\ZTMV'}} \\ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\\\ + \inconsistent{\cursorErase{\ZTMV'}}{\TMV_1} \\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1}}{\erase{\ECMV}}{\ECMV'}{\TMV_2} + }{ + \AAAction{\ctx}{\ZLamT{x}{\ZTMV}{\ECMV}}{\ZInconType{\ZLamT{x}{\ZTMV'}{\ECMV'}}}{\TMV}{\AMV} + } + + \inferrule[AAEZipLamE]{ + \matchedArrow{\TMV}{\TMV_1}{\TMV_2} \\ + \AAAction{\extendCtx{\ctx}{x}{\TMV_3}}{\ZMV}{\ZMV'}{\TMV_2}{\AMV} + }{ + \AAAction{\ctx}{\ZLamE{x}{\TMV_3}{\ZMV}}{\ZLamE{x}{\TMV_3}{\ZMV'}}{\TMV}{\AMV} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AAEZipLetL1]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\ + \consistent{\TMV_1}{\TMV_1'} + }{ + \AAAction{\ctx}{\ZLetL{x}{\ZMV}{\ECMV}}{\ZLetL{x}{\ZMV'}{\ECMV}}{\TMV}{\AMV} + } + + \inferrule[AAEZipLetL2]{ + \ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV_1} \\ + \ASEAction{\ctx}{\ZMV}{\TMV_1}{\ZMV'}{\TMV_1'}{\AMV} \\\\ + \ctxAnaFixedInto{\extendCtx{\ctx}{x}{\TMV_1'}}{\erase{\ECMV}}{\ECMV'}{\TMV} + }{ + \AAAction{\ctx}{\ZLetL{x}{\ZMV}{\ECMV}}{\ZLetL{x}{\ZMV'}{\ECMV'}}{\TMV}{\AMV} + } + + \inferrule[AAEZipLetR]{ + \ctxSynTypeM{\ctx}{\ECMV}{\TMV'} \\ + \AAAction{\extendCtx{\ctx}{x}{\TMV'}}{\ZMV}{\ZMV'}{\TMV}{\AMV} + }{ + \AAAction{\ctx}{\ZLetR{x}{\ECMV}{\ZMV}}{\ZLetL{x}{\ECMV}{\ZMV'}}{\TMV}{\AMV} + } +\end{mathpar} + +\begin{mathpar} + \inferrule[AAEZipIfC]{ + \AAAction{\ctx}{\ZMV}{\ZMV'}{\TBool}{\AMV} + }{ + \AAAction{\ctx}{\ZIfC{\ZMV}{\ECMV_1}{\ECMV_2}}{\ZIfC{\ZMV'}{\ECMV_1}{\ECMV_2}}{\TMV}{\AMV} + } + + \inferrule[AAEZipIfL]{ + \AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV} + }{ + \AAAction{\ctx}{\ZIfL{\ECMV_1}{\ZMV}{\ECMV_2}}{\ZIfL{\ECMV_1}{\ZMV'}{\ECMV_2}}{\TMV}{\AMV} + } + + \inferrule[AAEZipIfR]{ + \AAAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV} + }{ + \AAAction{\ctx}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV}}{\ZIfR{\ECMV_1}{\ECMV_2}{\ZMV'}}{\TMV}{\AMV} + } +\end{mathpar} + +\subsubsection{Iterated actions} +\label{sec:typed-iterated-actions} +The iterated type action and movements judgments are the same as in the untyped model. \\ + +\judgbox{\ensuremath{\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AIMV}}} +% +\begin{mathpar} + \inferrule[ASEIRefl]{ }{ + \ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV}{\TMV}{\AINil} + } + + \inferrule[ASEIExp]{ + \ASEAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV} \\ + \ASEActionIter{\ctx}{\ZMV'}{\TMV'}{\ZMV''}{\TMV''}{\AIMV} + }{ + \ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV''}{\TMV''}{\AICons{\AMV}{\AIMV}} + } +\end{mathpar} + +\judgbox{\ensuremath{\AAEActionIter{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AIMV}}} +% +\begin{mathpar} + \inferrule[AAEIRefl]{ }{ + \AAEActionIter{\ctx}{\ZMV}{\ZMV}{\TMV}{\AINil} + } + + \inferrule[AAEIExp]{ + \AAEAction{\ctx}{\ZMV}{\ZMV'}{\TMV'}{\AMV} \\ + \AAEActionIter{\ctx}{\ZMV'}{\ZMV''}{\TMV''}{\AIMV} + }{ + \AAEActionIter{\ctx}{\ZMV}{\ZMV''}{\TMV''}{\AICons{\AMV}{\AIMV}} + } +\end{mathpar} + +\subsection{Metatheorems} +\label{sec:typed-metatheorems} +\begin{theorem}[name=Sensibility] \ + \begin{enumerate} + \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\ASEAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV}$, then $\zWellFormed{\ZMV'}$ and + $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV'}}{\TMV'}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\AAEAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV}$, then $\zWellFormed{\ZMV'}$ and + $\ctxAnaType{\ctx}{\cursorErase{\ZMV'}}{\TMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Movement Erasure Invariance] \ + \begin{enumerate} + \item If $\AUTAction{\ZTMV}{\ZTMV'}{\AMove{\MMV}}$, then $\cursorErase{\ZTMV} = + \cursorErase{\ZTMV'}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\ASEAction{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMove{\MMV}}$, then $\zWellFormed{\ZMV'}$ and + $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$ and $\equal{\TMV}{\TMV'}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\AAEAction{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMove{\MMV}}$, then $\zWellFormed{\ZMV'}$ and + $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Reachability] \ + \begin{enumerate} + \item If $\cursorErase{\ZTMV} = \cursorErase{\ZTMV'}$, then there exists $\AIMV$ such that + $\movements{\AIMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV'}{\AIMV}$. + + \item If $\zWellFormed{\ZMV}$ and $\zWellFormed{\ZMV'}$ and + $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$, + then there exists $\AIMV$ such that $\movements{\AIMV}$ and + $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV}{\AIMV}$. + + \item If $\zWellFormed{\ZMV}$ and $\zWellFormed{\ZMV'}$ and + $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$, + then there exists $\AIMV$ such that $\movements{\AIMV}$ and + $\AAEActionIter{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AIMV}$. + \end{enumerate} +\end{theorem} + +\begin{lemma}[name=Reach Up] \ + \begin{enumerate} + \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ + and $\AUTActionIter{\ZTMV}{\ZTCursor{\TMV}}{\AIMV}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and + $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZTCursor{\ECMV}}{\TMV}{\AIMV}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and + $\AAEActionIter{\ctx}{\ZMV}{\ZTCursor{\ECMV}}{\TMV}{\AIMV}$. + \end{enumerate} +\end{lemma} + +\begin{lemma}[name=Reach Down] \ + \begin{enumerate} + \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ + and $\AUTActionIter{\ZTCursor{\TMV}}{\ZTMV}{\AIMV}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and + $\ASEActionIter{\ctx}{\ZTCursor{\ECMV}}{\TMV}{\ZMV}{\TMV}{\AIMV}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\cursorErase{\ZMV} = \ECMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ and + $\AAEActionIter{\ctx}{\ZTCursor{\ECMV}}{\ZMV}{\TMV}{\AIMV}$. + \end{enumerate} +\end{lemma} + +\begin{theorem}[name=Constructability] \ + \begin{enumerate} + \item For every $\TMV$, there exists $\AIMV$ such that + $\AUTActionIter{\ZTCursor{\TUnknown}}{\ZTCursor{\TMV}}{\AIMV}$. + + \item If $\ctxSynTypeM{\ctx}{\ECMV}{\TMV}$, then there exists $\AIMV$ such that + $\ASEActionIter{\ctx}{\ZCursor{\EEHole}}{\TUnknown}{\ZCursor{\ECMV}}{\TMV}{\AIMV}$. + + \item If $\ctxAnaType{\ctx}{\ECMV}{\TMV}$, then there exists $\AIMV$ such that + $\AAEActionIter{\ctx}{\ZCursor{\EEHole}}{\ZCursor{\ECMV}}{\TMV}{\AIMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Determinism] \ + \begin{enumerate} + \item If $\AUTActionIter{\ZTMV}{\ZTMV'}{\AMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV''}{\AMV}$, then + $\ZTMV' = \ZTMV''$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxSynTypeM{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV'}{\TMV'}{\AMV}$ and + $\ASEActionIter{\ctx}{\ZMV}{\TMV}{\ZMV''}{\TMV''}{\AMV}$, then $\ZMV' = \ZMV''$ and + $\equal{\TMV'}{\TMV''}$. + + \item If $\zWellFormed{\ZMV}$ and $\ctxAnaType{\ctx}{\cursorErase{\ZMV}}{\TMV}$ and + $\AAEActionIter{\ctx}{\ZMV}{\ZMV'}{\TMV}{\AMV}$ and + $\AAEActionIter{\ctx}{\ZMV}{\ZMV''}{\TMV}{\AMV}$, then $\ZMV' = \ZMV''$. + \end{enumerate} +\end{theorem} + +\end{document} diff --git a/supplement/untyped.tex b/supplement/untyped.tex new file mode 100644 index 0000000..a9300d5 --- /dev/null +++ b/supplement/untyped.tex @@ -0,0 +1,713 @@ +\documentclass[supplement.tex]{subfiles} + +\begin{document} + +\section{Untyped hazelnut} +\label{sec:untyped} + +\subsection{Syntax} +\label{sec:untyped-syntax} +\[\begin{array}{rrcl} + \ZTMName & \ZTMV & \Coloneqq & \ZTCursor{\TMV} \mid \ZTArrowL{\ZTMV}{\TMV} \mid \ZTArrowR{\TMV}{\ZTMV} \mid \ZTProdL{\ZTMV}{\TMV} \mid \ZTProdR{\TMV}{\ZTMV} \\ + \ZMName & \ZMV & \Coloneqq & \ZCursor{\EMV} \mid \ZLamT{x}{\ZTMV}{\EMV} \mid \ZLamE{x}{\TMV}{\ZMV} \mid \ZApL{\ZMV}{\EMV} \mid \ZApR{\EMV}{\ZMV} \\ + & & \mid & \ZLetL{x}{\ZMV}{\EMV} \mid \ZLetR{x}{\EMV}{\ZMV} \\ + & & \mid & \ZPlusL{\ZMV}{\EMV} \mid \ZPlusR{\EMV}{\ZMV} \\ + & & \mid & \ZIfC{\ZMV}{\EMV}{\EMV} \mid \ZIfL{\EMV}{\ZMV}{\EMV} \mid \ZIfR{\EMV}{\EMV}{\ZMV} \\ + & & \mid & \ZPairL{\ZMV}{\EMV} \mid \ZPairR{\EMV}{\ZMV} \mid \ZProjL{\ZMV} \mid \ZProjR{\ZMV} \\ +\end{array}\] + +\subsection{Cursor erasure} +\label{sec:untyped-cursor-erasure} + +\subsubsection{Type cursor erasure} +\label{sec:untyped-type-cursor-erasure} +\judgbox{\ensuremath{\cursorErase{\ZTMV}}} is a metafunction defined as follows: +% +\newcommand{\cursorErasesToRow}[2]{\ensuremath{\cursorErase{#1} & = & #2}} +\[\begin{array}{rcl} + \cursorErasesToRow{\ZTCursor{\TMV}}{\TMV} \\ + \cursorErasesToRow{(\ZTArrowL{\ZTMV}{\TMV})}{\TArrow{\cursorErase{\ZTMV}}{\TMV}} \\ + \cursorErasesToRow{(\ZTArrowR{\TMV}{\ZTMV})}{\TArrow{\TMV}{\cursorErase{\ZTMV}}} \\ + \cursorErasesToRow{(\ZTProdL{\ZTMV}{\TMV})}{\TProd{\cursorErase{\ZTMV}}{\TMV}} \\ + \cursorErasesToRow{(\ZTProdR{\TMV}{\ZTMV})}{\TProd{\TMV}{\cursorErase{\ZTMV}}} \\ +\end{array}\] + +\subsubsection{Expression cursor erasure} +\label{sec:untyped-expression-cursor-erasure} +\judgbox{\ensuremath{\cursorErase{\ZMV}}} is a metafunction defined as follows: +% +\[\begin{array}{rcl} + \cursorErasesToRow{\ZCursor{\EMV}}{\EMV} \\ + \cursorErasesToRow{(\ZLamT{x}{\ZTMV}{\EMV})}{\ELam{x}{\cursorErase{\ZTMV}}{\EMV}} \\ + \cursorErasesToRow{(\ZLamE{x}{\TMV}{\ZMV})}{\ELam{x}{\TMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZApL{\ZMV}{\EMV})}{\EAp{\cursorErase{\ZMV}}{\EMV}} \\ + \cursorErasesToRow{(\ZApR{\EMV}{\ZMV})}{\EAp{\EMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZLetL{x}{\ZMV}{\EMV})}{\ELet{x}{\cursorErase{\ZMV}}{\EMV}} \\ + \cursorErasesToRow{(\ZLetR{x}{\EMV}{\ZMV})}{\ELet{x}{\EMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZPlusL{\ZMV}{\EMV})}{\EPlus{\cursorErase{\ZMV}}{\EMV}} \\ + \cursorErasesToRow{(\ZPlusR{\EMV}{\ZMV})}{\EPlus{\EMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZIfC{\ZMV}{\EMV_1}{\EMV_2})}{\EIf{\cursorErase{\ZMV}}{\EMV_1}{\EMV_2}} \\ + \cursorErasesToRow{(\ZIfL{\EMV_1}{\ZMV}{\EMV_2})}{\EIf{\EMV_1}{\cursorErase{\ZMV}}{\EMV_2}} \\ + \cursorErasesToRow{(\ZIfL{\EMV_1}{\EMV_2}{\ZMV})}{\EIf{\EMV_1}{\EMV_2}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZPairL{\ZMV}{\EMV})}{\EPair{\cursorErase{\ZMV}}{\EMV}} \\ + \cursorErasesToRow{(\ZPairR{\EMV}{\ZMV})}{\EPair{\EMV}{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZProjL{\ZMV})}{\EProjL{\cursorErase{\ZMV}}} \\ + \cursorErasesToRow{(\ZProjR{\ZMV})}{\EProjR{\cursorErase{\ZMV}}} \\ +\end{array}\] + +\subsection{Action model} +\label{sec:untyped-action-model} +\[\begin{array}{rrcl} + \AMName & \AMV & \Coloneqq & \AMove{\MMV} \mid \ACon{\SMV} \mid \ADel \\ + \AIMName & \AIMV & \Coloneqq & \AINil \mid \AICons{\AMV}{\AIMV} \\ + \MMName & \MMV & \Coloneqq & \MChild{\MChildNMV} \mid \MParent \\ + \SMName & \SMV & \Coloneqq & \STArrowL \mid \STArrowR \mid \STProdL \mid \STProdR \mid \STNum \mid \STBool \\ + & & \mid & \SVar{x} \mid \SLam{x} \mid \SApL \mid \SApR \\ + & & \mid & \SLetL{x} \mid \SLetR{x} \\ + & & \mid & \SLit{n} \mid \SPlusL \mid \SPlusR \\ + & & \mid & \STrue \mid \SFalse \mid \SIfC \mid \SIfL \mid \SIfR \\ + & & \mid & \SPairL \mid \SPairR \mid \SProjL \mid \SProjR +\end{array}\] + +\subsubsection{Shape sort} +\label{sec:untyped-shape-sort} +\judgbox{\ensuremath{\tshape{\SMV}}} $\SMV$ is a shape on types +% +\begin{mathpar} + \inferrule[ASortArrow1]{ }{ + \tshape{\STArrowL} + } + + \inferrule[ASortArrow2]{ }{ + \tshape{\STArrowR} + } + + \inferrule[ASortProd1]{ }{ + \tshape{\STProdL} + } + + \inferrule[ASortProd2]{ }{ + \tshape{\STProdR} + } + + \inferrule[ASortNum]{ }{ + \tshape{\STNum} + } + + \inferrule[ASortBool]{ }{ + \tshape{\STBool} + } +\end{mathpar} + +\judgbox{\ensuremath{\eshape{\SMV}}} $\SMV$ is a shape on expressions +% +\begin{mathpar} + \inferrule[ASortVar]{ }{ + \eshape{\SVar{x}} + } + + \inferrule[ASortLam]{ }{ + \eshape{\SLam{x}} + } + + \inferrule[ASortAp1]{ }{ + \eshape{\SApL} + } + + \inferrule[ASortAp2]{ }{ + \eshape{\SApR} + } + + \inferrule[ASortLet1]{ }{ + \eshape{\SLetL{x}} + } + + \inferrule[ASortLet2]{ }{ + \eshape{\SLetR{x}} + } + + \inferrule[ASortLit]{ }{ + \eshape{\SLit{n}} + } + + \inferrule[ASortPlus1]{ }{ + \eshape{\SPlusL} + } + + \inferrule[ASortPlus2]{ }{ + \eshape{\SPlusR} + } + + \inferrule[ASortTrue]{ }{ + \eshape{\STrue} + } + + \inferrule[ASortFalse]{ }{ + \eshape{\SFalse} + } + + \inferrule[ASortIf1]{ }{ + \eshape{\SIfC} + } + + \inferrule[ASortIf2]{ }{ + \eshape{\SIfL} + } + + \inferrule[ASortIf3]{ }{ + \eshape{\SIfR} + } + + \inferrule[ASortPairL]{ }{ + \eshape{\SPairL} + } + + \inferrule[ASortPairR]{ }{ + \eshape{\SPairR} + } + + \inferrule[ASortProjL]{ }{ + \eshape{\SProjL} + } + + \inferrule[ASortProjR]{ }{ + \eshape{\SProjR} + } +\end{mathpar} + +\subsubsection{Type actions} +\label{sec:untyped-type-actions} +\judgbox{\ensuremath{\AUTAction{\ZTMV}{\ZTMV'}{\AMV}}} + +\paragraph{Movement} +\begin{mathpar} + \inferrule[ATMArrChild1]{ }{ + \AUTMArrowChildL{\TMV_1}{\TMV_2} + } + + \inferrule[ATMArrChild2]{ }{ + \AUTMArrowChildR{\TMV_1}{\TMV_2} + } + + \inferrule[ATMArrParent1]{ }{ + \AUTMArrowParentL{\TMV_1}{\TMV_2} + } + + \inferrule[ATMArrParent2]{ }{ + \AUTMArrowParentR{\TMV_1}{\TMV_2} + } + + \inferrule[ATMProdChild1]{ }{ + \AUTMProdChildL{\TMV_1}{\TMV_2} + } + + \inferrule[ATMProdChild2]{ }{ + \AUTMProdChildR{\TMV_1}{\TMV_2} + } + + \inferrule[ATMProdParent1]{ }{ + \AUTMProdParentL{\TMV_1}{\TMV_2} + } + + \inferrule[ATMProdParent2]{ }{ + \AUTMProdParentR{\TMV_1}{\TMV_2} + } +\end{mathpar} + +\paragraph{Deletion} +\begin{mathpar} + \inferrule[ATDel]{ }{ + \AUTDel{\TMV} + } +\end{mathpar} + +\paragraph{Construction} +\begin{mathpar} + \inferrule[ATConArrow1]{ }{ + \AUTConArrowL{\TMV} + } + + \inferrule[ATConArrow2]{ }{ + \AUTConArrowR{\TMV} + } + + \inferrule[ATConProd1]{ }{ + \AUTConProdL{\TMV} + } + + \inferrule[ATConProd2]{ }{ + \AUTConProdR{\TMV} + } + + \inferrule[ATConNum]{ }{ + \AUTConNum + } + + \inferrule[ATConBool]{ }{ + \AUTConBool + } +\end{mathpar} + +\paragraph{Zipper Cases} +\begin{mathpar} + \inferrule[ATZipArr1]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} + }{ + \AUTAction{\ZTArrowL{\ZTMV}{\TMV}}{\ZTArrowL{\ZTMV'}{\TMV}}{\AMV} + } + + \inferrule[ATZipArr2]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} + }{ + \AUTAction{\ZTArrowR{\TMV}{\ZTMV}}{\ZTArrowR{\TMV}{\ZTMV'}}{\AMV} + } + + \inferrule[ATZipProd1]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} + }{ + \AUTAction{\ZTProdL{\ZTMV}{\TMV}}{\ZTProdL{\ZTMV'}{\TMV}}{\AMV} + } + + \inferrule[ATZipProd2]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} + }{ + \AUTAction{\ZTProdR{\TMV}{\ZTMV}}{\ZTProdR{\TMV}{\ZTMV'}}{\AMV} + } +\end{mathpar} + +\subsubsection{Expression movement} +\label{sec:untyped-expression-movement} +\judgbox{\ensuremath{\AUEMove{\ZMV}{\ZMV'}{\MMV}}} +% +\begin{mathpar} + \inferrule[AEMLamChild1]{ }{ + \AUEMLamChildT{x}{\TMV}{\EMV} + } + + \inferrule[AEMLamChild2]{ }{ + \AUEMLamChildE{x}{\TMV}{\EMV} + } \\ + + \inferrule[AEMLamParent1]{ }{ + \AUEMLamParentT{x}{\TMV}{\EMV} + } + + \inferrule[AEMLamParent2]{ }{ + \AUEMLamParentE{x}{\TMV}{\EMV} + } \\ + + \inferrule[AEMApChild1]{ }{ + \AUEMApChildL{\EMV_1}{\EMV_2} + } + + \inferrule[AEMApChild2]{ }{ + \AUEMApChildR{\EMV_1}{\EMV_2} + } \\ + + \inferrule[AEMApParent1]{ }{ + \AUEMApParentL{\EMV_1}{\EMV_2} + } + + \inferrule[AEMApParent2]{ }{ + \AUEMApParentR{\EMV_1}{\EMV_2} + } \\ + + \inferrule[AEMLetChild1]{ }{ + \AUEMLetChildL{x}{\EMV_1}{\EMV_2} + } + + \inferrule[AEMLetChild2]{ }{ + \AUEMLetChildR{x}{\EMV_1}{\EMV_2} + } \\ + + \inferrule[AEMLetParent1]{ }{ + \AUEMLetParentL{x}{\EMV_1}{\EMV_2} + } + + \inferrule[AEMLetParent2]{ }{ + \AUEMLetParentR{x}{\EMV_1}{\EMV_2} + } \\ + + \inferrule[AEMPlusChild1]{ }{ + \AUEMPlusChildL{\EMV_1}{\EMV_2} + } + + \inferrule[AEMPlusChild2]{ }{ + \AUEMPlusChildR{\EMV_1}{\EMV_2} + } \\ + + \inferrule[AEMPlusParent1]{ }{ + \AUEMPlusParentL{\EMV_1}{\EMV_2} + } + + \inferrule[AEMPlusParent2]{ }{ + \AUEMPlusParentR{\EMV_1}{\EMV_2} + } \\ + + \inferrule[AEMIfChild1]{ }{ + \AUEMIfChildC{\EMV_1}{\EMV_2}{\EMV_3} + } + + \inferrule[AEMIfChild2]{ }{ + \AUEMIfChildL{\EMV_1}{\EMV_2}{\EMV_3} + } + + \inferrule[AEMIfChild3]{ }{ + \AUEMIfChildR{\EMV_1}{\EMV_2}{\EMV_3} + } + + \inferrule[AEMIfParent1]{ }{ + \AUEMIfParentC{\EMV_1}{\EMV_2}{\EMV_3} + } + + \inferrule[AEMIfParent2]{ }{ + \AUEMIfParentL{\EMV_1}{\EMV_2}{\EMV_3} + } + + \inferrule[AEMIfParent3]{ }{ + \AUEMIfParentR{\EMV_1}{\EMV_2}{\EMV_3} + } \\ + + \inferrule[AEMPairChild1]{ }{ + \AUEMPairChildL{\EMV_1}{\EMV_2} + } + + \inferrule[AEMPairChild2]{ }{ + \AUEMPairChildR{\EMV_1}{\EMV_2} + } \\ + + \inferrule[AEMPairParent1]{ }{ + \AUEMPairParentL{\EMV_1}{\EMV_2} + } + + \inferrule[AEMPairParent2]{ }{ + \AUEMPairParentR{\EMV_1}{\EMV_2} + } + + \inferrule[AEMProjLChild]{ }{ + \AUEMProjLChild{\EMV_1} + } + + \inferrule[AEMProjLParent]{ }{ + \AUEMProjLParent{\EMV_1} + } + + \inferrule[AEMProjRChild]{ }{ + \AUEMProjRChild{\EMV_1} + } + + \inferrule[AEMProjRParent]{ }{ + \AUEMProjRParent{\EMV_1} + } +\end{mathpar} + +\subsubsection{Expression actions} +\label{sec:untyped-expression-actions} +\judgbox{\ensuremath{\AUEAction{\ZMV}{\ZMV'}{\AMV}}} + +\paragraph{Movement} +\begin{mathpar} + \inferrule[AEMove]{ + \AUEMove{\ZMV}{\ZMV'}{\MMV} + }{ + \AUEMove{\ZMV}{\ZMV'}{\MMV} + } +\end{mathpar} + +\paragraph{Deletion} +\begin{mathpar} + \inferrule[AEDel]{ }{ + \AUEDel{\EMV} + } +\end{mathpar} + +\paragraph{Construction} +\begin{mathpar} + \inferrule[AEConVar]{ }{ + \AUEConVar{x} + } \\ + + \inferrule[AEConLam]{ }{ + \AUEConLam{x}{\EMV} + } \\ + + \inferrule[AEConAp1]{ }{ + \AUEConApL{\EMV} + } + + \inferrule[AEConAp2]{ }{ + \AUEConApR{\EMV} + } \\ + + \inferrule[AEConLet1]{ }{ + \AUEConLetL{x}{\EMV} + } + + \inferrule[AEConLet2]{ }{ + \AUEConLetR{x}{\EMV} + } \\ + + \inferrule[AEConNum]{ }{ + \AUEConNum{\ENumMV} + } + + \inferrule[AEConPlus1]{ }{ + \AUEConPlusL{\EMV} + } + + \inferrule[AEConPlus2]{ }{ + \AUEConPlusR{\EMV} + } \\ + + \inferrule[AEConTrue]{ }{ + \AUEConTrue + } + + \inferrule[AEConFalse]{ }{ + \AUEConFalse + } \\ + + \inferrule[AEConIf1]{ }{ + \AUEConIfC{\EMV} + } + + \inferrule[AEConIf2]{ }{ + \AUEConIfL{\EMV} + } + + \inferrule[AEConIf3]{ }{ + \AUEConIfR{\EMV} + } \\ + + \inferrule[AEConPair1]{ }{ + \AUEConPairL{\EMV} + } + + \inferrule[AEConPair2]{ }{ + \AUEConPairR{\EMV} + } \\ + + \inferrule[AEConProjL]{ }{ + \AUEConProjL{\EMV} + } + + \inferrule[AEConProjR]{ }{ + \AUEConProjR{\EMV} + } +\end{mathpar} + +\paragraph{Zipper Cases} +\begin{mathpar} + \inferrule[AEZipLam1]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} + }{ + \AUEAction{\ZLamT{x}{\ZTMV}{\EMV}}{\ZLamT{x}{\ZTMV'}{\EMV}}{\AMV} + } + + \inferrule[AEZipLam2]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZLamE{x}{\TMV}{\ZMV}}{\ZLamE{x}{\TMV}{\ZMV'}}{\AMV} + } \\ + + \inferrule[AEZipAp1]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZApL{\ZMV}{\EMV}}{\ZApL{\ZMV'}{\EMV}}{\AMV} + } + + \inferrule[AEZipAp2]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZApR{\EMV}{\ZMV}}{\ZApR{\EMV}{\ZMV'}}{\AMV} + } \\ + + \inferrule[AEZipLet1]{ + \AUTAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZLetL{x}{\ZMV}{\EMV}}{\ZLetL{x}{\ZMV'}{\EMV}}{\AMV} + } + + \inferrule[AEZipLet2]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZLetR{x}{\EMV}{\ZMV}}{\ZLetR{x}{\EMV}{\ZMV'}}{\AMV} + } \\ + + \inferrule[AEZipPlus1]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZPlusL{\ZMV}{\EMV}}{\ZPlusL{\ZMV'}{\EMV}}{\AMV} + } + + \inferrule[AEZipPlus2]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZPlusR{\EMV}{\ZMV}}{\ZPlusR{\EMV}{\ZMV'}}{\AMV} + } \\ + + \inferrule[AEZipIf1]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZIfC{\ZMV}{\EMV_1}{\EMV_2}}{\ZIfC{\ZMV'}{\EMV_1}{\EMV_2}}{\AMV} + } + + \inferrule[AEZipIf2]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZIfL{\EMV_1}{\ZMV}{\EMV_2}}{\ZIfL{\EMV_1}{\ZMV'}{\EMV_2}}{\AMV} + } + + \inferrule[AEZipIf3]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZIfR{\EMV_1}{\EMV_2}{\ZMV}}{\ZIfR{\EMV_1}{\EMV_2}{\ZMV'}}{\AMV} + } \\ + + \inferrule[AEZipPair1]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZPairL{\ZMV}{\EMV}}{\ZPairL{\ZMV'}{\EMV}}{\AMV} + } + + \inferrule[AEZipPair2]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZPairR{\EMV}{\ZMV}}{\ZPairR{\EMV}{\ZMV'}}{\AMV} + } \\ + + \inferrule[AEZipProjL]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZProjL{\ZMV}{\EMV}}{\ZProjL{\ZMV'}{\EMV}}{\AMV} + } + + \inferrule[AEZipProjR]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} + }{ + \AUEAction{\ZProjR{\EMV}{\ZMV}}{\ZProjR{\EMV}{\ZMV'}}{\AMV} + } +\end{mathpar} + +\subsubsection{Iterated actions} +\label{sec:untyped-iterated-actions} +\judgbox{\ensuremath{\AUTActionIter{\ZTMV}{\ZTMV'}{\AIMV}}} +% +\begin{mathpar} + \inferrule[ATIRefl]{ }{ + \AUTActionIter{\ZTMV}{\ZTMV}{\AINil} + } + + \inferrule[ATITyp]{ + \AUTAction{\ZTMV}{\ZTMV'}{\AMV} \\ + \AUTActionIter{\ZTMV'}{\ZTMV''}{\AIMV} + }{ + \AUTActionIter{\ZTMV}{\ZTMV''}{\AICons{\AMV}{\AIMV}} + } +\end{mathpar} + +\judgbox{\ensuremath{\AUEActionIter{\ZMV}{\ZMV'}{\AIMV}}} +% +\begin{mathpar} + \inferrule[AEIRefl]{ }{ + \AUEActionIter{\ZMV}{\ZMV}{\AINil} + } + + \inferrule[AEIExp]{ + \AUEAction{\ZMV}{\ZMV'}{\AMV} \\ + \AUEActionIter{\ZMV'}{\ZMV''}{\AIMV} + }{ + \AUEActionIter{\ZMV}{\ZMV''}{\AICons{\AMV}{\AIMV}} + } +\end{mathpar} + +\judgbox{\ensuremath{\movements{\AIMV}}} +% +\begin{mathpar} + \inferrule[AMINil]{ }{ + \movements{\AINil} + } + + \inferrule[AMICons]{ + \movements{\AIMV} + }{ + \movements{\AICons{\AMove{\MMV}}{\AIMV}} + } +\end{mathpar} + +\subsection{Metatheorems} +\label{sec:untyped-metatheorems} +\begin{theorem}[name=Sensibility] +\end{theorem} + +\begin{theorem}[name=Movement Erasure Invariance] \ + \begin{enumerate} + \item If $\AUTAction{\ZTMV}{\ZTMV'}{\AMove{\MMV}}$, then $\cursorErase{\ZTMV} = + \cursorErase{\ZTMV'}$. + + \item If $\AUEAction{\ZMV}{\ZMV'}{\AMove{\MMV}}$, then $\cursorErase{\ZMV} = + \cursorErase{\ZMV'}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Reachability] \ + \begin{enumerate} + \item If $\cursorErase{\ZTMV} = \cursorErase{\ZTMV'}$, then there exists $\AIMV$ such that + $\movements{\AIMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV'}{\AIMV}$. + + \item If $\cursorErase{\ZMV} = \cursorErase{\ZMV'}$, then there exists $\AIMV$ such that + $\movements{\AIMV}$ and $\AUEActionIter{\ZMV}{\ZMV'}{\AIMV}$. + \end{enumerate} +\end{theorem} + +\begin{lemma}[name=Reach Up] \ + \begin{enumerate} + \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ + and $\AUTActionIter{\ZTMV}{\ZTCursor{\TMV}}{\AIMV}$. + + \item If $\cursorErase{\ZMV} = \EMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ + and $\AUEActionIter{\ZMV}{\ZTCursor{\EMV}}{\AIMV}$. + \end{enumerate} +\end{lemma} + +\begin{lemma}[name=Reach Down] \ + \begin{enumerate} + \item If $\cursorErase{\ZTMV} = \TMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ + and $\AUTActionIter{\ZTCursor{\TMV}}{\ZTMV}{\AIMV}$. + + \item If $\cursorErase{\ZMV} = \EMV$, then there exists $\AIMV$ such that $\movements{\AIMV}$ + and $\AUEActionIter{\ZTCursor{\EMV}}{\ZMV}{\AIMV}$. + \end{enumerate} +\end{lemma} + +\begin{theorem}[name=Constructability] \ + \begin{enumerate} + \item For every $\TMV$, there exists $\AIMV$ such that + $\AUTActionIter{\ZTCursor{\TUnknown}}{\ZTCursor{\TMV}}{\AIMV}$. + + \item For every $\EMV$, there exists $\AIMV$ such that + $\AUEActionIter{\ZCursor{\EEHole}}{\ZCursor{\EMV}}{\AIMV}$. + \end{enumerate} +\end{theorem} + +\begin{theorem}[name=Determinism] \ + \begin{enumerate} + \item If $\AUTActionIter{\ZTMV}{\ZTMV'}{\AMV}$ and $\AUTActionIter{\ZTMV}{\ZTMV''}{\AMV}$, then + $\ZTMV' = \ZTMV''$. + + \item If $\AUEActionIter{\ZMV}{\ZMV'}{\AMV}$ and $\AUEActionIter{\ZMV}{\ZMV''}{\AMV}$, then + $\ZMV' = \ZMV''$. + \end{enumerate} +\end{theorem} + +% \begin{theorem}[name=Actionability] \ + % \begin{enumerate} + % \item For every $\TMV$ and $\AMV$, there exists $\ZTMV$ such that + % $\AUTAction{\ZTCursor{\TMV}}{\ZTMV}{\AMV}$. + + % \item For every $\EMV$ and $\AMV$, there exists $\ZMV$ such that + % $\AUEAction{\ZCursor{\EMV}}{\ZMV}{\AMV}$. + % \end{enumerate} +% \end{theorem} + +\end{document}