\documentclass[10pt,twoside]{report}

\usepackage[a-1b]{pdfx}
\usepackage{hyperref}
\usepackage{inputenc}
\hypersetup{pdfencoding=unicode}
\inputencoding{utf8}
\makeatother

%======================================================================
% General setup

\raggedbottom  % is not the default for twoside
\newcommand{\microfilm}[1]{}  	% \microfilm{gaga}: commands to be used
				% only for spacing for microfilm version.
\newcommand{\nomicrofilm}[1]{#1}% commands not to be used with microfilm
				% spacing. 

% Use fonts in the Times family.
\usepackage{times}

% We want to make an index.
\usepackage{makeidx}
\makeindex

% Margins: Left 1.5in, Right 1in, Top and Bottom 1in. U.S Letter Size
\textwidth=6in
\textheight=8.625in
\headsep=-.25in     % space between head and body of a page
\headheight=0in  % height of a box containing the head
\oddsidemargin=0.5in  % One inch less than the distance paper - left margin
\evensidemargin=0in	% left margin of even pages only 1 inch

% Use plain page style
\pagestyle{plain}

% Text is double-spaced (except title page, footnotes).
\newcommand{\doublespaced}{\renewcommand{\baselinestretch}{2}\normalsize}
\newcommand{\singlespaced}{\renewcommand{\baselinestretch}{1}\normalsize}
\newcommand{\draftspaced}{\renewcommand{\baselinestretch}{1}\normalsize}  
		% for 10pt draft only
\doublespaced 

%======================================================================
% General styles

\usepackage{latexsym}	% LaTeX fonts
\usepackage{amssymb}  	% for \feedback symbol; superset of amsfonts
\usepackage{amsmath}  	% \text{} etc
\usepackage{amsthm}   	% AMS style theorem and proof environments
\usepackage{mathrsfs}	% special script style \mathscr{S} for \Set
\usepackage[all]{xy}	% Xy-Pic
% ----------------------------------------------------------------------

% To produce straighter arrows, uncomment the following two lines:

%\xyoption{ps}		% backend
%\xyoption{dvips}	% To have prettier straight lines etc.

% ----------------------------------------------------------------------
% common text abbreviations
\newcommand{\eg}{\mbox{\it e.g.}}
\newcommand{\ie}{\mbox{\it i.e.}}
\newcommand{\etal}{\mbox{\it et al.}}
\newcommand{\apriori}{{\it a priori}}
\newcommand{\aposteriori}{{\it a posteriori}}
\newcommand{\wloss}{without loss of generality}

% ----------------------------------------------------------------------
% common symbols

% implication
\newcommand{\imp}{\Rightarrow}                  % implication (math mode)
\newcommand{\iimp}{\Longrightarrow}             % long implication (math mode)
\renewcommand{\implies}{$\imp\ $}		% '=>' (outside math mode)
\newcommand{\pmi}{\Leftarrow}			% <= (opposite of \imp) 

% set and category notation
\newcommand{\seq}{\subseteq}    
\newcommand{\such}{\,\,|\,\,}                   % in sets {x|...}
\newcommand{\cp}{\circ}                         % composition
\newcommand{\id}{{\sf id}}			% id : A --> A
\newcommand{\from}{\colon}			% F\from A\ii B       F:A->B
\newcommand{\ii}{\rightarrow} % '\to' already used. % functions f:a->b
\newcommand{\iii}{\longrightarrow}
\newcommand{\pii}{\rightharpoonup} 		% partial function f:a-`b
\newcommand{\adjoint}{\dashv}		% F\adjoint G: F is left adjoint.
\newcommand{\iso}{\cong}			% isomorph ~=
\newcommand{\family}[2]{(#1)_{#2}}		% (X_n)_J or {X_n|J}
\newcommand{\rest}[1]{|_{#1}}			% restriction S|A

% particular categories and sets
\newcommand{\Set}{\mathscr{S}}			% Cat of Sets
%\newcommand{\N}{{\rm I\hspace{-.2em}N}}	% Nat'l numbers
\newcommand{\N}{\mathbb{N}}			% Nat'l numbers AMS fonts
\newcommand{\Z}{\mathbb{Z}}			% Integers AMS fonts

% spacing
\newcommand{\sep}{\hspace{2em}} 
\newcommand{\ssep}{\hspace{1em}}
\newcommand{\void}[1]{}				% comment out the argument
\newcommand{\todo}[1]{[#1]\marginpar{\mbox{\Huge !}}}

% special symbols
\newcommand{\entails}{\vdash}			% turnstile
\newcommand{\semsuper}[3]{[\![#1]\!]_{#2}^{#3}}	% semantic brackets 
\newcommand{\sem}[2]{[\![#1]\!]_{#2}}		% semantic brackets
\newcommand{\semp}{\sem{\,\,\,}{}} 		% \sem prototype
\newcommand{\eqbyrule}[1]{\stackrel{#1}{=}}	% annotated =
\newcommand{\downdeal}{\mbox{$\downarrow$}}	% downdeal
\newcommand{\updeal}{\mbox{$\uparrow$}}		% updeal
\newcommand{\chk}{\checkmark}	% check in case distinctions
\newcommand{\ih}{{\rm (IH)}}                    % ind. hyp.

% styles 
\newcommand{\defit}{\it\bfseries\boldmath}
\newcommand{\textunderline}[1]{\underline{\raisebox{0in}[0in][0in]{#1}}}

% ----------------------------------------------------------------------
% theorem definitions
% numbered by default: 
% 	theorem, lemma, proposition, corollary, example, principle
% unnumbered by default: 
%	definition, openproblem, remark, remarks, convention
%
% get unnumbered versions by un-lemma etc., numbered by n-definition etc. 

\theoremstyle{plain}
\newtheorem{n-lemma}{Lemma}[chapter]
\newtheorem{n-theorem}[n-lemma]{Theorem}
\newtheorem{n-proposition}[n-lemma]{Proposition}
\newtheorem{n-corollary}[n-lemma]{Corollary} 
\newtheorem{n-principle}[n-lemma]{Principle}
\newtheorem*{un-lemma}{Lemma}
\newtheorem*{un-theorem}{Theorem}
\newtheorem*{un-proposition}{Proposition}
\newtheorem*{un-corollary}{Corollary} 
\newtheorem*{un-principle}{Principle}

\theoremstyle{definition}
\newtheorem{n-definition}[n-lemma]{Definition}
\newtheorem{n-openproblem}[n-lemma]{Open Problem}
\newtheorem{bn-remark}[n-lemma]{Remark}		% bold remark
\newtheorem*{un-definition}{Definition}
\newtheorem*{un-openproblem}{Open Problem}
\newtheorem*{bun-remark}{Remark}		% bold unnumbered remark

\theoremstyle{remark}
\newtheorem{n-example}[n-lemma]{Example}
\newtheorem{n-remark}[n-lemma]{Remark}
\newtheorem{n-remarks}[n-lemma]{Remarks}
\newtheorem{n-convention}[n-lemma]{Convention}
\newtheorem*{un-example}{Example}
\newtheorem*{un-remark}{Remark}
\newtheorem*{un-remarks}{Remarks}
\newtheorem*{un-convention}{Convention}

% defaults numbered/unnumbered
\newenvironment{theorem}{\begin{n-theorem}}{\end{n-theorem}}
\newenvironment{lemma}{\begin{n-lemma}}{\end{n-lemma}}
\newenvironment{proposition}{\begin{n-proposition}}{\end{n-proposition}}
\newenvironment{corollary}{\begin{n-corollary}}{\end{n-corollary}}
\newenvironment{definition}{\begin{un-definition}}{\end{un-definition}}
\newenvironment{example}{\begin{n-example}}{\end{n-example}}
\newenvironment{openproblem}{\begin{un-openproblem}}{\end{un-openproblem}}
\newenvironment{principle}{\begin{n-principle}}{\end{n-principle}}
\newenvironment{remark}{\begin{un-remark}}{\end{un-remark}}
\newenvironment{remarks}{\begin{un-remarks}}{\end{un-remarks}}
\newenvironment{convention}{\begin{un-convention}}{\end{un-convention}}

% proofs
\newenvironment{proofof}[1]			% loose proofs
	{\begin{trivlist}\item[]{\it Proof of #1:\hspace{.5em}}\rm}
	{\end{trivlist}}
\newenvironment{proofsketch}			% proof sketch
	{\begin{trivlist}\item[]{\it Proof sketch:\hspace{.5em}}\rm}
	{\end{trivlist}}

\renewcommand{\qed}{} 		% turn off automatic AMS-style \qed'ing.
\newcommand{\eotsymbol}{{\large $\Box$}} 	% can be redefined
\newcommand{\eot}{{\hspace*{\fill}\eotsymbol}}
\newcommand{\eottwo}{\vspace{-5ex}\par\eot}	% \eot after math display

% ----------------------------------------------------------------------
% case distinctions: label is flush left. 
% caselist causes no indentation. May use \case for automatic numbering
% itemlist causes indentation. 
% nienumerate is like enumerate but flush left

\newcounter{casecounter}
\newlength{\normalparindent}
\setlength{\normalparindent}{\parindent}
\newenvironment{caselist}
	{\begin{list}{{\bf Case \arabic{casecounter}:}}
	 {\usecounter{casecounter}
		\setlength{\leftmargin}{0ex}
		\setlength{\labelwidth}{0ex} 		 
		\setlength{\labelsep}{2ex}
		\setlength{\itemindent}{\labelsep}	
		\setlength{\parsep}{0ex}
		\setlength{\listparindent}{\normalparindent}
	}}	
	{\end{list}}
\newcommand{\case}{\item}
\newcommand{\caseimp}{\case[$\imp$:]}
\newcommand{\casepmi}{\case[$\pmi$:]}
\newcommand{\impl}[2]{$\text{#1}\imp\text{#2}$}
\newcommand{\caseimpl}[2]{\case[\impl{#1}{#2}:]}
\newenvironment{itemlist}{\begin{list}{\undefinedcase}
 	{	\setlength{\leftmargin}{2.5ex}
		\setlength{\labelwidth}{1.5ex}
 		\setlength{\labelsep}{1ex}
		\setlength{\itemindent}{0ex}}}
 	{\end{list}}

\newcounter{nicounter}
\newenvironment{nienumerate} % enumerate but no indentation
	{\begin{list}{\arabic{nicounter}.}
{\usecounter{nicounter} 		 \setlength{\leftmargin}{0ex}
\setlength{\labelwidth}{0ex} 		 \setlength{\labelsep}{1ex}
\setlength{\itemindent}{\labelsep} 	}	} 	{\end{list}}

% ----------------------------------------------------------------------
% stacking things
\newcommand{\hatt}[1]{\raisebox{0ex}[0ex]{\mbox{$\hat{#1}$}}} % f hat
\newlength{\stackwd}	% stacking without affecting line spacing
\newcommand{\stack}[2]{\mbox{\settowidth{\stackwd}{$#2$}%
        \raisebox{1.2ex}[0pt]{\makebox[0pt][l]{%
        \makebox[\stackwd]{\scriptsize$#1$}}}}%
        {#2}}

\newcommand{\blank}{\rule{0mm}{1.3ex}}  % for empty line in arrays etc.

\newcommand{\deriv}[2]{\begin{array}{c}#1\\\hline#2\end{array}}
\newcommand{\vstrut}{}

% ----------------------------------------------------------------------
% complex symbols
\newcommand{\dirsup}{\mathop{\setlength{\unitlength}{.7em}\raisebox{-.2em}%
    {\begin{picture}(1,1.5)\put(.5,0){\line(-1,3){.48}}
    \put(.5,0){\vector(1,3){.5}}\end{picture}}}} % directed sup
\newcommand{\funnel}{				% directed equality
    \stackrel{}{\textrm{\settowidth{\unitlength}{$\imp$}%
    \begin{picture}(1,.48)
	\put(.925,-.16){\oval(1.7,.57)[tl]}
	\put(.925,.64){\oval(1.7,.57)[bl]}
    \end{picture}}}}
\newcommand{\funnels}{				% bidirected equality
    \stackrel{}{\textrm{\settowidth{\unitlength}{$\imp$}%
    \begin{picture}(1,.48)
	\put(.5,-.16){\oval(.85,.57)[t]}
	\put(.5,.64){\oval(.85,.57)[b]}
    \end{picture}}}}

% ----------------------------------------------------------------------
% commands for having linked enumerate environments
\newcounter{enumisave}			
\newcounter{enumiisave}			
\newcounter{enumiiisave}
\newcounter{enumivsave}
\newcommand{\suspendenumerate}{
	\setcounter{enumisave}{\value{enumi}}
	\setcounter{enumiisave}{\value{enumii}}
	\setcounter{enumiiisave}{\value{enumiii}}
	\setcounter{enumivsave}{\value{enumiv}}		}
\newcommand{\resumeenumerate}{
	\setcounter{enumi}{\value{enumisave}}
	\setcounter{enumii}{\value{enumiisave}}
	\setcounter{enumiii}{\value{enumiiisave}}
	\setcounter{enumiv}{\value{enumivsave}}		}

% ----------------------------------------------------------------------
% xypic pullback, product, collective monic/epic in Freyd/Scedrov style
% see also xypullback.sty
%
% Usage: \pullback{hop1}{hop2} as an entry in the diagram matrix,
% where hop1+2 are combinations of udlr pointing to the matrix
% elements to which the pullback arrows point. 
% Example: \pullback{r}{d} for a pullback in
% the upper left corner of a diagram. 
%
% commands: \pullback[2], \product[2], \collmonic[2], \collcover[2]

\newcommand{\pullback}[2]
 {\POS[];{[#1]**{}?<>(.3)}:[#2]**{}?<>(.3)::
 (0,1);(1,1)**h\dir{-};(1,0)**h\dir{-},[]}
% The (x,y) pairs in the previous line are in a cartesian coordinate
% system with axis along the arrows of the pullback and normalized so
% that the pullback box is a 1x1 square. To create different kinds of
% diagrams, change these numbers.

\newcommand{\product}[2]
 {\POS[];{[#1]**{}?<>(.3)}:[#2]**{}?<>(.3)::
 (0,.8);(1.2,.8)**h\dir{-},(.8,1.2);(.8,0)**h\dir{-},[]} 
% For changes, see the above comment

\newcommand{\collmonic}[2]       % collectively monic
 {\POS[];{[#1]**{}?<>(.3)}:[#2]**{}?<>(.3)::
 (0,1);(1,0)**h\dir{-},[]} 
% For changes, see the above comment

\newcommand{\collcover}[2]       % collective cover
 {\POS[];{[#1]**{}?<>(.3)}:[#2]**{}?<>(.3)::
 (0,1);(1,0)\curve{(1,1)}\POS[]} 
% For changes, see the above comment

%----------------------------------------------------------------------
% The following are for making monic, epic arrows etc.: 
% \armonic[r], \arepic[r] 
% \arcoverright[r] (works only for right direction unless PostScript support)
% \arcover[ur] 	   (works for any direction, but uglier)
% \arembed[r]      makes a hooked arrow

\SelectTips{eu}{10}\NoTips  % Euler tips only for use in monics and epics

\newdir{|>}{{}*!/13.75pt/@{|}*!/9.25pt/:(-.866,-.5)@^{-}*!/9.25pt/:(-.866,+.5)@_{-}*!/19pt/@{-}}
\newdir{>>}{{}*!/5pt/@{>}*!/10pt/@{-}*!/7pt/@{>}} 
\newdir{ >}{{}*!/-3pt/@{>}} 
\newdir^{ (}{{}*!/-5pt/@^{(}}
\newdir{||>}{{}*!/6pt/{\triangleright}}

\newcommand{\monictail}{\UseTips\dir{ >}\NoTips}
\newcommand{\varmonictail}{\dir{|}}
\newcommand{\monichead}{\UseTips\dir{>}\NoTips}
\newcommand{\epichead}{\UseTips\dir{>>}\NoTips}

\newcommand{\armonic}{\ar@{*{\monictail}-*{\monichead}}}
\newcommand{\arepic}{\ar@{-*{\epichead}}}
\newcommand{\arcover}{\ar@{-|>}}
\newcommand{\arembed}{\ar@{^{ (}->}}

%======================================================================
% Definitions for math symbols local to this document

% ==================================================================
% Common Symbols
\newcommand{\lam}{\lambda}			
\newcommand{\del}{\delta}

\newcommand{\Aa}{{\bf A}}
\newcommand{\Bb}{{\bf B}}
\newcommand{\Cc}{{\bf C}}
\newcommand{\Dd}{{\bf D}}
\newcommand{\Pp}{{\bf P}}
\newcommand{\Rr}{{\bf R}}	% lts
\newcommand{\Ss}{{\bf S}}	% lts	
\newcommand{\Tt}{{\bf T}}	% lts 
\newcommand{\Uu}{{\bf U}}	% lts

\newcommand{\calA}{{\cal A}}		% a\in X, A\in P(X), \calA\in P(P(X))
\newcommand{\F}{{\cal F}}		% free ccc
\newcommand{\Th}{{\cal T}}		% (lambda) theory name
\newcommand{\calB}{{\cal B}}		% PL category

\newcommand{\xbar}{\bar{x}}
\newcommand{\ybar}{\bar{y}}
\newcommand{\abar}{\bar{a}}
\newcommand{\pbar}{\bar{p}}

% prettier symbols
\renewcommand{\leq}{\leqslant}		
\renewcommand{\geq}{\geqslant}	
\renewcommand{\preceq}{\preccurlyeq}
\renewcommand{\succeq}{\succcurlyeq}

% the following is needed for bibliography for obscure reasons (BibTeX
% tries to replace "-" by "--")
\newcommand{\dash}{-}

% ==================================================================
% Universal Algebra and CPO's

\newcommand{\dcpo}{dcpo}		% the word dcpo
\newcommand{\Dcpo}{Dcpo}
\newcommand{\dcpos}{dcpo's}
\newcommand{\cpo}{cpo}			% the word cpo
\newcommand{\cpos}{cpo's}		
\newcommand{\bc}{\textit{bc}}		% bounded complete tag
\newcommand{\stable}{\wedge}		% stable tag
\newcommand{\POSET}{\textbf{\bf POSET}}	% cat of posets
\newcommand{\CPO}{\textbf{\bf CPO}}	% cat of cpo's
\newcommand{\CPOp}{\CPO_{\bot}}  	% cat of pointed cpo's 
\newcommand{\CPObc}{\CPO^{\bc}}		% bounded complete cpo's 
\newcommand{\CPOstable}{\CPO^{\stable}} % stable cpo's 
\newcommand{\CPOpbc}{\CPOp^{\bc}}	
\newcommand{\CPOpstable}{\CPOp^{\stable}}  
\newcommand{\DCPO}{\textbf{\bf DCPO}}	% cat of dcpo's
\newcommand{\DCPOp}{\DCPO_{\bot}}  	 
\newcommand{\DCPObc}{\DCPO^{\bc}}	 
\newcommand{\DCPOstable}{\DCPO^{\stable}}
\newcommand{\DCPOpbc}{\DCPOp^{\bc}}	 
\newcommand{\DCPOpstable}{\DCPOp^{\stable}}
\newcommand{\DOM}{\mathcal{D}}		% cat of domains (any of the above)
\newcommand{\leqberry}{\leq_s}		% Berry order
\newcommand{\ep}{^e}			% tag for cat of ep-pairs
\newcommand{\diagram}{\Delta}		% name of a diagram D:I->C
\newcommand{\Idl}[1]{\textrm{\rm Idl}(#1)}	% Ideal completion
\newcommand{\IAa}{\mathcal{J}}		% short name for \Idl{\Aa}

\newcommand{\Words}{W}			% Words(X,\Ome)
\newcommand{\Sig}{\Sigma}		% Signature = (Omega, arity)
\newcommand{\freesymb}{\mathfrak{F}}	% symbol F for free things
\newcommand{\freealg}{\freesymb}	% symbol F for free algebra
\newcommand{\freeTOf}[1]{\T\!_{#1}}	% free T-algebra over X spec spacing
\newcommand{\freeDOf}[1]{\D\!_{#1}}	% free D-dcpo-algebra over X
\newcommand{\freeOOf}[1]{\OT\!_{#1}}	% free ord. O-algebra over X
\newcommand{\SigOf}[1]{{\Sig}_{#1}}	% Sigma-Terms
\newcommand{\Ome}{\Omega}		% Ome_k = k-ary function symbols
\newcommand{\arity}{\alpha}
\newcommand{\const}[1]{c_{#1}}		% constant symbol [x]
\newcommand{\T}{\mathbf{T}}		% alg variety; T-Algebra
\newcommand{\OT}{\mathbf{O}}		% ordered variety O-algebras
\newcommand{\D}{\mathbf{D}}		% dcpo variety D-algebras
\newcommand{\SAlg}{\textbf{\bf $\Sig$-Alg}} 	   % cat of Sigma-algebras
\newcommand{\SEAlg}{\textbf{\bf $\SE$-Alg}} % cat of (S,E)-alg's
\newcommand{\SE}{(\Sig,\Eqns)}		% (S,E)
\newcommand{\SOrd}{\textbf{\bf $\Sig$-Ord}}	% cat of Sig-order-algebras
\newcommand{\Ineqns}{{\cal I}}		% set of inequations
\newcommand{\SI}{(\Sig,\Ineqns)}	% (S,I)
\newcommand{\SIOrd}{\textbf{\bf $\SI$-Ord}}	% cat of (S,I)-order-algs
\newcommand{\SDCPO}{\textbf{\bf $\Sig$-\DCPO}}	% cat of (S,I)-order-algs
\newcommand{\SIDCPO}{\textbf{\bf $\SI$-\DCPO}}	% cat of (S,I)-order-algs
\newcommand{\concr}[2]{{#1}_{#2}}	% f fn symbol, f_A function.
\newcommand{\extension}[1]{\hat{#1}}	% rho:X->A, ext(rho):free(X)->A
\newcommand{\Eqns}{{\cal E}}		% set of equations
\newcommand{\class}[2]{[#1]_{#2}}	% eq. class [x]_\sim
\newcommand{\Nat}{\N}			% nat's numbers
\newcommand{\Int}{\Z}			% integers
\newcommand{\jota}{\jmath}		% inclusion X->A[X]
\newcommand{\jotb}{\iota}		% inclusion A->A[X]
\newcommand{\power}[1]{{\cal P}(#1)}	% power set
\newcommand{\preleq}{\preceq}		% preorder
\newcommand{\pregeq}{\succeq}		% inverse
\newcommand{\entailseq}{\entails_{\textit{eq}}}		% Eqns |- s=t
\newcommand{\entailsineq}{\entails_{\textit{ineq}}}	% Ineqns |- s<=t
\newcommand{\modelsSAlg}{\models_{\SAlg}}
\newcommand{\modelsSOrd}{\models_{\SOrd}}
\newcommand{\compatible}{\stackrel{}{\textrm{\settowidth{\unitlength}{$\smile$}\begin{picture}(1,0)\put(0,-.24){$\smile$}\put(0,.20){$\frown$}\end{picture}}}}
\newcommand{\incompatible}{\hspace{.25ex}\not\hspace{-.25ex}\compatible}

% ==================================================================
% Symbols for Combinatory Algebras

\newcommand{\Terms}{\Lambda}			% lambda terms
\newcommand{\rawTerms}{\Lambda^{\sf raw}}	% raw terms (no alpha)
\newcommand{\CTerms}{\mathfrak{C}}		% combinatory terms
\newcommand{\TermsOf}[1]{\Terms_{#1}}		% lambda terms, C
\newcommand{\ClTermsOf}[1]{\Terms^0_{#1}}	% closed lambda terms, C
\newcommand{\rawTermsOf}[1]{\rawTerms_{#1}}	% raw terms (no alpha), C
\newcommand{\CTermsOf}[1]{\CTerms_{#1}}		% combinatory terms, C
\newcommand{\ClCTermsOf}[1]{\CTerms^0_{#1}}	% closed comb terms, C

\newcommand{\CL}{\textit{CL}}	% minimal theory of comb log, =_CL, |-_CL
\newcommand{\cl}{\textit{cl}}	% translation M_cl
\newcommand{\LAtheory}{{\textit{LA}}}		% cat of lambda alg's
\newcommand{\Vars}{{\cal V}}			% Variables
\newcommand{\Val}[1]{\textrm{Val}(#1)}	% partial valuations: \Vars->X
\newcommand{\K}{{\mathbf{K}}}		% combinator K
\renewcommand{\SS}{{\mathbf{S}}} 	% combinator S
\newcommand{\I}{{\mathbf{I}}}		% combinator I=SKK
\newcommand{\one}{{\mathbf{1}}} 	% combinator 1=S(KI)
\newcommand{\app}{\cdot}			% application
\newcommand{\App}{\bullet}			% other application

\newcommand{\eqa}{=_{\alpha}}			% alpha-equivalence
\newcommand{\eqb}{=_{\beta}}			% beta-equivalence
\newcommand{\eqbe}{=_{\beta\eta}}		% beta-eta-equivalence
\newcommand{\eqcl}{=_{\CL}}			% CL-equivalence
\newcommand{\eqla}{=_{\LAtheory}}
\newcommand{\entailsb}{\entails_{\beta}}	% entails lam beta
\newcommand{\entailseta}{\entails_{\beta\eta}}	% entails lam beta eta
\newcommand{\entailscl}{\entails_{\CL}}		% entails comb. logic
\newcommand{\entailsla}{\entails_{\LAtheory}} 	% entails lam. alg
\newcommand{\LA}{{\textbf{\bf LA}}}		% cat of lambda alg's
\newcommand{\LT}{{\textbf{\bf LT}}}		% cat of lambda theories
\newcommand{\CA}{{\textbf{\bf CA}}}		% cat of comb. alg's
\newcommand{\modloc}{\models}			% A |= Eqn (locally)
\newcommand{\modlocca}{\models_{\CA}}		% in comb. algs
\newcommand{\modlocla}{\models_{\LA}}		% in lambda algs
\newcommand{\modabs}{\models^{\textrm{\rm abs}}}% A |= Eqn (absolutely)
\newcommand{\semabs}[2]{\sem{#1}{#2}^{\textrm{\rm abs}}} % abs interpretation
\newcommand{\pointobject}{\Upsilon}		% point object, usually 1

% projection and embedding for categorical lambda model
\newcommand{\e}{e}
\newcommand{\p}{p}

\newcommand{\refl}{\trule{refl}}		% rule names
\newcommand{\symm}{\trule{symm}}
\newcommand{\trans}{\trule{trans}}
\newcommand{\rulec}{\trule{cong}}
\newcommand{\rulex}{\nrule{\xi}}
\newcommand{\rulea}{\nrule{\alpha}}
\newcommand{\ruleb}{\nrule{\beta}}
\newcommand{\rulee}{\nrule{\eta}}
\newcommand{\rulek}{\trule{k}}
\newcommand{\rules}{\trule{s}}
\newcommand{\rulem}{\trule{MS}}			% Meyer-Scott axiom

\newcommand{\abs}[1]{|#1|}			% |A|: elements of algebra
\newcommand{\Theoryof}[1]{{\textrm{\rm Th}}(#1)}

\newcommand{\tru}{T}				% lambda term true
\newcommand{\fal}{F}				% lambda term false
\newcommand{\churchnum}[1]{\bar{\text{#1}}}	% Church numeral

%=======================================================================
% Symbols for Unorderability and Finite Lambda Models

\newcommand{\Top}{T}			% const. top function
\newcommand{\Bot}{B}			% const. bottom fn
\newcommand{\sqleq}{\sqsubseteq}	% preorder

\newcommand{\Malcev}{\mbox{Mal\hspace{-.2ex}'\hspace{-.3ex}cev}}

\newcommand{\SigTermsOf}[1]{\Lambda_{#1,\sigma}}
\newcommand{\sfun}{\phi}
\newcommand{\myleq}{\sqsubseteq}

\newcommand{\tmpll}{\lhd}

\newcommand{\redbes}{\stack{\beta\eta\sigma}{\longrightarrow}}
\newcommand{\redbe}{\stack{\beta\eta}{\longrightarrow}}
\newcommand{\redb}{\stack{\beta}{\longrightarrow}}
\newcommand{\reduces}{\longrightarrow}
\newcommand{\leftreduces}{\longleftarrow}
\newcommand{\notred}{\,\,\not\!\!\reduces}
\newcommand{\parred}{\rhd}
\newcommand{\conv}{\cong}
\newcommand{\neqbe}{\neq_{\beta\eta}}
\newcommand{\eqTh}{=_{\Th}}
\newcommand{\eqThs}{=_{\Th+\sigma}}
\newcommand{\eqbes}{=_{\beta\eta\sigma}}
\newcommand{\shortred}{\rightarrow}
\newcommand{\theorybeta}{\mbox{\textunderline{$\lambda\beta$}}}
\newcommand{\theorybetaeta}{\mbox{\textunderline{$\lambda\beta\eta$}}}

\newcommand{\bu}{u}
\newcommand{\bt}{t}
\newcommand{\kx}{{\mathrm{k}}}
\newcommand{\ox}{{\mathrm{0}}}
\newcommand{\ix}{{\mathrm{1}}}
\newcommand{\eqp}{=_p}

\newcommand{\malc}{\mbox{{\footnotesize}\bf M}}    % malcev operator

\newcommand{\diagaxiom}{{(\Delta)}}
\newcommand{\fix}{\textit{(fix)}}

% ==================================================================
% Symbols for Category Theory
\newcommand{\obj}[1]{|{#1}|}		% objects Obj(C) or |C|
\newcommand{\Obj}{\obj}			% can never remember which...
\newcommand{\Ccc}{{\cal CCC}}		% cat of ccc's
\newcommand{\Cat}{{\cal C}\textit{at}}	% cat of cats
\newcommand{\CatPL}{{\cal P\!L}}	% cat of pl-cats
\newcommand{\ucat}{U}			% underlying cat of a ccc
\newcommand{\op}{\textit{op}}		% for opposite cat C^o or C^op
\newcommand{\iiso}{\catarrow{\smash{\raisebox{-.1em}{$\scriptstyle\sim$}}}}
\newcommand{\iiepic}{\twoheadrightarrow} % epic arrow
\newcommand{\iimonic}{\rightarrowtail}	% monic arrow
\newcommand{\iivarmonic}{\mapsto}	% Freyd/Scedrov variant monic arrow
\newcommand{\iiemb}{\hookrightarrow}	% A-->B embedding
\newcommand{\embeds}{\iiemb}		% A-->B embedding
\newcommand{\homof}[2]{#1(#2)}		% hom set \homof{C}{A,B} = C(A,B)
\renewcommand{\hom}[1]{\homof{}{#1}}	% hom set \hom{A,B}      =  (A,B)
\newcommand{\catarrow}{\xrightarrow}	% extensible arrow for cat notation
\newcommand{\lowcatarrow}[1]{\catarrow{\smash[tb]{#1}}}	% no height (inline)
\newcommand{\Hom}{\textrm{\rm Hom}}	% Hom functor: C^op x C -> Set
\newcommand{\Free}{{\cal F}}		% free functor
\newcommand{\Point}{\Gamma}		% representable functor by 1
\newcommand{\nocommute}			% non-commuting diagram
	{\textrm{\setlength{\unitlength}{.13ex}\begin{picture}(10,10)
	\put(0,5){\line(1,0){3.3}}\put(5,0){\line(0,1){3.3}}
	\put(10,5){\line(-1,0){3.3}}\put(5,10){\line(0,-1){3.3}}
	\end{picture}}}
\newcommand{\iicover}			% a-->b cover
	{\stackrel{}{-\!\triangleright}}	

% ==================================================================
% Symbols for Henkin, Poly + Empty Types

\newcommand{\Cubric}{\v{C}ubri\'c}

\newcommand{\neSet}{\Set^+}		% non-empty sets
\newcommand{\polynom}[2]{#1[#2]}				% A[X]
\newcommand{\Ccadj}[1]{\polynom{\Cc}{#1}}			% C[X]
\newcommand{\adjpoint}[2]{1{\catarrow{\smash[t]{#1}}}#2} 	% x:1->A
\newcommand{\CcxA}{\Ccadj{\adjpoint{x}{A}}}			% C[x:1->A]

% Symbols for PL-cats
\newcommand{\base}{\mathbf{B}}		% base cat
\newcommand{\Om}{\Omega}		% kind of types
\newcommand{\fib}{F}			% fiber functor
\newcommand{\ffib}{G}			% nat.transf. between fibers
\newcommand{\fibnat}{\gamma}		% nat.iso. (V,\Om) -> |F(V)|
\newcommand{\all}{\forall}		% all-structure on a PL-cal
\newcommand{\allnat}{\eta}		% adjunction for \all
\newcommand{\homfib}[2]{\hom{#2}_{#1}}	% (C,D)_V = \homfib{V}{C,D}
\newcommand{\dummy}[1]{\Delta_{#1}}	% dummy functor fib_V --> fib_{VxOm}
\newcommand{\dummyp}[1]{\Delta'_{#1}}	% dummy prime
\newcommand{\allcounit}{\theta}		% counit of all-adjunction (change??)
\newcommand{\PL}{\textsl{PL}}		% PL-cats
\renewcommand{\phi}{\varphi}		% phi
\newcommand{\baral}{\bar{\alpha}}	% sequence \al_1...\al_n
\newcommand{\semi}[2]{\semsuper{#1}{#2}{I}} 	% interpretation assoc to I
\newcommand{\semia}[1]{\semi{#1}{\baral}} 	% 
\newcommand{\semio}[1]{\semi{#1}{}} 		%
\newcommand{\semo}[2]{\semsuper{#1}{}{#2}} 		%
\newcommand{\sema}[2]{\semsuper{#1}{\baral}{#2}}% 
\newcommand{\classofmodels}{{\cal M}}			% M, class of cats
\newcommand{\modelsns}{\models^{\textit{non-strict}}}	% non-strict entailment
\newcommand{\modelsclass}{\models_{\classofmodels}} 	% \models w.r.t. class M
\newcommand{\modelsnsclass}{\modelsns_{\classofmodels}}	% w.r.t a class
\newcommand{\modelsnsne}{\modelsns_{\neSet}}		% w.r.t \neSet
\newcommand{\modelsnsnepl}{\modelsns_{\stan{\neSet}}}	% w.r.t \stan\neSet
\newcommand{\modelsnsPpl}{\modelsns_{\Kripke}} % w.r.t \stan\neSet
\newcommand{\modelsnsset}{\modelsns_{\Set}}		% w.r.t \Set
\newcommand{\modelsnsP}{\modelsns_{\Kripke}}		% w.r.t \Set^P
\newcommand{\modelsext}{\models}
\newcommand{\modelsnsext}{\modelsns}
\newcommand{\modelsextclass}{\modelsext_{\classofmodels}} % w.r.t a class
\newcommand{\modelsextspecial}{\modelsext_{\Cccspecial}} % w.r.t. special ccc's
\newcommand{\modelsnsextclass}{\modelsnsext_{\classofmodels}} % w.r.t a class
\newcommand{\modelsnsextspecial}{\modelsnsext_{\Cccspecial}} % w.r.t a class
\newcommand{\Kripke}{\textit{Kripke}}
\newcommand{\Cccspecial}{\Ccc_{\textit{spec}}}		% special ccc's
\newcommand{\entailssimple}{\entails_s}
\newcommand{\entailsne}{\entails_s^{\textit{non-empty}}}	
\newcommand{\entailsext}{\entails_s^{\textit{ext}}}
\newcommand{\entailspl}{\entails_p}
\newcommand{\entailsplne}{\entails_p^{\textit{non-empty}}}	
\newcommand{\entailsplext}{\entails_p^{\textit{ext}}}
\newcommand{\Substof}[2]{[#2]_{#1}}	% substitution functor
\newcommand{\inst}{\textrm{\rm inst}}	% instantiation nat.trans.
\newcommand{\prestr}{{\cal P}}		% pre-structure
\newcommand{\Mbase}{{\bf P}}		% base of pre-structure
\newcommand{\Mfib}{M}			% fiber of pre-structure
\newcommand{\freeccc}[1]{\freesymb_{ccc}(#1)}	% free pl-cat 
\newcommand{\freepl}[1]{\freesymb_{\PL}(#1)}	% free ccc
\newcommand{\morphnamed}[1]{f_{#1}}	% Morph. named by M 
\newcommand{\theorypl}{\mbox{\textunderline{\PL}}}	   % the theory PL
\newcommand{\theorysimple}{\mbox{\textunderline{$\lambda$}}} % the theory ccc
\newcommand{\constinterp}{I}		% interpretation of constants
\newcommand{\Sierp}{\textbf{2}}		% Sierpinsky space
\newcommand{\f}{f}			% constant symbol for mmms example
\newcommand{\emp}[1]{\textit{e}(#1)}	% emptiness assertion
\newcommand{\eTh}{\Th}			% extended theory
\newcommand{\subth}[1]{#1^\circ}	% subtheory of an ext. th.
\newcommand{\sTh}{\subth{\eTh}}		% subtheory of the ext. th.
\newcommand{\EAss}{\Delta}		% seq. of emptiness assertions
\newcommand{\Eeq}{E}			% ext. equation (compare E for eqn)
\newcommand{\EEqns}{{\cal E}}		% set of ext. eqns (compare \Eqns)
\newcommand{\stan}[1]{\widetilde{#1}}	% standard structure
\newcommand{\polybool}{\textit{Polybool}}	% type \all a.a->a->a

% PL-calculus rule name
\newcommand{\trule}[1]{\textrm{(\textit{#1\/})}} % name of a rule like (text)
\newcommand{\nrule}[1]{\trule{$#1$}}  % name of a rule like (\xi_1)

\newcommand{\tjunit}{\nrule{*}}	% PL-calculus t.jud. rule name
\newcommand{\tjproja}{\nrule{\pi_1}}
\newcommand{\tjprojb}{\nrule{\pi_2}}
\newcommand{\tjpair}{\trule{pair}}
\newcommand{\tjvar}{\trule{var}}
\newcommand{\tjconst}{\trule{const}}
\newcommand{\tjlam}{\trule{abs}}
\newcommand{\tjapp}{\trule{app}}
\newcommand{\tjLam}{\trule{typeabs}}
\newcommand{\tjApp}{\trule{typeapp}}
\newcommand{\tjaddvar}{\trule{weaken}}

\newcommand{\plrefl}{\trule{refl}}
\newcommand{\plsymm}{\trule{symm}}
\newcommand{\pltrans}{\trule{trans}}
\newcommand{\plcong}[1]{\trule{cong$_{\textit{#1}}$}}
\newcommand{\plconga}{\plcong{1}}
\newcommand{\plcongb}{\plcong{2}}
\newcommand{\plcongc}{\plcong{3}}
\newcommand{\plcongd}{\plcong{4}}
\newcommand{\plconge}{\plcong{5}}
\newcommand{\plcongf}{\plcong{6}}
\newcommand{\plcongg}{\plcong{7}}
\newcommand{\plne}{\trule{non-empty}}
\newcommand{\plunit}{\trule{unit}}	% PL-calculus equational rule names
\newcommand{\plpair}{\trule{surj}}
\newcommand{\plproja}{\trule{proj$_1$}}
\newcommand{\plprojb}{\trule{proj$_2$}}
\newcommand{\plbeta}{\nrule{\beta}}
\newcommand{\pleta}{\nrule{\eta}}
\newcommand{\plBeta}{\nrule{B}}
\newcommand{\plEta}{\nrule{H}}
\newcommand{\pladdvar}{\trule{add-var}}
\newcommand{\plempty}{\trule{empty}}
\newcommand{\plcases}{\trule{cases}}
\newcommand{\pladdempty}{\trule{add-emp}}

% ccc's
\newcommand{\appl}{{\varepsilon}}	% \appl_{A,B}: B^A x A -> B
\newcommand{\curry}[1]{{#1}^{\star}}		% \curry: (AxB,C) -> (A,C^B)
\newcommand{\uncurry}[1]{{#1}_{\star}}	% \uncurry: (A,C^B) -> (AxB,C)
\newcommand{\proj}{\pi}			% all kinds of projections
\newcommand{\proja}{\proj}		% p_1 : AxB -> A
\newcommand{\projb}{\proj'}		% p_2 
\newcommand{\termarrow}{\textrm{\setlength{\unitlength}{.13ex}\begin{picture}(12,10)\put(6,5){\circle{10}}\end{picture}}}

% Lambda calculus
\newcommand{\TVars}{{\cal TV}}		% type variables
\newcommand{\Const}{C}			% individual constants
\newcommand{\TConst}{TC}		% type constants
\newcommand{\FV}{\textrm{\rm FV}}	% free variables
\newcommand{\FVof}[1]{\FV(#1)}		% preferred form
\newcommand{\FTV}{\textrm{\rm FTV}}	% free type variables (2nd \rm needed)
\newcommand{\FTVof}[1]{\FTV(#1)}	% ftv of a term
\newcommand{\FTVTof}[1]{\FTV(#1)}	% ftv of a type
\newcommand{\unit}{*}			% *:1
\newcommand{\lpra}{{\proj_1}}		% pi_1
\newcommand{\lprb}{{\proj_2}}		% pi_2
\newcommand{\typ}[2]{#1{:}#2}		% x:A
\newcommand{\lamabs}[3]{\lambda \typ{#1}{#2}.#3}	% lam x:A.M
\newcommand{\Lamabs}[2]{\Lambda #1.#2}			% Lam alpha.M
\newcommand{\tj}{\rhd}			% typing judgment
\newcommand{\eqj}{\rhd}			% equation judgment
\newcommand{\dom}[1]{\textrm{\rm dom}(#1)}	% domain
\newcommand{\simsubst}[2]{#1[#2]}	% simultaneous substitution
\newcommand{\substitem}[2]{#1/#2} 	% alternative {#2{:=}#1}
\newcommand{\subst}[3]{\simsubst{#1}{\substitem{#2}{#3}}}	
					% syntactic substitution

% BNF
\newcommand{\bnf}{::=}		% ::= in bnf
\newcommand{\bor}{\ \ \rule[-.75ex]{.01in}{2.75ex}\ \ }  % | in bnf

% =====================================================================
% Symbols for Asynchrony

\CompileMatrices

% Actions and transitions
\newcommand{\red}[1]{\xrightarrow{\smash[tb]{#1}}}		% -a->
\newcommand{\bred}[1]{\xrightarrow{\smash[b]{#1}}}
\newcommand{\Red}[1]{\stackrel{\smash[b]{#1}}{\Rightarrow}}	% =a=>
\newcommand{\bRed}[1]{\stackrel{#1}{\Rightarrow}}		% =a=>
\newcommand{\ired}[1]{\xleftarrow{#1}}				% <-a-
\newcommand{\iRed}[1]{\stackrel{#1}{\Leftarrow}}		% <=a=
\newcommand{\lred}[1]{\red{#1}}
\newcommand{\blred}[1]{\bred{#1}}
\newcommand{\lRed}[1]{\stackrel{\smash[b]{#1}}{\Longrightarrow}}% =a=>
\newcommand{\sred}[1]{\red{#1}^*}				% -t->*
\newcommand{\rout}[1]{\lred{\aout{#1}}}			% -out y->
\newcommand{\brout}[1]{\blred{\aout{#1}}}		% -out y->
\newcommand{\Rout}[1]{\lRed{\aout{#1}}}			% =out y=>
\newcommand{\rin}[1]{\lred{\ain{#1}}}			% -in x->
\newcommand{\Rin}[1]{\lRed{\ain{#1}}}			% =in x=>
\newcommand{\wout}{\rout}				% -out word->
\newcommand{\win}{\rin}					% -in word->
\newcommand{\atredb}[1]{\stackrel{#1}{\approx\!\succ}}	% ~a~>
\newcommand{\atredq}[1]{\stackrel{#1}{\approx\!\succ\!\!\!\succ}}	% ~a~>>
\newcommand{\atob}[1]{\atredb{\aout{#1}}}		% ~out y~>
\newcommand{\atib}[1]{\atredb{\ain{#1}}}		% ~in y~>
\newcommand{\atoq}[1]{\atredq{\aout{#1}}}		% ~out y~>>
\newcommand{\atiq}[1]{\atredq{\ain{#1}}}		% ~in y~>>
\newcommand{\rea}{\red{\alpha}}				% -alpha->
\newcommand{\brea}{\bred{\alpha}}			% -alpha->
\newcommand{\Rea}{\Red{\alpha}}				% =alpha=>
\newcommand{\bRea}{\bRed{\alpha}}			% =alpha=>
\newcommand{\lrea}{\lred{\alpha}}			% -alpha->
\newcommand{\blrea}{\blred{\alpha}}			% -alpha->
\newcommand{\lRea}{\lRed{\alpha}}			% =alpha=>
\newcommand{\redt}{\red{\tau}}				% -tau->
\newcommand{\bredt}{\bred{\tau}}			% -tau->
\newcommand{\Redt}{\Red{\tau}}				% =tau=>
\newcommand{\bRedt}{\bRed{\tau}}				% =tau=>
\newcommand{\lredt}{\lred{\tau}}			% -tau->
\newcommand{\blredt}{\blred{\tau}}			% -tau->
\newcommand{\lRedt}{\lRed{\tau}}			% =tau=>
\newcommand{\barb}{\bar{b}}				% bar(b) (CCS)
\newcommand{\redbb}{\red{\barb}}			% -bar(b)-> (CCS)
\newcommand{\melt}{\rightharpoonup}			% -` (melting)
\newcommand{\react}{\mapsto}				% |-> (reaction)

\newcommand{\aout}[1]{\lout\,#1}			% out y action
\newcommand{\ain}[1]{\lin\,#1}				% in x action
\newcommand{\lout}{{\textit{out}}}			% `out' word
\newcommand{\lin}{{\textit{in}}}			% `in' word
\newcommand{\Aout}[1]{{\textit{Out}}\,#1}		% Out Y set
\newcommand{\Ain}[1]{{\textit{In}}\,#1}			% In X set


% Relations
\newcommand{\sbis}{\sim}		% strong
\newcommand{\wbis}{\approx}		% weak

% Text mode
\newcommand{\lts}{{\small LTS}}				% LTS
\newcommand{\ltss}{{\small LTSs}}			% plural
\newcommand{\flts}{{\small FLTS}}			% fibered LTS

% Conditions
\newcommand{\arule}[1]{\trule{\sc #1}}
\newcommand{\OBcom}{\arule{ob1}}	% out buf (1)
\newcommand{\OBcon}{\arule{ob2}}	% out buf (2)
\newcommand{\OBdet}{\arule{ob3}}	% out buf (3)
\newcommand{\OQcom}{\arule{oq1}}	% out que (1)
\newcommand{\OQcon}{\arule{oq2}}	% out que (2)
\newcommand{\OQdet}{\arule{oq3}}	% out que (3)
\newcommand{\IBcom}{\arule{ib1}}	% in buf (1)
\newcommand{\IBcon}{\arule{ib2}}	% in buf (2)
\newcommand{\IBdet}{\arule{ib3}}	% in buf (3)
\newcommand{\IBacc}{\arule{ib4}}	% in buf (4)
\newcommand{\IQcom}{\arule{iq1}}	% in que (1)
\newcommand{\IQcon}{\arule{iq2}}	% in que (2)
\newcommand{\IQdet}{\arule{iq3}}	% in que (3)
\newcommand{\IQacc}{\arule{iq4}}	% in que (4)
\newcommand{\FBcom}{\arule{fb1}}	% out buf feedback (1)
\newcommand{\FBcon}{\arule{fb2}}	% out buf feedback (2)
\newcommand{\FBdet}{\arule{fb3}}	% out buf feedback (3)
\newcommand{\FBtau}{\arule{fb5}}	% out buf feedback (4)
\newcommand{\FBfee}{\arule{fb4}}	% out buf feedback (5)
\newcommand{\FBwdet}{\arule{weak-fb3}}	% weak out det.
\newcommand{\OB}{\OBcom--\OBdet}	% ob1-3
\newcommand{\OQ}{\OQcom--\OQdet}	% oq1-3
\newcommand{\IB}{\IBcom--\IBacc}	% ib1-4
\newcommand{\IQ}{\IQcom--\IQacc}	% iq1-4
\newcommand{\FB}{\FBcom--\FBtau}	% obfb1-5
\newcommand{\nOBi}{\arule{ob2*}}	 	% non-elementary (ob)
\newcommand{\nOBii}{\arule{ob1*}}
\newcommand{\nOBiii}{\arule{ob4*}}
\newcommand{\nOBiv}{\arule{ob3*}}
\newcommand{\nOBcoind}{\nOBii--\nOBiii}
\newcommand{\nOB}{\nOBii--\nOBx}
\newcommand{\nOBx}{\arule{ob5*}}
\newcommand{\nIBi}{\arule{ib3*}}	 	% non-elementary (ib)
\newcommand{\nIBii}{\arule{ib2*}}
\newcommand{\nIBiii}{\arule{ib1*}}
\newcommand{\nIBx}{\arule{ib4*}}
\newcommand{\nIB}{\nIBiii--\nIBx}
\newcommand{\nOQi}{\arule{oq2*}}	 	% non-elementary (oq)
\newcommand{\nOQii}{\arule{oq1*}}
\newcommand{\nOQiii}{\arule{oq4*}}
\newcommand{\nOQiv}{\arule{oq3*}}
\newcommand{\nOQx}{\arule{oq5*}}
\newcommand{\nOQ}{\nOQii--\nOQx}
\newcommand{\nIQi}{\arule{iq3*}}	 	% non-elementary (iq)
\newcommand{\nIQii}{\arule{iq2*}}
\newcommand{\nIQiii}{\arule{iq1*}}
\newcommand{\nIQx}{\arule{iq4*}}
\newcommand{\nIQ}{\nIQiii--\nIQx}

% Names
\newcommand{\Sm}{{\Ss^-}}	% S- ; an lts obtained from S
\newcommand{\Pred}{P}		% predicate
\newcommand{\Ff}{{\cal F}}	% set-valued operator
\newcommand{\Gg}{{\cal G}}	% set-valued operator
\newcommand{\One}{{\cal I}}	% buffer of capacity one (lts)
\newcommand{\Que}{{\cal Q}}	% queue (lts)
\newcommand{\Buf}{{\cal B}}	% buffer (lts)
\newcommand{\tensorunit}{{\bf I}} % tensor unit (lts)
\newcommand{\BUF}{\textbf{\bf Buf}}	% category 
\newcommand{\QUE}{\textbf{\bf Que}}	% category 
\renewcommand{\B}{B}		% set of ``visible'' non-i/o actions
\newcommand{\weakclos}[1]{{#1}^{\scriptscriptstyle\Rightarrow}}
\newcommand{\fm}[1]{{#1}^*}		% free monoid
\newcommand{\fcm}[1]{{#1}^{**}}		% free comm. monoid
\newcommand{\eword}{\epsilon}		% the empty word
\newcommand{\eset}{\emptyset}		% the empty multiset
\newcommand{\Nn}{{\cal N}}		% set of pi-calc names
\newcommand{\Act}{\textit{Act}}		% CCS Actions
\newcommand{\defeqn}{\,\stack{\textrm{\rm def}}=\,} % definition eqn's A=P for CCS.
\newcommand{\ccsrest}{\setminus}	% P\L
\newcommand{\SSccs}{\Ss_{\textrm{\rm CCS}}} 	% name of CCS as an LTS
\newcommand{\SSPi}{\Ss_{\pi}}		% name of pi-calc LTS
\newcommand{\SSjoin}{\Ss_{\textrm{\rm join}}}		% join calculus as lts
\newcommand{\nl}{\\[2ex]}		% newline in table of inf.rules
\newcommand{\II}{{\cal I}}		% base (or index) cat
\newcommand{\Two}{{\bf 2}}		% 2-element cat
\newcommand{\IT}{\II^{\Two}}		% functor cat
\newcommand{\ITstab}{\IT_{\textrm{\rm stab}}}	% functor cat; stable nat. transf.

% CCS rules
\newcommand{\act}{\trule{act}}
\newcommand{\suma}{\trule{sum}}
\newcommand{\sumb}{\trule{$\textit{sum}'$}}
\newcommand{\comp}{\trule{comp}}
\newcommand{\compb}{\trule{$\textit{comp}'$}}
\newcommand{\synch}{\trule{synch}}
\newcommand{\res}{\trule{res}}
\newcommand{\rel}{\trule{rel}}
\newcommand{\rec}{\trule{rec}}

% Pi calculus rules
\newcommand{\pitau}{\trule{$\tau$}}
\newcommand{\piin}{\trule{in}}
\newcommand{\piout}{\trule{out}}
\newcommand{\pioutex}{\trule{out$_{\textit{ex}}$}}
\newcommand{\pinu}{\trule{$\nu$}}
\newcommand{\pisynch}{\trule{synch}}
\newcommand{\pisynchex}{\trule{synch$_{\textit{ex}}$}}
\newcommand{\picomp}{\trule{comp}}
\newcommand{\pisum}{\trule{sum}}
\newcommand{\pirep}{\trule{rep}}
\newcommand{\picong}{\trule{cong}}
\newcommand{\piaddname}{\trule{add-names}}

% General Definitions
\newcommand{\tuple}[1]{\langle#1\rangle}		% <a,b,c...>
\newcommand{\rtuple}[1]{(#1)}	%round tuple		% (a,b,c...)
\newcommand{\pair}{\tuple}				% <a,b>
\newcommand{\eqdef}{:=}					% := or =_{def}
\newcommand{\tu}{\textunderline}
\newcommand{\idrel}{\Delta}		% identity relation
%\renewcommand{\todo}[1]{\par\noindent\fbox{\parbox{\textwidth}{#1}}\par}
\newcommand{\todoo}[1]{}		% marker
\newcommand{\jj}{\mbox{$\rightarrow$}}	% type X->Y
\newcommand{\jjB}{\jj_\B}		% X->_B Y
\newcommand{\fn}[1]{{\textit{fn}(#1)}}	% free names
\newcommand{\bn}[1]{{\textit{bn}(#1)}}	% bound names
\newcommand{\dn}[1]{{\textit{dn}(#1)}}	% defined names
\newcommand{\n}[1]{{\textit{n}(#1)}}	% names
\newcommand{\joindef}[2]{\textbf{def}\ #1\ \textbf{in}\ #2}	% def D in P
\newcommand{\pinull}{\textbf{0}}		% 0 in pi-calc
\newcommand{\feedback}[1]{\circlearrowleft #1}  % feedback X->Y 
\newcommand{\fee}[1]{{#1}^\circ}	% feedback X->X
\newcommand{\varfee}[1]{{#1}^{\bullet}}
\newcommand{\pcp}{\|}
\newcommand{\pcpf}{|}

% Diagrams

%  \diagcx  	\diagxc		\diagcc		\diagu	
%   #1 #2 #3 	#1 #2 #3	  #1 #2 #3	  #1    #2
% #4| 		       |#4	#4|	 |#5	#3|	 |#4
%   v		       v	  v      v	  v      v
%   #5		      #5 	  #6 #7 #8	  #5 #6 #7

\newlength{\diaglen}
\newcommand{\diagcx}[5]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}\ar[d]_<>(.5){#4}&*+!{#3}\\*+!{#5}}}}
\newcommand{\diagxc}[5]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}&*+!{#3}\ar[d]^<>(.5){#4}\\&*+!{#5}}}}
\newcommand{\diagcc}[8]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}\ar[d]_<>(.5){#4}&*+!{#3}\ar[d]^<>(.5){#5}\\
*+!{#6}\ar@{}[r]|<>(.5)*+!{#7}&*+!{#8}}}}
\newcommand{\diagCx}[5]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}\ar@{=>}[d]_<>(.5){#4}&*+!{#3}\\*+!{#5}}}}
\newcommand{\diagxC}[5]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}&*+!{#3}\ar@{=>}[d]^<>(.5){#4}\\&*+!{#5}}}}
\newcommand{\diagCC}[8]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}\ar@{=>}[d]_<>(.5){#4}&
*+!{#3}\ar@{=>}[d]^<>(.5){#5}\\
*+!{#6}\ar@{}[r]|<>(.5)*+!{#7}&*+!{#8}}}}
\newcommand{\diagcC}[8]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}\ar[d]_<>(.5){#4}&*+!{#3}
\ar@{=>}[d]^<>(.5){#5}\\*+!{#6}\ar@{}[r]|<>(.5)*+!{#7}&*+!{#8}}}}
\newcommand{\diagCc}[8]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}\ar@{=>}[d]_<>(.5){#4}&*+!{#3}
\ar[d]^<>(.5){#5}\\*+!{#6}\ar@{}[r]|<>(.5)*+!{#7}&*+!{#8}}}}
\newcommand{\diagCq}[8]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}\ar@{=>}[d]_<>(.5){#4}&*+!{#3}
\ar@{=}[d]^<>(.5){#5}\\*+!{#6}\ar@{}[r]|<>(.5)*+!{#7}&*+!{#8}}}}
\newcommand{\diagxq}[5]{\settowidth{\diaglen}{$#2$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar@{}[r]|<>(.5)*+!{#2}&*+!{#3}\ar@{=}[d]^<>(.5){#4}\\&*+!{#5}}}}
\newcommand{\diagu}[7]{\settowidth{\diaglen}{$#6$}
	\vcenter{\xymatrix@R=1.5em@C=\diaglen{*+!{#1}
\ar[d]_<>(.5){#3}&*+!{#2}\ar[d]^<>(.5){#4}\\
*+!{#5}\ar@{}[r]|<>(.5)*+!{#6}&*+!{#7}}}}

%  \diagd  	\diage		\diagf		\diagg		\diagh
%      #2	   #2		     #2		     #2		     #2
%   #1--->#3 	#1--->#3	  #1--->#3	  #1--->#3	  #1--->#3
% #4| 		       |#4	#4|	 |#5	#4|   /		     \   |#5
%   v		       v	  v  #7  v	  v  /#5	    #4\  v
%   #5		      #5 	  #6--->#8	  #6		        #6
%
%  \diagi
%        
%         #1 	
%          |#2		
%          v		
%   #3--->#5		
%      #4

\newcommand{\diagd}[5]{\xymatrix{{#1}\ar[r]^<>(.5){#2}\ar[d]_{#4}&{#3}\\{#5}}}
\newcommand{\diage}[5]{\xymatrix{{#1}\ar[r]^<>(.5){#2}&{#3}\ar[d]^{#4}\\&{#5}}}
\newcommand{\diagf}[8]{\xymatrix{{#1}\ar[r]^<>(.5){#2}\ar[d]_{#4}&{#3}\ar[d]^{#5}\\
		 {#6}\ar[r]^<>(.5){#7}&{#8}}}
\newcommand{\diagfpull}[8]{\xymatrix{{#1}\pullback{r}{d}\ar[r]^<>(.5){#2}
		 \ar[d]_{#4}&{#3}\ar[d]^{#5}\\
		 {#6}\ar[r]^<>(.5){#7}&{#8}}}
\newcommand{\diagD}[5]{\xymatrix{{#1}\ar@{=>}[r]^<>(.5){#2}
		\ar@{=>}[d]_{#4}&{#3}\\{#5}}}
\newcommand{\diagF}[9]{\xymatrix{{#1}\ar[rr]^<>(.5){#2}\ar[d]_{#4}&&
		{#3}\ar@{=>}[d]^{#4}\\{#5}\ar@{=>}[r]^<>(.5){#6}&
		{#7}\ar@{}[r]|{#8}&{#9}}}
\newcommand{\diagg}[6]{\xymatrix{{#1}\ar[r]^<>(.5){#2}\ar[d]_{#4}&{#3}\ar[dl]^{#5}\\{#6}}}
\newcommand{\diagh}[6]{\xymatrix{{#1}\ar[r]^<>(.5){#2}\ar[dr]_{#4}&{#3}\ar[d]^{#5}\\&{#6}}}
\newcommand{\diagi}[5]{\xymatrix{&{#1}\ar[d]^{#2}\\
		 {#3}\ar[r]_{#4}&{#5}}}

% Formated properties for Tables tab-ob -- tab-iq
\newcommand{\property}[3]{
    \mbox{ 	\begin{tabular}{@{}c@{}} 	 \fbox{
$\begin{array}{@{}c@{}}{#3} \\ \mbox{#2}\end{array}$ 	 } 	 \\
\textit{#1} 	\end{tabular} } }
\newcommand{\propertynoside}[2]{
    \mbox{ 	\begin{tabular}{@{}c@{}} 	 \fbox{
$\begin{array}{@{}c@{}}{#2}\end{array}$ 	 } 	 \\
\textit{#1} 	\end{tabular} } }  % no side condition

\newcommand{\propertya}[3]{
    \mbox{ 	\begin{tabular}{@{}c@{}} 	 \hline
\vline$#3$\vline\\ 	 \vline{#2}\vline\\ 	 \hline
    \textit{#1} 
	\end{tabular} } }

%======================================================================
% START OF DOCUMENT
\begin{document}

%======================================================================
% PRELIMINARY PAGES
\pagenumbering{roman}
\doublespaced

% large lettering and lots of white space for title and copyright
\large\newlength{\oldparskip}\setlength\oldparskip{\parskip}\parskip=.5in

%----------------------------------------------------------------------
% Title page: page (i)
\def\thetitle{%
  FUNCTIONALITY, POLYMORPHISM, AND CONCURRENCY:\\
  A MATHEMATICAL INVESTIGATION OF PROGRAMMING PARADIGMS
}
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
  \thetitle
  
  Peter Selinger

  A Dissertation in Mathematics
\end{center}

\noindent\singlespaced\large  
  Presented to the Faculties of the University of Pennsylvania in
  Partial Fulfillment of the Requirements for the Degree of Doctor of
  Philosophy

\doublespaced\large
\begin{center}  
  1997
\end{center}

\noindent\makebox[0in][l]{\rule[2ex]{3in}{.3mm}} 
  Supervisor of Dissertation

\noindent\makebox[0in][l]{\rule[2ex]{3in}{.3mm}} 
  Graduate Group Chairperson
\vspace*{\fill}
\cleardoublepage

%----------------------------------------------------------------------
% Copyright notice. If desired. Page (ii)
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
  COPYRIGHT

  PETER SELINGER

  1997
\end{center}
\vspace*{\fill}
\cleardoublepage

% back to normal size text and normal white space
\normalsize\parskip=\oldparskip

%----------------------------------------------------------------------
% Dedication.

\vspace*{\fill}
\begin{center}{\it\large
  In Memory of
  Moez Alimohamed

  1967--1994}
\end{center}
\vspace*{\fill}

%----------------------------------------------------------------------
% Acknowledgments.

\singlespaced
\chapter*{Acknowledgments}

{\parindent=0in\parskip=.6em
This research was supported by graduate fellowships from the Institute for
Research in Cognitive Science and from the School of Arts and Sciences at
the University of Pennsylvania, and by an Alfred P.~Sloan Doctoral
Dissertation Fellowship.

Some of the results in Chapters~\ref{cha-order} and {\ref{cha-finite}} were
announced in a paper that appeared in the Proceedings of the Eleventh
Annual IEEE Symposium on Logic in Computer Science {\cite{Sel96}}. Parts of
Chapter~\ref{cha-asynch} are scheduled to appear in the Proceedings of
CONCUR~'97 {\cite{Sel97b}}.

Part of this research was done while I was visiting the Isaac Newton
Institute at the University of Cambridge as an affiliated participant of
the Semantics of Computation Program in the Fall of 1995.

I am grateful to Gordon Plotkin for introducing me to the problem of
partial orders on term models, and for many stimulating and enjoyable
discussions on the lambda calculus. He has kindly consented to the
inclusion of his previously unpublished proof of Theorem~\ref{thm-gordon},
as well as the material in Section~\ref{sec-abs-unord-comb-algs}, some of
which resulted from his discussions with Alex Simpson.

I would also like to thank Peter Freyd, Furio Honsell, Martin Hyland,
Catuscia Palamidessi, Benjamin Pierce, Simona Ronchi, Davide Sangiorgi,
Dana Scott, Phil Scott, and Glynn Winskel. They all have contributed
valuable comments on parts of this work at various stages of its
completion.

Thanks to Peter Freyd, David Harbater, Andre Scedrov, and Scott Weinstein
for serving on my Ph.D. committee.

Thanks to the staff at the Math Department at the University of
Pennsylvania for helping me time and again with the administrative aspects
of being a graduate student.

Thanks to Jeny Carden, for her love and support.

Finally, I would like to express my special gratitude to my advisor Andre
Scedrov for his guidance, support, candid criticism, and for his faith in
my ability to complete this task.
\vspace{2em}

\hfill Philadelphia, June 1997
}


\cleardoublepage

%----------------------------------------------------------------------
% Abstract (350 Words) 
\vspace*{.5in}
\doublespaced
\begin{center}
  ABSTRACT\\
\thetitle\\
\vspace{.2in}
  Peter Selinger\\
  Andre Scedrov
\end{center}
\vspace{.2in}
\singlespaced

\noindent
The search for mathematical models of computational phenomena often leads
to problems that are of independent mathematical interest. Selected
problems of this kind are investigated in this thesis. First, we study
models of the untyped lambda calculus. Although many familiar models are
constructed by order-theoretic methods, it is also known that there are
some models of the lambda calculus that cannot be non-trivially ordered. We
show that the standard open and closed term algebras are unorderable.  We
characterize the absolutely unorderable $\T$-algebras in any algebraic
variety $\T$. Here an algebra is called absolutely unorderable if it cannot
be embedded in an orderable algebra. We then introduce a notion of finite
models for the lambda calculus, contrasting the known fact that models of
the lambda calculus, in the traditional sense, are always non-recursive.
Our finite models are based on Plotkin's syntactical models of reduction.
We give a method for constructing such models, and some examples that show
how finite models can yield useful information about terms. Next, we study
models of typed lambda calculi. Models of the polymorphic lambda calculus
can be divided into environment-style models, such as Bruce and Meyer's
non-strict set-theoretic models, and categorical models, such as Seely's
interpretation in {\PL}-categories.  Reynolds has shown that there are no
set-theoretic strict models. Following a different approach, we investigate
a notion of non-strict categorical models. These provide a uniform
framework in which one can describe various classes of non-strict models,
including set-theoretic models with or without empty types, and Kripke-style
models. We show that completeness theorems correspond to categorical
representation theorems, and we reprove a completeness result by Meyer
{\etal} on set-theoretic models of the simply-typed lambda calculus with
possibly empty types.  Finally, we study properties of asynchronous
communication in networks of communicating processes. We formalize several
notions of asynchrony independently of any particular concurrent process
paradigm. A process is asynchronous if its input and/or output is filtered
through a communication medium, such as a buffer or a queue, possibly with
feedback.  We prove that the behavior of asynchronous processes can be
equivalently characterized by first-order axioms.


\singlespaced
\def\contentsname{Contents\microfilm{\vskip-2.5ex}}
\cleardoublepage

%----------------------------------------------------------------------
% Table of Contents

\tableofcontents
\cleardoublepage

%----------------------------------------------------------------------
% List of Tables
\listoftables

%======================================================================
% MAIN PAGES

\draftspaced\normalsize

\newpage
\pagenumbering{arabic}

%======================================================================
\cleardoublepage
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}

The central aim in giving mathematical meaning to computer programs is to
represent {\em computational objects}, such as procedures, data types, or
communication channels, by {\em mathematical objects}, such as functions,
sets, or more generally, points in suitable mathematical spaces. Often, one
begins with an idealized programming language, such as the lambda calculus
or Milner's calculus of communicating systems, and then seeks to find a
mathematical model that reflects the relevant computational properties.
The search for such models is guided by computational as well as
mathematical intuitions, and it often leads to problems that are of
independent mathematical interest. Some selected problems of this kind are
investigated in this dissertation.

The first part of this thesis is devoted to the model theory of the untyped
lambda calculus. D. Scott discovered in the late 1960's that models of the
untyped lambda calculus can be constructed by a combination of
order-theoretic and topological methods. Scott's methods have been widely
studied and adapted to numerous situations, and today one can choose from a
wide array of model constructions that are based on Scott's principles.  On
the other hand, there are results that indicate that Scott's methods may
not in general be complete: Honsell and Ronchi Della Rocca {\cite{HRDR92}}
have shown that there exists a lambda theory that does not arise as the
theory of a reflexive model in the cartesian-closed category of complete
partial orders and Scott-continuous functions.  Moreover, there are
properties that one may desire in a model, but that are incompatible with
the presence of a partial order: for instance, Plotkin {\cite{Plo96}} has
recently shown that there exists an extensional lambda algebra which is
{\em finitely separable}. By definition, a lambda algebra $X$ is finitely
separable if for every finite subset $A\seq X$ and for every function
$f:A\ii X$, there exists an element $\hatt{f}\in X$ such that $\hatt{f}\app
x=f(x)$ for all $x\in X$. It is not hard to see that a finitely separable
algebra cannot be non-trivially partially ordered in a way such that the
order is compatible with the algebra structure.

In general, we define a lambda algebra $X$ to be {\em unorderable} if there
does not exist a non-trivial partial order on $X$ for which the application
operation is monotone.  Our first main result is the following: The
standard open and closed term algebras of the $\lambda\beta$- and
$\lambda\beta\eta$-calculi are unorderable. Recall that the standard term
algebras are just made up from lambda terms, taken up to $\beta$- or
$\beta\eta$-equivalence. The unorderability of the standard term algebras
is a surprising fact, because the algebras that were previously known to be
unorderable, such as Plotkin's finitely separable algebra, require a much
more delicate syntactic construction.  As a consequence of this result, it
follows that if a partially ordered model of the untyped lambda calculus is
complete for one of the theories $\theorybeta$ or $\theorybetaeta$, then
the denotations of closed terms in that model are pairwise incomparable,
{\ie} the term denotations form an anti-chain.

Closely related to the question of unorderability is the question of {\em
order-incompleteness\/}: does there exist a lambda theory that does not
arise as the theory of a non-trivially partially ordered model?  Or,
expressed in terms of algebras: does there exist a lambda algebra which
cannot be embedded in an orderable one? We call such an algebra {\em
absolutely unorderable}. The concept of absolute unorderability can be
formulated in any algebraic variety $\T$, and our second main result is a
theorem in universal algebra: In any algebraic variety $\T$, an algebra
$\Aa$ is absolutely unorderable if and only if, for some $n\geq 1$, there
exist polynomials $M_1,\ldots,M_n\in\Aa[x_1,x_2,x_3]$ such that the
equations $t=M_1(t,u,u)$, $M_i(t,t,u)=M_{i+1}(t,u,u)$ for $1\leq i<n$, and
$M_n(t,t,u)=u$ hold in $\Aa[u,t]$. Operators $M_1,\ldots,M_n$ satisfying
this condition are called {\em generalized {\Malcev} operators}. Such
operators were first used by Hagemann and Mitschke {\cite{HaM73}} to
characterize varieties with $n$-permutable congruences. The connection to
unorderability was first noticed by Taylor {\cite{Tay74,BFT76}}, who proved
that algebras in a variety with $n$-permutable congruences are unorderable;
the converse is a new result.

As a consequence, the question of order-incompleteness for the untyped
lambda calculus has been reduced to the question whether it is consistent,
for some $n\geq 1$, to add generalized {\Malcev} operators $M_1,\ldots,M_n$
to the lambda calculus. It was proved by Plotkin and Simpson that a
{\Malcev} operator is inconsistent with the lambda calculus for $n=1$.
Later, Plotkin and myself showed that it is also inconsistent for $n=2$. In
the remaining cases, the answer is not known.

We continue our investigation of models of the untyped lambda calculus by
introducing a notion of {\em finite lambda models}. These models provide a
tool for predicting the evaluation behavior of a lambda term by finitary
means. This yields a novel proof method for proving inequalities of untyped
lambda terms. Finite models differ from traditional models of the untyped
lambda calculus, which are always infinite and in fact never even
recursive, in that they are models of {\em reduction}, rather than models
of {\em conversion}. This means that they are equipped with a partial order
and a soundness property of the form $M\reduces
N\imp\sem{M}{}\leq\sem{N}{}$, where $\reduces$ denotes either $\beta$- or
$\beta\eta$-reduction. Models of reduction were considered by several
authors {\cite{Gir86,JMZ92,Plo94}}, and we use a formulation which was
given by Plotkin {\cite{Plo94}} in the spirit of the familiar syntactical
lambda models {\cite{Bar84}}. We focus on practical methods of constructing
such models, and we show in two examples that, despite their simplicity,
finite models can yield useful information about lambda terms.

The second part of this thesis is devoted to models of the simply-typed and
the polymorphic lambda calculus. The models in the literature follow one of
two basic designs: set-theoretic environment-style models, such as Henkin
models for the simply-typed lambda calculus {\cite{Fri75}} or Bruce-Meyer
models for polymorphism {\cite{BM84}}, and categorical models, such as the
interpretation of the simply-typed calculus in a cartesian closed category
{\cite{Lam80b}} or of the polymorphic calculus in a {\PL}-category
{\cite{See87}}. Environment-style models are typically {\em non-strict}, in
the sense that a function type $\sigma\ii\tau$ is interpreted as a {\em
subset} of the set of functions from $\sigma$ to $\tau$. On the other hand,
categorical models are always strict.

Reynolds has shown that there are no strict set-theoretic models of the
polymorphic lambda calculus {\cite{Rey84}}. Here, we take the opposite
approach and consider non-strict categorical models. This generalizes both
environment-style models and strict categorical models. The central concept
is that of a {\em Henkin representation}: a functor $H$ between
cartesian-closed categories that preserves finite products, such that for
all objects $A,B$, the canonical morphism $H(B^A)\ii H(B)^{H(A)}$ is monic.
Henkin representations provide a uniform framework in which one can
describe various classes of non-strict models, including set-theoretic
models with possibly empty types {\cite{MMMS87}}, set-theoretic models with
non-empty types {\cite{Fri75}}, and Kripke-style models {\cite{MM91}}. We
show that completeness theorems for each of these classes of models
correspond naturally to categorical Henkin representation theorems. One
such Henkin representation theorem characterizes those cartesian-closed
categories that can be Henkin-embedded in the category of sets: we show
that this is the case if and only if every object $A$ is either partially
initial, or the canonical morphism $A\ii 1$ is epic.  This allows a new
proof of a result by Meyer {\etal} {\cite{MMMS87}} on the semantic
consequences that hold in set-theoretic models of the simply-typed lambda
calculus with possibly empty types.

The last part of this dissertation is concerned with the study of
properties of asynchronous communication in networks of communicating
processes.  Informally, communication in such a network is said to be {\em
synchronous} if message transmission is instantaneous, such that sender and
receiver must be available at the same time in order to communicate. It is
{\em asynchronous} if messages are assumed to travel through a
communication medium with possible delay, such that the sender cannot be
certain when a message has been received.  Asynchronous communication is
often studied in the framework of a concurrent process calculus such as the
asynchronous $\pi$-calculus {\cite{HT91,Bou92}} or the join calculus
{\cite{FG96,FGLMR96}}. Here, we study asynchronous communication in
general, independently of any particular process paradigm.  We model
processes by labeled transition systems with input and output.  These
transition systems are similar to the input/output automata by Lynch and
Stark {\cite{LS89}}, but our presentation is more category-theoretic in a
style that resembles Abramsky's interaction categories
{\cite{Abr94,AGN94}}. In particular, we adopt Abramsky's notation $\Ss;\Tt$
for the sequential composition of two processes, by which we mean the
process obtained by connecting the output of $\Ss$ to the input of $\Tt$.

First, we formalize the intuitive notion of asynchrony in elementary terms:
we define a process to be asynchronous if its input and/or output is
filtered through an explicitly modeled communication medium, such as a
buffer or a queue, possibly with feedback. For instance, we call a process
{\em out-buffered} if it is, up to weak bisimulation, of the form
$\Ss;\Buf$, where $\Buf$ is a special buffer process. Our main result about
asynchronous processes is a characterization of various different such
notions of asynchrony in terms of first- and second-order axioms. These
axioms refer directly to the behavior of a process, without mentioning
buffers or queues explicitly. For instance, a process is out-buffered if
and only if it is weakly bisimilar to a process satisfying three properties
which we call output-commutativity, output-confluence, and
output-determinacy. We illustrate these concepts by applying them to an
asynchronous version of Milner's CCS and to the core join calculus.

This thesis is organized as follows: Chapter~1 is a summary of standard
concepts of category theory, domain theory, and universal algebra, which
are needed throughout the thesis. Chapter~2 is an introduction to the
untyped lambda calculus and its combinatory models. In Chapter~3, we
investigate unorderable and absolutely unorderable models of the untyped
lambda calculus. Chapter~4 is devoted to finite lambda models. In
Chapter~5, we study Henkin representation theorems and their applications
to non-strict models of the simply-typed and polymorphic lambda calculi. In
Chapter~6, we investigate properties of asynchronous communication.


%======================================================================
\cleardoublepage
\chapter{Preliminaries}\label{cha-basic}

We begin by gathering some basic concepts from category theory, domain
theory, and universal algebra. This is mostly for the purpose of
fixing terminology and notation for the later chapters of this thesis,
and to provide a brief reference. We do not give any proofs in this
chapter. For a more complete and detailed introduction to category
theory, see {\eg} {\cite{FrS89}} or {\cite{Mac71}}. For an
introduction to domain theory, see {\eg} {\cite{AJ94}} or
{\cite{Plo83}}.  For an introduction to universal algebra, see {\eg}
{\cite{Gra68}} or {\cite{Coh81}}.

%======================================================================
\section{Basic category theory}

%----------------------------------------------------------------------
\subsection{Categories}

A {\defit category\index{category}}
$\Cc=\tuple{\obj{\Cc},\hom{-,-},\id,\cp}$ consists of a class $\obj{\Cc}$
of {\defit objects\index{object in category}}, together with a set
$\hom{A,B}$ of {\defit morphisms\index{morphism}} for each pair of objects
$A,B\in\obj{\Cc}$, and together with operations
\[\begin{array}{l}
	\id_A\in\hom{A,A}
\\	\cp_{A,B,C}:\hom{B,C}\times\hom{A,B}\ii\hom{A,C}
\end{array}\]
for all $A,B,C\in\obj{\Cc}$, satisfying
\[\begin{array}{ll}
	\id_B\cp f=f=f\cp \id_A,
&	\mbox{for $f\in\hom{A,B}$}
\\	(h\cp g)\cp f=h\cp(g\cp f)
&	\mbox{for $f\in\hom{A,B}$, $g\in\hom{B,C}$, $h\in\hom{C,D}$.}
\end{array}\]
We will often omit the subscripts on $\id$ and $\cp$. A morphism $\id_A$ is
called an {\defit identity morphism\index{identity
morphism}\index{morphism!identity}}, and $g\cp f$ is called the {\defit
composition\index{composition}} of $f$ and $g$. The set $\hom{A,B}$ is
called the {\defit hom-set\index{hom-set}} of $A$ and $B$. If we want to
make the category unambiguous, we also write hom-sets as
$\homof{\Cc}{A,B}$. A morphism $f\in\hom{A,B}$ is also written $f:A\ii B$
or $A\stackrel{f}{\ii}B$, and we call $A$ the {\defit source\index{source
of a morphism}} or the {\defit domain\index{domain of a morphism}} and $B$
the {\defit target\index{target of a morphism}} or the {\defit
codomain\index{codomain of a morphism}} of $f$. If $f:A\ii B$ and $g:B\ii
C$, then we sometimes write the composition $g\cp f$ in diagrammatic order
as $A\stackrel{f}{\ii}B\stackrel{g}{\ii}C$ or as $f;g$.

\begin{example}
The category $\Set$\index{category!of sets@of sets $\Set$} of sets has sets
as its objects, and functions as its morphisms. Notice that the collection
of all sets is not itself a set; this is why, in the definition of a
category, one allows the collection of objects to be a proper class. A
category is said to be {\defit small\index{category!small}\index{small
category}} if the collection of its objects is a set.
\end{example}

\noindent
A category is {\defit discrete\index{discrete
category}\index{category!discrete}} if its only morphisms are identity
morphisms.  If $\Cc$ is any category, then its {\defit dual
category\index{dual category}\index{category!dual}} $\Cc^{\op}$ is defined
by $\Obj{\Cc^{\op}}=\Obj{\Cc}$ and
$\homof{\Cc^{\op}}{A,B}=\homof{\Cc}{B,A}$, {\ie} by reversing the direction
of all morphisms.  If $\Cc$ and $\Dd$ are categories, then their {\defit
product\index{product!of categories}} $\Cc\times\Dd$ is defined by
$\Obj{\Cc\times\Dd}=\Obj{\Cc}\times\Obj{\Dd}$ and
$\hom{\pair{A,A'},\pair{B,B'}}=\hom{A,B}\times\hom{A',B'}$, with the
pointwise identities and composition.

A diagram
\[	\xymatrix{A\ar[r]^f\ar[d]_h&B\ar[d]^g\\C\ar[r]_k&D}
\]
is used as a notation for the statement
\[	\mbox{$f\in\hom{A,B}$ and $g\in\hom{B,D}$ and $h\in\hom{A,C}$
	and $k\in\hom{C,D}$ and $g\cp f=k\cp h$,}
\]
and similarly for other diagrams. Note that this notation is not meant
to imply that $A,B,C,D$ or $f,g,h,k$ are different. In the diagrammatic
notation, we may also omit the names of the objects. Of course, it is
then still understood that the appropriate morphisms are
composable. The symbol $\nocommute$ in a diagram removes exactly one
equation, such that
\[	\xymatrix{
	{\cdot}\ar@<1ex>[r]^g\ar@<-1ex>[r]_h\ar@{}[r]|{\nocommute}
&	{\cdot}\ar[r]^f 
& 	{\cdot}
	}
\]
means $f\cp g=f\cp h$. This diagram does not say whether
$g=h$. Diagrams are just a notation for ordinary mathematical
statements, and we may use them together with logical symbols,
quantifiers etc.

\begin{example}
A morphism $f$ is said to be {\defit
monic\index{monic}\index{morphism!monic}} or a {\defit
monomorphism\index{monomorphism}} if
\[	\forall g,h\sep(\xymatrix{
	{\cdot}\ar@<1ex>[r]^g\ar@<-1ex>[r]_h\ar@{}[r]|{\nocommute}
&	{\cdot}\ar[r]^f 
& 	{\cdot}
	}\sep\imp\sep g=h).
\]
Dually, $f$ is said to be {\defit epic\index{epic}\index{morphism!epic}} or an {\defit
epimorphism\index{epimorphism}} if
\[	\forall g,h\sep(\xymatrix{
	{\cdot}\ar[r]^f
&	{\cdot}\ar@<1ex>[r]^g\ar@<-1ex>[r]_h\ar@{}[r]|{\nocommute}
& 	{\cdot}
	}\sep\imp\sep g=h).
\]
Also, $f$ is said to be {\defit iso\index{iso}\index{morphism!iso}} or an
{\defit isomorphism\index{isomorphism}} if
\[	\exists g\sep\vcenter{\xymatrix{
	{\cdot}\ar[rr]^{\id}\ar[rd]_g
&&	{\cdot}\ar[rd]^g
\\&	{\cdot}\ar[rr]_{\id}\ar[ru]_f
&&	{\cdot}
	}}
\]
If $f$ is an isomorphism, then $g$ is uniquely determined. $g$ is called
the {\defit inverse\index{inverse}\index{morphism!inverse}} of $f$
and it is denoted by $f^{-1}$.  If there is an isomorphism $f:A\ii B$, then
$A$ and $B$ are said to be isomorphic objects. We sometimes write
$f:A\iimonic B$ for a monomorphism, $f:A\iiepic B$ for an epimorphism, and
$f:A\iiso B$ for an isomorphism. Notice that if $f:A\ii B$ has a left
inverse $g\cp f=\id_A$, then $f$ is a monic, called a {\defit split
monic\index{split monic}\index{monic!split}}, and $g$ is an epic, called a
{\defit split epic\index{split epic}\index{epic!split}}. A collection of
morphisms $\family{A\catarrow{f_i}B_i}{i\in I}$ with the same source is
called {\defit collectively monic\index{collectively
monic}\index{monic!collective}} or a {\defit monic
cone\index{monic!cone}\index{cone!collectively monic}} if for all $g,h:C\ii
A$, whenever $f_i\cp g=f_i\cp h$ for all $i\in I$, then $g=h$.
\end{example}

%----------------------------------------------------------------------
\subsection{Functors}

If $\Cc$ and $\Dd$ are categories, then a {\defit (covariant)
functor\index{functor}\index{functor!covariant}\index{covariant functor}}
$F:\Cc\ii\Dd$ is a map $F:\Obj{\Cc}\ii\Obj{\Dd}$ of objects, together with
a map $F:\homof{\Cc}{A,B}\ii\homof{\Dd}{FA,FB}$ for each hom-set, such that
\[\begin{array}{l}
	F\id_A=\id_{FA}
\\	F(g\cp f)=Fg\cp Ff
\end{array}\]
The category of small categories, together with functors between them, is
denoted $\Cat$. A functor $F:\Cc^{\op}\ii\Dd$ is also called a {\defit
contravariant functor\index{functor!contravariant}\index{contravariant
functor}} from $\Cc$ to $\Dd$.

\begin{example}
For any category $\Cc$, there is a functor
$\Hom:\Cc^{\op}\times\Cc\ii\Set$, which is defined by
$\Hom(A,B)=\homof{\Cc}{A,B}$ and $\Hom(f,g)(x)=g\cp x\cp f$.  For any
object $A\in\Obj{\Cc}$, the functor $(A,-):\Cc\ii\Set$ is called the $A$-th
{\defit (covariant) representable functor\index{representable
functor}\index{functor!representable}}. Dually, the functor
$(-,A):\Cc^{\op}\ii\Set$ is called the $A$-th {\defit contravariant
representable functor}.
\end{example}

\noindent
A functor $F:\Cc\ii\Dd$ is {\defit full\index{full
functor}\index{functor!full}} if each $F:\hom{A,B}\ii\hom{FA,FB}$ is
onto. $F$ is an {\defit embedding\index{embedding!of
categories}\index{functor!embedding}} if each $F:\hom{A,B}\ii\hom{FA,FB}$
is one-to-one. We say $F$ is {\defit
faithful\index{functor!faithful}\index{faithful functor}} if it is an
embedding and it reflects isomorphisms, {\ie}, whenever $Ff$ is an
isomorphism, then so is $f$.

A category $\Cc$ is a {\defit subcategory\index{subcategory}} of $\Dd$ if
$\Obj{\Cc}\seq\Obj{\Dd}$, and for all $A,B\in\Obj{\Cc}$,
$\homof{\Cc}{A,B}\seq\homof{\Dd}{A,B}$. The corresponding {\defit inclusion
functor\index{inclusion functor}\index{functor!inclusion}} $I:\Cc\ii\Dd$,
with $IA=A$ and $If=f$, is always an embedding. $\Cc$ is said to be a
{\defit full subcategory\index{full subcategory}\index{subcategory!full}}
if $I$ is full, and a {\defit faithful subcategory\index{faithful
subcategory}\index{subcategory!faithful}} if $I$ is faithful.

%----------------------------------------------------------------------
\subsection{Natural transformations}

A {\defit natural transformation\index{natural transformation}} $\eta:F\ii
G$ between functors $F,G:\Cc\ii\Dd$ is a family
$\family{\eta_A}{A\in\Obj{\Cc}}$ of morphisms $\eta_A:FA\ii GA$ such that
for all $f:A\ii B$,
\[	\xymatrix{
	FA\ar[d]_{Ff}\ar[r]^{\eta_A}
&	GA\ar[d]^{Gf}
\\	FB\ar[r]_{\eta_B}
&	GB
	}
\]
There is a category whose objects are functors $F:\Cc\ii\Dd$, for fixed
$\Cc$ and $\Dd$ (say, $\Cc$ is small). The morphisms are natural
transformations.  For any functor $F$, the identity natural transformation
$\id_F:F\ii F$ is defined by $(\id_F)_A=\id_{FA}$. Composition of natural
transformations $\eta:F\ii G$ and $\eta':G\ii H$ is defined by
$(\eta'\cp\eta)_A=\eta'_A\cp\eta_A$.  The resulting category is written
$\Dd^{\Cc}$, and it is called a {\defit functor category\index{functor
category}\index{category!functor category}}.

Two functors $F,G:\Cc\ii\Dd$ are said to be {\defit naturally
isomorphic\index{natural isomorphism}\index{isomorphism!natural}}, in
symbols $F\cong G$, if there are natural transformations $\eta:F\ii G$ and
$\eta^{-1}:G\ii F$ such that $\eta\cp\eta'=\id_G$ and $\eta'\cp\eta=\id_F$.

We sometimes write $\eta:F(A)\ii_{A}G(A)$, $\eta:F(A,B)\ii_{A,B}
G(A,B)$ etc.\ to express that $\eta$, as a transformation of functors,
is natural in the indicated arguments. Similarly, we write
$F(A)\cong_{A}G(A)$ etc.\ to express that $F$ and $G$ are naturally
isomorphic.  Notice that this is different from writing $(\forall
A)F(A)\cong G(A)$; the latter statement expresses only a condition on
objects, and not on morphisms.

An {\defit equivalence of categories\index{equivalence of
categories}\index{categories!equivalence of}} $\Cc$ and $\Dd$ is a pair of
functors $F:\Cc\ii\Dd$ and $G:\Dd\ii\Cc$ such that $G\cp F$ and $F\cp G$
are naturally isomorphic to the identity functors on $\Cc$ and $\Dd$,
respectively.

%----------------------------------------------------------------------
\subsection{Adjunctions}

An {\defit adjunction\index{adjunction}} between functors $F:\Cc\ii\Dd$ and
$G:\Dd\ii\Cc$ is a natural isomorphism
\[	\phi:\hom{FA,B}\iiso_{A,B}\hom{A,GB}.
\]
In this case, the pair of functors $F$ and $G$ is called an {\defit adjoint
pair\index{functor!adjoint}}, and we write $\phi:F\adjoint G$, or simply
$F\adjoint G$. $F$ is a {\defit left adjoint} of $G$ and $G$ is a {\defit
right adjoint} of $F$.  The {\defit unit\index{unit of adjunction}}
$u:\id_{\Cc}\ii G\cp F$ of an adjunction $\phi$ is the natural
transformation given by $u_A=\phi(\id_{FA})\in\hom{A,GFA}$, and the {\defit
co-unit\index{co-unit of adjunction}} $c:F\cp G\ii\id_{\Dd}$ is defined
dually.  Each of the entities $\phi$, $u$ and $c$ determines the two others
uniquely. Moreover, $F$ and $G$ determine each other up to natural
isomorphism.

%----------------------------------------------------------------------
\subsection{Limits and colimits}

Let $I$ be a small category, $\Cc$ a category. A {\defit
diagram\index{diagram}} in $\Cc$ modeled on $I$ is a functor
$\diagram:I\ii\Cc$. A {\defit cone\index{cone}} over a diagram $\diagram$
is a pair $\pair{D,\family{d_i}{i\in\Obj{I}}}$, consisting of an object $D$
and a family of morphisms $d_i:D\ii \diagram(i)$ for each $i\in\Obj{I}$,
such that for each $f:i\ii j$ in $I$,
\[	\xymatrix{
	{\diagram(i)}\ar[rr]^{\diagram(f)}
&&	{\diagram(j).}
\\&	D\ar[ul]^{d_i}\ar[ur]_{d_j}}
\]
A morphism between cones $\pair{E,\family{e_i}{i\in\Obj{I}}}$ and
$\pair{D,\family{d_i}{i\in\Obj{I}}}$ over a diagram $\diagram$ is an arrow
$f:E\ii D$ such that $e_i=d_i\cp f$ for all $i\in\Obj{I}$. A cone
$\pair{D,\family{d_i}{i\in\Obj{I}}}$ is called {\defit
limiting\index{limiting cone}\index{cone!limiting}} or a {\defit
limit\index{limit}\index{diagram!limit of}} if it is terminal among cones
over $\diagram$, {\ie} from any other cone
$\pair{E,\family{e_i}{i\in\Obj{I}}}$, there is a unique morphism of cones
$f:E\ii D$. Sometimes, we also call the object $D$ a limit. The morphisms
$e_i$ of a limiting cone are called {\defit limiting
morphisms\index{limiting morphism}\index{morphism!limiting}}. Limiting
cones, if they exist at all, are uniquely determined up to isomorphism.
Limiting cones are collectively monic. Cocones\index{cocone},
colimits\index{colimit} and colimiting morphisms\index{morphism!colimiting}
are defined dually.

Some special limits are of interest: A limit of a diagram that is modeled
on a discrete category is called a {\defit
product\index{product}\index{diagram!product}}. The limiting morphisms of a
product are called {\defit projections\index{projection
morphism}\index{morphism!projection}}. A limit of the empty diagram is
called a {\defit terminator\index{terminator}} or a {\defit terminal
object\index{terminal object}}. A limit of a diagram
that is modeled on the category
\[	\xymatrix{
	{\cdot}\ar@<1ex>[r]\ar@<-1ex>[r]\ar@{}[r]|{\nocommute}
& 	{\cdot}
	}
\]
is called an {\defit equalizer\index{equalizer}}. A limit of a diagram that
is modeled on the category
\[	\xymatrix{
&	{\cdot}\ar[d]
\\	{\cdot}\ar[r]
& 	{\cdot}
	}
\]
is called a {\defit pullback\index{pullback}}.  The dual concepts are
coproduct, coterminator or initial object, co-equalizer, and pushout.

\begin{definition}
A category is {\defit complete\index{complete
category}\index{category!complete}} if every small diagram has a limit, and
{\defit cocomplete\index{cocomplete category}\index{category!cocomplete}}
if every small diagram has a colimit.
\end{definition}

\begin{proposition}
A category is complete iff it has products and equalizers. It is
cocomplete iff it has coproducts and co-equalizers.
\end{proposition}


%----------------------------------------------------------------------
\subsection{Cartesian-closed categories}\label{subsec-definition-ccc}
	
Recall that an object $B$ is a {\defit terminator\index{terminator}} if for
all $A$, $\hom{A,B}$ is a singleton. A terminator is unique up to
isomorphism. If we have chosen a terminator in a category, we denote it by
$1$. The unique morphism in $\hom{A,1}$ is then denoted $\termarrow_A$.

A diagram
\[	\xymatrix{
&	P\ar[dl]_f\ar[dr]^g
\\	B && C
	}
\]
is called a {\defit (binary) product
diagram\index{product!binary}\index{diagram!binary product}\index{binary
product}} if for every pair of morphisms $q:A\ii B$ and $r:A\ii C$, there
exists a unique $s:A\ii P$ such that $f\cp s=q$ and $g\cp s=r$. This is the
case if and only if
\[	\hom{A,P}\cong_A\hom{A,B}\times\hom{A,C}
\]
via a natural isomorphism that relates $\id_P$ to the pair $\pair{f,g}$. 
Product diagrams are determined (for fixed $B$ and $C$) uniquely up to
isomorphism. If we have chosen, for any $B$ and $C$, a product
diagram, then we denote it by
\[	\xymatrix{
&	B\times C\ar[dl]_\proja\ar[dr]^\projb
\\	B && C.
	}
\]
The unique morphism $s:A\ii B\times C$ such that $\proja\cp s=q:A\ii B$ and
$\projb\cp s=r:A\ii C$ is then denoted $\pair{q,r}$. The operation that
takes $q$ and $r$ to $\pair{q,r}$ is called {\defit
pairing\index{pairing}\index{morphism!pairing}}. If
$b:B\ii B'$ and $c:C\ii C'$, then we denote by $b\times c$ the morphism
$\pair{b\cp\proja,c\cp\projb}:B\times B'\ii C\times C'$. This makes
$F(B,C)=B\times C$ into a functor.

In a category with chosen products, a diagram
\[	\xymatrix{{D\times B}\ar[r]^<>(.5)f&C}
\]
is called an {\defit exponential diagram\index{exponential
diagram}\index{diagram!exponential}} if for every morphism $g:A\times B\ii
C$ there is a unique $h:A\ii D$ such that
\[	\xymatrix{{D\times B}\ar[r]^<>(.5)f&C.\\
	A\times B\ar[u]^{h\times\id_B}\ar[ur]_g
	}
\]
This is the case if and only if
\[	\hom{A,D}\cong_A\hom{A\times B,C}
\]
via a natural isomorphism that relates $\id_D$ to $f$. For given $B$
and $C$, exponential diagrams are determined uniquely up to
isomorphism. If we have chosen, for any $B$ and $C$, an exponential
diagram, then we denote it by
\[	\xymatrix{{C^B\times B}\ar[r]^<>(.5)\appl&C.}
\]
The unique morphism $h:A\ii C^B$ such that
$\appl\cp(h\times\id_B)=g:A\times B\ii C$ is then denoted $\curry{g}$.  The
operation that takes $g$ into $\curry{g}$ is called {\defit
currying\index{currying}\index{morphism!currying}}.
The inverse operation, which takes $h$ to
$\uncurry{h}=\appl\cp(h\times\id_B)$, is called {\defit
uncurrying\index{uncurrying}\index{morphism!uncurrying}}.
If $b:B'\ii B$ and $c:C\ii C'$, then $c^b$ denotes the morphism
$\curry{(c\cp\appl\cp(\id_{C^B}\times b))}:C^B\ii {C'}^{B'}$. This makes
$F(B,C)=C^B$ into a functor, contravariant in the first argument and
covariant in the second.

\begin{remark}
The following identities are often useful, where $a:A'\ii A$, $h:A\ii C^B$,
$g:A\times B\ii C$: 
\[\begin{array}{rclcl}
	\curry{(g\cp(a\times\id_B))}&=&\curry{g}\cp a&:&A'\ii C^B
\\	\curry{\appl}&=&\id	&:& C^B\ii C^B
\\	\uncurry{(h\cp a)}&=&\uncurry{h}\cp(a\times \id_B)&:& A'\times B\ii C
\\	\uncurry{\id}&=&\appl&:& C^B\times B\ii C
\end{array}\]
\end{remark}

\begin{definition}
A {\defit cartesian-closed category (ccc)\index{cartesian-closed
category|see{ccc}}\index{ccc}\index{category!cartesian-closed|see{ccc}}} is
a category with chosen terminator, chosen binary product diagrams and
chosen exponential diagrams. A {\defit
ccc-representation\index{ccc!representation}\index{representation!of
ccc's}\index{functor!ccc-representation}} is a functor that preserves the
chosen terminator, product and exponential diagrams. A functor that
preserves ccc structure up to isomorphism is called a {\defit
ccc-representation up to isomorphism}.
\end{definition}

\begin{example}\label{exa-yoneda}
For any small category $\Cc$, the functor category $\Set^{\Cc^{\op}}$ is
cartesian-closed. The {\defit Yoneda embedding\index{Yoneda
embedding}\index{embedding!Yoneda}\index{functor!Yoneda}}
$Y:\Cc\ii\Set^{\Cc^{\op}}$ maps an object $A$ to the functor
$(-,A):\Cc^{\op}\ii\Set$.  The Yoneda embedding is full and faithful, and
if $\Cc$ is cartesian-closed, then $Y$ is a ccc-representation up to
isomorphism.  The functor category $\Set^{\Cc^{\op}}$ is called the {\defit
category of presheaves over $\Cc$}.\index{presheaf}\index{category!of
presheaves@of presheaves $\Set^{\Cc^{\op}}$}
\end{example}

%========================================================================
\section{Basic domain theory}

We gather some basic domain-theoretic concepts. For a more detailed
introduction, consult {\eg} the texts by Abramsky and Jung {\cite{AJ94}} or
Plotkin {\cite{Plo83}}.

%----------------------------------------------------------------------
\subsection{Preorders and posets}\label{subsec-preorders}

A binary relation $\leq$ on a set $D$ is called a {\defit
preorder\index{preorder}\index{order!preorder}} if
\begin{enumerate}
\item $\forall x\in D.$ $x\leq x$ (Reflexivity\index{reflexivity}).
\item $\forall x,y,z\in D.$ $x\leq y$ and $y\leq z$ 
\implies $x\leq z$ (Transitivity\index{transitivity}).
\suspendenumerate
\end{enumerate}
A preorder $\leq$ is a {\defit partial order\index{partial
order|see{order}}\index{order!partial}\index{order}} if, in addition,
\begin{enumerate}
\resumeenumerate
\item $\forall x,y\in D.$ $x\leq y$ and $y\leq x$ \implies
$x=y$ (Antisymmetry\index{antisymmetry}).
\end{enumerate}
A partially ordered set $\pair{D,\leq}$ is also called a {\defit
poset\index{poset|see{order}}}. A function $f:D\ii E$ between posets is
{\defit monotone\index{monotone function}\index{function!monotone}} if
$x\leq y$ implies $fx\leq fy$, for all $x,y\in D$.  We denote the category
of posets and monotone functions by $\POSET$. It is cartesian-closed. The
exponential $E^D$ is given by the set of all monotone functions from $D$ to
$E$, with the {\defit pointwise order\index{pointwise
order}\index{order!pointwise}}, $f\leq g$ if for all $x\in D$, $fx\leq gx$.

For $A\seq D$, let $\downdeal A$ be the set $\{y\in D\such \exists x\in
A.y\leq x\}$. A set $A$ is called {\defit downward closed\index{downward
closed set}} or a {\defit downdeal\index{downdeal}} if $A=\downdeal A$. If
$A=\{x\}$ is a singleton, we also write $\downdeal x=\downdeal\{x\}$. The
sets $\updeal A$\index{updeal} and $\updeal x$ are defined dually.  An
element $x\in A$ is said to be {\defit minimal} in $A$ if $\downdeal x\cap
A=\{x\}$. Also, $x\in A$ is said to be a {\defit minimum} or a {\defit
least element} of $A$ if $A\seq\updeal x$. Maximal elements\index{maximum
and minimum}\index{minimum and maximum} and greatest elements are defined
dually.  An element $b\in D$ is said to be an {\defit upper
bound\index{upper bound}\index{bound, upper and lower}} of $A$ if $a\leq b$
for all $a\in A$. If among the upper bounds of $A$ there is a least one, it
is called the {\defit least upper bound}\index{least upper bound}, the
{\defit join\index{join and meet}\index{meet and join}} or the {\defit
supremum\index{supremum}} of $A$, and it is denoted by $\bigvee A$ or
$\bigvee_{x\in A} x$. We also write $x\vee y$ for the supremum of
$\{x,y\}$, if it exists. Lower bounds\index{lower bound} are defined
dually, and a greatest lower bound\index{greatest lower bound}, denoted
$\bigwedge A$, is also called a {\defit meet} or an {\defit
infimum\index{infimum}}. A poset $D$ is called a {\defit
lattice\index{lattice}} if it has finite suprema and infima, and a {\defit
complete lattice\index{complete lattice}\index{lattice!complete}} if it has
arbitrary suprema and infima.

A poset $\pair{D,\leq}$ is {\defit pointed\index{pointed
poset}\index{poset!pointed}} if it has a least element $\bot$. $D$ is
{\defit flat\index{flat poset}\index{poset!flat}} if it is pointed and if
all elements $a\neq\bot$ are maximal. An example of a flat poset are the
``flat natural numbers'', shown in Table~\ref{tab-posets}(1). Two elements
$x,y\in D$ are called {\defit compatible\index{compatible
elements}}, in symbols $x\compatible y$, if
there exists $z\in D$ with $x\leq z$ and $y\leq z$. Notice that two
elements in a flat poset are compatible iff and of them is $\bot$.
%..........................................................................
\begin{table*}[tbp]\caption{Some posets}\label{tab-posets}
\[\begin{array}{c@{\hspace{1in}}c}
	\vcenter{\xymatrix@C=2ex@R=3ex{
		0&1&2&\cdots&n&\cdots
	\\	&&\bot\ar@{-}[ull]\ar@{-}[ul]\ar@{-}[u]\ar@{-}[urr]
	}}
&	\vcenter{\xymatrix@R=2ex{
		{\vdots}\ar@{-}[d]
	\\	n\ar@{-}[d]  
	\\ 	{\vdots}\ar@{-}[d]  
	\\ 	2\ar@{-}[d] 
	\\	1\ar@{-}[d] 
	\\	0
	}}
\\	\mbox{(1) The flat natural numbers}
&	\mbox{(2) The ordinal $\omega$}
\end{array}\]
\end{table*}
%..........................................................................

\begin{remark}
Any poset $\pair{D,\leq}$ can itself be regarded as a category with
hom-sets
\[	\homof{D}{x,y}=
	\left\{\begin{array}{ll}
		\{*\}&\mbox{if $x\leq y$}
	\\	\emptyset&\mbox{else.}
	\end{array}\right.
\]
Under this interpretation, a least element $\bot$ is just an initial
object, suprema are colimits, functors are monotone maps, and an
adjunction is a pair of monotone maps $f:D\ii E$ and $g:E\ii D$ such
that 
\[	fx\leq y \iff x\leq gy.
\]
\end{remark}

%----------------------------------------------------------------------
\subsection{Complete partial orders}

A poset $I$ is {\defit directed\index{directed
poset}\index{poset!directed}\index{order!directed}} if it is non-empty and
if for all $x,y\in I$, there exists $z\in I$ with $x,y\leq z$. A poset
$\pair{D,\leq}$ is {\defit directed complete}\index{directed complete
partial order}\index{poset!directed complete}\index{order!directed
complete}\index{partial order!directed complete} if every directed subset
has a supremum. A directed complete poset is also called a {\defit
{\dcpo}\index{dcpo@\dcpo}}.  Directed suprema are also denoted by $\dirsup
I$ or $\dirsup_{x\in I} x$. A function $f:D\ii E$ between {\dcpos} is
called {\defit
Scott-continuous\index{Scott-continuity}\index{continuity!Scott-continuity}\index{function!continuous}}
if it is monotone and it preserves directed suprema. We denote the category
of {\dcpos} and Scott-continuous functions by $\DCPO$\index{category!of
directed complete partial orders@of directed complete partial orders
$\DCPO$}. The full subcategory of pointed {\dcpos} is denoted by
$\DCPOp$. Both these categories are cartesian-closed.  The exponential
$E^D$ is given by the set of all Scott-continuous functions from $D$ to $E$
with the pointwise order.  Directed suprema in $E^D$ can be computed
pointwise, {\ie}
\[	(\dirsup_i f_i)(x) = \dirsup_i (f_ix)
\]

A poset $I$ is {\defit linearly ordered\index{linear
order}\index{order!linear}\index{poset!linearly ordered}} or a {\defit
chain\index{chain}} if for all $x,y\in I$, either $x\leq y$ or $x\geq
y$. An example of a linearly ordered set is the ordinal $\omega$, which is
the set of natural numbers with their natural order, as shown in
Table~\ref{tab-posets}(2). A set $I$ which is isomorphic to $\omega$ is
called an {\defit $\omega$-chain\index{omega-chain@$\omega$-chain}}.  A
poset $\pair{D,\leq}$ is {\defit $\omega$-complete\index{omega-complete
poset@$\omega$-complete
poset|see{\cpo}}\index{poset!omega-complete@$\omega$-complete|see{\cpo}}\index{order!omega-complete@$\omega$-complete|see{\cpo}}}
if every $\omega$-chain $I\seq D$ has a supremum in $D$. An
$\omega$-complete poset is also called a {\defit complete partial
order\index{complete partial
order}\index{order!complete|see{\cpo}}\index{partial
order!complete|see{\cpo}}} or a {\defit
\cpo\index{cpo@\cpo}}.  A function $f:D\ii E$ between {\cpos} is called {\defit
$\omega$-continuous\index{omega-continuity@$\omega$-continuity}\index{continuity!omega-continuity@$\omega$-continuity}}
if it is monotone and it preserves suprema of $\omega$-chains. We denote
the category of {\cpos} and $\omega$-continuous functions by
$\CPO$\index{category!of complete partial orders@of complete partial orders
$\CPO$}, and its full subcategory of pointed {\cpos} by $\CPOp$. These
categories are cartesian-closed, with the exponential $E^D$ given by the
set of all $\omega$-continuous functions from $D$ to $E$ with the pointwise
order, and pointwise suprema of $\omega$-chains.

\begin{remark}
The categories $\CPO$ and $\DCPO$ have similar properties.  $\DCPO$ is
a subcategory of $\CPO$, but is neither full, nor is it a sub-ccc.
\end{remark}

%----------------------------------------------------------------------
\subsection{Bounded complete partial orders} 

A subset $A$ of a partially ordered set $D$ is called {\defit bounded} if
there is $d\in D$ with $A\seq\downdeal d$.  A {\cpo} $D$ is {\defit bounded
complete\index{bounded complete cpo@bounded complete
\cpo}\index{cpo@\cpo!bounded complete}\index{complete partial order!bounded
complete}} if every bounded subset $A\seq D$ has a supremum. Bounded
complete {\cpos} and $\omega$-continuous functions form a full sub-ccc
$\CPObc$ of $\CPO$. Notice that we do {\em not} require the morphisms to
preserve all bounded suprema.  The categories $\CPOpbc$, $\DCPObc$, and
$\DCPOpbc$ are defined analogously.

%----------------------------------------------------------------------
\subsection{Stability}\label{subsec-stable}

A {\cpo} $D$ is a {\defit meet {\cpo}\index{meet cpo@meet
\cpo}\index{cpo@\cpo!meet cpo@meet \cpo}\index{complete partial order!meet
cpo@meet \cpo}} if it has bounded binary meets which act continuously. This
means, that for every $x\in D$, the set $\downdeal x$ has binary meets, and
the function $\pair{a,b}\mapsto a\wedge b$ is continuous on $\downdeal
x\times\downdeal x$. A function $f:D\ii E$ between meet {\cpos} is {\defit
stable}\index{stable
function}\index{function!stable}\index{map|see{function}} if it preserves
bounded binary meets. We denote the category of meet {\cpos} and stable
maps by $\CPOstable$, and its full subcategory of pointed meet {\cpos} by
$\CPOpstable$. These categories are cartesian-closed too, and the
exponential $E^D$ is given by the set of all stable functions from $D$ to
$E$, not with the pointwise order, but with the {\defit Berry
order\index{Berry order}\index{order!Berry}} or {\defit stable
order\index{stable order}\index{order!stable}}:
\[	f\leqberry g 
\iff 	(\forall x,y\in D.\ x\leq y\imp f(x)=f(y)\wedge g(x))
\]
Directed suprema, as well as bounded infima, with respect to the Berry
order are taken pointwise.  The cartesian-closed categories
$\DCPOstable$ and $\DCPOpstable$ are defined analogously.

The theory of meet {\cpos} and stable functions is due to Berry
{\cite{Ber78}}, who used them to study the semantics of sequential
computations. 

%----------------------------------------------------------------------
\subsection{Domain equations}\label{subsec-domain-equations}

Let $\DOM$ be any one of the pointed categories $\DCPOp$, $\CPOp$,
$\DCPOpstable$, $\CPOpstable$, $\DCPOpbc$, or $\CPOpbc$. The objects of
$\DOM$ are called {\defit domains\index{domain}}.  One of the main features
of these categories of domains is that they can be used to solve {\defit
domain equations\index{domain equations}}, such as
\[	D\cong D^D.
\]
A solution to such an equation in a category $\DOM$ consists of an object
$D$, together with an isomorphism $\phi:D\ii D^D$.  The ability to solve
domain equations is an essential tool in mathematical programming semantics
to give meaning to a variety of programming language constructs, such as
recursive data types.  We are particularly interested in solutions to the
``classic'' domain equation $D\cong D^D$, whose solutions yield models of
the untyped lambda-$\beta\eta$-calculus (see Section~\ref{sec-cccs}).

General methods for solving domain equations were pioneered by D. Scott
{\cite{Sco72}}, and further developed by Smyth and Plotkin {\cite{SP82}}.
In general, a domain equation takes the form $D\cong F(D)$. Notice that,
since the right-hand-side may contain positive (covariant) as well as
negative (contravariant) occurrences of $D$, $F$ will not in general be a
functor. The problem of mixed variance can be solved by passing from the
category $\DOM$ to a category $\DOM\ep$ of
embeddings\index{embedding-projection pair}. The objects of $\DOM\ep$ are
the same as the objects of $\DOM$. The morphisms of $\DOM\ep$ are
embeddings, where $e:D\ii E$ in $\DOM$ is called an {\defit embedding} if
there exists a {\defit projection\index{projection-embedding pair}} $p:E\ii
D$ in $\DOM$ such that
\[	p\cp e=\id_D
\sep	e\cp p\leq\id_E,
\]
where the inequality is understood to be with respect to the relevant order
on functions, {\ie} the pointwise order in the case of $\DCPOp$, $\CPOp$,
etc., and the stable order in the case of $\DCPOpstable$ or
$\CPOpstable$. An embedding $e$ is uniquely determined by its associated
projection $p$ and {\em vice versa}. We write $p=e^*$ and $e=p_*$. One also
speaks of $\DOM\ep$ as a category of {\defit embedding-projection pairs}.

An {\defit expanding sequence}\index{expanding sequence}\index{sequence,
expanding} in $\DOM\ep$ is a diagram modeled on the ordinal $\omega$, {\ie}
a functor $\diagram:\omega\ii\DOM\ep$.  In more concrete terms, an
expanding sequence is a sequence $\family{D_n}{n\in\Nat}$ of objects,
together with embeddings $e_{nm}:D_n\ii D_m$ for all $n\leq m$, such that
$e_{mm}=\id_{D_m}$ and $e_{mn}\cp e_{pm}=e_{pn}$, for all $p\leq m\leq n$.

\begin{proposition}{\bf Limit-colimit coincidence.}
Every expanding sequence $\tuple{\family{D_n}{n},\family{e_{nm}}{n\leq m}}$
in $\DOM\ep$ has a colimit $D$ in $\DOM\ep$, with colimiting morphisms
$e_n:D_n\ii D$. Moreover, $\tuple{D,\family{e_n}{n}}$ is also a colimit in
$\DOM$, and $\tuple{D,\family{e^*_n}{n}}$ is a limit of
$\tuple{\family{D_n}{n},\family{e^*_{nm}}{n\leq m}}$ in $\DOM$. This is
called the {\defit limit-colimit coincidence\index{limit-colimit
coincidence}}, and $D$ is also called a {\defit bilimit\index{bilimit}}.
\eot
\end{proposition}

\begin{proposition}{\bf Characterization of bilimits.}\label{pro-ch-bilimits}
Let $\tuple{D,\family{e_n}{n}}$ be a cocone over the expanding sequence
$\tuple{\family{D_n}{n},\family{e_{nm}}{n\leq m}}$ in $\DOM\ep$. Then 
$\tuple{D,\family{e_n}{n}}$ is a bilimit if and only if
\[	\id_D=\dirsup_n e_n\cp e^*_n.
\]
\eottwo
\end{proposition}

\begin{definition}
A functor $F:\DOM\ep\ii\DOM\ep$ is {\defit continuous\index{continuous
functor}\index{functor!continuous}} if\nomicrofilm{ for every expanding
sequence $\tuple{\family{D_n}{n},\family{e_{nm}}{n\leq m}}$ with colimit
$\tuple{D,\family{e_n}{n}}$, the sequence
$\tuple{\family{FD_n}{n},\family{Fe_{nm}}{n\leq m}}$ has colimit
$\tuple{FD,\family{Fe_n}{n}}$.}\microfilm{, whenever
$\tuple{\family{D_n}{n},\family{e_{nm}}{n\leq m}}$ is an expanding sequence
with colimit $\tuple{D,\family{e_n}{n}}$, then the expanding sequence
$\tuple{\family{FD_n}{n},\family{Fe_{nm}}{n\leq m}}$ has colimit
$\tuple{FD,\family{Fe_n}{n}}$.}
\end{definition}

\begin{proposition}{\bf Solution of domain equations.}
\label{pro-solution-domain-eqn}
Consider a domain equation $D\cong F(D)$, where $F:\DOM\ep\ii\DOM\ep$
is a continuous functor. Starting with a domain $D_0$ and an embedding
$e_{01}:D_0\ii F(D_0)$, let $D_{n+1}=F(D_n)$ and
$e_{n+1,n+2}=F(e_{n,n+1})$ for all $n\in\Nat$. Let $D$ be the colimit
of the expanding sequence
$\tuple{\family{D_n}{n},\family{e_{nm}}{n\leq m}}$, where
$e_{nm}=e_{m-1,m}\cp\cdots\cp e_{n,n+1}$, for $n\leq m$. Then $D\cong
F(D)$.
\end{proposition}

\begin{proof}
Since $F$ is continuous, the sequence
$\tuple{\family{FD_n}{n},\family{Fe_{nm}}{n\leq m}}
=\tuple{\family{D_{n+1}}{n},\family{e_{n+1,m+1}}{n\leq m}}$ has colimit
$F(D)$. On the other hand, $D$ is a colimit of the same sequence, hence one
gets $D\cong F(D)$.\eot
\end{proof}

\noindent
The question remains how to identify a given functor as continuous. A
useful criterion was given by Smyth and Plotkin {\cite{SP82}}, who observed
that a continuous functor $F$ on $\DOM\ep$ can be obtained from a {\em
locally continuous functor} $\hatt{F}$ on $\DOM$. This works even if
$\hatt{F}$ is of mixed variance.

\begin{definition}
A functor $\hatt{F}:\DOM^{\op}\times \DOM\ii \DOM$ is {\defit locally
continuous\index{locally continuous functor}\index{functor!locally
continuous}\index{continuous functor!locally}} if for all objects
$D,D',E,E'\in\DOM$,
\[ 	\hatt{F}:\homof{\DOM}{D,D'}\times\homof{\DOM}{E,E'}\ii
	\homof{\DOM}{\hatt{F}(D',E),\hatt{F}(D,E')}
\]
if continuous as a map between hom-sets (with the pointwise order in
the case of $\DCPOp$ and $\CPOp$, and the stable order in the case of
$\DCPOpstable$ and $\CPOpstable$).
\end{definition}

\begin{proposition}
Every locally continuous functor
${\hatt{F}}:\DOM^{\op}\times\DOM\ii\DOM$ gives rise to a
continuous functor $F:\DOM\ep\ii\DOM\ep$, defined by
\[	F(D)=\hatt{F}(D,D)
\sep	F(e)=\hatt{F}(e^*,e)
\]
\eottwo
\end{proposition}

%----------------------------------------------------------------------
\subsection[The \texorpdfstring{$D_{\infty}$}{D^^e2^^88^^9e}-construction]
{The {\boldmath $D_{\infty}$}-construction}
\label{subsec-d-infty}

The method of Proposition~\ref{pro-solution-domain-eqn}, applied to
the locally continuous functor $F(D,E)=E^D$, serves to solve the
``classic'' domain equation $D\cong D^D$. This construction is due to
D. Scott, and it is called the $D_{\infty}$-construction. 

\begin{remark}
Notice that the construction of a $D_{\infty}$-model is dependent on some
parameters, namely a category $\DOM$, an object $D_0$ and an embedding
$e_{01}:D_0\ii D_0^{D_0}$. Hence, there is a whole class of such
models. Among these, we distinguish the {\defit standard
$D_{\infty}$-model\index{d-infinity-model@$D_{\infty}$-model}\index{model!d-infinity@$D_{\infty}$}}
to be the one model constructed in $\CPOp$ from the {\cpo} $D_0$ with two
elements $\bot\leq\top$, and the embedding $e_{01}:D_0\ii D_0^{D_0}$ which
maps $\bot$ to the constant $\bot$ function and $\top$ to the constant
$\top$ function.
\end{remark}

%========================================================================
\section{Basic universal algebra}\label{sec-universal-algebra}

%----------------------------------------------------------------------
\subsection[\texorpdfstring{$\Sig$}{^^ce^^a3}-algebras]
{{\boldmath $\Sig$}-algebras}

An {\defit algebraic signature\index{algebraic
signature}\index{signature!algebraic}} $\Sig$ is a pair
$\pair{\Ome,\arity}$ consisting of a set $\Ome$ of {\defit function
symbols\index{function symbol}} and a map $\arity:\Ome\ii\Nat$, assigning
an {\defit arity\index{arity}} $k\geq 0$ to each $f\in\Ome$. We let
$\Ome_k=\{f\in\Ome\such\arity(f)=k\}$ be the set of {$k$-ary function
symbols}.  A {\defit
$\Sig$-algebra\index{algebra}\index{sigma-algebra@$\Sig$-algebra}}
$\Aa=\pair{A,I}$ is a set $A$ together with an interpretation $I(f)$ of
every function symbol as a map from $A^{\arity(f)}\ii A$. We often write
$\abs{\Aa}$, or even $\Aa$ for the underlying set $A$ of an algebra, and
$\concr{f}{\Aa}$ or even $f$ for the interpretation $I(f)$.  A {\defit
homomorphism of $\Sig$-algebras\index{homomorphism}}
$\phi:\Aa\ii\Bb$ is a function $\phi:\abs{\Aa}\ii\abs{\Bb}$ such that for
all $f\in\Ome_k$ and all $a_1,\ldots,a_k\in\Aa$
\[	\phi(\concr{f}{\Aa}(a_1,\ldots,a_k))
=	\concr{f}{\Bb}(\phi a_1,\ldots,\phi a_k)
\]
We denote the category of $\Sig$-algebras and homomorphisms by $\SAlg$.
The category $\SAlg$ has all limits, and the forgetful functor
$U:\SAlg\ii\Set$ preserves and reflects them.  For instance, binary
products are given by $\abs{\Aa\times\Bb}=\abs{\Aa}\times\abs{\Bb}$ and
\microfilm{\[\concr{f}{\Aa\times\Bb}(\pair{a_1,b_1},\ldots,\pair{a_k,b_k})=
\pair{\concr{f}{\Aa}(a_1,\ldots,a_k),\concr{f}{\Bb}(b_1,\ldots,b_k)}.\]}
\nomicrofilm{$\concr{f}{\Aa\times\Bb}(\pair{a_1,b_1},\ldots,\pair{a_k,b_k})=
\pair{\concr{f}{\Aa}(a_1,\ldots,a_k),\concr{f}{\Bb}(b_1,\ldots,b_k)}$.}
A $\Sig$-algebra $\Aa$ is a {\defit subalgebra\index{subalgebra}} of
another $\Sig$-algebra $\Bb$ if $\abs{\Aa}\seq\abs{\Bb}$ and for all
$f\in\Ome_k$ and $a_1,\ldots,a_k\in\Aa$,
$\concr{f}{\Aa}(a_1,\ldots,a_k)=\concr{f}{\Bb}(a_1,\ldots,a_k)$. The
inclusion map $\Aa\ii\Bb$ of a subalgebra is a homomorphism.


\begin{n-definition}\label{def-compatible-relation}
A binary relation $R$ on a $\Sig$-algebra $\Aa$ is {\defit
compatible\index{compatible relation}\index{relation!compatible}} if it is
a subalgebra of $\Aa\times\Aa$. This is the case if and only if whenever
$\pair{a_i,b_i}\in R$ for $i=1\ldots k$, then $\pair{fa_1\ldots a_k,
fb_1\ldots b_k}\in R$, for each $k$-ary function symbol $f\in\Ome_k$.  A
{\defit congruence\index{congruence!on algebra}\index{relation!congruence}}
on a $\Sig$-algebra $\Aa$ is a compatible equivalence relation.  If $\sim$
is a congruence, then the {\defit quotient algebra\index{quotient
algebra}\index{algebra!quotient}} $\Aa/{\sim}$ is a well-defined
$\Sig$-algebra via
$\concr{f}{\Aa/{\sim}}(\class{x_1}{\sim},\ldots,\class{x_k}{\sim})=
\class{\concr{f}{\Aa}(x_1,\ldots,x_k)}{\sim}$. The natural map
$\Aa\ii\Aa/{\sim}$ is a homomorphism of $\Sig$-algebras.  The {\defit
kernel\index{kernel!of a homomorphism}} $\ker{\phi}$ of a homomorphism
$\phi:\Aa\ii\Bb$ is the congruence relation $\sim$ on $\Aa$ defined by
$a\sim a'$ iff $\phi(a)=\phi(a')$.
\end{n-definition}

\void{.................................................................
\begin{remark}
Notice that any intersection of congruences is again a congruence. In
particular, for any binary relation $R\seq\abs{\Aa\times\Aa}$, there
is a smallest congruence containing $R$. This follows from very
general principles which are outlined in Appendix~\ref{apx-metamath}.
\end{remark}
}%void.................................................................

%----------------------------------------------------------------------
\subsection{Term algebras}\label{subsec-term-algebras}

Let $X$ be a set. For each $x\in X$, pick a distinct symbol
$\const{x}$, which is not in $\Ome$.  Let $\Words(X,\Ome)$ be the set of
words (\ie finite sequences) from the alphabet $\{\const{x}\such x\in
X\}\cup\Ome$.

\begin{definition}
The set of {\defit $\Sig$-terms over
$X$\index{sigma-term@$\Sig$-term}}\index{term!sig-term@$\Sig$-term} is
defined to be the smallest subset $T\seq\Words(X,\Ome)$ such that
\[	\deriv{x\in X}{\const{x}\in T}
\sep	\deriv{f\in\Ome_k\sep t_1\in T\sep\ldots\sep t_k\in T}
	{ft_1\ldots t_k\in T}.
\]
Let $\SigOf{X}$ be the set of $\Sig$-terms thus defined. It has a natural
$\Sig$-algebra structure via $\concr{f}{\SigOf{X}}(t_1,\ldots ,t_k)=
ft_1\ldots t_k$. The algebra $\SigOf{X}$ is called the {\defit $\Sig$-term
algebra over $X$\index{algebra!term algebra}}\index{term algebra}.
\end{definition}

\begin{remark}
We have represented terms as words from some alphabet. There are other
possible choices; for instance, one could represent a term $ft_1\ldots
t_k$ as a labeled rooted tree with label $f$ at the root and with
immediate subtrees $t_1,\ldots,t_k$.  In general, we will not be too
concerned here with the details of how to represent syntax; rather, we
will treat syntax as a primitive notion. Independently of which
concrete representation for terms one chooses, $\SigOf{X}$, together
with its natural map $\jota:X\ii\SigOf{X}:x\mapsto \const{x}$, is completely
determined by the following universal property:
\end{remark}

\begin{proposition}\label{pro-free-sigma-alg}
For any $\Sig$-algebra $\Bb$ and any map $\rho:X\ii\Bb$, there is a
unique homomorphism $\extension{\rho}:\SigOf{X}\ii\Bb$ such that
\[	\xymatrix{
	X\ar[r]^<>(.5){\jota}\ar[dr]_{\rho}
&	{\SigOf{X}}\ar[d]^{\extension{\rho}}
\\&	{\Bb}.}
\]
Equivalently, the forgetful functor $U:\SAlg\ii\Set$ has a left
adjoint $\Free:\Set\ii\SAlg$ with $\Free(X)=\SigOf{X}$, and with
$X\ii\SigOf{X}$ as the unit of the adjunction. \eot
\end{proposition}

\noindent 
A map $\rho:X\ii\Bb$ is also called a {\defit valuation\index{valuation!in
algebra}} in $\Bb$. If $\extension{\rho}$ is the unique extension of $\rho$
to terms, then we often write $\sem{t}{\rho}$ instead of
$\extension{\rho}(t)$ for the interpretation of a term $t\in\SigOf{X}$. The
defining equations for $\semp$ are
\[	\begin{array}{rcll}
	\sem{x}{\rho}&=&\rho(x),	&\mbox{for $x$ a variable,}
\\	\sem{ft_1\ldots t_k}{\rho}&=&
		\concr{f}{\Aa}(\sem{t_1}{\rho},\ldots,\sem{t_k}{\rho}),
	&\mbox{for $f\in\Ome_k$.}
	\end{array}
\]
If $X=\{x_1,\ldots,x_n\}$ is a finite set of variables, then a term
$t\in\SigOf{X}$ is also called a {\defit $n$-ary
operation\index{operation in algebra}} in $\Sig$. We write
$t=t(x_1,\ldots,x_n)$. If $b_1,\ldots,b_n$ are elements of a $\Sig$-algebra
$\Bb$, then we sometimes write $t(b_1,\ldots,b_n)$ for $\sem{t}{\rho}$
where $\rho:X\ii\Bb:x_i\mapsto b_i$.

%----------------------------------------------------------------------
\subsection{Algebraic varieties}\label{subsec-algebraic-varieties}

Fix a countable set $\Vars$ of {\defit variables\index{variable}}. A
{\defit $\Sig$-equation\index{equation!in algebra}} is a pair of terms
$\pair{t,s}\in\SigOf{\Vars}\times\SigOf{\Vars}$.  Equations are often
written in the form $t=s$.  A $\Sig$-algebra $\Aa$ {\defit satisfies} an
equation $t=s$, in symbols $\Aa\models t=s$, if for all homomorphisms
$\phi:\SigOf{\Vars}\ii\Aa$, $\phi(t)=\phi(s)$. Equivalently, $\Aa\models
t=s$ if for all valuations $\rho:\Vars\ii\Aa$,
$\sem{t}{\rho}=\sem{s}{\rho}$.

\begin{definition}
Let $\Sig$ be a signature, and let $\Eqns$ be a set of $\Sig$-equations.  A
$\Sig$-algebra $\Aa$ that satisfies all equations in $\Eqns$ is called a
{\defit $\SE$-algebra}. The $\SE$-algebras form a full subcategory of
$\SAlg$, which we denote by $\SEAlg$. Any full subcategory $\T$ of $\SAlg$
that arises in this way is called an {\defit algebraic
variety\index{algebraic variety}\index{variety!algebraic}}. The algebras of
an algebraic variety $\T$ are also called {\defit
$\T$-algebras\index{t-algebra@$\T$-algebra}}.
\end{definition}

\noindent
Let $\T$ be an algebraic variety, defined by a signature $\Sig$ and
equations $\Eqns$. We construct $\freeTOf{X}$, the {\defit free
$\T$-algebra\index{algebra!free}\index{free!algebra}} over a set $X$, as
follows: On the term algebra $\SigOf{X}$, consider the smallest congruence
relation $\sim$ such that
\[	\deriv{\pair{s,t}\in\Eqns\sep\rho:\SigOf{\Vars}\ii\SigOf{X}}
	{\rho(s)\sim\rho(t)}.
\]
Let $\freeTOf{X}$ be the algebra $\SigOf{X}/{\sim}$. Then
$\freeTOf{X}$ is a $\T$-algebra. Together with the natural map
$\jota:X\ii\freeTOf{X}$, it has the universal property:

\begin{proposition}
For any $\T$-algebra $\Bb$ and any map $\rho:X\ii\Bb$, there is a
unique homomorphism $\extension{\rho}:\freeTOf{X}\ii\Bb$ such that
\[	\xymatrix{
	X\ar[r]^<>(.5){\jota}\ar[dr]_{\rho}
&	{\mbox{$\freeTOf{X}$}}\ar[d]^{\extension{\rho}}
\\&	\Bb.}
\]
\eottwo
\end{proposition}

\noindent
We say that a set of equations $\Eqns$ {\defit entails} an equation $s=t$,
in symbols $\Eqns\entailseq s=t$, if $s=t$ can be derived from the
hypotheses $\Eqns$ by the rules in Table~\ref{tab-equational-rules}.  We
write $\Eqns\modelsSAlg s=t$ if for all $\Sig$-algebras $\Aa$, if
$\Aa\models\Eqns$, then $\Aa\models s=t$.

\begin{proposition}
{\bf Soundness and Completeness for {\boldmath $\Sig$}-algebras.}
\[	\mbox{$\Eqns\entailseq s=t$ \ssep if and only if \ssep 
	$\Eqns\modelsSAlg s=t$}
\]
\eottwo
\end{proposition}

%..........................................................................
\begin{table*}[tb]\caption{Equational rules for $\Sig$-algebras}
\label{tab-equational-rules}
\[
\begin{array}{rc}
	\trule{refl}&\deriv{\vstrut}{s=s}
\nl	\trule{symm}&\deriv{s=t}{t=s}
\nl	\trule{trans}&\deriv{s=t\sep t=u}
	{s=u}
\end{array}\sep\begin{array}{rc}
	\trule{cong}&\deriv{f\in\Ome_k\sep s_i=t_i\sep
	(i=1\ldots k)}{fs_1\ldots s_k=ft_1\ldots t_k}
\nl	\trule{subst}&\deriv{s=t\sep\phi:\SigOf
	{\Vars}\ii\SigOf{\Vars}}{\phi(s)=\phi(t)}
\end{array}
\]
\end{table*}
%..........................................................................

%----------------------------------------------------------------------
\subsection{Indeterminates}

Let $\T$ be a variety with signature $\Sig$ and equations $\Eqns$.  Let
$\Aa$ be a $\T$-algebra, and let $X$ be a set.  Assume {\wloss} that $X$
and $\abs{\Aa}$ are disjoint. Relative to the variety $\T$, the {\defit
polynomial algebra\index{algebra!polynomial}\index{polynomial algebra}}
$\Aa[X]$ is defined as follows: On the term algebra $\SigOf{\abs{\Aa}+X}$,
consider the smallest congruence relation $\sim$ such that
\[	\deriv{a=\concr{f}{\Aa}a_1\ldots a_k}
	{\const{a}\sim f\const{a_1}\ldots\const{a_k}}
\sep	\deriv{\pair{s,t}\in\Eqns\sep\rho:\SigOf{\Vars}\ii\SigOf{\abs{\Aa}+X}}
	{\rho(s)\sim\rho(t)}.
\]
Let $\Aa[X]$ be the algebra $\SigOf{\abs{\Aa}+X}/{\sim}$. Together with
$\Aa[X]$, consider the natural maps $\jotb:\Aa\ii\Aa[X]$ defined by
$\jotb(a)=\class{\const{a}}{\sim}$, and $\jota:X\ii\Aa[X]$ defined by
$\jota(x)=\class{\const{x}}{\sim}$.

\begin{proposition}
$\Aa[X]$ is a $\T$-algebra with the following universal property: For
any $\T$-algebra $\Bb$, any homomorphism $f:\Aa\ii\Bb$ of
$\T$-algebras, and any map $g:X\ii\Bb$, there is a unique
homomorphism $h:\Aa[X]\ii\Bb$ such that
\[	\xymatrix{
	X\ar[r]^<>(.5){\jota}\ar[dr]_g
&	{\Aa[X]}\ar[d]^h
&	{\Aa}\ar[l]_<>(.5){\jotb}\ar[dl]^f
\\&	\Bb.}
\]
\eottwo
\end{proposition}

\begin{remark}
The map $\jotb:\Aa\ii\Aa[X]$ is always an injection; we will often regard
it as an inclusion. Notice that $\Aa[X][Y]\cong\Aa[X+Y]$.  In the case
where $X=\{x_1,\ldots,x_n\}$ is finite, we write
$\Aa[X]=\Aa[x_1,\ldots,x_n]$. The elements of $\Aa[X]$ are called {\defit
polynomials\index{polynomial}}, and $X$ is called a set of {\defit
indeterminates\index{indeterminate}}.
\end{remark}

\todoo{stick in a reference to the metamath and rule notation. }

%----------------------------------------------------------------------
\subsection{Ordered algebras}\label{subsec-ordered-algebras}

Let $\Aa$ be a $\Sig$-algebra, and let $\leq$ be a partial order on the
carrier set $\abs{\Aa}$. The pair $\pair{\Aa,\leq}$ is called an {\defit
ordered $\Sig$-algebra\index{algebra!ordered}\index{ordered algebra}} if
the order $\leq$ is a compatible relation on $\Aa$ in the sense of
Definition~\ref{def-compatible-relation}. Concretely, this is the case iff
for each $f\in\Ome_k$, $\concr{f}{\Aa}:\Aa^k\ii\Aa$ is a monotone map with
respect to $\leq$. A {\defit homomorphism of ordered $\Sig$-algebras} is a
homomorphism of $\Sig$-algebras that is monotone. We denote the resulting
category of ordered $\Sig$-algebras by $\SOrd$.

Just as we considered sets of equations for $\Sig$-algebras, we may
consider sets of inequations for ordered $\Sig$-algebras. Recall that
$\Vars$ is a countable set of variables, and that $\SigOf{\Vars}$ is the
$\Sig$-term algebra. A {\defit
$\Sig$-inequation\index{inequation}\index{equation!inequation}} is a pair
of terms $\pair{t,s}\in\SigOf{\Vars}\times\SigOf{\Vars}$, often written
$t\leq s$. An ordered $\Sig$-algebra $\pair{\Aa,\leq}$ {\defit satisfies}
an inequation $t\leq s$, in symbols $\Aa\models t\leq s$, if for all
homomorphisms $\phi:\SigOf{\Vars}\ii\Aa$ of $\Sig$-algebras,
$\phi(t)\leq\phi(s)$. Equivalently, $\Aa\models t\leq s$ if for all
valuations $\rho:\Vars\ii\Aa$, $\sem{t}{\rho}\leq\sem{s}{\rho}$.

\begin{definition}
An ordered $\Sig$-algebra that satisfies a given set $\Ineqns$ of
inequations is called an {\defit ordered $\SI$-algebra}.  The ordered
$\SI$-algebras form a full subcategory of $\SOrd$, which we denote by
$\SIOrd$. A full subcategory $\OT$ of $\SOrd$ that arises in this way is
called an {\defit ordered variety\index{ordered
variety}\index{variety!ordered}}.
\end{definition}

\noindent
Let $\OT$ be an ordered variety, defined by a pair $\SI$ of a signature and
a set of inequations. The {\defit free ordered
$\SI$-algebra\index{free!ordered algebra}} over
a poset $P$, denoted $\freeOOf{P}$, is constructed as follows: On the term
algebra $\SigOf{P}$, consider the smallest compatible preorder $\preleq$
satisfying
\[	\deriv{\pair{s,t}\in\Ineqns\sep\rho:\SigOf{\Vars}\ii\SigOf{P}}
	{\rho(s)\preleq\rho(t)}
	\sep
	\deriv{x\leq y\in P}{\const{x}\preleq\const{y}}.
\]
Let $\sim$ be the congruence ${\preleq}\cap{\pregeq}$ on $\SigOf{P}$,
and let $\freeOOf{P}$ be the algebra $\SigOf{P}/{\sim}$, together
with the partial order $\leq$ induced by $\preleq$ via
$\class{x}{\sim}\leq\class{y}{\sim}$ iff $x\preleq y$. Then
$\freeOOf{P}$ is an ordered $\SI$-algebra, and the natural map
$\jota:P\ii\freeOOf{P}$ is monotone. The following universal
property holds:

\begin{proposition}
For any ordered $\SI$-algebra $\Bb$ and any monotone map
$\rho:P\ii\Bb$, there is a unique homomorphism of
ordered $\SI$-algebras $\extension{\rho}:\freeOOf{P}\ii\Bb$ such
that
\[	\xymatrix{
	P\ar[r]^<>(.5){\jota}\ar[dr]_{\rho}
&	{\mbox{$\freeOOf{P}$}}\ar[d]^{\extension{\rho}}
\\&	\Bb.}
\]
\eottwo
\end{proposition}

\noindent
Rules for deriving inequations are given in
Table~\ref{tab-inequational-rules}.  We say that a set of inequations
$\Ineqns$ {\defit entails} an inequation $s\leq t$, in symbols
$\Ineqns\entailsineq s\leq t$, if $s\leq t$ can be derived from the
hypotheses $\Ineqns$ by these rules.  We write $\Eqns\modelsSOrd s\leq t$
if for all ordered $\Sig$-algebras $\Aa$, if $\Aa\models\Eqns$, then
$\Aa\models s\leq t$.

%..........................................................................
\begin{table*}[tb]\caption{Inequational rules for $\Sig$-algebras}
\label{tab-inequational-rules}
\[
\begin{array}{rc}
	\trule{refl}&\deriv{\vstrut}{s\leq s}
\nl 	\trule{trans}&\deriv{s\leq 
	t\sep t\leq u}
	{s\leq u}
\end{array}\sep\begin{array}{rc}
	\trule{cong}&\deriv{f\in\Ome_k\sep s_i\leq t_i
	\sep(i=1\ldots k)}
	{fs_1\ldots s_k\leq ft_1\ldots t_k}
\nl	\trule{subst}&\deriv{s\leq t\sep
	\phi:\SigOf{\Vars}\ii\SigOf{\Vars}}
	{\phi(s)\leq\phi(t)}
\end{array}
\]
\end{table*}
%..........................................................................

\begin{proposition}
{\bf Soundness and Completeness for ordered {\boldmath $\Sig$}-algebras.}
\[	\mbox{$\Eqns\entailseq s\leq t$ \ssep if and only if \ssep 
	$\Eqns\modelsSOrd s\leq t$}
\]
\eottwo
\end{proposition}

\noindent
We also sometimes write $\Ineqns\entailsineq s=t$ as an abbreviation for
$\Ineqns\entailsineq s\leq t$ and $\Ineqns\entailsineq t\leq s$.

%----------------------------------------------------------------------
\subsection{\Dcpo-algebras}

Let $\Sig$ be a signature. An ordered $\Sig$-algebra $\pair{\Aa,\leq}$ is
called a {\defit
$\Sig$-{\dcpo}-algebra\index{dcpo-algebra@\dcpo-algebra}\index{algebra!dcpo-algebra@\dcpo-algebra}}
if the partial order $\leq$ is directed complete, and if each interpreted
operation $\concr{f}{\Aa}:\Aa^k\ii\Aa$ is Scott-continuous. A {\defit
homomorphism of $\Sig$-{\dcpo}-algebras} is a Scott-continuous homomorphism
of ordered $\Sig$-algebras. We denote the resulting category of
$\Sig$-{\dcpo}-algebras by $\SDCPO$. Each set $\Ineqns$ of inequations
determines a full subcategory of $\SDCPO$, which we denote by $\SIDCPO$. We
call such a subcategory a {\defit
{\dcpo}-variety\index{dcpo-variety@\dcpo-variety}\index{variety!dcpo@\dcpo}}.

Let $\D$ be a {\dcpo}-variety, defined by $\SI$.  For every {\dcpo} $D$,
there exists a free
$\SI$-{\dcpo}-algebra\index{free!dcpo-algebra@\dcpo-algebra} $\freeDOf{D}$
over $D$, with an associated continuous map $\jota:D\ii\freeDOf{D}$,
satisfying the usual universal property.  The construction of the free
{\dcpo}-algebra is less trivial than in the case of ordered algebras, and
it relies an Freyd's Adjoint Functor Theorem. A proof of the existence of
$\freeDOf{D}$ can be found in Abramsky and Jung {\cite{AJ94}}.

%======================================================================
\cleardoublepage
\chapter{The Lambda Calculus is Algebraic}
\label{cha-combinatory}

The correspondence between Church's untyped lambda calculus and Curry's
and Sch\"onfinkel's combinatory algebras is among the oldest known, and
most esthetically pleasing, facts about the lambda calculus. However, the
combinatory interpretation is also known to be somewhat imperfect, as
Curry's combinatory abstraction operator does not in general satisfy the
rule
\[	\rulex~~\deriv{M=N}{\lam x.M=\lam x.N}.
\]
One usually resolves this problem by moving from the class of lambda
algebras to the smaller class of {\em lambda models}, which are, by
definition, those lambda algebras in which $\rulex$ holds. However, unlike
the class of lambda algebras, the class of lambda models is not
equationally definable. Therefore, it fails to enjoy some useful closure
properties such as being closed under subalgebras.

In this chapter, we point out that the failure of the $\xi$-rule, and the
subsequent need for a non-equational class of models, is not due to the
lambda calculus itself, but to the way free variables are usually
interpreted in these models. The usual interpretation of a lambda term is
defined relative to a valuation of its free variables.  Essentially, this
amounts to interpreting a term $M$ with $n$ free variables as a function
$\Aa^n\ii\Aa$. We argue that it is more natural to model free variables as
algebraic indeterminates and to interpret $M$ as an element of a polynomial
algebra $\Aa[x_1,\ldots,x_n]$.  Based on this interpretation, we show that
the class of lambda algebras is sound and complete for arbitrary lambda
theories. In particular, the notorious rule $\rulex$ is sound with respect
to this interpretation.

This chapter is intended to serve as a self-contained, brief introduction
to the lambda calculus and its combinatory models. We do not claim
originality for the results in this chapter, which follow from known
results in Barendregt's book {\cite{Bar84}} and in the work of Koymans
{\cite{Koy82}}. We do however hope to present these issues from a fresh
point of view, particularly where the interpretation of free variables is
concerned.  Maybe this exposition will help to clarify the precise
relationship between the lambda calculus, lambda algebras, and lambda
models, which are sometimes confused in the literature.

Lambda conversion and reduction are introduced in
Section~\ref{sec-lambda-calculus}. Combinatory algebras and lambda algebras
are defined in Section~\ref{sec-comb-models}.  Section~\ref{sec-lam-algs}
contains a detailed analysis of the behavior of indeterminates in the
theory of lambda algebras, which leads to a streamlined interpretation of
the lambda calculus. In Section~\ref{sec-theories-algebras-equiv}, we show
that the categories of lambda theories and of lambda algebras are
equivalent. This, to some extent, justifies the slogan ``the lambda
calculus is algebraic''.  Lambda models are the subject of
Section~\ref{sec-lam-models}, and Section~\ref{sec-beta-eta} is devoted to
models of the lambda-$\beta\eta$-calculus. Finally, in
Section~\ref{sec-cccs}, we relate the different kinds of algebraic models
to reflexive ccc models.

% ========================================================================
\section{The lambda calculus}
\index{untyped lambda calculus}\index{lambda calculus!untyped}
\index{lambda calculus!model|see{model}}
\label{sec-lambda-calculus}

The lambda calculus is a theory of {\em functions as rules}. Its two basic
constructions are {\em functional application}, where $(fx)$ denotes the
application of a function $f$ to an argument $x$, and {\em functional
abstraction}, where $\lambda x.t$ denotes the function that maps $x$ to
$t$.

\begin{definition}
Let $\Vars$ be a countable set of {\defit variables\index{variable}}, fixed
throughout the rest of this chapter. Let $C$ be a set of {\defit
constants\index{constant}}. The set of {\defit raw lambda
terms\index{lambda term!raw}\index{raw lambda term}} $\rawTermsOf{C}$ is
defined to be the least set of terms such that
\[	\deriv{x\in\Vars}{x\in\rawTermsOf{C}}
\sep	\deriv{c\in C}{c\in\rawTermsOf{C}}
\sep	\deriv{M,N\in\rawTermsOf{C}}{(MN)\in\rawTermsOf{C}}
\sep	\deriv{x\in\Vars\sep M\in\rawTermsOf{C}}{(\lam x.M)\in\rawTermsOf{C}}.
\]
Notation: We often use upper case letters $M,N,\ldots$, as well as lower
case letters $s,t,u,\ldots$ to denote lambda terms. We use $x,y,\ldots$ to
denote variables.  To save parentheses, we write $MNP$ instead of
$((MN)P)$\microfilm{. We also write}\nomicrofilm{,} $\lambda x.MN$ instead
of $(\lambda x.(MN))$, and $\lambda x_1\ldots x_n.M$ instead of $(\lam
x_1.(\ldots(\lam x_n.M)\ldots))$.  The set $\FV(M)\seq\Vars$ of {\defit
free variables}\index{variable!free and bound}\index{free!variable} of a
raw lambda term $M$ is defined recursively:
\[	{\microfilm{\def\sep{\ssep}}
	\FV(x)=\{x\}
\sep	\FV(c)=\emptyset
\sep	\FV(MN)=\FV(M)\cup\FV(N)
\sep	\FV(\lam x.M)=\FV(M)\setminus\{x\}.}
\]
Variables that are not free are {\defit bound\index{bound variable, in
lambda calculus}}. We write $M\eqa
N$\index{alpha-equivalence@$\alpha$-equivalence} if $M$ and $N$ are equal
up to renaming of bound variables. The set $\TermsOf{C}$ of {\defit lambda
terms}\index{lambda term!untyped} \index{term!lambda} is then defined to be
the set $\rawTermsOf{C}/\mbox{$\eqa$}$ of $\alpha$-equivalence classes of
raw terms. From now on, we will consider terms up to $\alpha$-equivalence
without further mentioning it.  A term with no free variables is {\defit
closed\index{closed lambda term}\index{lambda term!closed}}. The set of
closed terms is denoted $\ClTermsOf{C}$.  We write
$\subst{M}{N}{x}$\index{substitution}\index{lambda term!substitution of}
for the result of substituting $N$ for $x$ in $M$, taking appropriate care
to ensure that neither $x$ nor any of the free variables of $N$ are bound
in $M$. For a rigorous treatment of $\alpha$-equivalence and substitution,
see {\eg} {\cite{Bar84}}.
\end{definition}

%------------------------------------------------------------------------
%..........................................................................
\begin{table*}[tbp]\caption{The axioms and rules of the lambda
calculus}
\label{tab-lambda-axioms}
\[\begin{array}{rc}
	\refl  & \deriv{\vstrut}{M=M}
\nl	\symm  & \deriv{M=N}{N=M}
\nl	\trans & \deriv{M=N\sep N=P}{M=P}
\end{array}\sep\begin{array}{rc}
	\rulec & \deriv{M=M'\sep N=N'}{MN=M'N'}
\nl	\rulex & \deriv{M=N}{\lam x.M=\lam x.N}
\nl	\ruleb & \deriv{\vstrut}{(\lam x.M)N=\subst{M}{N}{x}}
\end{array}\]
\end{table*}
%..........................................................................

\subsection{Lambda conversion\index{lambda conversion}}

The axioms and rules for deriving equations between lambda terms are shown
in Table~\ref{tab-lambda-axioms}\index{lambda calculus!untyped}.  If
$\Eqns$ is a set of equations, we write $\Eqns\entailsb M=N$ if $M=N$ is
derivable from $\Eqns$ by using these rules. A {\defit lambda
theory\index{lambda theory}\index{theory!untyped}}
is a set $\Th$ of closed equations that is closed under derivability, {\ie}
$\Th\entailsb M=N$ implies $M=N\in\Th$, for closed $M$ and $N$. For a given
set of constants, there is a unique smallest theory
$\theorybeta$\index{lambda theory!lambdabeta@$\theorybeta$}, called the
{\defit pure theory\index{pure lambda theory}\index{lambda theory!pure}} or
the theory of {\defit
$\beta$-conversion\index{beta-conversion@$\beta$-conversion}\index{conversion}\index{lambda
calculus!conversion}}.  We also write $\entailsb M=N$ as $M\eqb N$ and we
say that $M$ and $N$ are {\defit $\beta$-convertible}.

The {\defit lambda-$\beta\eta$-calculus} is the lambda calculus with the
additional axiom
\[	\rulee\ \deriv{x\not\in\FV(M)}{\lam x.Mx=M}.
\]
We write $\Eqns\entailseta M=N$ if $M=N$ is derivable from a set of
equations $\Eqns$ and the axiom $\rulee$.  A lambda theory $\Th$ which is
closed under $\entailseta$ is called a {\defit lambda-$\beta\eta$-theory}.
The unique smallest such theory is called the theory of {\defit
$\beta\eta$-conversion\index{eta-conversion@$\eta$-conversion}},
and it is denoted $\theorybetaeta$\index{lambda
theory!lambdabetaeta@$\theorybetaeta$}. If $\entailseta M=N$, then we write
$M\eqbe N$ and we say that $M$ and $N$ are {\defit
$\beta\eta$-convertible}.

\begin{remark}
The notion of theory given here is a slightly more liberal than the
one given in {\cite{Bar84}}, where the equations of a theory are not
allowed to contain any constants.
\end{remark}

\noindent
Notice that the lambda calculus is not given by a signature and equations
in the sense of universal algebra. However, we will show in
Section~\ref{sec-lam-algs} that the lambda calculus is equivalent, in a
suitable sense, to an algebraic theory.

%------------------------------------------------------------------------
%..........................................................................
\begin{table*}[tbp]\caption{Reduction rules of the lambda
calculus\index{lambda calculus!reduction}}
\label{tab-lambda-reduction-axioms}
\[\begin{array}{rc}
	\refl & \deriv{\vstrut}{M\reduces M}
\nl	\trans & \deriv{M\reduces N\sep N\reduces P}{M\reduces P}
\end{array}\sep\begin{array}{rc}
	\rulec & \deriv{M\reduces M'\sep N\reduces N'}{MN\reduces M'N'}
\nl	\rulex & \deriv{M\reduces N}{\lam x.M\reduces \lam x.N}
\nl	\ruleb & \deriv{\vstrut}{(\lam x.M)N\reduces \subst{M}{N}{x}}
\end{array}\]
\end{table*}
%..........................................................................

\subsection{Lambda reduction and consistency\index{lambda reduction}}

When considering functions as rules, it is natural to think of the
evaluation of a function applied to an argument as a dynamic process. This
process is made explicit in the notions of $\beta$-reduction and
$\beta\eta$-reduction.

A term of the form $(\lambda x.M)N$ is called a {\defit
$\beta$-redex\index{redex}}, and it {\defit
$\beta$-reduces\index{reduction}\index{beta-reduction@$\beta$-reduction}}
to $\subst{M}{N}{x}$.  The relation $\redb$ is the reflexive, transitive
and contextual closure of this one-step $\beta$-reduction. More precisely,
$\redb$ is the smallest relation on lambda terms satisfying the axioms and
rules in Table~\ref{tab-lambda-reduction-axioms}.  A term of the form $\lam
x.Mx$, where $x\not\in\FV(M)$, is called an {\defit $\eta$-redex}, and it
{\defit $\eta$-reduces}\index{eta-reduction@$\eta$-reduction} to $M$. The
relation $\redbe$ is the reflexive, transitive and contextual closure of
the one-step $\beta$- and $\eta$-reductions, {\ie}, it is the smallest
relation satisfying the axioms and rules in
Table~\ref{tab-lambda-reduction-axioms} and also the axiom
\[	\rulee\ \deriv{x\not\in\FV(M)}{\lam x.Mx\reduces M}.
\]
A term $M$ is said to be in {\defit $\beta$-normal form\index{normal
form}\index{lambda term!normal form of}} no subterm is a $\beta$-redex,
{\ie} if $M\redb M' \imp M=M'$. Similarly, $M$ is in {\defit
$\beta\eta$-normal form} if it contains no $\beta$- or $\eta$-redex, {\ie}
if $M\redbe M'\imp M=M'$. Examples of terms in $\beta$-normal form include
the {\defit booleans\index{lambda term!boolean}} $\tru=\lam xy.x$ and
$\fal=\lam xy.y$, as well as the {\defit Church numerals\index{Church
numerals}\index{lambda term!Church numeral}} $\churchnum{0}=\lam xy.x$,
$\churchnum{1}=\lam xy.xy$, $\churchnum{2}=\lam xy.x(xy)$ etc.; all of
these except for $\churchnum{1}$ are also in $\beta\eta$-normal form.

\begin{definition}
A binary relation $\reduces$ is said to have the {\defit diamond
property\index{diamond property}} if whenever $a\reduces b$ and $a\reduces
c$, then there exists $d$ such that $b\reduces d$ and $c\reduces d$. In
diagrams:
\[	\vcenter{\xymatrix@=.7em{&a\ar[dl]\ar[dr]\\b&&c\\{\blank}}}
\sep\imp\sep
	\vcenter{\xymatrix@=.7em{&a\ar[dl]\ar[dr]\\b\ar[dr]&&c\ar[dl]\\&d}}
\]
Also, a relation $\reduces$ is said to be {\defit
Church-Rosser\index{Church-Rosser
property}\index{confluence!Church-Rosser}} if the transitive closure
$\reduces^*$ has the diamond property.
\end{definition}

\begin{theorem}[Church, Rosser {\cite{CR36}}]
The relations $\redb$ and $\redbe$ are Church-Rosser.\eot
\end{theorem}

\noindent 
This theorem was first proved by Church and Rosser in 1936 {\cite{CR36}}.
Since then, the proof has been adapted and streamlined in various ways by
Tait, Martin-L\"of, Girard and others. One can find a proof in Barendregt's
book {\cite{Bar84}}.

The Church-Rosser Theorem has several important consequences.  As a first
consequence, one proves that for each pair of $\beta$-convertible lambda
terms $M\eqb N$, there is a term $P$ with $M\redb P$ and $N\redb P$. This
is easily shown by induction on the derivation of $M\eqb N$, using the
rules in Table~\ref{tab-lambda-axioms}. This immediately implies
consistency of the lambda calculus: 

\begin{corollary}{\bf Consistency.}\index{consistency!of the lambda calculus}\index{lambda
calculus!consistency} If $M$ and $N$ are two different terms in
$\beta$-normal form, then $M\not\eqb N$. If $M$ and $N$ are two different
terms in $\beta\eta$-normal form, then $M\not\eqbe N$.\eot
\end{corollary}

%=========================================================================
%..........................................................................
\begin{table*}[tbp]\caption{The axioms and rules of combinatory
logic\index{combinatory logic}}
\label{tab-combinatory-axioms}
\[\begin{array}{rc}
	\refl  & \deriv{\vstrut}{A=A}
\nl	\symm  & \deriv{A=B}{B=A}
\nl	\trans & \deriv{A=B\sep B=C}{A=C}
\end{array}\sep\begin{array}{rc}
	\rulec & \deriv{A=A'\sep B=B'}{AB=A'B'}
\nl	\rulek & \deriv{\vstrut}{\K AB=A}
\nl	\rules & \deriv{\vstrut}{\SS ABC=AC(BC)}
\end{array}\]
\end{table*}
%..........................................................................

\section{Combinatory models of the lambda calculus}
\label{sec-comb-models}

%-------------------------------------------------------------------------
\subsection{Combinatory algebras and combinatory logic}
\label{subsec-comb-logic}

\begin{definition}
An {\defit applicative structure\index{applicative structure}} $(\Aa,\app)$
is a set $\Aa$ together with a binary operation. A {\defit combinatory
algebra\index{combinatory algebra}} $(\Aa,\app,k,s)$ is an applicative
structure with distinguished elements $k$ and $s$ such that for all
$x,y,z\in\Aa$,
\[	kxy=x
\sep	sxyz=xz(yz)
\]
Here we write $kxy$ for $(k\app x)\app y$, etc.  A {\defit homomorphism of
combinatory algebras\index{combinatory algebra!homomorphism of}} is
$f\colon\Aa\ii\Bb$ such that $fk=k$, $fs=s$ and $f(x\app y)=fx\app fy$, for
all $x,y\in\Aa$.
\end{definition}

\begin{un-example}
The {\defit closed term algebra\index{closed term algebra}\index{lambda
calculus!closed term algebra}\index{standard term algebra}\index{term
algebra!open and closed}} associated with a lambda theory $\Th$ is
$(\ClTermsOf{C}/\Th,\app,K,S)$, where $\ClTermsOf{C}/\Th$ is the set of
$\Th$-equivalence classes of closed terms, $M\app N=(MN)$, $K=\lam xy.x$
and $S=\lam xyz.xz(yz)$. Similarly, the {\defit open term
algebra\index{open term algebra}\index{lambda calculus!open term algebra}}
is $(\TermsOf{C}/\Th,\app,K,S)$.
\end{un-example}

\noindent
Combinatory algebras form an algebraic variety\index{algebraic variety!of
combinatory algebras}.  The corresponding algebraic language is combinatory
logic: let $\Vars$ be a set of variables and $C$ a set of constants as
before. The set $\CTermsOf{C}$ of {\defit combinatory
terms\index{term!combinatory}\index{combinatory term}} or {\defit terms of
combinatory logic\index{combinatory logic}} is defined to be the smallest
set of terms such that
\[	\deriv{x\in\Vars}{x\in\CTermsOf{C}}
\sep	\deriv{c\in C}{c\in\CTermsOf{C}}
\sep	\deriv{A,B\in\CTermsOf{C}}{(AB)\in\CTermsOf{C}}
\sep	\deriv{}{\K\in\CTermsOf{C}}
\sep	\deriv{}{\SS\in\CTermsOf{C}}.
\]
Again, we economize the use of parentheses by writing $ABC$ instead of
$((AB)C)$. A combinatory term is {\defit closed\index{closed combinatory
term}} if it contains no variables. The set of closed terms is denoted by
$\ClCTermsOf{C}$. A closed and constant-free term, {\ie} a term that is
made up only from $\K$ and $\SS$, is also called a {\defit
combinator\index{combinator}}.  The axioms and rules for deriving equations
of combinatory logic are shown in Table~\ref{tab-combinatory-axioms}.  We
write $\Eqns\entailscl A=B$ if $A=B$ can be derived from a set of equations
$\Eqns$ by these rules.  A {\defit theory of combinatory
logic\index{theory!of combinatory logic}} is a set of closed equations that
is closed under derivability. The minimal theory is denoted $\CL$, and we
also write $A\eqcl B$ instead of $\entailscl A=B$.

Terms of combinatory logic can be interpreted in a combinatory algebra
$\Aa$, relative to a valuation $\rho$ of variables an an interpretation $I$
of constants.  We call this the {\em local} interpretation to distinguish
it from the absolute interpretation that we will consider in
Section~\ref{subsec-absolute-int}.

\begin{definition}{\bf Local interpretation of combinatory logic.}
Let $\Aa$ be a combinatory algebra, and let $I:C\ii\Aa$ be an
interpretation of constants in $\Aa$.  A {\defit
valuation\index{valuation!in applicative structure}\index{combinatory
algebra!valuation in}} of variables in $\Aa$ is a map
$\rho\colon\Vars\ii\Aa$.  The {\defit local interpretation}\index{local
interpretation!of combinatory logic} $\semi{A}{\rho}$ of a term
$A\in\CTermsOf{C}$ is defined inductively:
\[	\semi{x}{\rho}=\rho(x)
\sep	\semi{c}{\rho}=I(c)
\sep	\semi{\K}{\rho}=k
\sep	\semi{\SS}{\rho}=s
\sep	\semi{AB}{\rho}=\semi{A}{\rho}\app\semi{B}{\rho}.
\]
For terms $A,B\in\CTermsOf{C}$, we say that the interpretation $I$ {\defit
locally satisfies} the equation $A=B$, notation $I\modloc A=B$, if for all
valuations $\rho$ in $\Aa$, $\semi{A}{\rho}=\semi{B}{\rho}$.  We write
$\Eqns\modlocca A=B$ if for all combinatory algebras $\Aa$ and all
interpretations $I:C\ii\Aa$, if $I\modloc\Eqns$ then $I\modloc A=B$.
\end{definition}

\begin{proposition}{\bf Soundness and Completeness for combinatory logic.}
Let $\Eqns$ be a set of closed equations of combinatory logic. For
combinatory terms $A$ and $B$,
\[ 	\mbox{$\Eqns\entailscl A=B$ \ssep if and only if \ssep
	$\Eqns\modlocca A=B$.}
\]
\eottwo
\end{proposition}

%-------------------------------------------------------------------------
\subsection{The derived lambda abstractor}
\label{sec-lam-local}

The significance of the two combinators $\K$ and $\SS$ of combinatory
logic lies in the fact that they can be used to simulate lambda
abstraction. Define $\I=\SS\K\K$. Notice that $\I x\eqcl x$, for all
$x$. For a combinatory term $A\in\CTermsOf{C}$ and a variable
$x\in\Vars$, define the term $\lam^* x.A\in\CTermsOf{C}$ inductively:
\[
\begin{array}{rcll}
	\lam^* x.x &=&\I& 
\\	\lam^* x.B &=&\K B,&\mbox{ if $x\not\in\FV(B)$}
\\	\lam^* x.BC &=&\SS(\lam^* x.B)(\lam^* x.C),&\mbox{ otherwise}.
\end{array}
\]
Notice that $(\lam^* x.A)x\eqcl A$ can be shown by induction for any term
$A$. Also, $\FV(\lam^* x.A)=\FV(A)\setminus\{x\}$.  We call $\lam^*$ the
{\defit derived lambda abstractor\index{derived lambda
abstractor}\index{combinatory logic!derived lambda abstractor}} of
combinatory logic.  It is important to remark here that, in general, the
operator $\lam^*$ is well-defined only on {\em terms}, and not on
equivalence classes of terms. For this reason, the $\lam^*$ operator does
not, in general, yield an operator $\lam^*\colon\Aa[x]\ii\Aa$, for a
combinatory algebra $\Aa$. We will see in Section~\ref{subsec-absolute-int}
that we do get such an operator when $\Aa$ is a lambda algebra.

\begin{proposition}{\bf Combinatory completeness.}\label{pro-comb-compl}
\index{combinatory completeness}
For every term $B\in\CTermsOf{C}$\microfilm{ whose variables are
among}\nomicrofilm{ with variables in} $x_1,\ldots,x_n$, there exists a
closed term $A$ such that $B\eqcl Ax_1\cdots x_n$.
\end{proposition}

\begin{proof}
Let $B=\lam^* x_1\ldots x_n.A$.\eot
\end{proof}

\noindent
As a consequence, in the variety of combinatory algebras, all elements of
$\Aa[x_1,\ldots,x_n]$ can be written in the form $Ax_1\ldots x_n$, where
$A\in\Aa$. However, such $A$ is not necessarily unique.

%-------------------------------------------------------------------------
\subsection{The local interpretation of lambda terms}

Using the derived lambda abstractor $\lam^*$ of combinatory logic, we
can define translations $\cl \colon\TermsOf{C}\ii\CTermsOf{C}$ and
$\lambda\colon\CTermsOf{C}\ii\TermsOf{C}$ from lambda terms to combinatory
terms and {\em vice versa}:
\[
\begin{array}{rcl}
\\	x_{\cl }&=&x
\\	c_{\cl }&=&c
\\	(MN)_{\cl }&=&M_{\cl }N_{\cl }
\\	(\lam x.M)_{\cl }&=&\lam^* x.M_{\cl }
\end{array}
\sep
\begin{array}{rcl}
\\	x_{\lam}&=&x
\\	c_{\lam}&=&c
\\	(AB)_{\lam}&=&A_{\lam}B_{\lam}
\\	\K_{\lam}&=&\lam xy.x
\\	\SS_{\lam}&=&\lam xyz.xz(yz)
\end{array}
\]
Notice: Again, these translations are defined on terms, rather than
equivalence classes of terms. For example, $(\lam z.(\lam
x.x)z)_{\cl}=\SS(\K\I)\I$ and $(\lam z.z)_{\cl}=\I$ are not equivalent in
combinatory logic. 
The following hold:

\begin{lemma}\label{lem-lam-cl-properties}
For any lambda term $M$, we have $M_{\cl ,\lam}\eqb M$. For combinatory
terms $A,B$, if $A\eqcl B$ then $A_{\lam}\eqb B_{\lam}$. For lambda
terms $M,N$, if $M_{\cl }\eqcl N_{\cl }$, then $M\eqb N$. For a combinatory
term $A$, $(\lam^* x.A)_{\lam}\eqb\lam x.A_{\lam}$.\eot
\end{lemma}

\noindent
We can now interpret lambda terms in any combinatory algebra, by first
translating them into combinatory logic via $\cl$:

\begin{definition}{\bf Local interpretation of lambda terms.}\index
{local interpretation!of the lambda calculus}\index{lambda calculus!local
interpretation} 
Let $\Aa$ be a combinatory algebra and $I:C\ii\Aa$ an interpretation of
constants. For lambda terms $M,N\in\TermsOf{C}$ and a valuation
$\rho\colon\Vars\ii\Aa$, define
\[	\begin{array}{rcl}
	\semi{M}{\rho}&=&\semi{M_{\cl}}{\rho}
\\	I\modloc M=N&{\rm iff}&I\modloc M_{\cl}=N_{\cl}
\\	\Theoryof{I}&=&\{M=N\such M,N\in\ClTermsOf{C},\ I\modloc M=N\}
	\end{array}
\]
\end{definition}

\noindent
This interpretation is not sound for the lambda calculus, since there are
derivable equations, such as for instance $\lam z.(\lam x.x)z=\lam z.z$,
that do not hold in all combinatory algebras. In particular, $\Theoryof{I}$
need not be a lambda theory!

This leads us to consider the class of lambda algebras, which are
precisely those combinatory algebras that satisfy all the equations of
the lambda calculus.

%-------------------------------------------------------------------------
\subsection{Lambda algebras}

Let $\Aa$ be a combinatory algebra. Then $\CTermsOf{\Aa}$ is the set of
combinatory terms with one constant symbol for each element of $\Aa$. Let
$I_0:\Aa\ii\Aa$ be the canonical interpretation of each constant symbol as
itself, {\ie} the identity function. For $A,B\in\CTermsOf{\Aa}$, we write
$\Aa\modloc A=B$ instead of $I_0\modloc A=B$.

\begin{definition}
A combinatory algebra $\Aa$ is called a {\defit lambda algebra\index{lambda
algebra}} if for all combinatory terms $A,B\in\CTermsOf{\Aa}$,
\[	A_{\lam}\eqb B_{\lam}\sep\imp\sep\Aa\modloc A=B.
\]
A {\defit homomorphism of lambda algebras\index{lambda
algebra!homomorphism of}} is a homomorphism of combinatory algebras.
\end{definition}

\begin{un-example}
For any lambda theory $\Th$, the open term algebra $\TermsOf{C}/\Th$ and
the closed term algebra $\ClTermsOf{C}/\Th$ are lambda algebras. In the
open terms algebra, $\TermsOf{C}/\Th\modloc A=B$ iff $\Th\entailsb
A_{\lam}=B_{\lam}$.
\end{un-example}

\begin{proposition}[Curry]\label{prop-curry}
Lambda algebras form an algebraic variety. In fact, the class of lambda
algebras can be axiomatized over the class of combinatory algebras by the
following five closed equations, known as the {\defit Curry
axioms\index{Curry axioms for lambda algebras}}:\rm
\begin{enumerate}
\item	$k=s(s(ks)(s(kk)k))(k(skk))$
\item	$s=s(s(ks)(s(k(s(ks)))(s(k(s(kk)))s)))(k(k(skk)))$
\item	$s(kk)=s(s(ks)(s(kk)(s(ks)k)))(kk)$
\item	$s(ks)(s(kk))=s(kk)(s(s(ks)(s(kk)(skk)))(k(skk)))$
\item	$s(k(s(ks)))(s(ks)(s(ks)))=s(s(ks)(s(kk)(s(ks)(s(k(s(ks)))s))))(ks)$
\end{enumerate}
\end{proposition}

\begin{proof}
See {\cite{Bar84}}. We will give a different axiomatization of lambda
algebras in Remark~\ref{rem-axioms-lambda-algebras}.\eot
\end{proof}

\noindent
We denote the variety of lambda algebras by $\LA$\index{algebraic
variety!of lambda algebras}. We write $\entailsla$ for provability from the
axioms and rules of combinatory logic plus the five Curry axioms. We also
write $A\eqla B$ instead of $\entailsla A=B$. The following complements
Lemma~\ref{lem-lam-cl-properties}:

\begin{lemma}
For any combinatory term $A$,
we have $A_{\lam,\cl}\eqla A$. For lambda terms $M,N$, if $M\eqb N$, then
$M_{\cl}\eqla N_{\cl}$. For combinatory terms $A,B$, if $A_{\lam}\eqb
B_{\lam}$, then $A\eqla B$.\eot
\end{lemma}

\noindent
If $\Eqns$ is a set of equations, we write $\Eqns\modlocla A=B$ if for all
lambda algebras $\Aa$ and all interpretations $I:C\ii\Aa$, if
$I\modloc\Eqns$ then $I\modloc A=B$.  The following is a soundness and
completeness theorem for the {\em pure} lambda calculus, {\ie} for
equations $M=N$ that are provable in the pure theory $\theorybeta$.  In
Section~\ref{subsec-la-sound}, we prove a more general theorem for
arbitrary theories.

\begin{theorem}{\bf Soundness and completeness for the pure lambda calculus.}
For lambda terms $M,N\in\TermsOf{C}$,
\[	\mbox{$\entailsb M=N$ \ssep if and only if \ssep $\modlocla M=N$.}
\]
\end{theorem}

\begin{proof}
Soundness follows directly from the definition of lambda algebras. For
completeness, notice that the open term algebra $\TermsOf{}/\theorybeta$ of
the lambda beta calculus is a lambda algebra in which $M=N$ iff $M\eqb
N$.\eot
\end{proof}

\begin{bn-remark}{\bf Failure of {\boldmath $\rulex$} for the local
interpretation.}\index{local interpretation!failure of rule x@failure of
rule $\rulex$}
The reason that we state the soundness and completeness only for the pure
lambda calculus at this point is that in general, the local interpretation
in a lambda algebra does not satisfy the rule $\rulex$, {\ie} it is not in
general true that $I\modloc A=B$ implies $I\modloc\lam^* x.A=\lam^* x.B$. A
counterexample is the closed term algebra ${\cal M}^0$ of the
lambda-$\beta$-calculus. Plotkin {\cite{Plo74}} shows that there exist
closed terms $M,N$ such that for all closed terms $Z$, $MZ\eqb NZ$, but
$Mx\not\eqb Nx$ for a variable $x$. Hence ${\cal M}^0\modloc Mx=Nx$, but
${\cal M}^0\not\modloc \lam x.Mx=\lam x.Nx$.  The absolute interpretation,
to be defined in Section~\ref{subsec-absolute-int}, takes care of this
problem.
\end{bn-remark}

%========================================================================
\section{Lambda algebras and indeterminates}
\label{sec-lam-algs}

%-------------------------------------------------------------------------
\subsection{A characterization of $\Aa[x]$ for lambda algebras}
\label{subsec-char}

Recall that for a combinatory algebra $\Aa$, we denote by $\Aa[x]$ the
algebra obtained by freely adjoining an indeterminate $x$ to $\Aa$ in the
variety of combinatory algebras.  If $\Aa$ is a lambda algebra then so is
$\Aa[x]$. More generally, if $\Aa$ is a lambda algebra and
$f\colon\Aa\ii\Bb$ is a homomorphism of combinatory algebras, then $\Bb$ is
a lambda algebra.  This is because lambda algebras are definable by closed
equations (Proposition~\ref{prop-curry}).

If $\Aa$ is a lambda algebra, then $\Aa[x]$ has an interesting explicit
description. The following construction is similar to constructions given
by Krivine {\cite{Kri93}} and, in the case of Curry algebras, by Freyd
{\cite{Fre89}}. Let $\Aa=(\Aa,\app,k,s)$, and define $\Bb=(\Bb,\App ,K,S)$,
where
\[
\begin{array}{rcll}
	\Bb &=&\{a\in\Aa\such a=\one a\},&
	\mbox{ where $\one=s(ki)$, $i=skk$}
\\	a\App b &=& sab&
\\	K &=& kk&
\\	S &=& ks&
\end{array}
\]
Note: $ab$ denotes application in $\Aa$, and $a\App b$ denotes
application in $\Bb$.

\begin{proposition}\label{prop-indet}
\begin{enumerate} 
\item %1.
$\Bb$ is a well-defined combinatory algebra. 
\item %2.
The map $\iota \colon\Aa\ii\Bb$ with $\iota(a)=ka$ is a well-defined
homomorphism.
\item %3.  
For every homomorphism $f\colon\Aa\ii\Cc$ and every $x\in\Cc$,
there is a unique homomorphism $g\colon\Bb\ii\Cc$ such that $f=g\cp
\iota $ and $g(i)=x$. Consequently, $\Bb\iso\Aa[x]$.
\end{enumerate}
\end{proposition}

\noindent
Notice that $\one ab\eqcl ab$, and $\one_{\lam}\eqb\lam xy.xy$.  The proof
of Proposition~\ref{prop-indet} relies on the following seven properties of
lambda algebras. We will see later that lambda algebras are already
characterized by these properties (see
Remark~\ref{rem-axioms-lambda-algebras}).

\begin{lemma}\label{lem-eqns}
The following hold in any lambda algebra:
\[
\begin{array}{crcl} 	
	(a)&	\one(sa) &=& sa,
\\	(b)&	\one(sab) &=& sab,
\\ 	(c)&	\one(ka) &=& ka,
\\ 	(d)&	s(s(kk)a)b  &=&\one a,
\\ 	(e)&	s(s(s(ks)a)b)c  &=&  s(sac)(sbc),
\\ 	(f)&	k(ab)  &=&  s(ka)(kb),
\\ 	(g)&	s(ka)i  &=&\one a,
\end{array}
\]
\end{lemma}

\begin{proof}
One easily checks that $(\one(sa))_{\lam}\eqb(sa)_{\lam}$, and
similarly for the other equations.\eot
\end{proof}

\begin{proofof}{Proposition~\ref{prop-indet}}
\begin{caselist}
\case[1.:] It follows by Lemma~\ref{lem-eqns}$(a)$--$(c)$
that all of $K$, $S$,
$a\App b$, $i$ and $\one$ are elements of $\Bb$, for any $a,b\in
\Bb$. In particular, the operations on $\Bb$ are
well-defined. Moreover, for all $a,b,c\in B$,
\[ 	K\App a\App b=s(s(kk)a)b\stackrel{\text{\ref{lem-eqns}}(d)}{=}
	\one a=a,\sep{\rm and}
\]\[ 	S\App a\App b\App c=s(s(s(ks)a)b)c 
	\stackrel{\text{\ref{lem-eqns}}(e)}{=}s(sac)(sbc)=a\App c\App(b\App c).
\]
\case[2.:]
Using Lemma~\ref{lem-eqns}$(f)$,
\[	\iota(ab)=k(ab)=s(ka)(kb)=\iota(a)\App \iota(b).
\]
\case[3.:]
Define $g(a)=f(a)\app x$, and check that this has the desired
properties. For uniqueness, take any homomorphism $h\colon\Bb\ii\Cc$
such that $f=h\cp\iota $ and $h(i)=x$. Then for all $a\in\Bb$,
\[	h(a)=h(\one a)\stackrel{\text{\ref{lem-eqns}}(g)}{=}
	h(s(ka)i)=h((ka)\App i)=h(ka)\app h(i)=h(\iota a)\app
	h(i)=f(a)\app x=g(a).
\]
\eottwo
\end{caselist}
\end{proofof}

\begin{corollary}\label{cor-1}
Let $\Aa$ be a lambda algebra, and $a,b\in\Aa$. Then $ax=bx$ holds in 
$\Aa[x]$ if and only if $\one a=\one b$ holds in $\Aa$. 
\end{corollary}

\begin{proof} 
\begin{caselist}
\caseimp 
Suppose $a,b\in\Aa$ and $ax=bx$ in $\Aa[x]$. By
Proposition~\ref{prop-indet}, items 1.\ and 2., there is a unique map
$h\colon\Aa[x]\ii\Bb$ extending $\iota$ and sending $x$ to $i$. Then
\[	\one a\stackrel{\text{\ref{lem-eqns}}(g)}{=}
	s(ka)i=(ka)\App i=h(ax) 
	=h(bx)=(kb)\App i
	=s(kb)i\stackrel{\text{\ref{lem-eqns}}(g)}{=}
	\one b.
\]
\casepmi 
$\one a=\one b$ in $\Aa$ \implies $\one a=\one b$ in $\Aa[x]$ \implies 
$ax=\one ax=\one bx=bx$ in $\Aa[x]$.
\eot
\end{caselist}
\end{proof}

%-------------------------------------------------------------------------
\subsection{The absolute interpretation}\label{subsec-absolute-int}

Let $M\in\CTermsOf{C}$ be a lambda term whose free variables are among
$x_1,\ldots,x_n=\xbar$. Let $\Aa$ be a combinatory algebra, and let
$I:C\ii\Aa$ be an interpretation of constants.  The local interpretation
$\semi{M}{\rho}$, defined in Section~\ref{subsec-comb-logic}, depends on a
valuation of variables $\rho\colon\Vars\ii\Aa$. Since, in fact, it depends
only on the values of $\rho$ at $x_1,\ldots,x_n$, the local interpretation
can be viewed as a function $\semi{M}{\xbar}\colon\Aa^n\ii\Aa$, sending
an $n$-tuple $\abar\in\Aa^n$ to $\semi{M}{(\xbar:=\abar)}$.  In these terms,
an equation $M=N$ holds {\em locally} in $\Aa$ if $M$ and $N$ define the
same function $\Aa^n\ii\Aa$.

We will now consider a different interpretation of terms, interpreting $M$
as an element in $\Aa[\xbar]$, {\ie} as a polynomial. We call this the {\em
absolute} interpretation of $M$. The absolute interpretation distinguishes
more terms than the local one, since, in general, two different polynomials
may define the same function. For closed terms, however, the absolute and
the local interpretations coincide.

\begin{definition}{\bf Absolute interpretation.}
Let $\Aa$ be a combinatory algebra, and let $I:C\ii\Aa$ be an
interpretation of constants in $\Aa$. For each combinatory term
$A\in\CTermsOf{C}$ whose variables are among $\xbar=x_1,\ldots,x_n$, we
define its {\defit absolute interpretation\index{lambda calculus!absolute
interpretation}\index{absolute interpretation!of the lambda calculus}}
$\semabs{A}{\xbar}$ as an element of $\Aa[\xbar]$ by the following
inductive clauses. Notice that although the absolute interpretation depends
on $I$, we omit the extra superscript.
\[	\semabs{x_i}{\xbar}=x_i
\sep	\semabs{c}{\xbar}=I(c)
\sep	\semabs{\K}{\xbar}=k
\sep	\semabs{\SS}{\xbar}=s
\sep	\semabs{AB}{\xbar}=\semabs{A}{\xbar}\app\semabs{B}{\xbar}
\]
We say that the interpretation $I$ {\defit absolutely satisfies} the
equation $A=B$, in symbols $I\modabs A=B$, if
$\semabs{A}{\xbar}=\semabs{B}{\xbar}$, where $FV(A,B)\subseteq\xbar$.
Notice that, since the canonical homomorphism $\Aa[\xbar]\ii\Aa[\bar{y}]$
is one-to-one for $\xbar\subseteq\bar{y}$, this notion is independent of
the choice of variables $\xbar$. The absolute interpretation of lambda
terms $M\in\TermsOf{C}$ is defined via the translation $\cl$:
\[	\begin{array}{rcl}
	\semabs{M}{\xbar}&=&\semabs{M_{\cl}}{\xbar}
\nl	I\modabs M=N&{\rm iff}&I\modabs M_{\cl}=N_{\cl}
	\end{array}
\]
\end{definition}

\begin{remark}\index{absolute interpretation!in an algebra}
In the language of universal algebra, $\semabs{\,\cdot\,}{\xbar}$ is just the
unique map making the following diagram commute. Hence the local and the
absolute interpretation can be defined in any algebraic variety.
\[	\xymatrix@R-4ex@!C{
&	{\SigOf{C}}\ar[dd]_{\extension{I}}\ar[r]^<>(.5){\jota}
&	{\SigOf{C+\xbar}.}\ar[dd]_{\objectstyle\semabs{\,\cdot\,}{\xbar}}
\\	{C}\ar[dr]_{I}\ar[ur]^{\jota}
&&&	{\{\xbar\}}\ar[ul]_{\jota}\ar[dl]^{\jota}
\\&	{\Aa}\ar[r]_<>(.5){\jotb}
&	{\Aa[\xbar]}
	}
\]
\end{remark}

\noindent
The terminology ``an equation holds absolutely'' is justified by the
following lemma:

\begin{lemma}\label{lem-tfae}
Let $A,B\in\CTermsOf{C}$ be combinatory terms with variables in $\xbar$.
Let $\Aa$ be a combinatory algebra and $I:C\ii\Aa$ an interpretation of
constants.  The following are equivalent:\rm
\begin{enumerate}
\item $I\modabs A=B$,
\item $\jotb\cp I\modloc A=B$, where $\jotb:\Aa\ii\Aa[\xbar]$ is the
canonical map, 
\item $f\cp I\modloc A=B$ for all homomorphisms $f\colon\Aa\ii\Bb$.
\end{enumerate}
\end{lemma}

\begin{proof}
\begin{caselist}
\tu{1.$\imp$3.:} Consider $f\colon\Aa\ii\Bb$ and
$\rho\colon\Vars\ii\Bb$. Let $g\colon\Aa[\xbar]\ii\Bb$ be the unique map
extending $f$ such that $g(x_i)=\rho(x_i)$ for all $i$. Then
$\semsuper{A}{\rho}{f\cp I}=g\semabs{A}{\xbar}$ and
$\semsuper{B}{\rho}{f\cp I}=g\semabs{B}{\xbar}$, hence
$\semsuper{A}{\rho}{f\cp I}=\semsuper{B}{\rho}{f\cp I}$, which proves
$f\cp I\modloc A=B$.
\tu{3.$\imp$2.:} Trivial.
\tu{2.$\imp$1.:} $\jotb\cp I\modloc A=B$ iff for all
$\rho:\Vars\ii\Aa[\xbar]$, $\semsuper{A}{\rho}{\jotb\cp
I}=\semsuper{B}{\rho}{\jotb\cp I}$. Take $\rho(x_i)=x_i$ to get
$\semabs{A}{\xbar}=\semabs{B}{\xbar}$. \eot
\end{caselist}
\end{proof}

\begin{lemma}\label{lem-eqns-h}
In any lambda algebra, $\one(\lam^*x.A) = \lam^*x.A$.
\end{lemma}

\begin{proof}
By definition of $\lam^*$ and Lemma~\ref{lem-eqns}$(b)$ and $(c)$.\eot
\end{proof}

\noindent
The next lemma, which is crucial for the soundness of the interpretation of
the lambda calculus, holds for absolute, but not for local interpretations.

\begin{lemma}\label{lem-xi}{\bf The rule {\boldmath $\rulex$} is sound for
the absolute interpretation.}\index{lambda algebra!soundness of
xi-rule@soundness of $\rulex$-rule}
Let $\Aa$ be a lambda algebra, $I:C\ii\Aa$ an interpretation and
$A,B\in\CTermsOf{C}$ combinatory terms.  Then
\[	I\modabs A=B
\sep\iff\sep
	I\modabs\lam^* x.A=\lam^* x.B
\]
\end{lemma}

\begin{proof} 
Assume the variables of $A$ and $B$ are contained in $x,y_1,\ldots,y_n$.
\begin{caselist}
\caseimp
Suppose $\Aa[x,\ybar]\modloc A=B$.  Then $\Aa[x,\ybar]\modloc(\lam^*
x.A) x=A=B=(\lam^* x.B) x$, hence by Corollary~\ref{cor-1},
$\Aa[\ybar]\modloc\one (\lam^* x.A)=\one (\lam^* x.B)$. The claim
follows by Lemma~\ref{lem-eqns-h}.
\casepmi
Suppose $\Aa[\ybar]\modloc\lam^* x.A=\lam^* x.B$.  Then
$\Aa[x,\ybar]\modloc A=(\lam^* x.A)x=(\lam^* x.B)x=B$.
\eot
\end{caselist}
\end{proof}

\noindent
It follows from this lemma that the derived lambda abstractor
$\lam^*x$ is a well-defined operator $\lam^*x:\Aa[x]\ii\Aa$ if
$\Aa$ is a lambda algebra. When $\Aa[x]$ is explicitly constructed as
$(B,\App,K,S)$ like in Section~\ref{subsec-char}, then
$\lam^*x\colon\Bb\ii\Aa$ turns out to be the map that sends every
element $a$ to itself.  Using this $\lam^*$ operator, the absolute
interpretation of a lambda term can be defined directly, {\ie} without
relying on the translation $\cl$ into combinatory logic:
\[	\semabs{c}{\xbar}=c
\sep	\semabs{x_i}{\xbar}=x_i
\sep	\semabs{MN}{\xbar}=\semabs{M}{\xbar}\app\semabs{N}{\xbar}
\sep	\semabs{\lam x.M}{\xbar}=\lam^*x.\semabs{M}{x,\xbar}
\]

\begin{proposition}
In the category of lambda algebras, the derived lambda abstractor
$\lam^*x:\Aa[x]\ii\Aa$ is natural in $\Aa$, {\ie} for all $\phi:\Aa\ii\Bb$,
\[	\xymatrix{
	{\Aa[x]}\ar[d]_{\lam^*x}\ar[r]^{\phi[x]}
&	{\Bb[x].}\ar[d]^{\lam^*x}
\\		{\Aa}\ar[r]_{\phi}
&	{\Bb}
	}
\]
\end{proposition}

\begin{proof}
Any element of $\Aa[x]$ can be written (not uniquely) as $ax$, where
$a\in\Aa$. Then $\phi(\lam^*x.ax)=\phi(\one a)=\one(\phi a)=\lam^*x.(\phi
a)x=\lam^*x.\phi[x](ax)$. \eot
\end{proof}

%-------------------------------------------------------------------------
\subsection{Soundness and completeness for lambda algebras}
\label{subsec-la-sound}

\begin{proposition}{\bf Soundness.}\label{pro-sound}
The set of equations that hold absolutely in a lambda algebra $\Aa$ is
closed under the axioms and rules of the lambda calculus.  As a
consequence, $\Theoryof{\Aa}$ is a lambda theory for any lambda algebra
$\Aa$.
\end{proposition}

\begin{proof}
Consider each axiom and rule of the lambda calculus.  $\rulea$ and $\ruleb$
are satisfied because $\Aa$ is a lambda algebra.  The rules $\refl$,
$\symm$, $\trans$ or $\rulec$ are trivially satisfied.  Finally, the rule
$\rulex$ is satisfied by Lemma~\ref{lem-xi}. For the second claim, notice
that a closed equation holds absolutely iff it holds locally.\eot
\end{proof}

\begin{theorem}{\bf Soundness and Completeness for lambda algebras.}
\index{lambda algebra!soundness and completeness}
\label{thm-main}
Let $\Eqns$ be a set of closed equations of the lambda calculus. Then for
lambda terms $M,N$,
\[	\mbox{$\Eqns\entailsb M=N$ \ssep if and only if \ssep
	$\Eqns\modlocla M=N$.}
\]
\end{theorem}

\begin{proof}
Soundness follows by Proposition~\ref{pro-sound}. For completeness, observe
that the open term algebra $\TermsOf{}/\Th$ associated with the theory
$\Th$ is a lambda algebra satisfying $M=N$ iff $\Th\entailsb M=N$.
\eot
\end{proof}

\begin{corollary}
For a set $\Eqns$ of closed equations of the lambda calculus, let
$\Eqns_{\cl}$ be its translation into combinatory logic. Then for lambda
terms $M$ and $N$,
\[	\mbox{$\Eqns\entailsb M=N$ \ssep if and only if \ssep	
	$\Eqns_{\cl }\entailsla M_{\cl }=N_{\cl }$.}
\]
\eottwo
\end{corollary}

\begin{n-remark}\label{rem-axioms-lambda-algebras}
It is worth noting that Corollary~\ref{cor-1}, Lemma~\ref{lem-xi}, and
Proposition~\ref{pro-sound} were all proved using only the seven properties
of Lemma~\ref{lem-eqns}. Hence, if a combinatory algebra $\Aa$ satisfies
{\ref{lem-eqns}$(a)$--$(g)$}, then $\Theoryof{\Aa}$ is a lambda theory, which
implies that $\Aa$ is a lambda algebra. Thus, the class of lambda algebras
is axiomatized over the class of combinatory algebras by the properties in
Lemma~\ref{lem-eqns}. Of course, these axioms can be closed by using the
derived lambda abstractor. However, after spelling everything out in terms
of $s$ and $k$, the axioms given in Proposition~\ref{prop-curry} are
considerably shorter.
\end{n-remark}

%-------------------------------------------------------------------------
\section{Lambda theories and lambda algebras form equivalent categories}
\label{sec-theories-algebras-equiv}

In this section, we define the category of lambda theories, and we
show that it is equivalent to the category of lambda algebras.

\begin{definition}
The category $\LT$ of lambda theories is defined as follows: An object is a
pair $\pair{C,\Th}$, where $C$ is a set of constants and $\Th$ a lambda
theory in the language $\ClTermsOf{C}$.  The pair $\pair{C,\Th}$, like
$\Th$ itself, is called a {\defit lambda theory\index{lambda
theories!category of}}.  A {\defit translation\index{translation of lambda
theories}} from $C$ to $C'$ is a function $\varphi\colon
C\ii\ClTermsOf{C'}$. Any such $\varphi$ extends uniquely to a function
$\tilde{\varphi}\colon\ClTermsOf{C}\ii\ClTermsOf{C'}$, defined by
$\tilde{\varphi}M(c_1,\ldots,c_n)=M(\varphi c_1,\ldots,\varphi c_n)$, where
$c_1,\ldots,c_n$ are the constants that appear in $M$.  A morphism from
$\pair{C,\Th}$ to $\pair{C',\Th'}$ is named by a translation from $C$ to
$C'$ such that $\Th\entailsb M=N$ implies
$\Th'\entailsb\tilde{\varphi}M=\tilde{\varphi}N$ for all
$M,N\in\ClTermsOf{C}$. $\varphi$ and $\psi$ name the same morphism if
$\Th'\entailsb\tilde{\varphi}M=\tilde{\psi}M$ for all $M\in\ClTermsOf{C}$.
Composition is defined by $\varphi\cp\psi:=\tilde{\varphi}\cp\psi$.
\end{definition}

\begin{theorem}\label{thm-equiv}
The category $\LT$ of lambda theories is equivalent to the category
$\LA$ of lambda algebras.  
\end{theorem}

\begin{proof} 
We define a pair of functors
$F\colon\LT\ii\LA$ and $G\colon\LA\ii\LT$. $F$ sends a lambda theory
$\pair{C,\Th}$ to its closed term algebra $\ClTermsOf{C}/\Th$, which is
always a lambda algebra. $F$ sends a morphism
$\varphi\colon\pair{C,\Th}\ii\pair{C',\Th'}$ to the homomorphism
$f\colon\ClTermsOf{C}/\Th\ii\ClTermsOf{C'}/\Th'$ induced by
$\tilde{\varphi}\colon\ClTermsOf{C}\ii\ClTermsOf{C'}$.  $G$ sends a lambda
algebra $\Aa$ to $\pair{\Aa,\Theoryof{\Aa}}$, which is a lambda theory by
Proposition~\ref{pro-sound}. $G$ sends a homomorphism
$f\colon\Aa\ii\Bb$ to the translation
$\varphi\colon\Aa\ii\ClTermsOf{\Bb}$ with $\varphi a=fa$.

Next, we describe a natural isomorphism $\eta\colon\id_{\LA}\ii F\cp
G$. For every lambda algebra $\Aa$, define $\eta_{\Aa}:\Aa\ii F\cp
G(\Aa)=\ClTermsOf{\Aa}/\Theoryof{\Aa}$ by $\eta_{\Aa}(a)=a$. This is clearly a
homomorphism, and it is natural in $\Aa$. To see that this is an
isomorphism, notice that for every $M\in\ClTermsOf{\Aa}$ there is a
unique $a\in\Aa$ with $\Theoryof{\Aa}\entailsb M=a$, namely, $a=\sem{M}{}$.

In order to show the existence of a natural isomorphism $G\cp
F\iso\id_{\LT}$, it now suffices to show that $F$ is full and
faithful. $F$ is one-to-one on hom-sets by definition of morphisms in
$\LT$. $F$ is also full: if
$f\colon\ClTermsOf{C}/\Th\ii\ClTermsOf{C'}/\Th'$ is any homomorphism, then
$f$ maps a closed lambda term $M(c_1,\ldots,c_n)$ to
$M(fc_1,\ldots,fc_n)$, where $c_1,\ldots,c_n$ are the constants that
appear in $M$. This is because $M$ is equivalent to an applicative
term made up from $c_1,\ldots,c_n$ and the combinators $k$ and $s$,
which are preserved by $f$.  It follows that $f=F\varphi$, where
$\varphi\colon C\ii\ClTermsOf{C'}$ is defined by choosing a
representative $\varphi(c)$ of $f(c)$, for every $c\in C$.\eot
\end{proof}

%-------------------------------------------------------------------------
\section{Lambda models}
\label{sec-lam-models}

The notion of {\defit lambda model\index{lambda model}} arises, as in
{\cite{Bar84}}, if one attempts to prove Proposition~\ref{pro-sound} with
respect to the equations that hold locally. To do this, one needs the
``local'' equivalent of Lemma~\ref{lem-xi}:
\[ 	\Aa\modloc A=B
\sep\imp\sep
	\Aa\modloc\lam^* x.A=\lam^* x.B.
\]
This property, which is called {\defit weak extensionality}\index{weak
extensionality}\index{extensionality!weak}, does not hold in general. Hence
one defines a {\defit lambda model} to be a weakly extensional lambda
algebra.

From our point of view, lambda models can be characterized as those lambda
algebras which are intrinsically local: in a lambda model, an equation
holds absolutely if and only if it holds locally.  Or in other words: in a
lambda model, every polynomial is determined by its behavior as a
function. In the language of category theory, such a property is called
well-pointedness, and indeed lambda models correspond to well-pointed
lambda algebras in a sense that will be made precise in
Proposition~\ref{pro-comparison-algebra-refl-obj}.

\begin{proposition}\label{prop-meyer-scott}
The following are equivalent for a lambda algebra $\Aa$:\rm
\begin{enumerate}
\item
$\Aa$ is weakly extensional.
\item
$\Aa$ satisfies the following {\defit Meyer-Scott axiom\index{Meyer-Scott
axiom}}: for all $a,b\in\Aa$,
\[	\deriv{\forall x\in\Aa.ax=bx}{\one a=\one b}{\ \rulem},
\sep	\mbox{where $\one=\SS(\K\I)$},
\]
\item
every equation that holds locally in
$\Aa$ already holds absolutely.
\end{enumerate}
\end{proposition}

\begin{proof}
\begin{caselist}
\caseimpl{1.}{3.}
Let $\Aa$ be weakly extensional and $\Aa\modloc A=B$. Assume
$FV(A,B)\subseteq\xbar$. By weak extensionality,
$\Aa\modloc\lam^*\xbar.A=\lam^*\xbar.B$. This is a closed equation,
hence $\Aa\modabs\lam^*\xbar.A=\lam^*\xbar.B$, and finally $\Aa\modabs
A=B$ by Lemma~\ref{lem-xi}.
\caseimpl{3.}{2.}
We show $\rulem$: Suppose for all $x\in\Aa$, $ax=bx$.  Then
$\Aa\modabs ax=bx$ by 3., {\ie} $ax=bx\in\Aa[x]$. Hence $\one
a=\one b$ by Corollary~\ref{cor-1}.
\caseimpl{2.}{1.}
To show weak extensionality, suppose $\Aa\modloc A=B$. Then
$\Aa\modloc(\lam^* x.A)x=A=B=(\lam^* x.B)x$, hence by 2.,
$\Aa\modloc\one(\lam^* x.A)=\one(\lam^* x.B)$, hence by
Lemma~\ref{lem-eqns-h}, $\Aa\modloc\lam^* x.A=\lam^* x.B$.
\eot
\end{caselist}
\end{proof}

\noindent
Lambda models are less natural than lambda algebras, because they do not
form an algebraic variety. Historically, lambda models were a vehicle for
proving soundness and completeness theorems such as Theorem~\ref{thm-main},
see {\eg} {\cite[Thm.\ 5.2.18]{Bar84}}.  We conclude this section by
remarking that every lambda algebra can be embedded in a weakly extensional
one:

\begin{proposition}\label{pro-embed-alg-in-mod}
If $\Aa$ is a lambda algebra and $X$ an infinite set, then $\Aa[X]$ is a
lambda model.
\end{proposition}

\begin{proof}
We show the Meyer-Scott axiom: assume $a,b\in\Aa[X]$ and $ax=bx$ for all
$x\in\Aa[X]$. Then there is some finite $Y\seq X$ with $a,b\in\Aa[Y]$. Let
$x\in X\setminus Y$, then $ax=bx$ in $\Aa[Y][x]$, hence $\one a=\one b$ in
$\Aa[Y]$ by Corollary~\ref{cor-1}.\eot
\end{proof}

% ========================================================================
\section{Models of the lambda-\texorpdfstring{$\beta\eta$}{^^ce^^b2^^ce^^b7}-calculus}\label{sec-beta-eta}

%-------------------------------------------------------------------------
\subsection{Curry algebras}

A {\defit Curry algebra\index{Curry algebra}} {\cite{Lam80b}} is a lambda
algebra with $\one=\I$.  Note that Curry algebras form an algebraic
variety.

\begin{proposition}
A lambda algebra $\Aa$ is a Curry algebra if and only if $\Theoryof{\Aa}$
is a lambda-$\beta\eta$-theory.
\end{proposition}

\begin{proof}
If $x\not\in\FV(M)$, then $\lam x.Mx\eqb (\lam xy.xy)M=\one_{\lam}M$.
Hence in any Curry algebra, $\lam x.Mx=\one M=M$.  Conversely, if
$\Theoryof{\Aa}$ is a lambda-$\beta\eta$-theory, then $\Aa\models\one=\lam
xy.xy=\lam x.x=\I$. \eot
\end{proof}

\noindent
Hence Curry algebras are to the lambda-$\beta\eta$-calculus what
lambda algebras are to the lambda-$\beta$-calculus.

%-------------------------------------------------------------------------
\subsection{Extensional models}

An applicative structure is {\defit
extensional\index{extensionality}\index{applicative structure!extensional}}
if for all $a,b\in\Aa$,
\[	\deriv{\forall x\in\Aa.ax=bx}{a=b}.
\]
Extensional combinatory algebras are Curry algebras, and hence models of
the $\lam\beta\eta$-calculus. Although extensionality is an intuitive
property, extensional models do not form an algebraic variety: {\eg} the
closed term algebra of the lambda-$\beta\eta$-calculus is extensional, but
the subalgebra of closed terms is not (see {\cite[Thm.\ 20.1.2]{Bar84}} and
{\cite{Plo74}}). In fact, a Curry algebra is extensional if and only if it
is a lambda model, since the Meyer-Scott axiom from
Proposition~\ref{prop-meyer-scott} is equivalent to extensionality in the
presence of the equation $\one=\I$.

% ========================================================================
\section{Lambda algebras and categorical models}\label{sec-cccs}

%----------------------------------------------------------------------
\subsection{Reflexive ccc models}\label{subsec-reflexive-ccc-models}

In this section, we relate the combinatory models of the lambda calculus to
the models that arise from a reflexive object in a cartesian-closed
category.  An object $D$ in a cartesian-closed category $\Cc$ is called
{\defit reflexive\index{reflexive object}} if there exists
morphisms ${\e}$ and ${\p}$ such that
\[	\xymatrix{D^D\ar[d]_{\p}\ar[dr]^{\id}\\D\ar[r]_{\e}&D^D}
\]
The triple $\tuple{D,{\e},{\p}}$ is called a {\defit reflexive
$\Cc$-model\index{reflexive ccc model}\index{model!reflexive ccc model}} or
a {\defit categorical model of $\beta$-conversion\index{categorical
model!of conversion}\index{conversion!categorical model of}\index{lambda conversion!categorical model of}\index{model!of
lambda conversion!categorical}}. If also ${\p}\cp {\e}=\id_{D}$, we speak of a {\defit
categorical model of $\beta\eta$-conversion}.

One defines an interpretation $\sem{M}{x_1,\ldots,x_n}$ of each lambda
term $M$ with $\FV(M)\seq\{x_1,\ldots,x_n\}$ as a morphism $D^n\ii
D$. Assume that bound variables are renamed as appropriate. Recall
that $\curry{g}$ and $\uncurry{{\e}}$ are our notations for the curry and
uncurry operations, respectively.
\[\begin{array}{rcl}
	\sem{x_i}{x_1,\ldots,x_n}&=&D^n\catarrow{\proj_i}
	D\sep\mbox{(the $i$th projection)}
\\	\sem{MN}{x_1,\ldots,x_n}&=&D^n\catarrow{\pair{\sem{M}
	{x_1,\ldots,x_n},\sem{N}{x_1,\ldots,x_n}}}
		D\times D\catarrow{\uncurry{{\e}}}D
\\	\sem{\lam x_{n+1}.M}{x_1,\ldots,x_n}&=&D^n
	\catarrow{\curry{(\sem{M}{x_1,\ldots,x_{n+1}})}}
		D^D\catarrow{{\p}}D.
\end{array}\]

\begin{proposition}\label{pro-soundness-cat-mod-conv}
The following are properties of categorical models of
$\beta$-conversion: \rm
\begin{enumerate}
\item {\bf Permutation.} The interpretation is independent of the
ordering of the free variables, or of the addition of dummy variables,
in the following sense: If $\sigma:\{1,\ldots,n\}\ii\{1,\ldots,m\}$ is
injective and $\FV(M)\seq\{x_{\sigma 1},\ldots,x_{\sigma n}\}$, then
\[	\xymatrix{D^m\ar[rr]^{\sem{M}{x_1,\ldots,x_m}}
	\ar[dr]_{\tuple{\proj_{\sigma 1},\ldots,\proj_{\sigma n}}}
&&	D.
\\&	D^n\ar[ur]_{\sem{M}{x_{\sigma 1},\ldots,x_{\sigma n}}}
	}
\]
\item {\bf Substitution.} Let $\FV(M)\seq\{x_1,\ldots,x_n\}$ and
$FV(N_1,\ldots,N_n)\seq\{y_1,\ldots,y_m\}$, and let
$\subst{M}{\bar{N}}{\bar{x}}$ denote the simultaneous substitution of
$N_1,\ldots,N_n$ for $x_1,\ldots,x_n$ in $M$. Then
\[	\xymatrix{D^m\ar[rr]^{\sem{\subst{M}{\bar{N}}{\bar{x}}}{\bar{y}}}
	\ar[dr]_*+{\labelstyle\tuple{\sem{N_1}{\bar{y}},\ldots,\sem{N_n}{\bar{y}}}}
&&	D.
\\&	D^n\ar[ur]_{\sem{M}{x_1,\ldots,x_n}}
	}
\]
\item {\bf Soundness.} 
If $M\eqb N$, then $\sem{M}{\bar{x}}=\sem{N}{\bar{x}}$. In a
categorical model of $\beta\eta$-conversion, if $M\eqbe N$, then
$\sem{M}{\bar{x}}=\sem{N}{\bar{x}}$.
\end{enumerate}
\end{proposition}

\begin{proof}
1. and 2. are straightforward by induction on the term $M$.  For 3., define
$M\sim N$ iff $\sem{M}{\bar{x}}=\sem{N}{\bar{x}}$; by 1., this is
independent of the sequence of variables $\bar{x}$, as long as
$\FV(M,N)\seq\bar{x}$. Clearly, $\sim$ satisfies the properties $\refl$,
$\symm$, $\trans$ from Table~\ref{tab-lambda-axioms}. Moreover, it
satisfies $\rulec$ and $\rulex$ by 2.; to see that it also satisfies
$\ruleb$, first note that
$\uncurry{{\e}}\cp({\p}\times\id_D)=\uncurry{({\e}\cp
{\p})}=\uncurry{(\id_{D^D})}=\appl$. Hence
\[	\xymatrix@C=8em@R=4em{
&	D\times D  \ar[dr]^{\uncurry{{\e}}}
\\	D^n	   
	\ar[ur]^*+{\labelstyle\tuple{\sem{\lam x.M}{\bar{x}},\sem{N}{\bar{x}}}}
	\ar[r]^{\tuple{\curry{(\sem{M}{\bar{x},x})},\sem{N}{\bar{x}}}}
	\ar[dr]_*+{\labelstyle\tuple{\id_{D^n},\sem{N}{\bar{x}}}}
&	D^D\times D \ar[u]|*+{\labelstyle {\p}\times \id_{D}} \ar[r]^{\appl}
&	D.
\\&	D^n\times D \ar[u]|*+{\labelstyle\tuple{\curry{(\sem{M}{\bar{x},x})},\id_{D}}}
	\ar[ur]_*+{\labelstyle\sem{M}{\bar{x},x}}
	}
\]
By definition, the composition along the top is $\sem{(\lam
x.M)N}{\bar{x}}$, while by the Substitution Property 2., the
composition along the bottom is $\sem{\subst{M}{N}{x}}{\bar{x}}$.  This shows
$(\lam x.M)N\sim \subst{M}{N}{x}$. Hence $\mbox{$\eqb$}\seq{\sim}$, and we are
done with the first claim. The case for $\eta$-conversion follows by a
similar diagram chase.
\eot
\end{proof}

%----------------------------------------------------------------------
\subsection{Reflexive ccc models and lambda algebras}
\label{subsec-cat-models-and-lambda-algs}
\index{reflexive ccc model!and lambda algebras}
\index{lambda algebra!and reflexive ccc models}

From a categorical model $\tuple{D,{\e},{\p}}$, one can define a lambda
algebra $\tuple{\Aa,\app,k,s}$:
\[\begin{array}{rcl}
	\Aa&=&\hom{1,D}\sep\mbox{(the hom-set)}
\\	a\app b&=&1\catarrow{\pair{a,b}}
		D\times D\catarrow{\uncurry{{\e}}}D
\\	k&=&1\catarrow{\sem{\lam xy.x}{}}D
\\	s&=&1\catarrow{\sem{\lam xyz.xz(yz)}{}}D.
\end{array}\]

\begin{lemma}
$\tuple{\Aa,\app,k,s}$ is a well-defined lambda algebra.
\end{lemma}

\begin{proof}
It is easy to show by induction on terms that for any combinatory term
$A$,
\[\begin{array}{rcl}
	\sem{A}{\rho}&=&1\catarrow{\tuple{\rho
	x_1,\ldots\rho x_n}}D^n
	\catarrow{\sem{A_{\lam}}{x_1,\ldots,x_n}}D.
\end{array}\]
Hence, $A_{\lam}\eqb B_{\lam}\imp\sem{A_{\lam}}{\bar{x}}
=\sem{B_{\lam}}{\bar{x}}\imp\sem{A}{\rho} =\sem{B}{\rho}\imp\Aa\models
A=B$.
\eot
\end{proof}

\begin{remark}
Every lambda algebra arises from a reflexive model. The construction of a
cartesian-closed category from a lambda algebra is due to Scott
{\cite{Sco80}}, and it is also described in {\cite{Koy82}}.
\end{remark}

\noindent
The following proposition relates various concepts of lambda algebras to
corresponding concepts of the categorical interpretation. An object $D$ in
a category is {\defit well-pointed\index{well-pointed object}} if for all
$f,g:D\ii E$,
\[	(\forall x.\xymatrix{
	{1}\ar[r]^x
&	{D}\ar@<1ex>[r]^f\ar@<-1ex>[r]_g\ar@{}[r]|{\nocommute}
& 	{E}
	})\sep\imp\sep f=g.
\]
We say that $D$ is {\defit locally well-pointed\index{locally well-pointed
object}\index{well-pointed object!locally}} if the same holds for all
$f,g:D\ii D$.

\begin{proposition}\label{pro-comparison-algebra-refl-obj}
~\vspace{.5ex}\par\noindent
\begin{tabular}{lrcl}
	1.& $\Aa$ is a lambda model &iff& 
		$D$ is locally well-pointed.
\\[1ex] 2.& $\Aa$ is a Curry algebra &iff& ${\p}\cp {\e}=\id_{D}$.
\\[1ex] 3.& $\Aa$ is extensional &iff& $D$ is locally well-pointed and
		${\p}\cp {\e}=\id_{D}$.
\\[1ex]	4.& $\Aa[x]$&$\iso$&$(1,D^D)\iso(D,D)$. 
\\[1ex]	5.& $\Aa[x_1,\ldots,x_n]$&$\iso$&$(D^n,D)$.
\\[1ex]	6.& $\Aa\modloc M=N$ &iff& 
		$M=N\colon(1,D)^n\ii(1,D)$.
\\[1ex]	7.& $\Aa\modabs M=N$ &iff& $M=N\in(D^n,D)$.
\end{tabular}
\end{proposition}

\begin{proof}
In $\Aa$, one first computes $\I=\sem{\lam x.x}{}={\p}\cp\curry{(\id_D)}$,
$\one=\sem{\lam xy.xy}{}={\p}\cp\curry{({\p}\cp {\e})}$, and for all $a\in\Aa$,
$\one\app a={\p}\cp {\e}\cp a$.
\begin{itemlist}
\item[1.]
 \begin{caselist}
 \caseimp
  Suppose $\Aa$ is a lambda model and suppose $f,g:D\ii D$ such that
  for all $x:1\ii D$, $f\cp x=g\cp x$.
  Let $\hatt{f}={\p}\cp\curry{f}$ and $\hatt{g}={\p}\cp\curry{g}\in\Aa$.
  Then $\hatt{f}\app x=f\cp x=g\cp x=\hatt{g}\app x$ for all
 $x\in\Aa$, hence $\one\app\hatt{f}=\one\app\hatt{g}\imp {\p}\cp {\e}\cp
 {\p}\cp \curry{f}={\p}\cp {\e}\cp {\p}\cp \curry{g}\imp f=g$.  
 \casepmi
  Suppose $D$ is locally well-pointed. We show the Meyer-Scott axiom (see
  Proposition~\ref{prop-meyer-scott}). Suppose 
  $a,b\in\Aa$ such that for all $x\in\Aa$, $ax=bx$. This implies for
  all $x:1\ii 1\times D$,
  \[	\xymatrix@R=0em{
  &&	D\times D\ar[dr]^-{\uncurry{{\e}}}
  \\	1\ar[r]^-{x}
  &	1\times D\ar[ur]^-{a\times\id_D}\ar[dr]_-{b\times\id_D}
  & 	{\nocommute}
  &	D,
  \\&&	D\times D\ar[ur]_-{\uncurry{{\e}}}
	}
  \]
  hence, by local well-pointedness, the square
  commutes. Currying the square, we get ${\e}\cp a={\e}\cp b$,  
  hence $\one\app a=\one\app b$.
 \end{caselist}
\item[2.]
 \begin{caselist}
 \caseimp
  Suppose $\Aa$ is a Curry algebra. Then 
  \[	\curry{({\p}\cp {\e})}={\e}\cp {\p}\cp\curry{({\p}\cp {\e})}={\e}\cp\one={\e}\cp\I={\e}\cp
 	{\p}\cp\curry{(\id_D)}=\curry{(\id_D)}, 
  \] hence ${\p}\cp {\e}=\id_D$.  
 \casepmi
  Suppose ${\p}\cp {\e}=\id_D$, then $\one={\p}\cp\curry{({\p}\cp
 {\e})}={\p}\cp\curry{(\id_D)}=\I$. 
 \end{caselist}
\item[3.] From 1. and 2.
\item[4.] and 5.\hspace{1ex}
 Consider the following two retracts:
 \[	\xymatrix{{\Aa[x]}\ar[d]_{\lam^* x}\ar[dr]^{\id}
 \\	{\Aa}\ar[r]_{(-)\app x}
 &	{\Aa[x]}}
 \sep\mbox{and}\sep
 	\xymatrix{D^D\ar[d]_{\p}\ar[dr]^{\id}\\D\ar[r]_{\e}&D^D.}
 \]
 As we have seen in Section~\ref{sec-lam-algs}, the set $\Aa[x]$ can be
 identified with those $a\in\Aa$ such that $\one\app a=a$. On the other
 hand, arrows $1\ii D^D$ can be identified with those $a:1\ii D$ such that
 ${\p}\cp {\e}\cp a=a$, which is again just $\one\app a=a$. This gives a 
 one-to-one correspondence between the points of $\Aa[x]$ and
 $(1,D^D)\cong(D,D)$. The correspondence $\Aa[x_1,\ldots,x_n]\cong (D^n,D)$
 is similar. Moreover, this correspondence induces a lambda algebra
 structure on 
 $(D^n,D)$, which turns out to be the natural ``pointwise'' one given by
 \[\begin{array}{rcl}
	a\app b&=&D^n\catarrow{\pair{a,b}}
		D\times D\catarrow{\uncurry{{\e}}}D
 \\	k&=&D^n\catarrow{~}1\catarrow{\sem{\lam xy.x}{}}D
 \\	s&=&D^n\catarrow{~}1\catarrow{\sem{\lam xyz.xz(yz)}{}}D.
 \end{array}\]
\item[6.]
 We have $\Aa\modloc M=N$ iff $\sem{M}{\rho}=\sem{N}{\rho}$ for all
 $\rho:\Vars\ii(1,D)$, iff  
 $\sem{M}{\bar{x}}\cp f=\sem{N}{\bar{x}}\cp f\in(1,D)$ for all
 $f\in(1,D^n)$. 
\item[7.]
 Follows from 5. and Lemma~\ref{lem-tfae}.
\eot
\end{itemlist}
\end{proof}

\nocite{Lam80b,Mey82,Koy82}

%======================================================================
\cleardoublepage
\chapter{Unorderability}\label{cha-unorderable}\label{cha-order}

The formulation of the untyped lambda calculus, by Church and Curry in
the 1930's, has preceded its modern semantic theory by more than 30 years.
It was not until the 1960's that Dana Scott constructed the first truly
``mathematical'' models of the lambda calculus. Scott discovered that such
models can be constructed by a combination of order-theoretic and
topological methods. Specifically, he observed that there exist non-trivial
diagrams of the form
\[	\xymatrix{D^D\ar[d]_{\p}\ar[dr]^{\id}\\D\ar[r]_<>(.5){\e}&D^D}
\]
in certain cartesian-closed categories of complete partial orders and
Scott-continuous functions. Recall that an object $D$ in this situation is
called {\em reflexive}, and that it gives rise to a model of the lambda
calculus in a canonical way as described in Chapter~\ref{cha-combinatory}.

The question now arises whether all models of the lambda calculus can be
constructed in this way. This question must be modified, since a simple
analysis reveals that every reflexive {\CPO}-model is uncountable
{\cite{Plo93}}, while there are some countable models of the lambda
calculus. Instead, one can ask the refined question: can every model of the
lambda calculus be {\em embedded} in a reflexive {\CPO}-model?
Alternatively: does every lambda theory arise as the theory of a reflexive
{\CPO}-model?  The answer is known to be negative: Honsell and Ronchi Della
Rocca {\cite{HRDR92}} have exhibited a lambda theory that does not arise
from such a model. One may now further relax this question by asking:

\begin{enumerate}
\item[(i)] Can every model of the
lambda calculus be partially ordered? 
\item[(ii)] Can every model of the lambda
calculus be embedded in one that admits a partial order? 
\end{enumerate}

\noindent
These two questions are the subject of this chapter.  Let us call a lambda
algebra {\em unorderable} if it does not admit a non-trivial partial order
that is compatible with the algebra structure.  Unorderable algebras are
known to exist. Plotkin has recently constructed a {\em finitely separable}
algebra, a property with implies unorderability. In
Section~\ref{sec-terms-unordered}, however, we show that one does not have
to look very far to find unorderable algebras: the most natural term models
of the lambda calculus, namely the standard open and closed term algebras,
are unorderable. An application to reflexive {\CPO}-models is discussed in
Section~\ref{sec-topo-comp}.

Question (ii) is more difficult to answer, as indicated by the fact that
the answer is still unknown. Let us call a lambda algebra {\em
absolutely unorderable} if it cannot be embedded in an orderable one.  In
Section~\ref{sec-malcev}, we give an algebraic characterization of
absolutely unorderable $\T$-algebras in any algebraic variety $\T$. We show
that a $\T$-algebra is absolutely unorderable if and only if it has a
family of so-called {\em generalized {\Malcev} operators}. The question
(ii) thereby reduces to the syntactic question whether it is consistent to
add such {\Malcev} operators to the lambda calculus. This is an open
problem in general, but we discuss some special cases in
Section~\ref{sec-abs-unord-comb-algs}.  Finally, in
Section~\ref{sec-notions-unord}, we relate various different notions of
unorderability.


%========================================================================
\section{Lambda terms cannot be ordered}\label{sec-terms-unordered}

In this section, we investigate unorderable models of the lambda calculus.
Let us first fix some terminology. Preorders and partial orders were
defined in Section~\ref{subsec-preorders}.  The unique minimal preorder on
any set $X$ is called {\defit discrete\index{discrete
preorder}\index{preorder!discrete}}, the unique maximal preorder is called
{\defit indiscrete\index{indiscrete preorder}\index{preorder!indiscrete}},
and discrete or indiscrete preorders are called {\defit
trivial\index{trivial preorder}\index{preorder!trivial}}.  By convention,
if we wish to refer to a preorder that satisfies $x\leq y\imp y\leq x$, we
will not call it trivial, but {\defit symmetric\index{symmetric
preorder}\index{preorder!symmetric}}.  Of course, a partial order is
symmetric iff it is discrete iff it is trivial.

Applicative structures and combinatory algebras were defined in
Section~\ref{subsec-comb-logic}.  Let $(X,\app)$ be an applicative
structure. Recall that a preorder $\leq$ on $X$ is called {\defit
compatible\index{compatible relation!preorder}} if the application
operation is monotone in both arguments with respect to $\leq$, {\ie} if
\[	\mbox{$\forall a,b,a',b'\in X.$ $a\leq a'$ and $b\leq b'$ \implies
	$a\app b\leq a'\app b'$.}
\] 
An applicative structure is called {\defit
unorderable\index{unorderable!combinatory algebra}\index{applicative
structure!unorderable}\index{combinatory algebra!unorderable}} if it does
not allow a non-trivial compatible partial order.

Notice that if $(X,\app,k,s)$ is a combinatory algebra, then a
preorder $\leq$ is compatible if and only if application is monotone
in just the second argument. Monotonicity in the first argument then
follows by considering $f=\lam^* x.x\app b$, because $a\leq a'$
implies $a\app b=f\app a\leq f\app a'=a'\app b$.

Recall that the {\defit open term algebra\index{open term
algebra}\index{standard term algebra}\index{term algebra!open and closed}}
of the $\lambda\beta$-calculus is the combinatory algebra
\microfilm{given by} $(\TermsOf{C}/\mbox{$\eqb$},\app,K,S)$, where $\TermsOf{C}$ is the set of
untyped lambda terms with constants from $C$, $\app$ is the application
operation on terms, and $K$ and $S$ are the terms $\lambda xy.x$ and
$\lambda xyz.xz(yz)$, respectively.  The {\defit closed term
algebra\index{closed term algebra}}
$(\ClTermsOf{C}/\mbox{$\eqb$},\app,K,S)$ is defined analogously, and
similarly for the $\lambda\beta\eta$-calculus.

%------------------------------------------------------------------------
\subsection{Plotkin's unorderable algebra: Separability}

In a recent paper {\cite{Plo96}}, G. Plotkin has constructed a finitely
separable lambda, a property which implies unorderability.  Following an
idea of Flagg and Myhill {\cite{FM89}}, Plotkin calls a subset $A$ of a
lambda algebra $X$ {\defit separable\index{separable subset of lambda
algebra}} if every function $\phi\from A\ii X$ is realized by some element
$\hatt{\phi}\in X$, meaning that for all $a\in A$, $\phi(a)=\hatt{\phi}\app
a$.  A lambda algebra is said to be {\defit finitely
separable\index{finitely separable lambda algebra}\index{model!finitely
separable}\index{lambda algebra!finitely separable}} if every finite subset
is separable. Flagg and Myhill noticed that finitely separable algebras do
not allow non-trivial compatible preorders: This is because if $a<b$ are
two distinct comparable elements in $X$, then all pairs $x,y$ of elements
are comparable via some $\hatt{\phi}\in X$ with $\hatt{\phi}\app a=x$ and
$\hatt{\phi}\app b=y$.

%------------------------------------------------------------------------
\subsection{The standard term algebras are unorderable}
\label{subsec-terms-unord}

We will now show that the standard open and closed term algebras cannot be
non-trivially partially ordered.  Notice that these are not finitely
separable. For instance, consider the terms $\omega=(\lambda x.xx)(\lambda
x.xx)$ and $I=\lambda x.x$. The term $\omega$ is unsolvable, while $I$ is
in normal form.  Let $T$ be another term in normal form. By the Genericity
Lemma (Barendregt {\cite{Bar84}}, Proposition 14.3.24), whenever
$R\omega=T$, then $RI=T$.  Hence, $\omega$ and $I$ cannot be separated.

How would one go about constructing a partial order on, say, the open term
algebra of the $\lambda\beta$-calculus? As a first approximation, one might
take two distinct variables $x$ and $y$, and let $\myleq$ be the preorder
generated by a single inequality $x\myleq y$. For this preorder, one has
$M\myleq N$ iff $N$ is obtained from $M$ up to $\beta$-equivalence by
replacing some, but not necessarily all occurrences of the variable $x$ by
$y$.  In other words, $M\myleq N$ iff there is a term $P$ (not itself
containing $x$ or $y$) such that $M\eqb Pxxy$ and $N\eqb Pxyy$. This
preorder is non-trivial, because $y\not\myleq x$. But is it a partial
order? The following lemma, to be proved in
Section~{\ref{sec-partial-examples}}, shows that this is not the case:

\begin{lemma}\label{lem-auuut}
There exists a closed term $A$ of the untyped lambda calculus with
$Axxxy\eqb Axyyy$, but $Axxxy\neqbe Axxyy\neqbe Axyyy$ for variables
$x\neq y$. \eot
\end{lemma}

\noindent
Notice that in the preorder that we have just defined, $Axxxy\myleq
Axxyy\myleq Axyyy=Axxxy$.  But since $Axxxy\not=Axxyy$, the preorder
$\myleq$ is not antisymmetric, hence not a partial order.  By the same
reasoning, $x$ and $y$ cannot be related in {\em any} compatible
partial order on open terms.  To show this section's main result, we
need to replace the variables $x$ and $y$ by arbitrary terms $\bu$ and
$\bt$. This is achieved by the following lemma, which states that, if
$s$ is a fresh variable, then $s\bu$ and $s\bt$ behave essentially
like indeterminates: any equation that holds for $s\bu$ and $s\bt$
will hold for variables $x$ and $y$.  Let $\Th$ be one of the theories
$\theorybeta$ or $\theorybetaeta$.

\begin{lemma}\label{lem-generic}
Let $\bu_1,\ldots,\bu_n$ be terms that are distinct with respect to
$\Th$.  If $s$ is a variable not free in $\bu_1,\ldots,\bu_n$, then
$s\bu_1,s\bu_2,\ldots,s\bu_n$ behave like generic arguments. More
precisely, for all terms $M,N$ with $s\not\in\FV(M,N)$, and for
variables $x_1,\ldots,x_n$,
\[\begin{array}{c}
 M(s\bu_1)(s\bu_2)\ldots(s\bu_n) \eqTh N(s\bu_1)(s\bu_2)\ldots(s\bu_n)
 \\\mbox{implies}\\
 Mx_1x_2\ldots x_n \eqTh Nx_1x_2\ldots x_n.
\end{array}\]
\end{lemma}

\begin{proof}
Let $\{z_1,z_2,\ldots,z_m\}$ be a list of all the free variables of
the terms $\bu_1,\ldots,\bu_n$. Choose fresh, distinct constants
$c_1,\ldots,c_m$ and $d_1,\ldots,d_n$. For $i=1\ldots n$, let
$\overline{\bu_i}$ be the closed term obtained from $\bu_i$ by
replacing free variables with the appropriate constants:
$\overline{\bu_i}=\simsubst{\bu_i}{\substitem{c_1}{z_1},\ldots
,\substitem{c_m}{z_m}}$.  Further, add to the lambda calculus a new
constant $\sigma\not\in C$ and equations $\sigma\overline{\bu_i}=d_i$,
for $i=1\ldots n$. Let $\Th+\sigma$ denote the theory that is obtained
in this way on $\TermsOf{C+\{\sigma\}}$.  Then
\[\begin{array}{rcl}
	M(s\bu_1)(s\bu_2)\ldots(s\bu_n) 
&	\makebox[10pt]{$\eqTh$}
&	N(s\bu_1)(s\bu_2)\ldots(s\bu_n) 
\\\imp\ M(\sigma\overline{\bu_1})\ldots(\sigma\overline{\bu_n})
&	\makebox[10pt]{$\eqThs$}
&	N(\sigma\overline{\bu_1})\ldots(\sigma\overline{\bu_n})
\sep	\mbox{(by renaming)}
\\\imp\ Md_1\ldots d_n 
&	\makebox[10pt]{$\eqThs$}
& 	Nd_1\ldots d_n
\end{array}\]
The claim now follows from the fact that $\Th+\sigma$ is conservative over
$\Th$. This is a consequence of Plotkin's separability result
{\cite{Plo96}}: the closed term algebra can be embedded in a separable
algebra. Let $\iota:\ClTermsOf{C}/\Th\ii\Aa$ be such an embedding. Then
choose $\hatt{\phi}\in\Aa$ such that $\hatt{\phi}\app\iota u_i=\iota d_i$,
for $i=1\ldots n$. There is a unique extension
$\iota':\ClTermsOf{C+\sigma}/\Th\ii\Aa$ of $\iota$, sending $\sigma$ to
$\hatt{\phi}$. Clearly, the theory induced by $\iota'$ is a conservative
extension of $\Th$ satisfying the additional equations.\eot
\end{proof}

\begin{theorem}\label{thm-unorderable}
Let $\cal M$ be the open or the closed term algebra of the
$\lambda\beta$- or $\lambda\beta\eta$-calculus. Then $\cal M$ does not
allow a non-trivial compatible partial order.
\end{theorem}

\begin{proof}
Let $\leq$ be a compatible partial order on $\cal M$.  Let
$\bu\not=\bt\in{\cal M}$, and assume, by way of contradiction, that
$\bu\leq\bt$. Let $A$ be as in Lemma~\ref{lem-auuut}, and let $s$ be a
fresh variable.  Then by compatibility,
\begin{eqnarray*}
\lambda s.A(s\bu)(s\bu)(s\bu)(s\bt)
        &\leq& \lambda s.A(s\bu)(s\bu)(s\bt)(s\bt)
\\      &\leq&  \lambda s.A(s\bu)(s\bt)(s\bt)(s\bt)
\\      &=& \lambda s.A(s\bu)(s\bu)(s\bu)(s\bt),
\end{eqnarray*}
hence, by antisymmetry,
\[
 A(s\bu)(s\bu)(s\bu)(s\bt)= A(s\bu)(s\bu)(s\bt)(s\bt)
\]
Applying Lemma~\ref{lem-generic} to $M=\lambda xy.Axxxy$ and $N=\lambda
xy.Axxyy$, one gets $Axxxy=Axxyy$ for variables $x$ and $y$,
contradicting the choice of $A$.  Consequently, the order is
trivial.\eot
\end{proof}

%======================================================================
\section{The Topological Completeness Problem}\label{sec-topo-comp}

Recall that, for any cartesian-closed category $\Cc$, a {\defit reflexive
$\Cc$-model\index{reflexive ccc model}} is a model of the lambda calculus
that arises from a diagram
\[	\xymatrix{D^D\ar[d]_{\p}\ar[dr]^{\id}\\D\ar[r]_{\e}&D^D}
\]
in the category $\Cc$ (see Section~\ref{sec-cccs}). These models have been
particularly well studied in the category $\CPO$ of {\cpos} and
Scott-continuous functions. Reflexive $\CPO$-models are sometimes referred
to as {\defit continuously complete\index{continuously complete
model}\index{model!continuously complete}}, because every Scott-continuous
function $f:D\ii D$ is definable by an element $\hatt{f}\in D$.  Honsell
and Ronchi Della Rocca {\cite{HRDR92}} also use the term {\defit
topological model\index{topological model}\index{model!topological}}. The following is a long standing open problem ({\cite{HRDR92}}):

\begin{openproblem}{\bf (Topological Completeness)}\index{topological
completeness problem}
Is there a reflexive $\CPO$-model whose theory is $\theorybeta$ or
$\theorybetaeta$?
\end{openproblem}

\noindent
Two related questions have been answered: Honsell and Ronchi Della Rocca
{\cite{HRDR92}} have shown that there is a lambda theory ${\cal
C}_{\Lambda_0}$ which is not induced by any reflexive $\CPO$-model.  The
reflexive $\CPO$-models are thus incomplete for arbitrary lambda
theories. On the other hand, Di~Gianantonio {\etal} {\cite{DHP94}} have
shown that $\theorybetaeta$ can arise as the theory of a reflexive
$\CPO_1$-model.  If $\omega_0$ and $\omega_1$ denote, respectively, the
first infinite ordinal and the first uncountable ordinal, then $\CPO_1$ is
the category whose objects are $\omega_0$- and $\omega_1$-complete partial
orders, and whose morphisms preserve limits of $\omega_1$-chains (but not
necessarily of $\omega_0$-chains). However, the construction given in
{\cite{DHP94}} makes decisive use of non-Scott-continuous functions.

We will now explore some consequences of Theorem~\ref{thm-unorderable}
for topological completeness. First, one notices that in all models
whose theory is $\theorybeta$ or $\theorybetaeta$, the denotations of
closed lambda terms necessarily form a discrete subset:

\begin{corollary}\label{cor-discretely-ordered}
In any partially ordered lambda algebra whose theory is $\theorybeta$
or $\theorybetaeta$, the denotations of closed terms are pairwise
incomparable.
\end{corollary}

\begin{proof}
The set of closed term denotations is a sub-lambda algebra which is
isomorphic to the closed term algebra; hence the partial order is
discrete on it by Theorem~\ref{thm-unorderable}.\eot
\end{proof}

\noindent
Recall that two elements $x,y$ of a partially ordered set $D$ are called
{\defit compatible\index{compatible elements}} if there exists $z\in D$
with $x\leq z$ and $y\leq z$.  We can now show that any complete reflexive
$\CPOp$-model, if such a model exists, must satisfy one of two peculiar
properties:

\begin{theorem}
Suppose $D$ is a reflexive $\CPOp$-model whose theory is $\theorybeta$ or
$\theorybetaeta$. Then either:
\begin{enumerate}
\item
The denotations of closed terms are pairwise incompatible, or
\item
There exist closed lambda terms $M$ and $N$ such that, for all $x,y\in
D$, 
\[	(x\leq y\mbox{ or }y\leq x)\sep\iff\sep Mxy=Nxy.
\]
\end{enumerate}
\end{theorem}

\begin{proof}
Suppose 1. does not hold, {\ie} there are two distinct closed terms
$u$ and $t$ whose denotations have an upper bound $v\in D$. Let $A$ be
as in Lemma~\ref{lem-auuut}, and let \nomicrofilm{$M=\lambda
xyrs.A(s(rx))(s(rx))(s(rx))(s(ry))$ and $N=\lambda
xys.A(s(rx))(s(rx))(s(ry))(s(ry))$.}\microfilm{\[M=\lambda
xyrs.A(s(rx))(s(rx))(s(rx))(s(ry))\mbox{ and }N=\lambda
xys.A(s(rx))(s(rx))(s(ry))(s(ry)).\]}
\begin{caselist}
\case[$\imp$:] Suppose
$x\leq y$ or $y\leq x$. Then $Mxy=Nxy$ by the same reasoning as in the
proof of Theorem~\ref{thm-unorderable}. 
\case[$\pmi$:]
Suppose, by way of contradiction, that $Mxy=Nxy$ for incomparable
$x,y\in D$. Define $r:D\ii D$ by
\[	r(z)=\left\{
\begin{array}{ll}
	\bot	& \mbox{if $z\leq x$ and $z\leq y$} \\
	u	& \mbox{if $z\leq x$ and $z\not\leq y$} \\
	t	& \mbox{if $z\not\leq x$ and $z\leq y$} \\
	v	& \mbox{if $z\not\leq x$ and $z\not\leq y$} 
\end{array}
	\right.
\]
Then $r$ is continuous; suppose it is represented by $\hatt{r}\in D$. Then
\[	D\models
	\lam s.A(su)(su)(su)(st)
	= Mxy\hatt{r}
	= Nxy\hatt{r}
	= \lam s.A(su)(su)(st)(st).
\]
But the proof of Theorem~\ref{thm-unorderable} shows that the first
and the last term are $\theorybetaeta$-different, contradicting the
assumption that $D$ was a complete model.\eot
\end{caselist}
\end{proof}

%======================================================================
\section{A characterization of absolutely unorderable algebras}
\label{sec-malcev}

In Section~\ref{sec-terms-unordered}, we have shown that the combinatory
algebra of open lambda terms cannot be non-trivially ordered. However, it
can be {\em embedded} in an orderable algebra; this follows {\eg} from the
work of Di~Gianantonio {\etal} {\cite{DHP94}}. Plotkin conjectures in
{\cite{Plo96}} that there exists a combinatory algebra which is {\em
absolutely unorderable}, {\ie} which cannot be embedded in an orderable
combinatory algebra.  In this section, we characterize, for any algebraic
variety $\T$, those $\T$-algebras which are absolutely unorderable.

Let $\T$ be an algebraic variety.  Recall that a preorder $\leq$ on a
$\T$-algebra $\Aa$ is {\defit compatible\index{compatible
relation!preorder}} if whenever $a_i\leq b_i$ for $i=1\ldots k$, then
$fa_1\ldots a_k\leq fb_1\ldots b_k$, for each $k$-ary function symbol
$f\in\Ome_k$. Notice that monotone preorders are closed under arbitrary
intersections. If $\leq$ is monotone, then so is the dual preorder
$\geq$. Every monotone preorder determines a congruence $\sim_\leq$ on
$\Aa$, which is the intersection of $\leq$ and $\geq$. Also notice that
$\leq$ naturally defines a partial order on $\Aa/\mbox{$\sim_{\leq}$}$.

A $\T$-algebra $\Aa$ is said to be {\defit
unorderable\index{unorderable!t-algebra@$\T$-algebra}} if it does not allow
a non-trivial compatible partial order. Also, $\Aa$ is said to be {\defit
absolutely unorderable\index{absolutely unorderable
algebra}\index{unorderable!absolutely}} if for any embedding $\Aa\ii\Bb$ of
$\T$-algebras, $\Bb$ is unorderable.

%---------------------------------------------------------------------
\subsection{Absolutely unorderable algebras and generalized 
		{\Malcev} operators}

Consider a $\T$-algebra $\Aa$. Let $\preceq$ be the smallest
compatible preorder on $\Aa[u,t]$ such that $u\preceq t$.

\begin{lemma}\label{l2}
$\preceq$ is trivial on $\Aa$, {\ie} $a\preceq b\imp a=b$ for $a,b\in\Aa$.
\end{lemma}

\begin{proof}
Let $\sim$ be the kernel of the canonical morphism $\Aa[u,t]\ii\Aa[x]$
which sends both $u$ and $t$ to $x$. Then $\sim$ is a congruence,
hence in particular a compatible preorder on $\Aa[u,t]$. Since also
$u\sim t$, by definition $\preceq$ is contained in it. But $\sim$,
hence $\preceq$, is trivial on $\Aa$.
\eot
\end{proof}

\begin{lemma}\label{t1}
$\Aa$ is absolutely unorderable if and only if $t\preceq u$.
\end{lemma}

\begin{proof}
\begin{caselist}
\case[$\imp$:]
Suppose $\Aa$ is absolutely unorderable. Consider the natural map
$\Aa\ii\Aa[u,t]\ii\Aa[u,t] / \mbox{$\sim_\preceq$}$.  Lemma~\ref{l2}
implies that, the composition is an embedding, hence $\preceq$ must be
trivial as a partial order on $\Aa[u,t] / \mbox{$\sim_\preceq$}$.
Equivalently, $\preceq$ as a preorder on $\Aa[u,t]$ is symmetric.
Since $u\preceq t$, it follows that $t\preceq u$.
\case[$\pmi$:]
Suppose $\Aa$ is not absolutely unorderable. Then there is an
embedding $F:\Aa\ii\Bb$ of $\T$-algebras where $\Bb$ has a non-trivial
compatible partial order $\leq$. Hence there are $U\neq T\in\Bb$ such
that $U\leq T$. Consider the unique map $G:\Aa [u,t]\ii\Bb$ such that
$u\mapsto U$, $t\mapsto T$ and $G\rest{\Aa}=F$. Define $a\leq b$ in
$\Aa[u,t]$ iff $G(a)\leq G(b)$ in $\Bb$. Then $\leq$ is a compatible
preorder on $\Aa[u,t]$. But $u\leq t$, hence $\preceq$ is contained in
$\leq$. But $t\not\leq u$, hence $t\not\preceq u$.
\eot
\end{caselist}
\end{proof}

\noindent
Further, $\preceq$ has the following explicit description: On $\Aa[u,t]$,
define $a\tmpll b$ if and only if there is a polynomial
$A(x_1,x_2,x_3)\in\Aa[x_1,x_2,x_3]$ such that $A(t,u,u)=a$ and
$A(t,t,u)=b$.

\begin{lemma}\label{l1}
$\preceq$ is the transitive closure of $\tmpll $.
\end{lemma}

\begin{proof}
Notice that $\tmpll$ is reflexive. Let $\tmpll^*$ be the transitive
closure.  Clearly, $\tmpll$, and hence $\tmpll^*$, is contained in
$\preceq$. On the other hand, $\tmpll^*$ is a preorder on $\Aa[u,t]$
satisfying $u\tmpll^*t$.  To see that $\tmpll^*$ is compatible, let
$f$ be a $k$-ary function symbol in $\Sig$. First assume $a_i\tmpll
b_i$ for $i=1\ldots k$. Then there are
$A_i(x_1,x_2,x_3)\in\Aa[x_1,x_2,x_3]$, for $i=1\ldots k$, such that
$A_i(t,u,u)=a_i$ and $A_i(t,t,u)=b_i$ for each $i$. By considering
$A(x_1,x_2,x_3)=f(A_1(x_1,x_2,x_3)\ldots A_k(x_1,x_2,x_3))$, it
follows that $fa_1\ldots a_k\tmpll fb_1\ldots b_k$. Hence $\tmpll$ is
compatible, which readily implies compatibility for
$\tmpll^*$. Therefore, $\preceq$ is contained in $\tmpll^*$. \eot
\end{proof}

\noindent
Putting this together with Lemma~\ref{t1}, we get the following
characterization of absolutely unorderable algebras. Recall that an
equation $p(u,t)=q(u,t)$ holds {\defit absolutely\index{absolute
interpretation!in an algebra}} in $\Aa$ iff it holds in $\Aa[u,t]$.

\begin{theorem}\label{thm-malcev}
{\bf Characterization of absolutely unorderable $\T$-algebras.} Let $\T$ be
an algebraic variety. A $\T$-algebra $\Aa$ is absolutely unorderable if and
only if, for some $n\geq 1$, there exist polynomials
$\malc_i(x_1,x_2,x_3)\in\Aa[x_1,x_2,x_3]$, for $i=1\ldots n$, such that the
following equations hold absolutely in $\Aa$:
\begin{eqnarray}
 t &=& \malc_1(t,u,u) \nonumber\\
 \malc_1(t,t,u) &=& \malc_2(t,u,u) \nonumber\\
 \malc_2(t,t,u) &=& \malc_3(t,u,u) \label{eqn-malcev}\\
 &\vdots& \nonumber\\
 \malc_n(t,t,u) &=& u\nonumber
\end{eqnarray}
\end{theorem}

\begin{proof}
By Lemmas~\ref{t1} and~\ref{l1}, $\Aa$ is absolutely unorderable if and
only if there are $t_1,\ldots,t_{n-1}\in\Aa[u,t]$ such that $t\tmpll
t_1\tmpll\ldots\tmpll t_n\tmpll u$. The corollary follows by definition of
$\tmpll$. \eot
\end{proof}

\noindent
In the case $n=1$, the equations (\ref{eqn-malcev}) have the simple form
$t=\malc(t,u,u)$ and $\malc(t,t,u)=u$.  These equations were first studied
by A.I. {\Malcev} {\cite{Mal54}} to characterize varieties of
congruence-permutable algebras (so-called {\Malcev} varieties\index{malcev
variety@{\Malcev} variety}). A ternary operator $\malc$ satisfying these
equations is called a {\Malcev} operator\index{malcev operator@{\Malcev}
operator}. Accordingly, we call $\malc_1,\ldots,\malc_n$ satisfying
(\ref{eqn-malcev}) a family of {\defit (generalized) {\Malcev}
operators\index{generalized malcev operators@generalized {\Malcev}
operators}}, and we call the equations (\ref{eqn-malcev}) the {\defit
(generalized) {\Malcev} axioms\index{malcev axioms@{\Malcev} axioms}}.
Hagemann and Mitschke {\cite{HaM73}} have shown that an algebraic variety
has $n$-permutable congruences\index{n-permutability@$n$-permutability} if
and only if it has operators satisfying the axioms (\ref{eqn-malcev}). It
was proved by W. Taylor {\cite{Tay74,BFT76}} that algebras in a variety
with $n$-permutable congruences are unorderable; however, the converse, to
the best of my knowledge, is a new result. Also note that
Theorem~\ref{thm-malcev} characterizes {\em individual} algebras that are
absolutely unorderable, rather than varieties of unorderable algebras.

%--------------------------------------------------------------------------
\subsection{An application to ordered algebras and {\dcpo}-algebras}

Recall from Section~\ref{subsec-ordered-algebras} that an algebraic
signature $\Sig$ and a set of inequations $\Ineqns$ define a variety $\OT$
of ordered algebras\index{ordered algebra}\index{ordered
variety}\index{variety!ordered}\index{algebra!ordered}. The free ordered
$\SI$-algebra\index{free!ordered algebra} over any poset $P$ was denoted by
$\freeOOf{P}$.  One may ask under which circumstances the canonical map
$\jota:P\ii\freeOOf{P}$ is order-reflecting. The following theorem shows
that the answer depends only on the presence of $\Malcev$ operators in
$\SI$.  Recall that a $k$-ary operation in $\Sig$ is simply a $\Sig$-term
$t(x_1,\ldots,x_k)$.

\begin{theorem}\label{thm-order-alg-reflect}
Let $\Sig$ be a signature and $\Ineqns$ a set of inequations. Let $P$
be a non-trivially ordered poset and let $\jota:P\ii\freeOOf{P}$
be the canonical map from $P$ into the free ordered $\SI$-algebra over
$P$. The following are equivalent:\rm
\begin{enumerate}
\item %1.
$\jota$ is {\em not} order-reflecting.
\item %2.
Every ordered $\SI$-algebra is trivially ordered.
\item %3.
There are ternary operations $\malc_1,\ldots,\malc_n$ in $\Sig$ such
that $\Ineqns$ entails
\begin{eqnarray}
 t &\leq& \malc_1(t,u,u) \nonumber\\
 \malc_1(t,t,u) &\leq& \malc_2(t,u,u) \nonumber\\
 \malc_2(t,t,u) &\leq& \malc_3(t,u,u) \label{ineqn-malcev}\\
 &\vdots& \nonumber\\
 \malc_n(t,t,u) &\leq& u\nonumber
\end{eqnarray}
\end{enumerate}
\end{theorem}

\begin{proof}
\begin{caselist}
\caseimpl{1.}{2.}
Suppose $\Bb$ is a non-trivially ordered $\SI$-algebra with elements
$a<b$. We show that $\jota$ is order-reflecting. Let $x,y\in P$ with
$\jota(x)\leq\jota(y)$. Define $g:P\ii\Bb$ by
\[	g(z)=\left\{\begin{array}{ll}
	a &\mbox{if $z\leq y$}
\\	b &\mbox{if $z\not\leq y$}
	\end{array}\right.
\]
Then $g$ is monotone; therefore, by the universal property of
$\freeOOf{P}$, there exists a unique homomorphism of ordered
algebras $h:\freeOOf{P}$ such that $g=h\cp\jota$. By
monotonicity of $h$, we get $g(x)=h(\jota(x))\leq h(\jota(y))=g(y)=a$,
hence $x\leq y$.
\caseimpl{2.}{3.}
Suppose every ordered $\SI$-algebra is trivially ordered. Then, in
particular, $\freeOOf{\Vars}$ is trivially ordered, and hence
$\Ineqns\entailsineq s\leq t$ iff $\Ineqns\entailsineq t\leq s$. We
can therefore regard $\Ineqns$ as a set of equations. The claim
follows by applying Theorem~\ref{thm-malcev} to
$\Aa=\freeOOf{\emptyset}$.
\caseimpl{3.}{2.}
Suppose $\SI$ has operators satisfying (\ref{ineqn-malcev}). Then for
any $\SI$-algebra $\Bb$, if $a\leq b\in\Bb$, then
$b\leq\malc_1(b,a,a)\leq\malc_1(b,b,a)
{\leq}\ldots\leq\malc_n(b,b,a)\leq a$, hence $\Bb$ is trivially
ordered.
\caseimpl{2.}{1.}
A map $\jota:P\ii\freeOOf{P}$ from a non-trivially ordered
set into a trivially ordered one cannot be order-reflecting.
\eot
\end{caselist}
\end{proof}

\begin{remark}
Notice that the proof of {\impl{3.}{2.}} shows that the inequalities
(\ref{ineqn-malcev}) already imply the corresponding equalities
(\ref{eqn-malcev}).
\end{remark}

\noindent
The equivalent of Theorem~\ref{thm-order-alg-reflect} holds for
{\dcpo}-algebras as well. This is due to the following lemma, which relates
the existence of non-trivial
{\dcpo}-algebras\index{dcpo-variety@\dcpo-variety}\index{variety!dcpo@\dcpo}\index{dcpo-algebra@\dcpo-algebra}\index{algebra!dcpo-algebra@\dcpo-algebra}
to the existence of non-trivial ordered algebras:

\begin{lemma}
\label{lem-order-dcpo}
Let $\Sig$ be a signature and $\Ineqns$ a set of inequations. There
exists a non-trivially ordered $\SI$-{\dcpo}-algebra if and only if
there exists a non-trivially ordered $\SI$-algebra.
\end{lemma}

\begin{proof}
\begin{caselist}
\case[$\imp$:] Trivial, since every {\dcpo}-algebra is an ordered algebra.
\case[$\pmi$:]
Let $\pair{\Aa,\leq}$ be an ordered $\SI$-algebra. We consider the ideal
completion of $\Aa$: A subset $I\seq\Aa$ is an {\defit ideal\index{ideal in
a poset}} if it is downward closed and directed. Let $\IAa=\Idl{\Aa}$, the
{\defit ideal completion\index{ideal completion}} of $\Aa$, be the set of
all ideals, ordered by inclusion.  Abramsky and Jung {\cite{AJ94}} prove
that $\IAa$ is a $\SI$-{\dcpo}-algebra. Moreover, the map
$\Aa\ii\IAa:x\mapsto\downdeal x$ is order preserving and reflecting, and
hence $\IAa$ is non-trivially ordered if $\Aa$ is.
\end{caselist}
\end{proof}

\begin{corollary}
Let $\Sig$ be a signature and $\Ineqns$ a set of inequations. Let $D$
be a non-trivially ordered {\dcpo} and let $\jota:D\ii\freeDOf{D}$
be the canonical map from $D$ into the free ordered $\SI$-algebra over
$D$. The following are equivalent:\rm
\begin{enumerate}
\item %1.
$\jota$ is {\em not} order-reflecting.
\item %2.
Every $\SI$-{\dcpo}-algebra is trivially ordered.
\item %3.
There are ternary operations $\malc_1,\ldots,\malc_n$ in $\Sig$ such
that $\Ineqns$ entails (\ref{ineqn-malcev}).
\end{enumerate}
\end{corollary}

\begin{proof}
The equivalence of 2.\ and 3.\ follows from
Theorem~\ref{thm-order-alg-reflect} and
Lemma~\ref{lem-order-dcpo}. The implication {\impl{2.}{1.}} is trivial,
and {\impl{1.}{2.}} follows as in the proof of
Theorem~\ref{thm-order-alg-reflect}; notice that the function $g$
defined there is continuous.\eot
\end{proof}

%======================================================================
\section{Absolutely unorderable combinatory algebras}
\label{sec-abs-unord-comb-algs}

If $\Aa$ is a combinatory algebra, then the statement of
Theorem~\ref{thm-malcev} takes a particularly simple form, due to
combinatory completeness: A combinatory algebra $\Aa$ is absolutely
unorderable if and only if there are a number $n\geq 1$ and elements
$\malc_1,\ldots,\malc_n\in\Aa$ such that the following hold absolutely in
$\Aa$:
\begin{eqnarray}
 t &=& \malc_1tuu \nonumber\\
 \malc_1ttu &=& \malc_2tuu \nonumber\\
 \malc_2ttu &=& \malc_3tuu \label{eqn-malcev-comb}\\
 &\vdots& \nonumber\\
 \malc_nttu &=& u\nonumber
\end{eqnarray}
Note that if $\Aa$ is a lambda algebra, one can replace these equations by
the closed equations $\lam^* tu.t=\malc_1tuu$ etc.

But does an absolutely unorderable combinatory algebra exist?
Unfortunately, this is not known. Clearly, an absolutely unorderable
combinatory algebra exists if and only if the equations
(\ref{eqn-malcev-comb}) are consistent\index{consistency!of the malcev
axioms@of the {\Malcev} axioms} with the axioms of combinatory algebras for
some $n$.  The answer is only known in the cases $n=1$ and $n=2$. In these
cases, (\ref{eqn-malcev-comb}) is inconsistent with combinatory logic, as
we will now show. Notice that if the axioms are consistent for some $n$,
then also for all $m\geq n$, by letting $\malc_{n+1},\ldots,\malc_m=\lam
xyz.z$

Let $Y$ be any fixpoint operator of combinatory logic, for instance the
paradoxical fixpoint combinator $Y=\lambda f.(\lam x.f(xx))(\lam x.f(xx))$.
Write $\mu x.M$ for $Y(\lambda x.M)$.  The operator $\mu$ satisfies the
fixpoint property:
\[	\mu x.A(x) = A(\mu x.A(x)).
\sep	\fix
\]
The {\defit diagonal axiom\index{diagonal axiom}} is 
\[	\mu y. \mu x.A(x,y) = \mu x.A(x,x).
\sep	\diagaxiom
\]
The following lemma is due to G. Plotkin and A. Simpson:

\begin{lemma}[Plotkin, Simpson]\label{lem-simpson}
Assuming the diagonal axiom, the {\Malcev} axioms (\ref{eqn-malcev-comb})
are inconsistent with combinatory logic for all $n$.
\end{lemma}

\begin{proof}
Let $x$ be arbitrary. Let $A = \mu z.\malc_1 xzz$. Then $A = \mu z.x = x$.  
Also,  
\[\begin{array}{rcll}
	x\ =\ A &=& \mu z.\malc_1 xzz		&
\\	&=& \mu y.\mu z.\malc_1 xyz	& {\rm by}\ \diagaxiom
\\	&=&  \mu z.\malc_1 xxz		& {\rm by}\ \fix 
\\	&=& \mu z.\malc_2 xzz		& {\rm by}\ (\ref{eqn-malcev-comb})
\\	&=& \ldots			&
\\	&=&  \mu z.\malc_{n-1} xxz	&
\\	&=& \mu z.z			& {\rm by}\ (\ref{eqn-malcev-comb})
\end{array}\]
Hence $x=\mu z.z$ for all $x$, which is an inconsistency. \eot
\end{proof}

\begin{theorem}[Plotkin, Simpson]
For $n=1$, the {\Malcev} axioms are inconsistent with combinatory logic.
\end{theorem}

\begin{proof}
Suppose $\malc$ is a {\Malcev} operator. Let $x$ be arbitrary and let
$A = \mu y.\mu z.\malc xyz$. Then
\[	A \eqbyrule{\fix } \mu z.\malc xAz \eqbyrule{\fix } \malc xAA
	\eqbyrule{({\it Malcev}_{1})} x,
\]
hence $x = \mu z.\malc xAz = \mu z.\malc xxz = \mu z.z$. \eot
\end{proof}

\begin{theorem}[Plotkin, Selinger]
For $n=2$, the {\Malcev} axioms are inconsistent with combinatory logic.
\end{theorem}

\begin{proof}
Suppose $\malc_1$ and $\malc_2$ are operators satisfying the {\Malcev}
axioms (\ref{eqn-malcev-comb}).  Define $A$ and $B$ by mutual recursion
such that
\[\begin{array}{rcr}
	A &=& \mu x.f(\malc_1 xAB)(\malc_1 xAB)
\\	B &=& \mu y. \mu z.f(\malc_2 ABy)(\malc_2 ABz).
\end{array}\]
Then 
\[\begin{array}{rcll}
	B &=& f(\malc_2 ABB)(\malc_2 ABB)	& {\rm by}\ \fix
\\	&=& f(\malc_1 AAB)(\malc_1 AAB)		& {\rm by}\ (\ref{eqn-malcev-comb})
\\	&=& A.					& {\rm by}\ \fix
\end{array}\]
So $\mu x. fxx = \mu x.f(\malc_1 xAA)(\malc_1 xAA) = A = B = \mu y.
\mu z.f(\malc_2 AAy)(\malc_2 AAz) = \mu y. \mu z.fyz$, which is the
diagonal axiom. By Lemma~\ref{lem-simpson}, this leads to an
inconsistency.\eot
\end{proof}

%======================================================================
\section{Relating different notions of unorderability}
\label{sec-notions-unord}

%----------------------------------------------------------------------
\subsection{Local notions}\label{subsec-local-notions}

We defined a combinatory algebra to be unorderable if it does not allow a
non-trivial compatible partial order. There are other notions of
unorderability that are worth investigating. For instance, one can ask for
the existence of non-symmetric preorders instead of partial orders. Or one
can ask for the (pre)order to be compatible with abstraction as well as
with application: $\leq$ is called a {\defit
lambda-(pre)order\index{lambda-preorder}\index{lambda-order}} if it is
compatible and
\[	\deriv{\forall x\in\Aa.ax\leq bx}{\one a\leq \one b}.
\]
We thus arrive at the following four unorderability notions for a
combinatory algebra $\Aa$:
\begin{enumerate}
\item 
{\defit unorderable\index{unorderable!combinatory algebra}} if every
compatible partial order on $\Aa$ is trivial.
\item
{\defit un-preorderable\index{un-preorderable}} if every compatible preorder on $\Aa$ is symmetric.
\item
{\defit un-$\lam$-orderable\index{un-lambda-orderable@un-$\lam$-orderable}}
if every lambda-order on $\Aa$ is trivial.
\item
{\defit
un-$\lam$-preorderable\index{un-lambda-preorderable@un-$\lam$-preorderable}}
if every lambda-preorder on $\Aa$ is symmetric.
\end{enumerate}

\noindent
Between these notions, only the obvious implications hold:
\[	\vcenter{\xymatrix@!C@C=-.5in{
& 	*!+<10pt>\txt{unorderable}\ar@{=>}[dr]
\\	*!+<10pt>\txt{un-preorderable}\ar@{=>}[ur]\ar@{=>}[dr]
&&	*!+<10pt>\txt{un-$\lam$-orderable} 
\\&	*!+<10pt>\txt{un-$\lam$-preorderable}\ar@{=>}[ur]
	}}
\]
To see that no other implications hold, first observe that the open term
algebra is unorderable, but $\lam$-pre\-order\-able: let $M\leq N$ iff for
all valuations $\rho$, $\sem{M}{\rho}\leq\sem{N}{\rho}$ in the standard
$D_{\infty}$-model. It follows from {\cite{Hyl76,Wad76}} that this preorder
is non-trivial; it is a lambda-preorder because the order on the standard
$D_{\infty}$-model is pointwise.

The counterexample in the other direction is due to G. Plotkin, and it is
given in the following theorem:

\begin{theorem}\label{thm-gordon}{\bf (G. Plotkin)}
There is an extensional, partially ordered lambda algebra $\Aa$ that
does not allow a non-trivial lambda-preorder.
\end{theorem}

\begin{proof}
The idea of the construction is to work in a category where the order
relation on function spaces is not pointwise. We use the category of meet
{\cpos} and stable functions $\CPOstable$, which was defined in
Section~\ref{subsec-stable}. Recall that the objects of this category are
{\cpos} with bounded binary meets which act continuously, and that the
morphisms are stable functions, {\ie} continuous functions preserving the
bounded meets. As we outlined in Section~\ref{subsec-domain-equations}, the
usual Scott $D_{\infty}$-construction of models of the
lambda-$\beta\eta$-calculus goes through in this category.

Let $D_0$ be the {\cpo} with two elements $\bot\leq\top$.  Define
$D_{n+1}$ to be the stable function space $D_n^{D_n}$. Then $D_1$ has
three elements $\Bot,I,\Top$, where $\Bot$ is the constantly $\bot$
function, $\Top$ is the constantly $\top$ function, and $I$ is the
identity. Notice that the stable order on $D_1$ is as shown:
\[ 	\xymatrix@=2ex{
	{\top}\ar@{-}[d]	% \ar[rrr]
&&&	{\Top}\ar@{-}[dr]
&&	{I}\ar@{-}[dl]		% \ar[dlllll]
\\	{\bot}			% \ar[rrrr]
&&&&	{\Bot}
\\	D_0
&&&&	D_1
	}
\]
Define $e_{01}: D_0\ii D_1$ to send $\top$ to $\Top$ and $\bot$ to
$\Bot$, and define $p_{10}: D_1\ii D_0$ to send $f$ to $f(\bot)$.  The
pair $\pair{e_{01},p_{10}}$ is is an embedding-projection pair in the
category $\CPOstable$, in particular, $e_{01}\cp p_{10}$ is stably
less than the identity. From this, one constructs the other embedding
projection pairs and takes the inverse limit $D$ as usual. Then
$D\cong D^D$, and as a lambda algebra, $D$ is extensional by
Proposition~\ref{pro-comparison-algebra-refl-obj}. Clearly the order
$\leq$ on $D$ is non-trivial and compatible.  

For convenience, we identify all relevant function spaces with the
corresponding subspaces of $D$. Let $p_n:D\ii D_n$ be the projection
of $D$ onto $D_n$, and $e_n$ the corresponding embedding.

Now suppose that $\sqleq$ is a lambda-preorder. We will show it is
trivial, {\ie} it is either discrete or indiscrete.  First notice
that, since we are in an extensional model, $\one=\I$ and hence
\begin{equation}\label{eqn-sqleq-order-ext}
	\deriv{\forall x\in D.ax\sqleq bx}{a\sqleq b}.
\end{equation}
Chasing the definition of the $D_{\infty}$-model, one calculates that
for $f\in D_{n+1}=D_n^{D_n}$ and $x\in D$, the application $f\app x$
is given by $e_n\cp f\cp p_n(x)$. From this and
(\ref{eqn-sqleq-order-ext}), it follows that $f\sqleq g\in D_{n+1}$
iff $f\app x\sqleq g\app x$ for all $x\in D_n$. One distinguishes
three cases:

\begin{caselist}
\case 
$I\sqleq\Top$. For any pair of elements $x,y\in D$, define $f:D_1\ii D$
by $f(I)=x$ and $f(\Top)=y$ and $f(\Bot)=\bot$. This is stable and
therefore realized by some $\hatt{f}\in D$. We get that $x\sqleq y$ and
hence $\sqleq$ is indiscrete.
\case  
$\Top\sqleq I$. Similar.  
\case
Neither $I\sqleq\Top$ nor $\Top\sqleq I$. Suppose, by way of
contradiction, that there are distinct elements $x,y\in D$ such that
$x\sqleq y$. Then for some $n$ the projections $x_n=p_n(x)$ and
$y_n=p_n(y)$ are distinct. Since the projection $p_n$ itself is
realized by some $\hatt{p}_n\in D$, one gets $x_n\sqleq y_n$. But
then, since $x_n\not=y_n$, there are $z_{n-1},\ldots,z_0$ in
$D_{n-1},\ldots,D_0$ such that $a=x_n z_{n-1}\ldots z_0$ and $a'=y_n
z_{n-1}\ldots z_0$ are distinct elements of $D_0$. One then knows that
$a\sqleq a'$, and hence it must be the case that either
$\bot\sqleq\top$ or $\top\sqleq\bot$. 
In the first case, one has 
\begin{eqnarray*}
	\top=&I\app\top\sqleq\Top\app\top&=\top
\\	\bot=&I\app\bot\sqleq\Top\app\bot&=\top,
\end{eqnarray*}
hence, since $\sqleq$ is a lambda-preorder, $I\sqleq\Top$. Similarly,
in the second case, one has $\Top\sqleq I$, the required
contradiction.\eot
\end{caselist}
\end{proof}

%----------------------------------------------------------------------
\subsection{Absolute notions}

There is a multitude of notions of absolute unorderability that one
can consider. Fortunately, we will see that all of them
coincide. Recall that we defined a combinatory algebra $\Aa$ to be
absolutely unorderable if for every embedding $\Aa\embeds\Bb$, the
algebra $\Bb$ is unorderable.  First, one can adapt this with respect
to preorders, lambda-orders etc. Second, one can replace the word
``embedding'' by ``homomorphism''. Third, one can restrict attention
to certain subcategories, {\eg} lambda algebras or lambda models.

Instead of cataloging some 30 different notions and showing them all to be
equivalent, we start with some simple observations. If $P$ is some property
of objects in a category, we say that an object $\Aa$ {\defit absolutely
satisfies} $P$ if for all $\Aa\ii\Bb$, $\Bb$
satisfies $P$.

First notice that, since lambda algebras are defined by closed
equations, their full subcategory is right-closed in the category of
combinatory algebras: {\ie}, if $\Aa\ii\Bb$ is a homomorphism of
combinatory algebras, and $\Aa$ is a lambda algebra, then so is
$\Bb$. Hence, a lambda algebra $\Aa$ satisfies some property
absolutely {\em as a lambda algebra} iff it does so {\em as a
combinatory algebra}. The corresponding property is true for Curry
algebras.

Next, there are some obvious implications: if $\Aa$ absolutely
satisfies $P$ with respect to homomorphisms, then also with respect to
embeddings. We also have the implications that were discussed in
Section~\ref{subsec-local-notions}. 

It therefore suffices to show, for each of the categories of
combinatory algebras, lambda algebras, and Curry algebras, that the
weakest notion that we are considering implies the strongest one. This
is done in the following proposition.

\begin{proposition}
For a combinatory algebra $\Aa$, the following are equivalent:
\begin{enumerate}
\item There is $\Aa\ii\Bb$ for some non-symmetrically preordered
combinatory algebra $\Bb$.
\item There is $\Aa\embeds\Bb$ for some non-trivially partially ordered
combinatory algebra $\Bb$.
\suspendenumerate
\end{enumerate}
For a lambda algebra $\Aa$, the following are equivalent:
\begin{enumerate}
\resumeenumerate
\item There is $\Aa\ii\Bb$ for some non-symmetrically preordered
lambda algebra $\Bb$.
\item There is $\Aa\embeds\Bb$ for some non-trivially lambda-ordered
lambda model $\Bb$.
\suspendenumerate
\end{enumerate}
For a Curry algebra $\Aa$, the following are equivalent:
\begin{enumerate}
\resumeenumerate
\item There is $\Aa\ii\Bb$ for some non-symmetrically preordered
Curry algebra $\Bb$.
\item There is $\Aa\embeds\Bb$ for some non-trivially lambda-ordered
extensional algebra $\Bb$.
\suspendenumerate
\end{enumerate}
\end{proposition}

\begin{proof}
\begin{caselist}
\caseimpl{1.}{2.} Suppose $\Aa\ii\Bb$ and $\Bb$ is non-symmetrically
preordered. Let $\Bb'=\Bb/{(\leq\cap\geq)}$, then $\Bb'$ is
non-trivially partially ordered and $\Aa\ii\Bb'$. Now let
$\Bb''=\Bb'\times\Aa$, which is non-trivially ordered by the
componentwise order where $\Aa$ is discrete. We have $\Aa\embeds\Bb''$.
\caseimpl{3.}{4.} Suppose $\Aa\ii\Bb$ and $\Bb$ is non-symmetrically
preordered. First, construct $\Aa\embeds\Bb''$ as in 2.; then consider
$\Aa\embeds\Bb''\embeds\Bb''[X]$ for a countable set $X$. We know that
$\Bb''[X]$ is a lambda model by Proposition~\ref{pro-embed-alg-in-mod}. It
has a non-trivial lambda order by Lemma~\ref{lem-BX-nontrivial-lam-order}
below.
\caseimpl{5.}{6.} Same as 3.$\imp$4.
\eot
\end{caselist}
\end{proof}

\begin{lemma}\label{lem-BX-nontrivial-lam-order}
Suppose $\leq$ is a non-trivial partial order on a lambda algebra
$\Bb$. Then $\leq$ extends naturally to a lambda-order on $\Bb[X]$,
for countable $X$.
\end{lemma}

\begin{proof}
First, consider the case of adjoining a single indeterminate
$\Aa\seq\Aa[x]$. Let $\leq$ be a partial order on $\Aa$, and define on
$\Aa[x]$ the partial order $a\leq b$ iff $\lam^* x.a\leq \lam^*
x.b$. Notice that if $a$ and $b$ were in $\Aa$, then $\lam^* x.a=\K a$ and
$\lam^* x.b=\K b$, hence $a\leq b$ in $\Aa[x]$ iff $\K a\leq\K b$ in $\Aa$
iff $a\leq b$ in $\Aa$, {\ie} the order on $\Aa[x]$ is an extension of the
order on $\Aa$.  Now consider $\Bb[X]$, which can be regarded as a union of
an ascending chain of subsets $\Bb\seq\Bb[x_1]\seq\Bb[x_1,x_2]\seq\cdots$.
Starting with a partial order on $\Bb$, one can extend it step by step to
all of $\Bb[X]$. In the limit, we obtain a lambda-order, because if $ax\leq
bx$ for all $x$, then $a,b\in\Aa=\Bb[x_1,\ldots,x_{n-1}]$ for some $n$ and
one can take $x=x_n$. But $ax_n=bx_n$ in $\Aa[x_n]$ iff
$\lam^*x_n.ax_n=\lam^*x_n.bx_n$ in $\Aa$, {\ie} $\one a=\one b$.
\eot
\end{proof}

\noindent
Finally, notice that none of the local notions of unorderability that
we have considered implies absolute unorderability: Plotkin's finitely
separable algebra {\cite{Plo96}}, although it cannot be non-trivially
preordered, can still be embedded in an orderable algebra (for example
by Theorem~\ref{thm-malcev}).

%======================================================================
\cleardoublepage
\chapter{Finite Lambda Models}\label{cha-finite}

It has long been known that a model of the untyped lambda calculus, in
the traditional sense, can never be finite or even recursive
{\cite{Bar84}}.  For instance, no consistent lambda theory equates any two
of the countably many Church numerals $\churchnum{0}=\lam xy.y$,
$\churchnum{1}=\lam xy.xy$, $\churchnum{2}=\lam xy.x(xy)$, etc.; hence,
these terms must have distinct denotations in any non-trivial model.
Consequently, model constructions of the lambda calculus typically involve
passing to an infinite limit, yielding unwieldy models in which term
denotations or equality of terms are not effectively computable.

By contrast, we introduce a notion of finite models for the lambda
calculus. These finite models are models of reduction, rather than of
conversion.  Therefore, as we shall see, they are not subject to the
usual limitations on size and complexity.  Informally, by a {\em model of
conversion\/}, we mean a model with a soundness property of the form
\[
	M\conv N\imp\sem{M}{}=\sem{N}{},
\]
where $\conv$ is {\eg} $\beta$- or $\beta\eta$-convertibility, and $\semp$
is the function that carries a lambda term to its interpretation in the
model.  On the other hand, a {\em model of reduction} has an underlying
partial order and a soundness property of the form
\[
	M\reduces N\imp\sem{M}{}\leq\sem{N}{},
\]
where $\reduces$ is {\eg} $\beta$- or $\beta\eta$-reduction.  Models of
reduction have been considered by different authors
{\cite{Gir86,JMZ92,Plo94}}. We will focus here on a formulation which was
given by Plotkin~\cite{Plo94} in the spirit of the familiar {\em
syntactical lambda models} {\cite{Bar84}}. The key observation here is that
models of reduction, unlike models of conversion, may be finite, and
that they can be easily constructed. In special cases, models of
reduction allow a limited form of reasoning about convertibility of terms.
This is the case for instance if the underlying partial order is a tree.

We begin by reviewing syntactical and categorical models of reduction in
Section~\ref{sec-mod-red}. In Section~\ref{sec-trees}, we introduce a
reasoning principle for models whose underlying order is a tree. We also
give a method for efficiently constructing such models.  In
Section~\ref{sec-partial-models}, this is further specialized to the case
where the underlying order is flat.  Examples are given in
Section~\ref{sec-partial-examples}.  Some reflections on completeness
properties follow in Section~\ref{sec-completeness}. In
Section~\ref{sec-relating-d-infty}, we investigate the connection between
models of reduction and the $D_{\infty}$-construction.

%===========================================================================
\section{Models of reduction}\label{sec-mod-red}

%----------------------------------------------------------------------
\subsection{Syntactical models of reduction}

\begin{definition}{\bf (Plotkin {\cite{Plo94}})}
An {\defit ordered applicative structure\index{ordered applicative
structure}\index{applicative structure!ordered}} $\tuple{P,\app}$ is a
poset $P$, together with a monotone binary operation
$\app\from\mbox{$P\times P$}\ii P$. Let $P^{\Vars}$ be the set of all
{\defit valuations\index{valuation!in ordered applicative structure}},
{\ie} functions from variables to $P$. A {\defit syntactical model of
$\beta$-reduction\index{syntactical model!of reduction}\index{model!of
lambda reduction!syntactical}\index{reduction!syntactical model of}}
$\tuple{P,\app,\semp}$ is an ordered applicative structure together with an
{\defit interpretation function}
\[ 	\sem{\,\,\cdot\,\,}{\cdot}\from \Terms\times P^{\Vars}\ii P 
\]
with the following properties:
\begin{enumerate}
\item\label{a1}
   $\sem{x}{\rho}=\rho(x)$
\item\label{a2}
   $\sem{MN}{\rho}=\sem{M}{\rho} \app \sem{N}{\rho}$
\item\label{a3}
   $\sem{\lambda x.M}{\rho} \app a \leq \sem{M}{\rho(x:=a)}$, for all
$a\in P$
\item\label{a4}
   $\rho|_{\FV(M)}=\rho'|_{\FV(M)}\imp\sem{M}{\rho}=\sem{M}{\rho'}$
\item\label{a5}
   $(\forall a.\sem{M}{\rho(x:=a)}\leq\sem{N}{\rho(x:=a)})\imp
\sem{\lambda x.M}{\rho} \leq \sem{\lambda x.N}{\rho}$
\suspendenumerate
\end{enumerate}
Moreover, we say $\tuple{P,\app,\semp}$ is a {\defit syntactical model
of $\beta\eta$-reduction}, if it also satisfies the property
\begin{enumerate}\resumeenumerate
\item\label{a6}
   $\sem{\lambda x.Mx}{\rho}\leq\sem{M}{\rho}$, if $x\not\in\FV(M)$.
\end{enumerate}
A {\defit syntactical model of conversion\index{syntactical model!of
conversion}\index{model!of lambda
conversion!syntactical}\index{conversion!syntactical model of}\index{lambda
conversion!syntactical model of}} is a syntactical model of
$\beta$-reduction $\tuple{X,\app,\semp}$, where $X$ is discretely ordered,
{\ie}, a set. Notice that this notion coincides with the familiar
syntactical lambda models as defined {\eg} in {\cite{Bar84}}.
\end{definition}

\begin{remark}
Properties {\ref{a1}.}--{\ref{a3}.}\ do not form an inductive definition;
rather they state properties of a function $\semp$ which is given
{\apriori}. In particular, {\ref{a3}.}\ does not uniquely determine the
interpretation of a lambda abstraction $\sem{\lambda x.M}{\rho}$.
\end{remark}

\noindent
We have seen in Chapter~\ref{cha-unorderable} that many models of
conversion are equipped with a partial order.  This, however, is
entirely different from the partial order we consider on a model of
reduction. Models of conversion have an {\em approximation order},
where $a\leq b$ is often understood to mean that $a$ is ``less defined'' or
``diverges more often'' than $b$. On the other hand, models of reduction
have a {\em reduction order}, where $a\leq b$ means $a$ reduces to $b$.
More precisely, one has the following soundness theorem:

\begin{proposition}[Plotkin {\cite{Plo94}}]\label{prop-sound-mod-red}
The following are properties of syntactical models of $\beta$-reduction:\rm
\begin{enumerate}
\item {\bf Monotonicity.} 
	If $\rho(x)\leq \rho'(x)$ for all $x$, then
	$\sem{M}{\rho}\leq\sem{M}{\rho'}$.
\item {\bf Substitution.}
	$\sem{\subst{M}{N}{x}}{\rho}=\sem{M}{\rho(x:=\sem{N}{\rho})}$.
\item {\bf Soundness for reduction.}
	If $M\redb N$, then $\sem{M}{\rho}\leq\sem{N}{\rho}$.  In a
	syntactical model of $\beta\eta$-reduction: If $M\redbe N$, then
	$\sem{M}{\rho}\leq\sem{N}{\rho}$.
\eot
\end{enumerate}
\end{proposition}

\noindent
Syntactical models of $\beta$-reduction are easily constructed. One may,
for example, start with any pointed poset $P$ and monotone function
$\app\from P\times P\ii P$, and define, somewhat uningeniously, $\sem{\lam
x.M}{\rho}=\bot$.  Among the possible interpretation functions on a given
ordered applicative structure, this choice is the minimal one. Much more
interesting is the situation in which there exists a maximal such choice.
We will explore such a situation in
Section~\ref{subsec-construction-par-mod}.

%----------------------------------------------------------------------
\subsection{Categorical models of reduction}
\label{subsec-cat-mod-red}

Let $\DOM$ be a cartesian-closed category of posets and monotone functions,
with the pointwise order on hom-sets.

\begin{definition}
A {\defit categorical model of $\beta$-reduction}\index{model!of lambda
reduction!categorical}\index{categorical model!of
reduction}\index{reduction!categorical model of} $\tuple{P,{\e},{\p}}$ is
given by an object $P\in\DOM$, together with a pair of morphisms ${\e}\from
P\ii P^P$ and ${\p}\from P^P\ii P$, such that
\[	\xymatrix{P^P\ar[d]_{\p}\ar[dr]^{\id}_{\leq}\\P\ar[r]_{\e}&P^P.}
\]
If moreover ${\p}\cp {\e}\leq\id_{P}$, then $\tuple{P,{\e},{\p}}$ is a
{\defit categorical model of $\beta\eta$-reduction}.
\end{definition}

\noindent
Categorical models of reduction have been studied by various authors, {\eg}
by Girard {\cite{Gir86}} for the case of qualitative domains, or by Jacobs
{\etal} {\cite{JMZ92}}, where they are called models of expansion. For a
detailed discussion of these and other references, see Plotkin
{\cite{Plo94}}.

From a categorical model of reduction $\tuple{P,{\e},{\p}}$, one can
construct a syntactical model of reduction $\tuple{P,\app,\semp}$ by
letting $a\app b={\e}(a)(b)$ and by defining $\semp$ inductively:
\[\begin{array}{r@{~}c@{~}l}
	\sem{x}{\rho}	&=&	\rho(x),
\\	\sem{MN}{\rho}	&=&	{\e}(\sem{M}{\rho})(\sem{N}{\rho}),
\\	\sem{\lam x.M}{\rho}&=&	{\p}(\lam a.\sem{M}{\rho(x:=a)}).
\end{array}\] 

\begin{proposition}\label{pro-synt-from-cat}
If $\tuple{P,{\e},{\p}}$ is a categorical model of $\beta$-reduction, then the
above construction yields a well-defined syntactical model of
$\beta$-reduction $\tuple{P,\app,\semp}$.  Moreover, $\tuple{P,{\e},{\p}}$
is a categorical model of $\beta\eta$-reduction, then
$\tuple{P,\app,\semp}$ is a syntactical model of
$\beta\eta$-reduction.
\end{proposition}

\begin{proof}
To see that the inductive definition is well-defined, and in
particular\microfilm{ to see} that the function $\lam
a.\sem{M}{\rho(x:=a)}$ indeed defines an element in $P^P$, it is best to
work directly in the category $\DOM$ and to define an interpretation
$\sem{M}{x_1,\ldots,x_n}$ of each lambda term $M$ with
$\FV(M)\seq\{x_1,\ldots,x_n\}$ as a morphism $P^n\ii P$, just as we did for
categorical models of conversion:
\[\begin{array}{rcl}
	\sem{x_i}{x_1,\ldots,x_n}&=&P^n\catarrow{\proj_i}
	P\sep\mbox{(the $i$th projection)}
\\	\sem{MN}{x_1,\ldots,x_n}&=&P^n\catarrow{\pair{\sem{M}
	{x_1,\ldots,x_n},\sem{N}{x_1,\ldots,x_n}}}
		P\times P\catarrow{\uncurry{p}}P
\\	\sem{\lam x_{n+1}.M}{x_1,\ldots,x_n}&=&P^n
	\catarrow{\curry{(\sem{M}{x_1,\ldots,x_{n+1}})}}
		P^P\catarrow{e}P.
\end{array}\]
It is easily seen that the two definitions coincide in the sense that
\[	\sem{M}{\rho}=1\catarrow{\tuple{\rho(x_1),\ldots,\rho(x_n)}}
	P^n\catarrow{\sem{M}{x_1,\ldots,x_n}}P. 
\]
The verification that this is a syntactical model of $\beta$-,
respectively, $\beta\eta$-reduction is now routine.\eot
\end{proof}

%----------------------------------------------------------------------
\subsection{Models of \texorpdfstring{$\beta\eta$}{^^ce^^b2^^ce^^b7}-reduction: Order-extensionality}

We have seen in Chapter~\ref{cha-combinatory} that an extensional model of
$\beta$-conversion is always a model of $\beta\eta$-conversion. The
property that corresponds to extensionality for models of reduction is
order-extensionality: An ordered applicative structure $\pair{P,\app}$ is
called {\defit
order-extensional\index{order-extensionality}\index{applicative
structure!order-extensional}\index{ordered applicative
structure!order-extensional}\index{extensionality!order}} if
\[	\deriv{\forall x\in P.~ax\leq bx}{a\leq b}.
\]

\begin{lemma}\label{lem-order-extensional}
If a syntactical model of $\beta$-reduction $\tuple{P,\app,\semp}$ is
order-extensional, then it is a model of $\beta\eta$-reduction.
\end{lemma}

\begin{proof}
Suppose $x\in\FV(M)$. Then for all $a\in P$, $\sem{\lam x.Mx}{\rho}\app
a\leq\sem{Mx}{\rho(x:=a)} =
\sem{M}{\rho(x:=a)}\app\sem{x}{\rho(x:=a)} =\sem{M}{\rho}\app a$,
hence $\sem{\lam x.Mx}{\rho}\leq\sem{M}{\rho}$.\eot
\end{proof}


%======================================================================
\section{Tree models}\label{sec-trees}

%----------------------------------------------------------------------
\subsection{Recapturing convertibility}\label{subsec-recapturing}

The soundness property for models of reduction does not in general yield
useful information about convertibility, since interconvertible terms
$M\conv N$ may have different denotations. However, if the reduction under
consideration is Church-Rosser, then $M\conv N$ implies that there is a
term $Q$ with $M\reduces Q$ and $N\reduces Q$.  Therefore, the denotations
$\sem{M}{\rho}$ and $\sem{N}{\rho}$ must be compatible. Recall that $a$ and
$b$ are {\defit compatible\index{compatible elements}}, in symbols
$a\compatible b$, if there exists $c$ with $a\leq c$ and $b\leq c$.  In a
model of reduction, one has the following restricted form of soundness for
convertibility:
\begin{equation}\label{eqn-sound-conv}
	M\conv N\imp\sem{M}{\rho}\compatible\sem{N}{\rho}.
\end{equation}
The latter property is especially useful if the underlying poset $P$ has
many pairs of incompatible elements.  Therefore, we will pay special
attention to the cases where $P$ is a tree or a flat partial order.

\begin{definition}
A pointed poset $P$ is called a {\defit tree\index{tree}} if for all
$a,b\in P$, $a\compatible b$ implies $a\leq b$ or $a\geq b$. Equivalently,
for each $x\in P$, the downdeal $\downdeal x$ is linearly ordered. A tree
$P$ is said to be {\defit bounded\index{bounded tree}\index{tree!bounded}}
if there is a number $n\in\Nat$ such that each $\downdeal x$ has at most
$n$ elements. The smallest such $n$ is called the {\defit
height\index{height of a bounded tree}} of $P$.
\end{definition}

\noindent
A model of reduction is called a {\defit tree model\index{tree
model}\index{model!tree model}} if the underlying poset is a tree.

%======================================================================
\subsection{A method for constructing models}
\label{subsec-construction-par-mod}

In general, there may be many different ways of defining an interpretation
function $\semp$ that makes a given ordered applicative structure
$\tuple{P,\app}$ into a syntactical model of reduction. Even if one
restricts attention to those cases where $\semp$ is defined inductively
from a categorical model $\tuple{P,{\e},{\p}}$, with ${\e}(a)(b)=a\app b$, there is
a choice involved in determining the morphism ${\p}:P^P\ii P$. In general, the
greater ${\p}$ is chosen with respect to the pointwise order, the greater the
resulting interpretation $\semp$ will be, and the better one will be able
to make use of the soundness property for convertibility
{\ref{eqn-sound-conv}}.

The best possible situation arises if we can find a right adjoint ${\p}$ of
${\e}$, because if ${\p}$ is such a right adjoint, then it is maximal with
the property ${\e}\cp {\p}\leq\id$. It is well-known that if $P$ is a
complete lattice, then ${\e}:P\ii Q$ has a right adjoint if and only if
${\e}$ preserves suprema. In this case, one can define
${\p}(y)=\bigvee\{x\in P\such {\e}(x)\leq y\}$. But following the remarks
in Section~\ref{subsec-recapturing}, we are interested in posets $P$ that
have incompatible pairs of elements, and which can therefore not be
complete lattices. In the case of bounded trees, the existence of a right
adjoint is characterized by a property which we call strong extensionality:

\begin{definition}
Let $P$ be a bounded tree. We say that an ordered applicative structure
$\pair{P,\app}$ is {\defit strongly extensional\index{strong
extensionality}\index{extensionality!strong}\index{ordered applicative
structure!strongly extensional}} if for all $a,b\in P$,
\[	\deriv{\forall x\in P.~ax\compatible bx}
	{a\compatible b}.
\]
\end{definition}

\begin{proposition}\label{pro-strong-ext-adjoint}
Let $\pair{P,\app}$ be an ordered applicative structure, where $P$ is a
bounded tree. Let ${\e}:P\ii P^P$ be the map defined by
${\e}(a)(b)=a\app b$. Then ${\e}$ has a right adjoint in the category of posets
if and only if $\pair{P,\app}$ is strongly extensional.
\end{proposition}

\begin{proof}
\begin{caselist}
\caseimp
Suppose ${\e}$ has a right adjoint ${\p}:P^P\ii P$. Let $a,b\in P$ such that
$ax\compatible bx$ for all $x$. Since $P$ is a tree, one has $ax\leq bx$ or
$ax\geq bx$ for every $x$. Define a monotone map $f:P\ii P$ by
$f(x)=\max(ax,bx)$. Since ${\e}(a)(x)=ax\leq f(x)$ for all $x$, one has
${\e}(a)\leq f$ and hence $a\leq {\p}(f)$, and similarly for $b$. Hence
$a\compatible b$, and $\pair{P,\app}$ is strongly extensional.
\casepmi
Suppose $\pair{P,\app}$ is strongly extensional. For any $f\in P^P$,
consider the subset $P_f=\{x\in P\such {\e}(x)\leq f\}\seq P$. Notice that for
any $a,b\in P_f$, ${\e}(a)\compatible {\e}(b)$, hence $ax\compatible bx$ for all
$x$, hence $a\compatible b$ by strong extensionality. Since $P$ is a tree,
either $a\leq b$ or $a\geq b$. Therefore $P_f$ is linearly ordered. Since
$P$ is bounded, the set $P_f$ is finite, and hence it has a maximal element
${\p}(f)$.  Clearly, the function ${\p}$ thus defined is monotone, and $x\leq
{\p}(f)$ iff $x\in P_f$ iff ${\e}(x)\leq f$. Therefore ${\e}\adjoint {\p}$.
\eot
\end{caselist}
\end{proof}

\begin{corollary}\label{cor-strong-inductive}
The last proposition yields a practical method for constructing a tree
model of reduction: Begin with a tree $P$ and a monotone binary operation
$\app\from P\times P\ii P$, such that $\pair{P,\app}$ is strongly
extensional. Define $\semp$ inductively as follows:
\begin{enumerate}
\item\label{d1}   $\sem{x}{\rho}=\rho(x)$
\item\label{d2}   $\sem{MN}{\rho}=\sem{M}{\rho} \app \sem{N}{\rho}$
\item\label{d3}   
	$\sem{\lambda x.M}{\rho}$ is the maximal $b\in P$ such that
        $b\app a\leq\sem{M}{\rho(x:=a)}$ for all $a\in P$.
\end{enumerate}
Then $\tuple{P,\app,\semp}$ is a well-defined model of $\beta$-reduction.
\end{corollary}

\begin{proof}
Proposition~\ref{pro-strong-ext-adjoint}, together with
Proposition~\ref{pro-synt-from-cat}, ensures that this is well-defined, in
particular, that a maximal $b$ exists in 3. \eot
\end{proof}

\noindent
The following lemma is sometimes useful for reasoning about such a model:

\begin{lemma}
If\/ $\semp$ is defined as in Corollary~\ref{cor-strong-inductive}, then for
all $n\geq 1$, the denotation of an $n$-fold lambda abstraction
$\sem{\lambda x_1\ldots x_n.M}{\rho}$ is the maximal $b\in P$ such that for
all $a_1\ldots a_n\in X$,
\[	b\app a_1\cdots a_n\leq\sem{M}{\rho(x_1:=a_1)\ldots(x_n:=a_n)}.
\]
\end{lemma}

\begin{proof}
By induction on $n$.\eot
\end{proof}

If $\pair{P,\app}$ is order-extensional, then the construction in
Corollary~\ref{cor-strong-inductive} yields a model of
$\beta\eta$-reduction by Lemma~\ref{lem-order-extensional}. We end this
section with a lemma that relates order-extensionality to strong
extensionality for tree models:

\begin{lemma}
If $P$ is a tree, and if $\pair{P,\app}$ is strongly extensional and
extensional, then it is also order-extensional.
\end{lemma}

\begin{proof}
Suppose for all $x$, $ax\leq bx$, hence $ax\compatible bx$, hence
$a\compatible b$ by strong extensionality. Since $P$ is a tree, either
$a\leq b$ or $a\geq b$. In the first case, we are done; in the second case,
$ax\geq bx$, and hence $ax=bx$, for all $x$, which implies $a=b$ by
extensionality.\eot
\end{proof}


%======================================================================
\section{Partial models}\label{sec-partial-models}

As the examples in Section~\ref{sec-partial-examples} will show, it often
suffices to consider tree models whose underlying poset $P$ is flat, {\ie}
$P=X_{\bot}$ for a discrete set $X$. If one also assumes that the
application operation $\app\from P\times P\ii P$ is strict in each
argument, then one can think of $\bot$ as the {\em undefined} element, and
of $\app$ and $\semp$ as {\em partial} functions. Since it is sometimes
convenient to think in terms of these partial operations, we restate the
definition of a model of reduction in this special case. The venturi-tube
$\funnel$ denotes {\defit directed equality\index{directed equality}}:
$A\funnel B$ means that if $A$ is defined, then so is $B$, and they are
equal.

\begin{definition}
A {\defit partial applicative structure\index{partial applicative
structure}\index{applicative structure!partial}} $\tuple{X,\app}$ is a set
$X$ with a {partial} binary operation $\app\from X\times X\pii X$. Let
$\Val{X}$ be the set of partial valuations $\Vars\pii X$. A {\defit partial
syntactical lambda model\/}\index{partial syntactical lambda model}
$\tuple{X,\app,\semp}$, or {\defit partial
model\/}\index{model!partial}\index{partial model} for short, is given by a
partial applicative structure together with a partial map
\[	\sem{\,\,\cdot\,\,}{\cdot}\from\Lambda_X\times\Val{X}\pii X,
\]
such that 
\begin{enumerate}
\item\label{aa1}
   $\sem{x}{\rho}=\rho(x)$
\item\label{aa2}
   $\sem{MN}{\rho}=\sem{M}{\rho} \app \sem{N}{\rho}$
\item\label{aa3}
   $\sem{\lambda x.M}{\rho} \app a \funnel \sem{M}{\rho(x:=a)}$, for all
$a\in X$
\item\label{aa4}
   $\rho|_{\FV(M)}=\rho'|_{\FV(M)}\imp\sem{M}{\rho}=\sem{M}{\rho'}$
\item\label{aa5}
   $(\forall a.\sem{M}{\rho(x:=a)}\funnel\sem{N}{\rho(x:=a)})\imp
\sem{\lambda x.M}{\rho} \funnel \sem{\lambda x.N}{\rho}$
\suspendenumerate
\end{enumerate}
Moreover, if 
\begin{enumerate}\resumeenumerate
\item\label{aa6}
   $\sem{\lambda x.Mx}{\rho}\funnel\sem{M}{\rho}$, if $x\not\in\FV(M)$.
\end{enumerate}
then $\tuple{X,\app,\semp}$ is a {\defit partial $\beta\eta$-model\/}.
\end{definition}

\noindent
Here, equality is understood to be {\defit Kleene equality\index{Kleene
equality}}, meaning $A=B$ if and only if $A$ and $B$ are either both
undefined or both defined and equal.  Notice that the directed equality
$\funnel$ on $X$ is just the partial order on the flat poset
$X_{\bot}$. Thus, the axioms 1--5 and 6 correspond exactly to the axioms
for a syntactical model of $\beta$-, respectively, $\beta\eta$-reduction.

In a partial model, the denotation of some terms may be undefined. The idea
of using partiality in models for the lambda calculus is not new.  In fact,
Kleene's ``first model'', which consists of G\"odel numbers of partial
recursive functions and their application, is partial. The models we
consider here are even ``more'' partial; we do not even assume that the
interpretations of basic combinators such as $S$ and $K$ are defined.
The following soundness properties ensure that the class of terms whose
denotation is defined is closed under reduction, and that interconvertible
terms have the same denotation if they are both defined. 

\begin{proposition}\label{prop-sound-par-mod}
The following are properties of partial models:\rm
\begin{enumerate}
\item {\bf Soundness for reduction.}
	If $M\redb N$, then $\sem{M}{\rho}\funnel\sem{N}{\rho}$.
\item {\bf Soundness for convertibility.}
	If $M\eqb N$, and if $\sem{M}{\rho}$ and $\sem{N}{\rho}$ are
	both defined, then $\sem{M}{\rho}=\sem{N}{\rho}$.
\item In a partial $\beta\eta$-model, the respective properties hold for
	$\redbe$ and $\eqbe$.
\end{enumerate}
\end{proposition}

\begin{proof}
Soundness for reduction follows from Proposition~\ref{prop-sound-mod-red}.
Soundness for convertibility follows from the Church-Rosser property.\eot
\end{proof}

\noindent
Partial applicative structures are particularly easy to manipulate in
practice, since they are just given by a set $X$ and a ``multiplication
table'' such as the one in Table~\ref{tab-omega-multi}. It is easy to read
properties such as strong extensionality off the table: A partial
applicative structure is strongly extensional if no two rows of the
multiplication table are compatible, and it is order-extensional if no row
is subsumed by another. In particular, if the table is everywhere defined,
{\ie} if $\pair{X,\app}$ is a total applicative structure, then both strong
extensionality and order-extensionality coincide with (ordinary)
extensionality.

%===========================================================================
\section{Examples}\label{sec-partial-examples}

%----------------------------------------------------------------------
\subsection[A class of finite models to distinguish the terms \texorpdfstring{${\Omega_n}$}{^^ce^^a9^^e2^^82^^99}]
{A class of finite models to distinguish the terms {\boldmath ${\Omega_n}$}}

Let $x$ be a variable and define $x^1=x$ and $x^{n+1}=x^nx$ for $n\geq
1$. Let $\omega_n=\lam x.x^n$ and $\Omega_n=\omega_n\omega_n$. None of
these terms has a normal form, {\eg} $\Omega_2=(\lam x.xx)(\lam x.xx)$
reduces only to itself. The terms $\Omega_n$ are unsolvable;
therefore, their interpretations coincide with $\bot$ in the
$D_{\infty}$-model {\cite{Hyl76,Wad76}}. We will now give a class of
finite partial models that distinguishes these terms.

Fix an integer $p\geq 1$ and let
$X=\Int_p=\{1,2,\ldots,p\}$. Addition and subtraction in $X$ are
modulo $p$; let $\eqp $ denote equality modulo $p$. Define $\app\from X\ii X$
by
%..........................................................................
\begin{table*}[tbp]\caption{Multiplication table for a partial model}
\label{tab-omega-multi}
\[	\begin{array}{c|cccccc}
	\app&	1&2&3&\cdots&p-1&p
\\\hline 1&	2&3&4&\cdots&p&1
\\ 	2&	3&3&4&\cdots&p&1
\\ 	3&	4&3&4&\cdots&p&1
\\	\vdots&\vdots&\vdots&\vdots&\ddots&\vdots&\vdots
\\ 	p-1&	p&3&4&\cdots&p&1
\\ 	p&	1&3&4&\cdots&p&1
	\end{array}
\]
\end{table*}
%..........................................................................

\[	n\app m\eqp \left\{
	\begin{array}{ll}
	n+1 &\mbox{if $m\eqp1$} 
\\	m+1 &\mbox{if $m\not\eqp 1$}.
     	\end{array}\right.
\]
A ``multiplication table'' for this operation is shown in
Table~\ref{tab-omega-multi}. Clearly, $\tuple{X,\app}$ is a strongly
extensional applicative structure. Define $\semp$ as in
Corollary~\ref{cor-strong-inductive} to get a partial model. For
$n\geq 2$, we calculate $1^n\eqp n$ and $m^n\eqp m+1$ for $m\neq
1$. Hence, for all $x\in X$ and $n\geq 2$,
\begin{eqnarray*}
	x^n &\eqp& (n-1)\app x
\\ 	\imp\sep
	\sem{\omega_n}{}=\sem{\lam x.x^n}{}&\eqp& n-1
\\ 	\imp\sep
	\sem{\Omega_n}{}=\sem{\omega_n\omega_n}{}&\eqp&(n-1)\app(n-1)\eqp n.
\end{eqnarray*}
Hence, $\sem{\Omega_n}{}$ is always defined for $n\geq 2$, and we have
$\sem{\Omega_n}{}=\sem{\Omega_m}{}$ iff $n\eqp m$. 

%----------------------------------------------------------------------
\subsection{A non-trivial 3-element model}\label{sec-example-auttt}

In this section, we provide the proof of Lemma~\ref{lem-auuut} from
Chapter~\ref{cha-unorderable}.  At the heart of the proof is a
3-element partial model which distinguishes two appropriately chosen
unsolvable terms $Auuut$ and $Auutt$.

\begin{un-lemma} 
There is a closed term $A$ of the untyped lambda calculus with
$Auuut\eqb Auttt$, but $Auuut\neqbe Auutt\neqbe Auttt$ for variables
$u\neq t$.
\end{un-lemma}

\begin{proof}
Define terms 
\begin{eqnarray*}
 h &=& \lambda zyx.zzy(zzy(zzyx))               \\
 f &=& hh                                       \\
 A &=& \lambda uvwt.\lambda x.fu(fv(fw(ftx))).
\end{eqnarray*}
Then for all $x$, $y$:
\begin{eqnarray*}
 fyx & \redb & fy(fy(fyx)),
\end{eqnarray*}
hence for all $u$, $t$:
\begin{eqnarray*}
 \lambda x.fu(ftx) & \redb & \lambda x.fu(fu(fu(ftx))) = Auuut \\
 \lambda x.fu(ftx) & \redb & \lambda x.fu(ft(ft(ftx))) = Auttt.
\end{eqnarray*}

\noindent
To see that $Auuut \neqbe Auutt$ for variables $u$ and $t$, we will
construct a partial model.  Let $X=\{\kx,\ox,\ix\}$, and let $\app$ be
defined by the following ``multiplication table'':
\[\begin{array}{c|ccc}
\app & \kx & \ox & \ix \\
\hline
\kx & \ox & \ox & \ox \\
\ox & \ox & \ox & \ix \\
\ix & \ox & \ix & \ox
\end{array}\]
Then $\tuple{X,\app}$ is a strongly extensional applicative
structure.  Define $\semp$ inductively as in
Corollary~\ref{cor-strong-inductive}.  Although $\tuple{X,\app}$ is total,
$\semp$ will be partial.

%..........................................................................
\begin{table*}[tbp]
\caption{Values for $\psi(c,b,a)$ and $\kx\app c\app b\app a$}
\label{tab-values-for-psi}
\[\begin{array}{c|cc||c|c}	      		% vertical, nice table
 		c & b &  a 	 & \psi(c,b,a) & \kx\app c\app b\app a\\
 \hline \kx\mbox{ or }\ox\mbox{ or }\ix 
		 & \kx & \kx      & \ox                    & \ox    \\
 	 	 & \kx & \ox      & \ox                    & \ox    \\
	 	 & \kx & \ix      & \ix                    & \ix    \\
 \cline{2-5}  	 & \ox & \kx      & \ox                    & \ox    \\
	  	 & \ox & \ox      & \ox                    & \ox    \\
	 	 & \ox & \ix      & \ix                    & \ix    \\
 \cline{2-5}  	 & \ix & \kx      & \ox                    & \ox    \\
	  	 & \ix & \ox      & \ix                    & \ix    \\
	  	 & \ix & \ix      & \ox                    & \ox    \\
 \hline
\end{array}\]
\end{table*}
%..........................................................................

Consider the function $\psi(c,b,a):=\sem{zzy(zzy(zzyx))} {\rho(z:=c)
(y:=b)(x:=a)} =ccb(ccb(ccba))$.  Table~\ref{tab-values-for-psi} shows
the values of this function, and one observes that
$\psi(c,b,a)=\kx\app c\app b\app a$ for all $c,b,a\in X$.  Hence by
Corollary~\ref{cor-strong-inductive}, $\sem{h}{}=\sem{\lambda
zyx.zzy(zzy(zzyx))}{}$ is defined and equal to $\kx$, and consequently
$\sem{f}{}=\sem{hh}{}=\kx\kx=\ox$. If $\rho(u)=\rho(x)=\ox$ and
$\rho(t)=\ix$, then
\begin{eqnarray*}
        \sem{fu(fu(fu(ftx)))}{\rho} &=& \ix \\
        \sem{fu(fu(ft(ftx)))}{\rho} &=& \ox.
\end{eqnarray*}
By soundness, $fu(fu(fu(ftx))) \not\eqbe fu(fu(ft(ftx)))$ $\imp$
$Auuut \not\eqbe Auutt$.
\eot
\end{proof}

%======================================================================
\section{Completeness}
\label{sec-completeness}

Given a syntactical model of $\beta$- or $\beta\eta$-reduction
$\tuple{P,\app,\semp}$, one can define its {\defit lift\index{lift of a
model of reduction}} $\tuple{P_{\bot},\App,\semp'}$ as follows:
\[\begin{array}{ccl}
	a\App b &=& 
	\left\{\begin{array}{ll}
		a\app b	&\mbox{if $a,b\neq\bot$}
	\\	\bot	&\mbox{else,}
	\end{array}\right.
\\\\	\sem{M}{\rho}' &=&
	\left\{\begin{array}{ll}
		\sem{M}{\rho}	
		&\mbox{if $\rho(x)\neq\bot$ for all $x\in\FVof{M}$}
	\\	\bot	&\mbox{else.}
	\end{array}\right.
\end{array}\]
It is easily checked that this is again a model of $\beta$-, respectively,
$\beta\eta$-reduction. As a trivial consequence, one has the following
completeness theorem for partial models:

\begin{proposition}\label{completeness}
{\bf Completeness:} If $M\not\eqb N$, then there is a partial model and
$\rho$ for which $\sem{M}{\rho}$, $\sem{N}{\rho}$ are defined and
$\sem{M}{\rho}\neq\sem{N}{\rho}$. If $M\not\eqbe N$, then the model
can be chosen to be strongly extensional.
\eot
\end{proposition}

\begin{proof}
Take a model of conversion such that $\sem{M}{\rho}\neq\sem{N}{\rho}$
for some $\rho$, {\eg} a term model. Then its lift is a partial model with
$\sem{M}{\rho}'\incompatible\sem{N}{\rho}'$.\eot
\end{proof}

\noindent
Of course much more interesting questions can be asked, {\eg} how close one
can come to a {\em finite completeness theorem} for models of reduction? In
other words: can every inequality $M\not\eqb N$ be demonstrated in a finite
model of reduction?  The answer to this question must be no, since such a
finite completeness theorem would yield a decision procedure for
convertibility of lambda terms, which is known to be an undecidable
problem.  It is an open problem to identify subclasses of terms for which a
finite completeness property holds, or to describe the class of equations
that hold in all finite models of reduction, tree models, partial models
etc.

%======================================================================
\section[Relating models of reduction to \texorpdfstring{$D_{\infty}$}{D^^e2^^88^^9e}-models]
{Relating models of reduction to {\boldmath $D_{\infty}$}-models}
\label{sec-relating-d-infty}\index{d-infinity-model@$D_{\infty}$-model}

Consider a finite categorical model of reduction $\tuple{P,{\e},{\p}}$,
such that ${\e}\cp{\p}\leq\id_{P^P}$ and ${\p}\cp{\e}=\id_P$.  Since $P$ is
finite, it is a {\dcpo} and ${\e}$ and ${\p}$ form a Scott-continuous
embedding-projection pair. Therefore, one can take $P$, ${\e}$ and ${\p}$
as the basis for carrying out the $D_{\infty}$-construction in the category
$\CPO$, as outlined in Section~\ref{subsec-d-infty}.

Let $D_0=P$ and $D_{n+1}=D_n^{D_n}$. Let $e_{0}={\e}:D_0\ii D_1$ and
$p_{0}={\p}:D_1\ii D_0$. From this, construct the other
embedding-projection pairs and take the bilimit $D_{\infty}$ as usual. Let
$\iota_n:D_n\ii D_{\infty}$ and $\pi_n:D_{\infty}\ii D_n$ be the limiting
morphisms. For each $n\geq 0$ one has
\[	\vcenter{\xymatrix{
	D_n\ar[r]^{e_n}\ar[d]_{\iota_n}
&	D_n^{D_n}\ar[d]^{\iota_n^{\pi_n}}
\\	D_{\infty}\ar[r]_{e_{\infty}}
&	D_{\infty}^{D_{\infty}}
	}}
\sep\mbox{and}\sep
	\vcenter{\xymatrix{
	D_n\ar@{<-}[r]^{p_n}\ar@{<-}[d]_{\pi_n}
&	D_n^{D_n}\ar@{<-}[d]^{\pi_n^{\iota_n}}
\\	D_{\infty}\ar@{<-}[r]_{p_{\infty}}
&	D_{\infty}^{D_{\infty}}.
	}}
\]
Note that each $\tuple{D_n,e_n,p_n}$ and
$\tuple{D_{\infty},e_{\infty},p_{\infty}}$ is a categorical model of
reduction. Let $\semp^n$ and $\semp^{\infty}$ be the respective
interpretation functions. How are they related? For a valuation of
variables $\rho:\Vars\ii D_{\infty}$, denote by $\rho_n$ the valuation
$\pi_n\cp\rho:\Vars\ii D_n$. One may expect that $\sem{M}{\rho_n}^n
=\pi_n\sem{M}{\rho}^{\infty}$.  However, this is in general {\em not} the
case. The following proposition relates $\semp^n$ and $\semp^{\infty}$:

\begin{proposition}
For all lambda terms $M$,
\[	\sem{M}{\rho}^{\infty}=\dirsup_{n\geq 0}\iota_n\sem{M}{\rho_n}^n.
\]
\end{proposition}

\begin{proof}
First recall from Proposition~\ref{pro-ch-bilimits} that
$\id_{D_{\infty}}=\dirsup_n\iota_n\cp\pi_n$. Also note that $\pi_n\cp
p_{\infty}\cp\iota_n^{\pi_n}=p_n\cp\pi_n^{\iota_n}\cp\iota_n^{\pi_n}=p_n$.
The proposition is proved by induction on $M$. There are three cases:
\begin{caselist}
\case %------------------------------
$\begin{array}[t]{r@{~}c@{~}l}
\sem{x}{\rho}^{\infty}
&=&\rho(x)
=\dirsup_n\iota_n\cp\pi_n\cp\rho(x)
=\dirsup_n\iota_n\cp\rho_n(x)
=\dirsup_n\iota_n\sem{x}{\rho_n}^n.
\end{array}$
\case %------------------------------
$\begin{array}[t]{r@{~}c@{~}l}
\sem{MN}{\rho}^{\infty}
&=&e_{\infty}(\sem{M}{\rho}^{\infty})(\sem{N}{\rho}^{\infty})
\stackrel{\ih}{=}e_{\infty}(\dirsup_n\iota_n\sem{M}{\rho_n}^n)
	(\dirsup_n\iota_n\sem{N}{\rho_n}^n)
\nl&=&\dirsup_n e_{\infty}(\iota_n\sem{M}{\rho_n}^n)(\iota_n\sem{N}{\rho_n}^n)
=\dirsup_n \iota_n^{\pi_n}(e_n\sem{M}{\rho_n}^n)(\iota_n\sem{N}{\rho_n}^n)
\nl&=&\dirsup_n (\iota_n\cp(e_n\sem{M}{\rho_n}^n)\cp\pi_n)
	(\iota_n\sem{N}{\rho_n}^n)
=\dirsup_n \iota_n(e_n(\sem{M}{\rho_n}^n)(\sem{N}{\rho_n}^n))
\nl&=&\dirsup_n \iota_n\sem{MN}{\rho_n}^n.
\end{array}$
\case %------------------------------
$\begin{array}[t]{r@{~}c@{~}l}
\sem{\lam x.M}{\rho}^{\infty}
&=&p_{\infty}(\lam a\in D_{\infty}.\sem{M}{\rho(x:=a)}^{\infty})
\stackrel{\ih}{=}p_{\infty}
	(\lam a.\dirsup_n\iota_n\sem{M}{\rho_n(x:=\pi_na)}^n)
\nl&=&\dirsup_n p_{\infty}(\lam a.\iota_n\sem{M}{\rho_n(x:=\pi_na)}^n)
=\dirsup_n p_{\infty}\cp\iota_n^{\pi_n}(\lam b\in D_n.\sem{M}{\rho_n(x:=b)}^n)
\nl&=&\dirsup_n \iota_n\cp\pi_n\cp p_{\infty}\cp\iota_n^{\pi_n}
	(\lam b\in D_n.\sem{M}{\rho_n(x:=b)}^n)
\nl&=&\dirsup_n \iota_n\cp p_n(\lam b\in D_n.\sem{M}{\rho_n(x:=b)}^n)
=\dirsup_n \iota_n\sem{\lam x.M}{\rho_n}^n.
\end{array}$

~\eottwo
\end{caselist}
\end{proof}

\noindent
In particular, it follows that
$\iota_n\sem{M}{\rho_n}^n\leq\sem{M}{\rho}^{\infty}$ for every $M$, and by
applying $\pi_n$ to both sides, it also follows that
$\sem{M}{\rho_n}^n\leq\pi_n\sem{M}{\rho}^{\infty}$. To see that equality
does not in general hold, notice that $D_{\infty}$, by construction, is a
model of conversion. Hence for all $M\eqb N$, one has
$\pi_n\sem{M}{\rho}^{\infty}=\pi_n\sem{N}{\rho}^{\infty}$. On the other
hand, $D_n$ is finite and hence a proper model of reduction. Therefore, it
is possible to find $M,N$ with $M\eqb N$ and
$\sem{M}{\rho_n}^n\neq\sem{N}{\rho_n}^n$.

\begin{corollary}
If $M$ and $N$ are lambda terms such that, for some $n$,
$\sem{M}{\rho_n}^n\incompatible\sem{N}{\rho_n}^n$, then
$\sem{M}{\rho}^{\infty}\incompatible\sem{N}{\rho}^{\infty}$. The converse
holds if $D_{\infty}$ is bounded complete (this is the case, for instance,
if $P$ is a tree).
\end{corollary}

\begin{proof}
Suppose $\sem{M}{\rho}^{\infty}\compatible\sem{N}{\rho}^{\infty}$. Let $c\in
D_{\infty}$ such that $\sem{M}{\rho}^{\infty},\sem{N}{\rho}^{\infty}\leq
c$. Then $\sem{M}{\rho_n}^n\leq\pi_n\sem{M}{\rho}^{\infty}\leq\pi_nc$, and
similarly for $\sem{N}{\rho_n}^n$. For the converse, assume $D_{\infty}$ is
bounded complete. Assume that for all $n\geq 0$,
$\sem{M}{\rho_n}^n\compatible\sem{N}{\rho_n}^n$. Then
$\iota_n\sem{M}{\rho_n}^n\compatible\iota_n\sem{N}{\rho_n}^n$ for all
$n$. Let $c_n=\iota_n\sem{M}{\rho_n}^n\vee\iota_n\sem{N}{\rho_n}^n$ in
$D_{\infty}$. Then $\family{c_n}{n\geq 0}$ is an increasing sequence and
$\sem{M}{\rho}^{\infty}=\dirsup_{n}\iota_n\sem{M}{\rho_n}^n\leq\dirsup_n
c_n$, and similarly $\sem{N}{\rho}^{\infty}\leq\dirsup_n c_n$, hence
$\sem{M}{\rho}^{\infty}\compatible \sem{N}{\rho}^{\infty}$.\eot 
\end{proof}

%======================================================================
\cleardoublepage
\chapter{Henkin Representations, Polymorphism, and Empty Types}
\label{cha-poly}

The polymorphic lambda calculus was independently discovered by Girard
{\cite{Gir71}} and Reynolds {\cite{Rey74}}. It has been extensively studied
as a prototypical programming language because of its great expressive
power and economy of syntax. The basic idea is to augment the simply-typed
lambda calculus with type variables $\alpha,\beta,\ldots$ and with explicit
universal quantification over types. This allows the formulation of
algorithms that uniformly handle data of more than one type. Type
instantiation and type abstraction is made explicit on terms: If $t$ is a
term of type $\all\alpha.\tau$, then $t\sigma$ is a term of type
$\subst{\tau}{\sigma}{\alpha}$, for all types $\sigma$. Conversely, if $s$
is a term of type $\tau$, then $\Lamabs{\alpha}{s}$ is a term of type
$\all\alpha.\tau$.  Now consider for instance the type
\[	\polybool=\all\alpha.\alpha\ii\alpha\ii\alpha.
\]
A term $t$ of this type yields a term $t\sigma$ of type
$\sigma\ii\sigma\ii\sigma$, for every type $\sigma$. Moreover, following
Strachey's concept of {\em parametric polymorphism} {\cite{Str67}}, one
expects the behavior of $t\sigma$ to vary uniformly with the choice of
$\sigma$. In the polymorphic lambda calculus, there are only two such
uniform functions of type $\polybool$, {\ie} there are exactly two closed
terms of type $\polybool$, corresponding to the first and second
projections:
\[	p_1=\Lamabs{\alpha}{\lamabs{x}{\alpha}{\lamabs{y}{\alpha}{x}}}
\ssep\mbox{and}\ssep
	p_2=\Lamabs{\alpha}{\lamabs{x}{\alpha}{\lamabs{y}{\alpha}{y}}}.
\]

\noindent
Several notions of models for the polymorphic lambda calculus have been
proposed in the 1980's. These models follow one of two basic designs:
\begin{enumerate}
\item
Environment-style models, which have been considered by Bruce and Meyer
{\cite{BM84}}, extend the familiar Henkin models of the simply-typed lambda
calculus.  These models are {\em non-strict}, in the sense that a function
type $\sigma\ii\tau$ is interpreted as a subset of the set of functions
from $\sigma$ to $\tau$, and similarly a universal type $\all\alpha.\tau$
is interpreted as a subset of an infinite product
$\prod_{\sigma}\subst{\tau}{\sigma}{\alpha}$.
\item
Categorical models, introduced by Seely {\cite{See87}}, are based on
general principles for the interpretation of quantifiers in categorical
hyperdoctrines.  Seely's {\PL}-categories are a canonical extension of the
ccc interpretation of the simply-typed lambda calculus.  These
interpretations are {\em strict}, in the sense that both function types and
universal types are interpreted directly by their categorical counterparts.
\end{enumerate}

\noindent
These two classes of models do not readily mesh, because it is known that
strict interpretations collide with the classical foundations: Reynolds
showed that there are no set-theoretic strict models of the polymorphic
lambda calculus {\cite{Rey84}}.

The aim of this chapter is to reconcile the categorical and the
set-theoretical approaches by giving a categorical treatment of non-strict
models. This generalizes both Seely's models and the models of Bruce and
Meyer. The central concept is that of a {\em Henkin representation}: a
functor $H$ between ccc's is a Henkin representation if it preserves finite
products and if for all objects $A,B$, the canonical morphism
$H(B^A)\iimonic H(B)^{H(A)}$ is monic.

In Section~\ref{sec-henkin-1}, we prove three Henkin representation theorems
characterizing those ccc's which can be Henkin-represented, respectively,
in the category of non-empty sets $\neSet$,
the category of sets $\Set$, and a category
$\Set^P$ of presheaves over
some poset $P$. After reviewing the simply-typed lambda calculus in
Section~\ref{sec-henkin-2}, we show in Section~\ref{sec-henkin-3} that the
three Henkin representation theorems correspond naturally to completeness
theorems for three different classes of non-strict models: Friedman's
set-theoretic models with non-empty types {\cite{Fri75}}, set-theoretic
models with possibly empty types, as investigated by Meyer {\etal}
{\cite{MMMS87}}, and Mitchell and Moggi's Kripke lambda models
{\cite{MM91}}, respectively.  Sections~\ref{sec-henkin-4} through
{\ref{sec-henkin-6}} are devoted to Henkin representations of
{\PL}-categories and their relationship to completeness theorems for the
polymorphic lambda calculus.

%======================================================================
\section{Henkin representations of cartesian-closed categories}
\label{sec-henkin-1}

%----------------------------------------------------------------------
\subsection{Henkin representations}

\begin{definition}
Let $\Cc$ and $\Dd$ be cartesian-closed categories. A functor $H:\Cc\ii\Dd$
is called a {\defit Henkin representation}\index{Henkin
representation}\index{ccc!representation!Henkin
representation}\index{functor!Henkin representation} if it preserves
terminator and binary products, and if for all objects $A,B\in\Cc$, the
canonical arrow $\curry{(H\appl_{A,B})}: H(B^A)\iimonic HB^{HA}$ is monic.
\end{definition}

\noindent
Recall that a ccc-representation $F:\Cc\ii\Dd$ is a functor that preserves
all ccc structure, and in particular $F(B^A)=FB^{FA}$ and
$\curry{(F\appl_{A,B})}= F(\curry{\appl_{A,B}})=\id$. Thus, every
ccc-representation is a Henkin representation, but not {\em vice versa}.
Henkin representations arise naturally as the forgetful functors of various
concrete ccc's into $\Set$. Even though Henkin representations do not in
general preserve exponentials, they are `compatible' with ccc structure in
an essential way: their kernels are ccc-congruences. This is why they
correspond to useful notions of `model' for typed lambda calculi.

\begin{n-definition}\label{def-ccc-cong}
A {\defit ccc-congruence\index{ccc!congruence}\index{congruence!on ccc}}
$\sim$ on a ccc $\Cc$ is given by an equivalence relation $\sim_{A,B}$ on
each hom-set $(A,B)$, such that the following hold:
\[	1.\ \deriv{f\sim_{A,B} f'\sep g\sim_{B,C} g'}
		{g\cp f\sim_{A,C} g'\cp f'} 
\sep	2.\ \deriv{f\sim_{A,B} f'\sep g\sim_{A,C}g'}
		{\pair{f,g}\sim_{A,B\times C}\pair{f',g'}}
\sep	3.\ \deriv{f\sim_{A\times B,C} f'}
		{\curry{f}\sim_{A,C^B}\curry{f'}}
\]
\end{n-definition}

\noindent
The {\defit kernel}\index{kernel!of a functor}\index{kernel!of a Henkin
representation}\index{functor!kernel} of a functor $F:\Cc\ii\Dd$ is defined
by $f\sim_{A,B} f'$ iff $Ff=Ff'$, for all $f,f':A\ii B$.  Clearly, the
kernel of a ccc-representation is a ccc-congruence.  The same is true for
Henkin representations:

\begin{lemma}\label{lem-kernel-henkin-ccc}
The kernel of a Henkin representation $H:\Cc\ii\Dd$ is a ccc-congruence.
\end{lemma}

\begin{proof}
1.\ and 2.\ are obvious, since $H$ preserves binary products. For 3.,
suppose $f\sim_{A\times B,C}f'$, {\ie} $Hf=Hf'$.  One has
\[	{\microfilm{\def\ssep{\hspace{0em}}}
	\vcenter{\xymatrix@u{
 	{A\times B}
	\ar[r]^<>(.5){\curry{f}\times\id_B}
	\ar[dr]_{f} 
& 	{C^B\times B}
	\ar[d]^<>(.5){\appl} 
\\&	{C}
	}}
\ssep\imp\ssep
	\vcenter{\xymatrix@R-3ex@u{
 	{HA\times HB}
	\ar[r]^<>(.5){H(\curry{f})\times\id_{HB}}
	\ar[dr]_{Hf} 
&	{H(C^B)\times HB}
	\ar[d]^<>(.5){H\appl} 
\\& 	{HC}
	}}
\ssep\imp\ssep
	\vcenter{\xymatrix@u{
 	{HA}
	\ar[r]^<>(.5){H(\curry{f})}
	\ar[dr]_{\curry{(Hf)}} 
& 	{H(C^B)}
	\armonic[d]^<>(.5){\curry{(H\appl)}}  	
\\&	{HC^{HB},}
	}}}
\]
and similarly for $f'$. Since $\curry{(Hf)}=\curry{(Hf')}$, and since
$\curry{(H\appl)}$ is monic, one gets $H(\curry{f})=H(\curry{f'})$.
\eot
\end{proof}

\begin{n-remark}\label{rem-henkin-composition}
Henkin representations do not form a category, since they do not in
general compose.  If $H_1$ and $H_2$ are Henkin representations, then
the composition $H_2\cp H_1$ will be a Henkin representation if $H_2$
preserves monics or if $H_1$ is a ccc-representation.
\end{n-remark}

\noindent
Henkin representations can also be described in terms of partial
exponential diagrams. We say that a diagram $D\times B\catarrow{f}C$ is a
{\defit partial exponential diagram\index{partial exponential
diagram}\index{diagram!partial exponential}} if for every morphism
$g:A\times B\ii C$, there is {\em at most} one $h:A\ii D$ such that
\[	\xymatrix{{D\times B}\ar[r]^<>(.5)f&C.\\
	A\times B\ar[u]^{h\times\id_B}\ar[ur]_g
	}
\]
We have dropped the condition for the existence of $h$ from the definition
of exponential diagrams in Section~\ref{subsec-definition-ccc}.  In
general, the word ``partial'' stipulates that one requires uniqueness, but
not existence, while the word ``weak'' or the prefix ``pre-'' indicates the
opposite. 

A Henkin representation of a ccc $\Cc$ can now be characterized as a finite
product preserving functor $H:\Cc\ii\Dd$ such that for all $A,B\in\Cc$, the
arrow $H(B^A)\times HA\catarrow{H\appl_{A,B}}HB$ is a partial exponential
diagram. The advantage of this definition is that it makes sense for a
category $\Dd$ with finite products, even if it is not cartesian-closed.
Our definition of Henkin representations for {\PL}-categories in
Section~\ref{subsec-henkin-pl} will make use of a similar notion of partial
$\all$-diagrams. 

%----------------------------------------------------------------------
\subsection{Henkin representations and well-pointed ccc's}

\begin{definition}
An object $A$ is {\defit well-pointed\index{well-pointed object}} if for
every $f\neq g:A\ii B$, there is a point $p:1\ii A$ such that $f\cp p\neq
g\cp p$. A category $\Dd$ is well-pointed if all its objects are
well-pointed.
\end{definition}

\noindent
Note that for a ccc $\Dd$, the following are equivalent:
\begin{enumerate}
\item $\Dd$ is well-pointed.
\item The point functor $\Point=(1,-)$ is an embedding.
\item  $\Point$ is a Henkin representation.
\end{enumerate}

\begin{proposition}
Every ccc representation $F:\Cc\ii\Dd$ from a ccc $\Cc$ into a
well-pointed ccc $\Dd$ gives rise to a Henkin representation
$H=\Point\cp F:\Cc\ii\Set$. Conversely, every Henkin representation
$H:\Cc\ii\Set$ arises in this way.  
\end{proposition}

\begin{proof}
If $\Dd$ is well-pointed, then $\Point\cp F:\Cc\ii\Set$ is a Henkin
representation by Remark~\ref{rem-henkin-composition}. For the
converse, suppose $H:\Cc\ii\Set$ is a Henkin representation. Define
$\Dd$ by $\Obj{\Dd}=\Obj{\Cc}$ and $\Dd(A,B)=H(B^A)$.  Composition and
identities are given by the respective $H$-images of the canonical
morphisms $\cp:C^B\times B^A\ii C^A$ and $\curry{\id}:1\ii A^A$ in
$\Cc$. Associativity and the identity laws follow from the
commutativity of the following diagrams in $\Cc$, and of their images
under $H$:
\[	\xymatrix{
 	D^C\times C^B\times B^A
	\ar[r]^<>(.5){\id\times\cp}	\ar[d]_{\cp\times\id} 
& 	D^C\times C^A	\ar[d]^{\cp} 
\\ 	D^B\times B^A	\ar[r]_<>(.5){\cp} 
& 	D^A
	}
\sep	\xymatrix{
 	B^A	\ar[r]^<>(.5){\pair{\id,\curry{\id}}}
	\ar[d]_{\pair{\curry{\id},\id}}	\ar[dr]^{\id} 
& 	B^A\times A^A	\ar[d]^{\cp} 
\\ 	B^B\times B^A	\ar[r]_<>(.5){\cp} 
& 	B^A
	}
\]
Define $F:\Cc\ii\Dd$ as the identity on objects, and by sending
$f:A\ii B$ to $H(\curry{f}):1\ii H(B^A)=\Dd(A,B)$. It is routine to
check that $\Dd$ is a well-pointed ccc, that $F$ is a ccc
representation, and $\Point\cp F=H$. \eot
\end{proof}

%----------------------------------------------------------------------
\subsection{Freely adjoining arrows to a ccc}\label{subsec-ccxa}

If $A$ is an object of a ccc $\Cc$, let $\CcxA$ be the ccc obtained from
$\Cc$ by freely adjoining an indeterminate arrow $x:1\ii A$.  The category
$\CcxA$, together with the canonical ccc-representation
$\jota:\Cc\ii\CcxA$, is uniquely determined by the following universal
property: for every ccc-representation $F:\Cc\ii\Dd$ and every arrow
$f:1\ii FA$ in $\Dd$, there is a unique ccc-representation
$\extension{F}:\CcxA\ii\Dd$ such that 
\[	\xymatrix{
	{\Cc}
	\ar[r]^<>(.5){\jota}
	\ar[dr]_{F}
&	{\CcxA}
	\ar[d]^{\extension{F}}
\\&	\Dd}
\]
and $\extension{F}x=f$. The category $\Cc'=\CcxA$ has a concrete
description as the Kleisli category of the comonad $T(B)=A\times B$ (see
Lambek and Scott {\cite{LaS86}}). This means, the objects of $\Cc'$ are
those of $\Cc$, and the hom-sets are given by
$\homof{\Cc'}{B,C}=\homof{\Cc}{A\times B,V}$. The identity at $B$ in $\Cc'$
is $\projb:A\times B\ii B$ in $\Cc$, and the composition $g\cp f$ in $\Cc'$
is $A\times B\catarrow{\pair{\proja,f}}A\times C\catarrow{g}D$ in $\Cc$.
$x:1\ii A$ in $\Cc'$ is $\id:A\ii A$ in $\Cc$. The canonical functor
$\jota:\Cc\ii\Cc'$ sends $f:B\ii C$ to $f\cp\projb:A\times B\ii C$.

It is an interesting question to ask which properties are preserved or
reflected by the canonical functor $\jota:\Cc\ii\CcxA$. We will pay
particular attention to the question under what conditions $\jota$ is an
embedding, and under what conditions it is faithful ({\ie}, isomorphism
reflecting). 

\begin{definition}
In any category, a morphism $f:A\ii B$ is called a {\defit
cover\index{cover}\index{morphism!cover}} if, whenever $f$ factors through
a monic $m$,
\[	\xymatrix{
	A\ar[dr]\arcover[r]^<>(.5){f}
&	B
\\&	U,\armonic[u]_{m}
	}
\]
then $m$ is necessarily iso.  We sometimes write $f:A\iicover B$ for a
cover. Notice that any morphism $f:A\ii B$ with a right inverse $f\cp
g=\id_B$ is a cover, called a {\defit split cover\index{split
cover}\index{cover!split}}. Also notice that any $f$ is iso iff it is a
monic cover.  An object $A$ is called {\defit
well-supported\index{well-supported object}} if for each object $B$, the
second projection $\projb:A\times B\iicover B$ is a cover.

An object $A$ is {\defit partially initial\index{partial initial object}}
if every hom-set $\hom{A,B}$ has at most one element.
\end{definition}

\begin{lemma}\label{lem-adjoint-preserves-stuff}
Suppose $F:\Cc\ii\Dd$ has a right adjoint.
Then $F$ preserves epics and partial initial objects. Moreover, if
$\Cc$ has pullbacks, then $F$ preserves covers.
\end{lemma}

\begin{proof}
Let $\phi:F\adjoint G$ be the adjunction. Suppose $e:B\iiepic C$ is epic
and
\[	\xymatrix{
	{FB}\ar[r]^<>(.5){Fe}
&	{FC}\ar@<1ex>[r]^<>(.5)g\ar@<-1ex>[r]_<>(.5)h\ar@{}[r]|<>(.5){\nocommute}
& 	{D}
	}
\sep\imp\sep
	\xymatrix{
	{B}\ar[r]^<>(.5){e}
&	{C}\ar@<1ex>[r]^<>(.5){\phi g}\ar@<-1ex>[r]_<>(.5){\phi h}\ar@{}[r]|<>(.5){\nocommute}
& 	{GD,}
	}
\]
which implies $\phi g=\phi h$, hence $g=h$. Hence $Fe$ is epic. Dually,
right adjoints preserve monics. Now suppose $A$ is partially
initial. Then $\abs{\hom{FA,B}}\iso\abs{\hom{A,GB}}\leq 1$, hence $FA$ is
partially initial. Now assume $\Cc$ has pullbacks, and suppose $f:A\iicover
B$ is a cover. Assume $Ff=FA\stackrel{g}{\ii}U\stackrel{m}{\iimonic}FB$. Since
$G$ is a right adjoint, $Gm:GU\iimonic GFB$ is monic, and we can consider
\[	\vcenter{\xymatrix{
	A\ar[dr]\arcover@<.5ex>[drr]^{f}\ar[ddr]_{\phi g}
\\&	{\cdot}\armonic[r]^<>(.3){m'}\ar[d]_<>(.3){u'}\pullback{d}{r}
&	B\ar[d]^{u}
\\&	{GU}\armonic[r]_<>(.5){Gm}
&	{GFB}
	}}
\sep\imp\sep
	\vcenter{\xymatrix{
	{\blank}
\\&	B\ar[dl]\ar[d]^{u}
\\	GU\armonic[r]_<>(.5){Gm}
&	GFB	
	}}
\sep\imp\sep
	\vcenter{\xymatrix{
	{\blank}
\\&	FB\ar[dl]\ar[d]^{\id}
\\	U\armonic[r]_<>(.5){m}
&	FB,	
	}}
\]	
where $u$ is the unit of the adjunction. Notice that pullbacks always
preserve monics, hence $m'$ is monic, and it must be iso since $f$ is a
cover. The last diagram implies that $m$ is iso, and it follows that $Ff$
is a cover.\eot
\end{proof}

\begin{lemma}\label{lem-prop-cc-ccxa}
Let $\Cc'=\CcxA$ and $\jota:\Cc\ii\Cc'$ the canonical functor. The
following hold:
\begin{enumerate}
\item
$\jota$ preserves epics, monic cones, partial initial objects, and
well-pointed objects.
\item
$\jota$ is an embedding if and only if the unique morphism $A\iiepic 1$ is
epic in $\Cc$.
\item
$\jota$ is faithful if and only if it is an embedding and $A$ is
well-supported.
\end{enumerate}
\end{lemma}

\begin{proof}
\begin{caselist}
\case[1.:]
Recall that in a ccc, the product functor $T(B)=A\times B$ has a right
adjoint; hence it preserves epics and partial initial objects by
Lemma~\ref{lem-adjoint-preserves-stuff}. Now suppose $f:B\iiepic C$ is epic
in $\Cc$ and $g\cp\jota f=h\cp\jota f$ in $\Cc'$. By the characterization
of $\CcxA$, this means
\[	\xymatrix{
	{A\times B}
	\arepic[r]^<>(.5){\id_A\times f}
&	{A\times C}
	\ar@<1ex>[r]^<>(.5)g
	\ar@<-1ex>[r]_<>(.5)h\ar@{}[r]|<>(.5){\nocommute}
& 	{D,}
	}
\]
holds in $\Cc$, and hence $g=h$. Thus, $\jota f$ is epic. Now, suppose $B$
is a partial initial object in $\Cc$. Then $A\times B$ is also partially
initial, hence $\abs{\homof{\Cc'}{B,C}}=\abs{\homof{\Cc}{A\times B,C}}\leq
1$, hence $B$ is partially initial in $\Cc'$. Moreover, $T$, and hence
$\jota$, preserves monic cones. Now, suppose $B$ is well-pointed in $\Cc$,
and suppose $f\neq g:B\ii C$ in $\Cc'$. Then $f\neq g:A\times B\ii C$,
hence $\curry{f}\neq\curry{g}:B\ii C^A$ in $\Cc$, and since $B$ is
well-pointed, there is $p:1\ii B$ with $\curry{f}\cp p\neq\curry{g}\cp p$.
This implies $f\cp(\id_A\times p)\neq g\cp(\id_A\times p)$, hence
$f\cp\jota p\neq g\cp\jota p$ in $\Cc'$.
\case[2.:]
\begin{caselist}
\caseimp
Certainly $A\iiepic 1$ is epic in $\CcxA$ (it splits). But embeddings
reflect epics. 
\casepmi
Suppose $A\iiepic 1$ is epic in $\Cc$. Then $\projb:A\times B\iiepic B$ is
epic for all $B$. Consider $f,g:B\ii C$ in $\Cc$ with $\jota f=\jota g$.
Then $f\cp\projb=g\cp\projb:A\times B\ii C$, hence $f=g$.
\end{caselist}
\case[3.:]
First notice that any monic-preserving embedding $F$ reflects isos iff it
reflects covers: Suppose $F$ reflects isos and $Ff$ is a cover. Suppose $f$
factors through a monic $m$, then $Ff$ factors through $Fm$, hence $Fm$ is
iso, hence $m$ is iso, hence $f$ is a cover. Conversely, suppose $F$
reflects covers. If $Ff$ is iso, then $Ff$, hence $f$, is a monic cover,
hence an iso. Since $\jota:\Cc\ii\CcxA$ preserves monics, it suffices to
show that $\jota$ reflects covers iff $A$ is well-supported. 
\begin{caselist}
\caseimp
Suppose $\jota$ reflects covers. Clearly, $A\times B\iicover B$ is a split
cover in $\CcxA$, hence a cover in $\Cc$, making $A$ well-supported in
$\Cc$.
\casepmi
Suppose $A$ is well-supported in $\Cc$, and suppose $f:C\ii B$ is such that
$Ff$ is a cover in $\CcxA$. Suppose $f$ factors through a monic $m:D\iimonic
C$. Then $Ff$ factors through $Fm$, hence $Fm$ is iso in $\CcxA$. This
means, there is $m^{-1}\in\homof{\Cc'}{C,D}=\homof{\Cc}{A\times C,D}$ such
that in $\Cc$,
\[	\xymatrix{
	{A\times C}
	\ar[dr]_{m^{-1}}
	\arcover[r]^<>(.5){\projb}
&	C
\\&	D.\armonic[u]_{m}
	}
\]
But $\projb$ is a cover, therefore $m$ an iso in $\Cc$. This shows $f$ is a
cover.\eot
\end{caselist}
\end{caselist}
\end{proof}

\begin{lemma}\label{lem-point-ccxa}
If $f\neq g:A\ii B$ in $\Cc$, then $\jota f\cp x\neq\jota g\cp x$ in
$\CcxA$.
\end{lemma}

\begin{proof}
$\jota f\cp x=f\cp\projb\cp\pair{\id_A,\id_A}=f$ in $\Cc$, and similarly
for $\jota g\cp x$. \eot
\end{proof}

\begin{proposition}\label{pro-wellp-embedding}
Let $\Cc$ be a small ccc. If $\calA\seq\Obj{\Cc}$ is a set of objects such
that $A\iiepic 1$ for all $A\in\calA$, then there is a ccc-embedding
$F_{\calA}:\Cc\ii\Dd$ such that $FA$ is well-pointed for all $A\in\calA$.
$F_{\calA}$ preserves monic cones. Moreover, if each $A\in\calA$ is
well-supported, then $F_{\calA}$ can be chosen to be faithful, {\ie}
isomorphism-reflecting.
\end{proposition}

\begin{proof}
We adjoin countably many arrows $1\ii A$ to each $A\in\calA$. More
precisely, let $I$ be the directed poset of finite subsets
$X\seq\Nat\times\calA$, ordered by inclusion. Let $\diagram:I\ii\Ccc$ be
the diagram that associates to each
$X=\{\pair{i_1,A_1},\ldots,\pair{i_n,A_n}\}\in I$ a ccc
$\Ccadj{X}:=\Ccadj{\adjpoint{x_{i_1,A_1}}{A_1},\ldots
,\microfilm{\linebreak}\adjpoint{x_{i_n,A_n}}{A_n}}$, and to each inclusion
$\iota:X\iiemb Y\in I$ the canonical ccc-representation
$\diagram_{\iota}:\Ccadj{X}\ii\Ccadj{Y}$. Notice that by
Lemma~\ref{lem-prop-cc-ccxa}, $\diagram_{\iota}$ is a monic-preserving
embedding, and moreover, if each $A\in\calA$ is well-supported, then
$\diagram_{\iota}$ is faithful.  We can take $\Dd$ to be the colimit of the
diagram $\diagram$.  Concretely, assume that each $\Ccadj{X}$ has the same
objects as $\Cc$, and that the embeddings $\diagram_{\iota}$ are actual
inclusions on hom-sets.  Then $\Dd$ can be described as follows: the
objects of $\Dd$ are those of $\Cc$, and the hom-set $\homof{\Dd}{B,C}$ is
the directed union of the hom-sets $\homof{\Ccadj{X}}{B,C}$, where $X\in
I$. One checks that $\Dd$ is a ccc and that the inclusion $F:\Cc\iiemb\Dd$
is a ccc-embedding preserving collective monics, and moreover, $F$ is
faithful if the $\diagram_{\iota}$ are. To show that $A$ is well-pointed in
$\Dd$, let $A\in\calA$ and assume $f\neq g:A\ii B$ in $\Dd$. Then there is
$X\in I$ with $f,g\in\Ccadj{X}$. Let $\pair{i,A}\not\in X$ and consider
$\Ccadj{X,\adjpoint{x_{i,A}}{A}}$: one has $f\cp x_{i,A}\neq g\cp x_{i,A}$
by Lemma~\ref{lem-point-ccxa}. Hence $A$ is well-pointed in $\Dd$.
\eot
\end{proof}

%----------------------------------------------------------------------
\subsection{Henkin representation theorems}\label{subsec-henkin-r-thms}

A Henkin representation theorem characterizes those ccc's which can be
Henkin embedded in a given category, or in a category from a given class.
We consider Henkin representations into the category of non-empty sets
$\neSet$, into the category of sets $\Set$, and into a category $\Set^P$ of
presheaves over a poset $P$. We will see in
Section~\ref{sec-henkin-and-completeness} how each of these target
categories corresponds to a certain class of models of the simply-typed
lambda calculus. The first one corresponds to Friedman's set-theoretic
models with non-empty types {\cite{Fri75}}; the second one corresponds to
set-theoretic models with possibly empty types, as investigated by Meyer
{\etal} {\cite{MMMS87}\nocite{Hue90}}, and the third one corresponds
to Mitchell and Moggi's Kripke models {\cite{MM91}}. Our Henkin
representation theorems will translate into completeness theorems for each
of these classes of models.

Representation Theorems for cartesian-closed categories have been
considered in the papers of {\v{C}ubri\'c} {\cite{Cub95}} and Simpson
{\cite{Sim95}}. The difference to our representation theorems is that
{\v{C}ubri\'c} and Simpson work with strict ccc representations rather than
Henkin representations, and they only consider representations of a {\em
free} cartesian-closed category.

%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
\subsubsection{Henkin representations in $\neSet$}
\index{category!of non-empty sets@of non-empty sets $\neSet$}
\index{Henkin representation!in setplus@in
$\neSet$}\index{embedding!Henkin|(}

\begin{theorem}\label{thm-henkin-repr-neset}
A small ccc $\Cc$ can be Henkin-embedded in $\neSet$ if and only if for
 every object $A$, the morphism $A\iiepic 1$ is epic.
\end{theorem}

\begin{proof}
\begin{caselist}
\caseimp 
In $\neSet$, one has $A\iiepic 1$ for all $A$; moreover, embeddings reflect
epics. 
\casepmi 
Consider the ccc-embedding $F_{\calA}:\Cc\ii\Dd$ from
Proposition~\ref{pro-wellp-embedding}, with $\calA=\Obj{\Cc}$. Then
$\Cc\catarrow{F_{\calA}}\Dd\catarrow{\Point}\neSet$ is a
Henkin-embedding.\eot
\end{caselist}
\end{proof}

\begin{corollary}\label{cor-henkin-repr-neset-faith}
If for every object $A$ in a small ccc $\Cc$, the morphism $A\iiepic1$ is
epic and $A$ is well-supported, then there is a faithful ({\ie},
isomorphism-reflecting) Henkin-embedding $H:\Cc\ii\neSet$.\eot
\end{corollary}


%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
\subsubsection{Henkin representations in $\Set$}
\index{category!of sets@of sets $\Set$}\index{Henkin representation!in set@in
$\Set$}

\begin{definition}
A cartesian-closed category $\Cc$ is called {\defit special\index{special
ccc}\index{ccc!special}} if for every object $A$, either the morphism
$A\iiepic 1$ is epic, or $A$ is partially initial.
\end{definition}

\begin{theorem}\label{thm-henkin-repr-set}
A small ccc $\Cc$ can be Henkin-embedded in $\Set$ if and only if it is
special.
\end{theorem}

\begin{proof}
\begin{caselist}
\caseimp 
The category $\Set$ is special, because each non-empty set $A$ satisfies
$A\iiepic 1$, while the empty set is (partially) initial.  Moreover,
embeddings reflect epics and partial initial objects, and hence
specialness.
\casepmi 
Suppose $\Cc$ is special. Consider the ccc-embedding $F_{\calA}:\Cc\ii\Dd$
from Proposition~\ref{pro-wellp-embedding}, with
$\calA=\{A\in\Obj{\Cc}\such A\iiepic 1\}$. Then each $A\in\calA$ is
well-pointed in $\Dd$ by construction of $\Dd$; moreover, each
$A\not\in\calA$ is partially initial and therefore trivially well-pointed.
Hence $\Cc\catarrow{F_{\calA}}\Dd\catarrow{\Point}\Set$ is a
Henkin-embedding.\eot
\end{caselist}
\end{proof}

\begin{corollary}
Let $M$ be a monoid, {\ie} a one-object category. A small ccc $\Cc$ can be
Henkin-embedded in $\Set^M$ if and only if $\Cc$ is special. 
\end{corollary}

\begin{proof}
\begin{caselist}
\caseimp $\Set^M$ is special, and embeddings reflect specialness.
\casepmi There is an obvious ccc-embedding $H:\Set\ii\Set^M$ which
preserves monics. If $\Cc$ is special, it can be Henkin-embedded in $\Set$
and hence, by Remark~\ref{rem-henkin-composition} in $\Set^M$.\eot
\end{caselist}
\end{proof}

\begin{corollary}\label{cor-henkin-emb-discrete}
Let $I$ be a set. A small ccc $\Cc$ can be Henkin-embedded in $\Set^I$ if
and only if there is a family $\family{\sim_i}{i\in I}$ of ccc-congruences
on $\Cc$ such that each quotient $\Cc/{\sim_i}$ is special, and such that
$\bigcap_{i\in I}\sim_i$ is the identity relation.\eot
\end{corollary}

\begin{remark}\label{rem-preserve-stuff}
If a ccc $\Cc$ has an object $A$ such that $A$ is partially initial {\em and}
$A\iiepic 1$, then $\Cc$ is a preorder, {\ie} every hom-set has at most one
element. Indeed, if $f,g:B\ii C$, then
\[	\xymatrix{
	{A}
	\arepic[r]
&	{1}
	\ar@<1ex>[r]^<>(.5){\curry{f}}
	\ar@<-1ex>[r]_<>(.5){\curry{g}}
	\ar@{}[r]|<>(.5){\nocommute}
& 	{C^B,}
	}
\]
hence $f=g$. As a consequence, if $\Cc$ has a non-trivial hom-set, then any
Henkin embedding $\Cc\ii\Set$ not only reflects, but also preserves partial
initial objects and epics $A\iiepic1$.
\end{remark}

%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
\subsubsection{Henkin representations in $\Set^P$}
\index{category!of presheaves over a poset@of presheaves over a poset
$\Set^P$}\index{Henkin representation!in setP@in $\Set^P$}

Any small ccc $\Cc$ can be ccc-embedded in a category of
presheaves\index{presheaf} $\Set^{\Aa}$, for instance by the Yoneda
embedding (see Example~\ref{exa-yoneda}). If one takes $\Aa$ to be a poset,
it is still possible to obtain a Henkin embedding:

\begin{theorem}\label{thm-henkin-repr-presheaf}
Any small ccc $\Cc$ can be Henkin-embedded in $\Set^{P}$ for some poset
$P$. Moreover, the embedding preserves monic cones.
\end{theorem}

\noindent
Let $\Aa$ and $\Bb$ be small categories, and let $F:\Aa\ii\Bb$ be a
functor. This induces a functor $\Set^F:\Set^{\Bb}\ii\Set^{\Aa}$, which we
denote by $F_*$. Note that $F_*$ always preserves monic cones and limits, since
these are taken pointwise in $\Set^{\Aa}$ and $\Set^{\Bb}$. The following
two lemmas give sufficient conditions for $F_*$ to be a Henkin
representation, respectively, an embedding.

\begin{definition}
A functor $F:\Aa\ii\Bb$ is called {\defit left-full\index{left-full
functor}\index{functor!left-full}} if for all $g:FA\ii B$ in $\Bb$, there
exists $f:A\ii A'$ in $\Aa$ such that $B=FA'$ and $g=Ff$.
\end{definition}

\begin{lemma}\label{lem-presheaf-henkin}
If $F:\Aa\ii\Bb$ is left-full, then $F_*:\Set^{\Bb}\ii\Set^{\Aa}$ is a
Henkin representation.
\end{lemma}

\begin{proof}
We need to show that the canonical natural transformation $\phi:F_*(Q^P)\ii
F_*Q^{F_*P}$ is monic for all $P,Q\in\Set^{\Bb}$. Let $A\in\Aa$.
Unraveling the definition of exponentiation in a functor category yields
that $\phi_A:\homof{\Set^{\Bb}}{\homof{\Bb}{FA,-}\times
P,Q}\ii\homof{\Set^{\Aa}}{\homof{\Aa}{A,-}\times F_*P,F_*Q}$ is given by
$(\phi_A\eta)_{A'}(f,x)=\eta_{FA'}(Ff,x)$, where
$\eta:\homof{\Bb}{FA,-}\times P\ii Q$, $A'\in A$, $f:A\ii A'$ and $x\in
(F_*P)A'=P(FA')$. To show that $\phi_A$ is one-to-one, assume
$\eta\neq\eta'\homof{\Aa}{FA,-}\times P\ii Q$. Then there are $B\in\Bb$,
$g:FA\ii B$ and $x\in PB$ such that $\eta_{B}(g,x)\neq\eta'_{B}(g,x)$.
Since $F$ is left-full, there is $f:A\ii A'$ in $\Aa$ such that $B=FA'$ and
$g=Ff$, hence
\[	(\phi_A\eta)_{A'}(f,x)=\eta_{FA'}(Ff,x)
	=\eta_B(g,x)\neq\eta'_{B}(g,x)
	=\eta'_{FA'}(Ff,x)=(\phi_A\eta')_{A'}(f,x),
\]
and therefore $\phi_A\eta\neq\phi_A\eta'$. This shows that $\phi_A$ is
one-to-one for every $A$, hence $\phi$ is monic.\eot
\end{proof}

\begin{lemma}\label{lem-presheaf-embed}
If $F:\Aa\ii\Bb$ is onto objects, then $F_*:\Set^{\Bb}\ii\Set^{\Aa}$ is an
embedding.
\end{lemma}

\begin{proof}
Let $P,Q\in\Set^{\Bb}$ and $\eta\neq\eta':P\ii Q$. Then
$\eta_B\neq\eta'_B:PB\ii QB$ for some $B\in\Bb$. Let $A\in\Aa$ with $B=FA$.
Then $(F_*\eta)_A=\eta_{FA}\neq\eta'_{FA}=(F_*\eta')_A$, hence $F_*\eta\neq
F_*\eta'$. \eot
\end{proof}

\noindent
The proof of Theorem~\ref{thm-henkin-repr-presheaf} now rests on the fact
that every small category $\Aa$ is, in the terminology of Freyd and Scedrov
{\cite{FrS89}}, {\defit dominated\index{category!dominated by a
poset}\index{dominated category}} by some poset $P$, {\ie} there is a
left-full functor $F:P\ii\Aa$ which is onto objects.

\begin{lemma}[Freyd, Scedrov \cite{FrS89}]\label{lem-domination}
Every small category $\Aa$ is dominated by some poset $P$.
\end{lemma}

\begin{proof}
Let the objects of $P$ be finite sequences of objects and morphisms
$A_0\catarrow{f_0}A_1\catarrow{f_1}\ldots\catarrow{f_{n-1}}A_n$, ordered by
the prefix ordering. Then $P$ is a poset, and the obvious functor
$F:P\ii\Aa$ is left-full and onto objects.\eot 
\end{proof}

\begin{proofof}{Theorem~\ref{thm-henkin-repr-presheaf}}
Let $\Cc$ be a small ccc. Then $\Cc^{\op}$ is dominated by some poset $P$
by Lemma~\ref{lem-domination}; let $F:P\ii\Cc^{\op}$. By
Lemmas~\ref{lem-presheaf-henkin} and {\ref{lem-presheaf-embed}}, the
functor $F_*:\Set^{\Cc^{\op}}\ii\Set^P$ is a Henkin embedding; moreover it
preserves monic cones. By precomposing $F_*$ with the Yoneda embedding, one
obtains a Henkin embedding $F_*\cp Y:\Cc\ii\Set^P$.\eot
\end{proofof}

%......................................................................
\begin{table*}[tbp]
\caption{Typing rules for the simply-typed lambda calculus}
\label{tab-simple-lambda-terms}
\[
\begin{array}{rc}
	\tjvar
&	\deriv{}{\Gamma,\typ{x}{\sigma}\tj x:\sigma}
\nl 	\tjconst
&	\deriv{}{\Gamma\tj c^{\sigma}:\sigma}
\nl	\tjunit
&	\deriv{}{\Gamma\tj\unit:1}
\nl	\tjpair
&	\deriv{\Gamma\tj M:\sigma\sep\Gamma\tj N:\tau}
		{\Gamma\tj\pair{M,N}:\sigma\times\tau}
\nl	\tjproja
&	\deriv{\Gamma\tj M:\sigma\times\tau}{\Gamma\tj\lpra M:\sigma}
\nl    	\tjprojb
&	\deriv{\Gamma\tj M:\sigma\times\tau}{\Gamma\tj\lprb M:\tau}
\end{array}
\begin{array}{rc}
	\tjapp
&	\deriv{\Gamma\tj M:\sigma\ii\tau\sep\Gamma\tj N:\sigma}
		{\Gamma\tj MN:\tau}
\nl	\tjlam
&	\deriv{\Gamma,\typ{x}{\sigma}\tj M:\tau}
		{\Gamma\tj\lamabs{x}{\sigma}{M}:\sigma\ii\tau}
\nl	\tjaddvar
&	\deriv{\Gamma\tj M:\sigma\sep\Gamma\seq\Gamma'}{\Gamma'\tj M:\sigma}
\end{array}
\]
\end{table*}
%......................................................................
\begin{table*}[tbp]
\caption{Equational rules for the simply-typed lambda calculus}
\label{tab-simple-equations}
\microfilm{\small}
\[
\begin{array}{rc}
	\plrefl
&	\deriv{}{\Gamma\eqj M=M:\sigma}
\nl	\plsymm
&	\deriv{\Gamma\eqj M=N:\sigma}{\Gamma\eqj N=M:\sigma}
\nl	\pltrans
&	\deriv{\Gamma\eqj M=N:\sigma
	\sep	\Gamma\eqj N=P:\sigma}
		{\Gamma\eqj M=P:\sigma}
\nl	\plconga
&	\deriv{\Gamma\eqj M=M':\sigma
	\sep	\Gamma\eqj N=N':\tau}
		{\Gamma\eqj\pair{M,N}=\pair{M',N'}:\sigma\times\tau}
\nl	\plcongb
&	\deriv{\Gamma\eqj M=M':\sigma\times\tau}
		{\Gamma\eqj\lpra M=\lpra M':\sigma}
\nl	\plcongc
&	\deriv{\Gamma\eqj M=M':\sigma\times\tau}
		{\Gamma\eqj\lprb M=\lprb M':\tau}
\nl	\plcongd
&	\deriv{\Gamma\eqj M=M':\sigma\ii\tau
	\ssep	\Gamma\eqj N=N':\sigma}
		{\Gamma\eqj MN=M'N':\tau}
\nl	\plconge
&	\deriv{\Gamma,\typ{x}{\sigma}\eqj M=M':\tau}
	  {\Gamma\eqj\lamabs{x}{\sigma}{M}=\lamabs{x}{\sigma}{M'}:\sigma\ii\tau}
\end{array}
\begin{array}{rc}
	\plunit
&	\deriv{}{\Gamma\eqj M=\unit:1}
\nl	\plproja
&	\deriv{}{\Gamma\eqj\lpra\pair{M,N}=M:\sigma}
\nl	\plprojb
&	\deriv{}{\Gamma\eqj\lprb\pair{M,N}=N:\tau}
\nl	\plpair
&	\deriv{}{\Gamma\eqj\pair{\lpra M,\lprb M}=M:\sigma\times\tau}
\nl	\plbeta
&	\deriv{}{\Gamma\eqj(\lamabs{x}{\sigma}{M})N=\subst{M}{N}{x}:\tau}
\nl	\pleta
&	\deriv{x\not\in\FV(M)}
		{\Gamma\eqj\lamabs{x}{\sigma}{(Mx)}=M:\sigma\ii\tau}
\nl	\pladdvar
&	\deriv{\Gamma\eqj M=M':\sigma
	\sep	\Gamma\subseteq\Gamma'}
		{\Gamma'\eqj M=M':\sigma}
	\end{array}
\]
\end{table*}
%......................................................................

%======================================================================
\section{The interpretation of the simply-typed lambda calculus}
\label{sec-henkin-2}

%----------------------------------------------------------------------
\subsection{The simply-typed lambda calculus}\index{simply-typed lambda
	calculus}\index{lambda calculus!simply-typed}\index{typed lambda
	calculus}

Let $\TConst$ be a set of {\defit type
constants\index{type!constant}\index{constant!type}} $t,u,\ldots$.  {\defit
Simple types\index{simple type}\index{type!simple}} $\sigma,\tau,\ldots$
are given by the grammar:
\[	\sigma\bnf t \bor 1 \bor\sigma\times\tau
	\bor\sigma\ii\tau
\]
Let $\Vars$ be an infinite set of {\defit variables\index{variable}}
$x,y,\ldots$. For each type $\sigma$, let $\Const_{\sigma}$ be a set of
{\defit individual constants\index{individual
constant}\index{constant!individual}} $c^{\sigma},d^{\sigma},\ldots$. The
collection $\pair{\TConst,\family{\Const_{\sigma}}{\sigma}}$ is also called
a {\defit simply-typed signature\index{simply-typed
signature}\index{signature!simply-typed}}.  {\defit Raw typed lambda
terms\index{raw lambda term!simply-typed}\index{lambda term!raw}}
$M,N,\ldots$ are given by the grammar:
\[	M\bnf x \bor c^{\sigma} \bor\unit \bor\pair{M,N} \bor\lpra{M}
	\bor\lprb{M} \bor MN \bor\lamabs{x}{\sigma}{M}\bor
	M\sigma
\]
We have the usual notions of free and
bound\index{free!variable}\index{variable!free and bound}\index{bound
variable, in lambda calculus} variables, and we write $\FVof{M}$ for the
free variables of a term $M$. We identify raw terms up to renaming of bound
variables, and we write $\subst{M}{N}{x}$ for the result of substituting
$N$ for $x$ in $M$.

A {\defit type assignment\index{type
assignment!simply-typed}} $\Gamma=\typ{x_1}{\sigma_1} ,\typ{x_2}{\sigma_2}
,\ldots,\typ{x_m}{\sigma_m}$ is a finite, possibly empty sequence of pairs
of a variable and a type, such that $x_i\neq x_j$ for all $i\neq j$.  We
write $\Gamma\seq\Gamma'$ if $\Gamma$ is contained in $\Gamma'$ {\em as a
set}.  A {\defit valid typing judgment\index{valid typing
judgment!simply-typed}\index{typing
judgment!simply-typed}}
is an expression of the form $\Gamma\tj M:\sigma$ which can be derived by
the rules in Table~\ref{tab-simple-lambda-terms}.  An {\defit
equation\index{equation!of simply-typed lambda calculus}} of the simply-typed lambda calculus is an expression of
the form $\Gamma\eqj M=N:\sigma$, where $\Gamma\tj M:\sigma$ and $\Gamma\tj
N:\sigma$ are valid typing judgments.  If $E$ is an equation and $\Eqns$ is
a set of equations, we write $\Eqns\entailssimple E$ if $E$ can be derived
from $\Eqns$ by the rules in Table~\ref{tab-simple-equations}. As usual,
$\Eqns$ is called a {\defit
theory\index{theory!simply-typed}} if it is closed under derivability, {\ie} if
$\Eqns\entailssimple E$ implies $E\in\Eqns$.  The smallest theory of the
simply-typed lambda calculus (for a fixed signature) is denoted by
$\theorysimple$. It is also called the {\defit pure\index{pure lambda
theory!simply-typed}\index{lambda theory!pure}} theory.

%----------------------------------------------------------------------
\subsection{Strict interpretation in a cartesian-closed category}

Fix a simply-typed signature. An {\defit (strict)
interpretation\index{interpretation!in ccc}\index{model!of simply-typed
lambda calculus}\index{strict interpretation!of simply-typed lambda
calculus}\index{model!strict}} $I$ of the simply-typed lambda calculus in a
ccc $\Cc$, which we schematically write as $I:\theorysimple\ii\Cc$,
consists of an interpretation of types and an interpretation of typing
judgments. A type $\sigma$ is interpreted as an object $\semio{\sigma}$ of
$\Cc$. A valid typing judgment $\Gamma\tj M:\tau$ is interpreted as a
morphism $\semio{\Gamma\tj M:\tau}$.  A strict interpretation $I$ is
uniquely determined by its values on type constants and individual
constants.

Let $\constinterp:\TConst\ii\Obj{\Cc}$ be an interpretation of type
constants as objects of $\Cc$.  This extends uniquely to an interpretation
$\semi{\sigma}{}$ of every type:
\[\begin{array}{rcl}
\\	\semio{t}
&=&	\constinterp(t)
\\	\semio{1}
&=&	1
\\	\semio{\sigma\times\tau}
&=&	\semio{\sigma}\times
	\semio{\tau}
\\	\semio{\sigma\ii\tau}
&=&	(\semio{\tau})^{
	\semio{\sigma}}
\end{array}\]

\noindent
If $\Gamma=\typ{x_1}{\sigma_1},\ldots,\typ{x_m}{\sigma_m}$ is a type
assignment, we write
$\semio{\Gamma}=\semio{\sigma_1}\times\cdots\times\semio{\sigma_m}$.  Let
$\constinterp_{\sigma}:\Const_{\sigma}\ii\hom{1,\semi{\sigma}{}}$ be an
interpretation of term constants as morphisms of $\Cc$, for each type
$\sigma$. This extends uniquely to an interpretation $\semio{\Gamma\tj
M:\tau}$ of valid typing judgments:
\[\begin{array}{rcl}
	\semio{\Gamma\tj x_j:\sigma_j}
&=&	\semio{\Gamma}\catarrow{\proj_j}\semio{\sigma_j}
	\mbox{, the $j$th projection}
\\	\semio{\Gamma\tj c^{\sigma}:\sigma}
&=&	\semio{\Gamma}\catarrow{\termarrow}1
	\catarrow{\constinterp_{\sigma}(c^{\sigma})}\semio{\sigma}
\\	\semio{\Gamma\tj\unit:1}
&=&	\semio{\Gamma}\catarrow{\termarrow}1=\semio{1}
\\	\semio{\Gamma\tj\pair{M,N}:\sigma\times\tau}
&=&	\semio{\Gamma}\catarrow{\pair{\semio{\Gamma\tj M:\sigma},
	\semio{\Gamma\tj N:\tau}}}\semio{\sigma}\times\semio{\tau}
	=\semio{\sigma\times\tau}
\\	\semio{\Gamma\tj\lpra M:\sigma}
&=&	\semio{\Gamma}\catarrow{\semio{\Gamma\tj M:\sigma\times\tau}}
	\semio{\sigma}\times\semio{\tau}\catarrow{\proja}
	\semio{\sigma}
\\	\semio{\Gamma\tj\lprb M:\tau}
&=&	\semio{\Gamma}\catarrow{\semio{\Gamma\tj M:\sigma\times\tau}}
	\semio{\sigma}\times\semio{\tau}\catarrow{\projb}
	\semio{\sigma}
\\	\semio{\Gamma\tj MN:\tau}
&=&	\semio{\Gamma}\catarrow{\pair{\semio{\Gamma\tj M:\sigma\ii\tau},
	\semio{\Gamma\tj N:\sigma}}}(\semio{\tau})^{\semio{\sigma}}\times
	\semio{\sigma}\catarrow{\appl}\semio{\tau}
\\	\semio{\Gamma\tj\lamabs{x}{\sigma}{M}:\sigma\ii\tau}
&=& 	\semio{\Gamma}
	\catarrow{\curry{(\semio{\Gamma,\typ{x}{\sigma}\tj M:\tau})}} 
	(\semio{\tau})^{\semio{\sigma}}=\semio{\sigma\ii\tau}
\end{array}\]

\begin{lemma}\label{lem-simple-perm-subst}
The interpretation of the simply-typed lambda calculus in a ccc has the
following properties, which are proved by induction on $M$:\rm
\begin{enumerate}
\item {\bf Permutation of Individual Variables.}
If $s:\{1,\ldots,l\}\ii\{1,\ldots,m\}$ is injective and
$\FVof{M}\seq\{x_{s1},\ldots,x_{sl}\}$, and if
$\Gamma'=\typ{x_1}{\sigma_1},\ldots\typ{x_m}{\sigma_m}$ and
$\Gamma=\typ{x_{s1}}{\sigma_{s1}},\ldots\typ{x_{sl}}{\sigma_{sl}}$ 
then
\[	\xymatrix{
	{\semio{\Gamma'}}
	\ar[rr]^{\semio{\Gamma'\tj M:\tau}}
	\ar[dr]_{\tuple{\proj_{s1},\ldots,\proj_{sl}}}
&&	{\semio{\tau}.}
\\&	{\semio{\Gamma}}
	\ar[ur]_{\semio{\Gamma\tj M:\tau}}
	}
\]
\item {\bf Term Substitution.}
Let $\Gamma=\typ{x_1}{\sigma_1},\ldots\typ{x_m}{\sigma_m}$ and
$\Gamma'=\typ{y_1}{\rho_1},\ldots\typ{y_l}{\rho_l}$, and suppose
$\Gamma\tj M:\tau$ and $\Gamma'\tj N_j:\sigma_j$ for
$j=1,\ldots,m$. Let $\subst{M}{\bar{N}}{\bar{x}}$ denote the simultaneous
substitution of $N_1,\ldots,N_n$ for $x_1,\ldots,x_n$ in $M$. Then
\[	\xymatrix{
	{\semio{\Gamma'}}
	\ar[rr]^{\semio{\Gamma'\tj\subst{M}{\bar{N}}{\bar{x}}:\tau}}
	\ar[dr]_<>(.3)*+{\labelstyle\tuple{\semio{\Gamma'\tj
	N_1:\sigma_1},\ldots,\semio{\Gamma'\tj N_n:\sigma_n}}}
&&	{\semio{\tau}.}
\\&	{\semio{\Gamma}}
	\ar[ur]_{\semio{\Gamma\tj M:\tau}}
	}
\]
\end{enumerate}
\eottwo
\end{lemma}

\noindent
We say that an interpretation $I$ {\defit satisfies} an equation
$\Gamma\eqj M=N:\tau$, in symbols, $I\models\Gamma\eqj M=N:\tau$, if
$\semio{\Gamma\tj M:\tau}=\semio{\Gamma\tj N:\tau}$. If $\Eqns$ is a set of
equations, then we write $I\models\Eqns$ if $I\models E$ for all
$E\in\Eqns$. The set of all equations that an interpretation $I$ satisfies
is written $\Theoryof{I}$. If $\classofmodels$ is a class of ccc's, then we
write $\Eqns\modelsclass E$, for an equation $E$ and a set of equations
$\Eqns$, if for every strict interpretation $I$ in a ccc
$\Cc\in\classofmodels$, $I\models\Eqns$ implies $I\models E$.

\begin{proposition}{\bf Soundness of the strict ccc interpretation.}
\[	\mbox{$\Eqns\entailssimple E$ \ssep implies \ssep 
	$\Eqns\models_{\Ccc} E$.}
\]
\eottwo
\end{proposition}

\noindent
If $\Th$ is a theory and $I:\theorypl\ii\Cc$ is an interpretation such that
$I\models\Th$, then we also write $I:\Th\ii\Cc$.  An interpretation can be
post-composed with a ccc-representation in an evident way:
$\Th\lowcatarrow{I}\Cc\lowcatarrow{F}\Cc$ is the interpretation $J$ defined
by $\semsuper{\sigma}{}{J}=F\semio{\sigma}$ and $\semsuper{\Gamma\tj
M:\tau}{}{J}=F\semio{\Gamma\tj M:\tau}$.

%----------------------------------------------------------------------
\subsection{The cartesian-closed category associated to a theory}
\label{subsec-free-ccc}

From a theory $\Th$ over a simply-typed signature, one constructs a
cartesian-closed category $\freeccc{\Th}$\index{ccc!associated to a theory}
as follows: The objects are simple types $\sigma$, and the morphisms
$\morphnamed{M}\in\hom{\sigma,\tau}$ are named by terms $M$ such that
$\typ{x}{\sigma}\tj M:\tau$ is a valid typing judgment.  Two terms $M$ and
$N$ name the same morphism if $\Th\entailssimple\typ{x}{\sigma}\eqj
M=N:\tau$.

\begin{proposition}
The above construction yields a well-defined cartesian-closed category
$\freeccc{\Th}$. There is a canonical strict interpretation
$I_0:\Th\ii\freeccc{\Th}$ with $\semo{\sigma}{I_0}=\sigma$ and
$\semo{\typ{x}{\sigma}\tj M:\tau}{I_0}=\morphnamed{M}:\sigma\ii\tau$.
Moreover, $I_0$ has the following universal property: For any
strict interpretation $J:\Th\ii\Cc$, there is a unique ccc-representation
$F:\freeccc{\Th}\ii\Cc$ such that
\[	\xymatrix{
	{\Th}
	\ar[d]_{I_0}
	\ar[dr]^{J}
\\	{\freeccc{\Th}}
	\ar[r]_<>(.5){F}
&	{\Cc.}
	}
\]
\eottwo
\end{proposition}

\begin{corollary}{\bf Completeness of the strict ccc interpretation.}
Each theory $\Th$ of the simply-typed lambda calculus arises as the theory
of some ccc-interpretation. Consequently, for any set of equations $\Eqns$,
\[	\mbox{$\Eqns\models_{\Ccc} E$ \ssep implies \ssep
	$\Eqns\entailssimple E$.}
\]
\eottwo
\end{corollary}

\subsection{Henkin representations of a free ccc}

\begin{definition}
The {\defit free ccc\index{free!ccc}\index{ccc!free}} over a simply-typed
signature is the cartesian-closed category associated to the {\em pure}
theory $\theorysimple$ over that signature.
\end{definition}

\noindent
{\Cubric} proved in {\cite{Cub95}} that for any object $A$ in a free ccc,
the unique morphism $A\iiepic 1$ is epic, and hence the condition of
Theorem~\ref{thm-henkin-repr-neset} is satisfied. The proof uses a strongly
normalizing system of Mints reductions. Let us remark here that, using
these Mints reductions, one can show more about the morphism $A\ii 1$:

\begin{proposition}
In a free ccc, the morphism $A\ii 1$ is a coequalizer of the diagram
\[	\xymatrix{
	{A\times A}
	\ar@<1ex>[r]^<>(.5){\proja}
	\ar@<-1ex>[r]_<>(.5){\projb}
	\ar@{}[r]|<>(.5){\nocommute}
& 	{A.}
	}
\]
\end{proposition}

\begin{proofsketch}
Let $f:A\ii B$ be named by the term $\typ{x}{A}\tj M:B$, and assume
$f\cp\proja=f\cp\projb$. This means
$\entailssimple\typ{y}{A},\typ{z}{A}\eqj\subst{M}{y}{x}=\subst{M}{z}{x}$.
Suppose $M'$ is the unique normal form of $M$ with respect to the system of
Mints reductions. Then $\subst{M'}{y}{x}$ and $\subst{M'}{z}{x}$ are the
respective unique normal forms of $\subst{M}{y}{x}$ and $\subst{M}{z}{x}$,
hence they are syntactically equal. It follows that $M'$ does not contain
$x$ freely, and therefore $f$ factors as $A\ii 1\catarrow{M'}B$. We already
know that the factorization is unique because $A\iiepic 1$.\eot
\end{proofsketch}

\noindent 
As a consequence, in a free ccc, every object $A$ is well-supported, {\ie}
$\projb:A\times B\iicover B$ for all $B$. Indeed, products preserve
coequalizers, and coequalizers are covers. With
Corollary~\ref{cor-henkin-repr-neset-faith}, one gets:

\begin{corollary}
Any free ccc has a faithful ({\ie} isomorphism-reflecting) Henkin-embedding
into $\neSet$.\eot
\end{corollary}


%----------------------------------------------------------------------
\subsection{The non-strict interpretation of the simply-typed lambda calculus}

\noindent
Let $\Cc$ be a ccc. A {\defit non-strict interpretation\index{non-strict
interpretation!of simply-typed lambda calculus}\index{model!of simply-typed
lambda calculus}\index{interpretation!in
ccc!non-strict}\index{model!non-strict}} of the simply-typed lambda
calculus $I:\theorysimple\ii\Cc$ is a Henkin representation
$H:\freeccc{\theorysimple}\ii\Cc$. One defines
$\semo{\sigma}{I}=H\semo{\sigma}{I_0}$ and $\semo{\Gamma\tj
M:\tau}{I}=H\semo{\Gamma\tj M:\tau}{I_0}$.  A non-strict interpretation $I$
{\defit satisfies} an equation $\Gamma\eqj M=N:\tau$, in symbols
$I\models\Gamma\eqj M=N:\tau$, if $\semio{\Gamma\tj
M:\tau}=\semio{\Gamma\tj N:\tau}$. As before, we denote by $\Theoryof{I}$
the set of equations that are satisfied in $I$. For a class
$\classofmodels$ of ccc's we write $\Eqns\modelsnsclass E$ if any
non-strict interpretation in some $\Cc\in\classofmodels$ that satisfies
$\Eqns$ also satisfies $E$.  The following soundness theorem is an obvious
consequence of Lemma~\ref{lem-kernel-henkin-ccc}:

\begin{proposition}{\bf Soundness of the non-strict ccc-interpretation.}
\label{sound-non-strict-simple}
\[	\mbox{$\Eqns\entailssimple E$ \ssep implies \ssep $\Eqns\modelsns_{\Ccc} E$.}
\]
\eottwo
\end{proposition}

\begin{remark}
Completeness is also evident, because the strict ccc-interpretations are
among the non-strict ones.  More interesting are completeness theorems with
respect to certain smaller classes of models. This is the subject of the
next section.
\end{remark}

%======================================================================
\section{From Henkin representation theorems to completeness theorems}
\label{sec-henkin-and-completeness}
\label{sec-henkin-3}

%----------------------------------------------------------------------
\subsection{The problem with empty types}\index{empty types}

By a {\defit set-theoretic model\index{set-theoretic model!of simply-typed
lambda calculus}\index{model!set-theoretic}\index{model!with empty
types}\index{set-theoretic model!with empty types}} of the simply-typed
lambda calculus, we mean a non-strict interpretation in $\Set$.  The
equational rules for the lambda calculus from
Table~\ref{tab-simple-equations} are not complete for equational reasoning
in set-theoretic models. This was first noticed by Meyer {\etal} in
{\cite{MMMS87}}. If in some model, the interpretation $\semio{\sigma}$ of a
type $\sigma$ is the empty set, then the model satisfies {\em every}
equation of the form
\begin{equation}\label{eqn-mmms-empty}
	\typ{x}{\sigma},\Gamma\eqj M=N:\tau.
\end{equation}
On the other hand, if $\semio{\sigma}$ is non-empty, then the model
satisfies the rule
\begin{equation}\label{eqn-mmms-non-empty}
	\plne\index{rule $\plne$}\index{non-empty rule@$\plne$ rule}
\sep	\deriv{\typ{x}{\sigma},\Gamma\eqj M=N:\tau\sep
	x\not\in\FVof{M,N}}{\Gamma\eqj M=N:\tau}
\end{equation}
for that type $\sigma$. (By this we mean, for every instance of the rule,
if the model satisfies the premise, then it satisfies the conclusion. We
also say the rule is {\defit sound} for the model.) So in any particular
set-theoretic model, for each $\sigma$, either (\ref{eqn-mmms-empty}) or
(\ref{eqn-mmms-non-empty}) holds. However, in a general theory of the
simply-typed lambda calculus, this is not true. Meyer and his co-authors
give the following example: Let $\sigma$ and $\tau$ be type constants, and
let $\f:(\sigma\ii\sigma\ii\sigma)\ii\tau$ be an individual constant. Let
$p_1=\lamabs{x}{\sigma}{\lamabs{y}{\sigma}{x}}$ and
$p_2=\lamabs{x}{\sigma}{\lamabs{y}{\sigma}{y}}$.  Then the following is
sound for any set-theoretic interpretation:
\begin{equation}\label{eqn-mmms-example}
	\deriv{\typ{x}{\sigma}\eqj \f p_1=\f p_2:\tau}
		{\eqj \f p_1=\f p_2:\tau}.
\end{equation}
This is because, if $\semio{\sigma}$ is empty, then $p_1=p_2$ holds as a
consequence of (\ref{eqn-mmms-empty}), while if $\semio{\sigma}$ is
non-empty, then (\ref{eqn-mmms-example}) follows from
(\ref{eqn-mmms-non-empty}). 
On the other hand, (\ref{eqn-mmms-example}) is not sound for arbitrary
theories of the lambda calculus: specifically, let $\Sierp$ be the poset
with two elements $\bot\leq\top$, and consider the following interpretation
$I:\theorysimple\ii\Set^{\Sierp}$: for types, we let
\[	\semio{\sigma}(\bot)=\emptyset,
\sep	\semio{\sigma}(\top)=\{s_1,s_2\},
\sep	\semio{\tau}(\bot)=\{t_1,t_2\},
\sep	\semio{\tau}(\top)=\{u\},
\]
with the unique maps $\semio{\sigma}(\bot)\ii\semio{\sigma}(\top)$ and
$\semio{\tau}(\bot)\ii\semio{\tau}(\top)$. Let
$A=\semio{\sigma\ii\sigma\ii\sigma}$, and notice that
$A(\bot)=A(\top)=\{s_1,s_2\}^{\{s_1,s_2\}^2}$. Let
$\proj_2:\{s_1,s_2\}^2\ii\{s_1,s_2\}$ be the first projection. Now define
$\semio{\f}:\semio{\sigma\ii\sigma\ii\sigma}\ii\semio{\tau}$ via
\[	\semio{\f}(\bot)(x)=\left\{
	\begin{array}{ll}	
		t_1&	\mbox{if $x=\proj_1$}
	\\	t_2&	\mbox{else,}
	\end{array}
	\right.
\sep	\semio{\f}(\top)(x)=u.
\]
With respect to this interpretation, $\semio{\f p_1}(\bot)=t_1\neq
t_2=\semio{\f p_2}(\bot)$. On the other hand, there is a unique morphism
$\semio{\sigma}\ii\semio{\tau}$. Hence, $\typ{x}{\sigma}\eqj \f p_1=\f
p_2:\tau$ holds for the interpretation $I$, while $\eqj \f p_1=\f p_2:\tau$
does not. Consequently, the rule (\ref{eqn-mmms-example}) is not admissible
for arbitrary lambda theories. 

As the example shows, the equational rules in
Table~\ref{tab-simple-equations} are not complete for the class of
set-theoretic models. On the other hand, the rule $\plne$ is sound only
for set-theoretic models with non-empty types. Hence, the need arises
to consider the following three classes of models, and their
associated completeness theorems, separately:
\begin{enumerate}
\item 
One may consider set-theoretic models where all types are non-empty. This
is the classical approach {\cite{Fri75}}. In this case, the rules in
Table~\ref{tab-simple-equations}, together with $\plne$, are sound and
complete.
\item One may consider all set-theoretic models. This necessitates a more
elaborate system of inference rules. A sound and complete system was given
in {\cite{MMMS87}\nocite{Hue90}}.
\item One may enlarge the class of models to allow non-set-theoretic ones.
The class of Kripke lambda models, introduced in {\cite{MM91}}, is a
convenient such class, and for it, the rules in
Table~\ref{tab-simple-equations} are sound and complete.
\end{enumerate}
Each of the three classes of models can be described in terms of Henkin
representations, and the completeness theorems in each of the three cases
can be derived from the three respective Henkin representation theorems of
Section~\ref{subsec-henkin-r-thms}. 

%----------------------------------------------------------------------
\subsection{A categorical analysis of the rule $\plne$}
\label{subsec-categorical-nonempty}

We have already remarked that in a set-theoretic model, the rule $\plne$ is
sound for a type $\sigma$ if $\semio{\sigma}$ is non-empty. More generally,
if $I:\theorysimple\ii\Cc$ is a non-strict interpretation of the
simply-typed lambda calculus, and if $\semio{\sigma}$ is an object such
that $\semio{\sigma}\iiepic 1$ is epic, then the rule $\plne$ is sound for
$\sigma$ with respect to $I$. Because if $x\not\in\FVof{M,N}$, and if
$\semio{\typ{x}{\sigma},\Gamma\tj M:\tau} =\semio{\typ{x}{\sigma},\Gamma\tj
N:\tau}$, then, using Lemma~\ref{lem-simple-perm-subst},
\[	\xymatrix{
	{\semio{\sigma}\times\semio{\Gamma}}
	\arepic[r]^<>(.5){\projb}
&	{\semio{\Gamma}}
	\ar@<1ex>[rr]^<>(.5){\semio{\Gamma\tj M:\tau}}
	\ar@<-1ex>[rr]_<>(.5){\semio{\Gamma\tj N:\tau}}
	\ar@{}[rr]|<>(.5){\nocommute}
&& 	{\semio{\tau},}
	}
\]
and hence $I\models\Gamma\eqj M=N:\tau$. Conversely, assume that $\plne$ is
sound for $\sigma$ in some theory $\Th$. Then $\semo{\sigma}{I_0}\iiepic 1$
is epic in the ccc $\freeccc{\Th}$, for the canonical interpretation $I_0$.

%----------------------------------------------------------------------
\subsection{Set-theoretic models with non-empty types}
\index{model!with non-empty types}
\index{set-theoretic model!with non-empty types}
\index{non-empty types}

Fix a simply-typed signature. By a {\defit set-theoretic model with
non-empty types\index{set-theoretic model!with non-empty
types}\index{model!with non-empty types}\index{non-empty types}} of the
simply-typed lambda calculus, we mean a non-strict interpretation
$I:\theorysimple\ii\neSet$.  We write $\Eqns\modelsnsne E$ for semantic
consequence with respect to that class of models.  We write
$\Eqns\entailsne E$ if $E$ can be derived from the equations $\Eqns$ by the
usual simply-typed lambda calculus rules, together with the rule $\plne$.

\begin{theorem}{\bf Soundness and Completeness for non-strict
interpretations in $\neSet$.}  The rule $\plne$ is sound for non-strict
interpretations in $\neSet$. Moreover, any theory that is closed under
$\plne$ arises from such an interpretation. As a consequence,
\[	\mbox{$\Eqns\modelsnsne E$ \ssep if and only if \ssep
	$\Eqns\entailsne E$.}
\]
\end{theorem}

\begin{proof}
\begin{caselist}
\case[Soundness:]
It follows from the remarks in
Section~\ref{subsec-categorical-nonempty} that the rule $\plne$ is sound
for $\modelsnsne$. 
\case[Completeness:]
Assume $\Eqns\modelsnsne E$. Let $\Th$ be the theory generated by $\Eqns$
and $\plne$. We need to show $E\in\Th$. Let $I_0:\Th\ii\freeccc{\Th}$ be
the canonical interpretation. Then $A\iiepic1$ for all objects of
$\freeccc{\Th}$, hence there is a Henkin embedding
$H:\freeccc{\Th}\ii\neSet$ by Henkin Representation
Theorem~\ref{thm-henkin-repr-neset}. Let $I=H\cp I_0:\Th\ii\neSet$. Then
$\Theoryof{I}=\Theoryof{I_0}=\Th$, hence $I\models\Eqns\imp I\models E\imp
E\in\Th$. \eot
\end{caselist}
\end{proof}

%......................................................................
\begin{table*}[tbp]
\caption{Rules for the simply-typed lambda calculus with emptiness assertions}
\label{tab-simple-exteqns}
\[
\begin{array}{rc}
	\plempty
&	\deriv{}{\EAss,\emp{\sigma},\typ{x}{\sigma},\Gamma\eqj M=N:\tau}
\nl	\plcases
&	\deriv{\EAss,\emp{\sigma},\Gamma\eqj M=N:\tau
	\sep 	\EAss,\typ{x}{\sigma},\Gamma\eqj M=N:\tau}
		{\EAss,\Gamma\eqj M=N:\tau}
\nl	\pladdempty
&	\deriv{\EAss,\Gamma\eqj M=N:\tau
	\sep 	\EAss\seq\EAss'}
		{\EAss',\Gamma\eqj M=N:\tau}
\end{array}
\]
\end{table*}
%......................................................................
%----------------------------------------------------------------------
\subsection{Set-theoretic models with empty types}
\index{model!with empty types}
\index{set-theoretic model!with empty types}
\index{empty types}

For reasoning about possibly empty types, we use the extended proof system
of Meyer {\etal} {\cite{MMMS87}}.  Fix a simply-typed signature.  An
{\defit emptiness assertion\index{emptiness assertion}} is an expression
$\emp{\tau}$, where $\tau$ is a type. We use the letter $\EAss$ to denote a
sequence of emptiness assertions, and we write $\EAss\seq\EAss'$ if $\EAss$
is contained in $\EAss'$ as a set. An {\defit extended
equation\index{extended equation}\index{equation!extended}} is an
expression of the form $\EAss,\Gamma\eqj M=N:\tau$, where $\Gamma\eqj
M:\tau$ and $\Gamma\eqj N:\tau$ are valid typing judgments (note that no
$\EAss$ appears in typing judgments). The intuitive meaning of an extended
equation $\emp{\tau_1} ,\ldots,\emp{\tau_k},\Gamma\eqj M=N:\tau$ is: if
$\tau_1$ through $\tau_k$ are empty, then $\Gamma\eqj M=N:\tau$ holds.  We
freely use suggestive notation such as $\emp{\sigma}\eqj\Eeq$ to denote an
extended equation whose left-hand side contains an emptiness assertion
$\emp{\sigma}$, and $\typ{x}{\sigma}\eqj\Eeq$ to denote an extended
equation whose left-hand side contains a type assertion $\typ{x}{\sigma}$,
where $E$ may contain other emptiness or type assertions.

We consider three special rules for extended equations, which are shown in
Table~\ref{tab-simple-exteqns}. Notice that in the rule $\plcases$, the
variable $x$ cannot be free in $M,N$.  We write $\EEqns\entailsext\Eeq$ for
derivability using these rules, together with the equational rules of the
simply-typed lambda calculus. Throughout this subsection, we will write
$\Eeq$ for an extended equation, and $\EEqns$ for a set of extended
equations. An {\defit extended theory\index{extended
theory}\index{theory!extended}} is a set of extended equations that is
closed under derivability. If $\eTh$ is an extended theory, then we write
$\subth{\eTh}$ for its subset of equations, {\ie} those extended equations
of $\eTh$ that contain no emptiness assertions. $\subth{\eTh}$ is a theory,
which we call the {\defit core\index{core of an extended
theory}\index{extended theory!core of}} of $\eTh$.

Recall that a ccc $\Cc$ is {\defit special\index{special
ccc}\index{ccc!special}} if for every object $A$, either $A\iiepic 1$ is
epic or $A$ is partially initial. Let $I:\theorysimple\ii\Cc$ be an
interpretation of the simply-typed lambda calculus in a special ccc, and
let $\Eeq$ be an extended equation, say, $\emp{\tau_1},\ldots,\emp{\tau_k}
,\Gamma\eqj M=N:\tau$. We say that $I$ {\defit satisfies}
$\Eeq$, in symbols $I\modelsext\Eeq$, if
\[	\semio{\tau_1},\ldots,\semio{\tau_k}
	\mbox{ partially initial} 
\sep\imp\sep
	\semio{\Gamma\tj M:\tau}=\semio{\Gamma\tj N:\tau}.
\]
If $\classofmodels$ is a class of special ccc's, we write
$\EEqns\modelsextclass\Eeq$, respectively $\EEqns\modelsnsextclass\Eeq$, if
$I\modelsext\EEqns$ implies $I\modelsext\Eeq$ for all strict, respectively
non-strict, interpretations $I$ in a ccc in $\classofmodels$.

\begin{n-definition}\label{def-theory-principal}
An extended theory $\eTh$ is called {\defit principal\index{principal
extended theory}\index{extended theory!principal}} if for each type
$\sigma$, either $\eTh$ contains {\em all} extended equations of the form
$\typ{x}{\sigma}\eqj\Eeq'$, or it contains {\em all} extended equations of
the form $\emp{\sigma}\eqj\Eeq'$.
\end{n-definition}

\begin{proposition}{\bf The correspondence between principal extended
theories and special ccc's.}\label{prop-principal-special}
\begin{enumerate}
\item
Let $I:\theorysimple\ii\Cc$ be a strict or non-strict interpretation of the
simply-typed lambda calculus in a special ccc. Then the set
$\eTh=\{\Eeq\such I\modelsext\Eeq\}$ is a principal extended theory.
\item
Conversely, every principal extended theory arises in this way from some
strict interpretation $I$.
\end{enumerate}
\end{proposition}

\begin{proof}
\begin{caselist}
\case[1.:] 
First, we need to check that $\eTh$ is indeed an extended theory. It is
easily checked that the rules $\plempty$, $\plcases$ and $\pladdempty$ are
sound with respect to any interpretation $I$ in a special ccc $\Cc$. For
$\plcases$, one uses the fact that $\Cc$ is special: the conclusion follows
from the first premise if $\semio{\sigma}$ is partially initial, and from
the second premise if $\semio{\sigma}\iiepic 1$. The fact that $\eTh$ is
principal follows directly from the definition of $I\modelsext\Eeq$: consider
any type $\sigma$. If $\semio{\sigma}$ is partially initial, then $\eTh$
contains all extended equations of the form $\typ{x}{\sigma}\eqj\Eeq'$. If
$\semio{\sigma}$ is {\em not} partially initial, then $\eTh$ (trivially)
contains all extended equations of the form $\emp{\sigma}\eqj\Eeq'$.
\case[2.:]
Let $\eTh$ be a principal extended theory. Let $\sTh$ be the core of
$\eTh$, {\ie} the subset of those extended equations of $\eTh$ that contain
no emptiness assertions. Let $\Cc=\freeccc{\sTh}$ be the cartesian-closed
category associated to the theory $\sTh$, and let $I_0:\sTh\ii\Cc$ be the
canonical interpretation. We show that $\Cc$ is a special ccc. Consider any
object $\sigma$. If $\eTh$ contains all extended equations of the form
$\typ{x}{\sigma}\eqj\Eeq'$, then $\semo{\sigma}{I_0}$ is partially initial.
Otherwise, $\eTh$ contains all extended equations of the form
$\emp{\sigma}\eqj\Eeq'$. Therefore, the first premise of $\plcases$ always
holds for the type $\sigma$, and hence the rule $\pladdempty$ is sound for
$\eTh$ at type sigma.  By the remarks in
Section~\ref{subsec-categorical-nonempty} this means that
$\semo{\sigma}{I_0}\iiepic 1$. Therefore $\Cc$ is special.

We now claim that $\eTh\modelsext\Eeq$ iff $I_0\modelsext\Eeq$, for any
extended equation $\Eeq$. Let $\Eeq$ be $\emp{\tau_1},\ldots
,\emp{\tau_k}\eqj E_0$, where $E_0$ is an equation, {\ie} $E_0$ contains no
more emptiness assertions.

First, assume $\eTh\modelsext\Eeq$. Assume that $\semo{\tau_1}{I_0},\ldots
,\semo{\tau_k}{I_0}$ are partially initial in $\Cc$. Under this hypothesis,
we need to show $I_0\models E_0$. Since $\Cc$ is the ccc associated to the
theory $\sTh$, this implies that $\sTh\entails\typ{x_i}{\tau_i}\eqj E_0$
for $i=1\ldots k$.  With $\Eeq$, by repeated application of the rules
$\plcases$ and $\pladdempty$, one gets $\eTh\entailsext E_0$. Since $E_0$
is a (non-extended) equation, it must be in the core, {\ie}
$\sTh\entailsext E_0$, hence $I_0\models E_0$.

Conversely, assume that $\eTh\not\modelsext\Eeq$. We claim that
$I_0\not\modelsext\Eeq$. Since $\eTh$ is a principal extended theory and
$\eTh\not\entailsext\Eeq$, it must be the case that $\eTh$ contains all
extended equations of the form $\typ{x}{\tau_j}\eqj\Eeq'$, for each
$j=1\ldots k$. Therefore, each $\semo{\tau_j}{I_0}$ is partially initial in
$\Cc$. Also, from $\eTh\not\entailsext\Eeq$, by $\pladdempty$ one has
$\eTh\not\entailsext E_0$, hence $I_0\not\models E_0$. This shows that
$I_0\not\models\Eeq$.\eot
\end{caselist}
\end{proof}

\noindent
The proof of the completeness result for set-theoretic models rests on the
following lemma, which implies that any extended theory is an intersection
of principal ones:

\begin{lemma}{\bf Maximal extended theories are principal.}
\label{lem-maximal-principal}
Let $\Eeq$ be an extended equation and let $\eTh$ be a maximal extended
theory such that $\eTh\not\entailsext\Eeq$. Then $\eTh$ is principal.
\end{lemma}

\begin{proof}
Consider the following two hypothetical arguments:
\begin{caselist}
\case[1.:]
If there is some extended equation $\typ{x}{\sigma}\eqj\Eeq'$ that is {\em
not} in $\eTh$, then, by maximality,
$\eTh\cup\{\typ{x}{\sigma}\eqj\Eeq'\}\entailsext\Eeq$.  Consider any
derivation of $\Eeq$ from $\eTh\cup\{\typ{x}{\sigma}\eqj\Eeq'\}$. Alter
this derivation by adding an emptiness assertion $\emp{\sigma}$ to each
extended equation throughout. An inspection of the proof rules in
Tables~\ref{tab-simple-equations} and {\ref{tab-simple-exteqns}} shows that
this alteration yields a valid derivation of
$\emp{\sigma}\eqj\eTh\cup\{\emp{\sigma},\typ{x}{\sigma}\eqj
\Eeq'\}\entailsext\emp{\sigma}\eqj\Eeq$, where $\emp{\sigma}\eqj\eTh$
denotes the set of equations $\{\emp{\sigma}\eqj E''\such
E''\in\eTh\}$. Applying the rules $\pladdempty$ and $\plempty$ at the
leaves, one gets $\eTh\entailsext\emp{\sigma}\eqj\Eeq$.
\case[2.:]
If there is some extended equation $\emp{\sigma}\eqj\Eeq'$ that is {\em
not} in $\eTh$, then, by the same reasoning as in 1.,
$\eTh\entailsext\typ{x}{\sigma}\eqj\Eeq$.
\end{caselist}
Now observe that cases 1.\ and 2.\ cannot happen simultaneously, since
otherwise $\eTh\entailsext\Eeq$ by $\plcases$.  It follows that $\eTh$ is
principal.\eot
\end{proof}

\begin{theorem}\label{thm-compl-special-ccc}
{\bf Soundness and Completeness for special ccc's.} Let
$\Cccspecial$ be the class of special ccc's. Then
\[	\mbox{$\EEqns\modelsextspecial\Eeq$
	\ssep iff \ssep $\EEqns\modelsnsextspecial\Eeq$
	\ssep iff \ssep $\EEqns\entailsext\Eeq$.}
\]
\end{theorem}

\begin{proof}
Soundness is an immediate consequence of the first part of
Proposition~\ref{prop-principal-special}. For completeness, assume
$\EEqns\not\entailsext\Eeq$. Let $\eTh$ be a maximal extended theory
containing $\EEqns$ such that $\eTh\not\entailsext\Eeq$. $\eTh$ is
principal by Lemma~\ref{lem-maximal-principal}.  By the second part of
Proposition~\ref{prop-principal-special}, it follows that $\eTh$ is the
extended theory of some strict interpretation
$I:\theorysimple\ii\Cc$. Hence $I\modelsext\EEqns$ but
$I\not\modelsext\Eeq$, which implies $\EEqns\not\modelsextspecial\Eeq$.\eot
\end{proof}

\noindent
Soundness and completeness for set-theoretic models now follows by applying
the Henkin Representation Theorem~\ref{thm-henkin-repr-set}.  We write
$\modelsnsset$ for semantic consequence for extended equations with respect
to set-theoretic models.

\begin{theorem}\label{thm-compl-ns-simple-set}
{\bf Soundness and Completeness for non-strict interpretations in $\Set$.}
\[	\mbox{$\EEqns\modelsnsset\Eeq$
	\ssep if and only if \ssep $\EEqns\entailsext\Eeq$.}
\]
\end{theorem}

\begin{proof}
Soundness is a special case of Theorem~\ref{thm-compl-special-ccc}.
For completeness, suppose $\EEqns\not\entailsext\Eeq$. By
Theorem~\ref{thm-compl-special-ccc}, there is a special ccc $\Cc$ and a
strict interpretation $I_0:\theorysimple\ii\Cc$ such that
$I_0\models\EEqns$ but $I_0\not\models\Eeq$. By
Theorem~\ref{thm-henkin-repr-set}, there is a Henkin embedding
$H:\Cc\ii\Set$. Let $I=H\cp I_0:\theorysimple\ii\Set$.  It follows from
Remark~\ref{rem-preserve-stuff} that $I$ validates the same extended
equations as $I_0$.\eot
\end{proof}
\index{embedding!Henkin|)}

%----------------------------------------------------------------------
\subsection{Kripke lambda models}

By a {\defit Kripke lambda model\index{Kripke lambda
model!simply-typed}\index{model!Kripke}}, we mean a a non-strict interpretation
$I:\theorysimple\ii\Set^P$ in a presheaf category over some poset $P$.  We
write $\Eqns\modelsnsP E$ for semantic consequence in the class of Kripke
lambda models.

\begin{theorem}{\bf Soundness and Completeness for non-strict 
interpretations in $\Set^P$.}  
Each simp\-ly-typed lambda theory arises from
some non-strict interpretation in a presheaf category $\Set^P$ over some
poset $P$. As a consequence, 
\[	\mbox{$\Eqns\modelsnsP E$ \ssep if and only if \ssep
	$\Eqns\entailssimple E$.}
\]
\end{theorem}

\begin{proof}
Soundness is a special case of Proposition~\ref{sound-non-strict-simple}.
Completeness is an immediate consequence of
Theorem~\ref{thm-henkin-repr-presheaf}.\eot
\end{proof}

%----------------------------------------------------------------------
\subsection{A remark on the principal model property}

The class of set-theoretic models with non-empty types and the class of
Kripke lambda models each have the {\em principal model property}: any
lambda theory that arises from the class actually arises as the theory of a
{\em single} model. However, the principal model property does not hold for
interpretations in $\Set$. Indeed, among the extended theories, the ones
that arise from a single model are the {\em principal} ones in the sense of
Definition~\ref{def-theory-principal}---but not all theories are principal.

The reason for the failure of the principal model property lies with the
categorical properties of $\Set$. Unlike the category of non-empty sets,
the category of sets does not embed its own discrete powers. Notice that
any discrete power $(\neSet)^I$ of the category of non-empty sets has
enough points to be Henkin-embedded in $\neSet$ via the point functor
$\Gamma=\hom{1,-}$. As a consequence, a ccc $\Cc$ can be Henkin-embedded in
$(\neSet)^I$ if and only if it can be Henkin-embedded in $\neSet$, and a
lambda theory arises as the theory of a family of models with non-empty
types if and only if it arises as the theory of a single such model. A
similar property holds for the class of Kripke lambda models, because any
discrete power of a presheaf category $\Set^P$ is again of this form.

What the proofs of Theorems~\ref{thm-compl-special-ccc} and
{\ref{thm-compl-ns-simple-set}} really show about set-theoretic models is
that any extended theory is the theory of some interpretation in a discrete
power $\Set^I$ of the category of sets. The proof is indirect, by first
showing that any extended theory is an intersection of principal (namely,
maximal) ones. In the process, the categorical meaning of the extended
equations gets lost. Is it possible to give a more direct proof in the
spirit of categorical logic, via a construction of a category directly from
an extended theory? This would be the ultimate form of
Theorem~\ref{thm-compl-ns-simple-set}.  Presumably such a proof would
require a categorical characterization of those ccc's that can be
Henkin-embedded in $\Set^I$.  Unfortunately, the characterization given in
Corollary~\ref{cor-henkin-emb-discrete} is not very elegant, and a more
satisfactory Henkin Representation Theorem for the class $\Set^I$ is not
known.

%======================================================================
\section{Henkin representations of {\PL}-categories}
\label{sec-henkin-4}

%----------------------------------------------------------------------
\subsection{{\PL}-categories}

Let $\ucat:\Ccc\ii\Cat$ and $\Obj{-}:\Ccc\ii\Set$ be the forgetful functors
that map a small ccc to its underlying category and to its set of objects,
respectively.

\begin{definition}
A {\defit
{\PL}-category\index{pl-category@{\PL}-category}\index{category!pl-category@{\PL}-category}}
$\calB=\tuple{\base,\Om,\fib,\fibnat,\all,\allnat}$ consists of
\begin{enumerate}
\item a small {\defit base category\index{base category}\index{pl-category@{\PL}-category!base}} $\base$ with 
finite products and a distinguished object $\Om$,
\item a contravariant {\defit fiber functor\index{fiber}\index{pl-category@{\PL}-category!fiber}}  
$\fib:\base^{\op}\ii\Ccc$, together with a natural isomorphism
\[	\fibnat:\hom{V,\Om}\iiso_V\Obj{\fib_V},
\]
\item a natural transformation
$\all:\ucat(\fib_{V\times\Om})\ii_V\ucat(\fib_V)$, together with a natural
isomorphism 
\[	\allnat:\homfib{V\times\Om}{\fib_{\proj_V}C,D}
	\iiso_{V,C,D}\homfib{V}{C,\all_V D}.
\]
\end{enumerate}
We sometimes write a {\PL}-category as $\tuple{\base,\fib,\all}$ if
the remaining parts of the structure are understood.
\end{definition}

\begin{remarks}
We assume that the finite products of the base category are chosen. We use
the letters $V,W,\ldots$ for objects of $\base$. The fiber functor $\fib$
maps an object $V$ to a cartesian-closed category $\fib_V$, called the
{\defit fiber at $V$}. We also call $\fib_{\Om^n}$ the {\defit $n$-fiber},
and in particular, $\fib_1$ is called the {\defit
0-fiber\index{zero-fiber@0-fiber}}. We use the letters $C,D,\ldots$ for
objects and $f,g,\ldots$ for morphisms of the fibers, and we denote
hom-sets of $\fib_V$ by $\homfib{V}{C,D}$.  Each morphism of the base
$\phi:V\ii W$ gives rise to a ccc-representation of fibers
$\fib_{\phi}:\fib_W\ii\fib_V$. For an object $V\in\base$, let
$\proj_V:V\times\Om\ii V$ be the first projection. The resulting functor
$\fib_{\proj_V}:\fib_V\ii\fib_{V\times\Om}$ is called the {\defit dummy
functor at $V$\index{dummy functor}}, and we denote it by $\dummy{V}$.
Notice that $\dummy{V}$, like $\proj_V$, is natural in $V$. Each
$\dummy{V}$ has a right adjoint $\all_V:\fib_{V\times\Om}\ii\fib_V$. Notice
that $\all_V$ is not assumed to be a ccc-representation. Both the functor
$\all_V$ and the adjunction $\allnat_V:\dummy{V}\adjoint\all_V$ are assumed
to be natural in $V$.  The naturality of $\allnat$ in $V$ means that for
all $C\in\fib_W$ and $D\in\fib_{W\times\Om}$ and for all $\phi:V\ii W$,
\begin{equation}\label{eqn-nat-aV}
	\vcenter{\xymatrix@C+2em{
	{\homfib{W\times\Om}{\dummy{W}C,D}}
	\ar[d]_<>(.5){\fib_{\phi\times\Om}}
	\ar[r]^<>(.5){\allnat_{W,C,D}}_<>(.5){\sim}
&	{\homfib{W}{C,\all_W D}}
	\ar[d]^<>(.5){\fib_{\phi}}
\\	{\homfib{V\times\Om}{\dummy{V}C',D'}}
	\ar[r]_<>(.5){\allnat_{V,C',D'}}^<>(.5){\sim}
&	{\homfib{V}{C',\all_VD'},}
	}}
\end{equation}
where $C'=\fib_{\phi}C$ and $D'=\fib_{\phi\times\Om}D$.  In the literature
on hyperdoctrines and universal quantification {\cite{See83,Cub97}}, the
condition that $\all$ is natural in $V$ is sometimes relaxed: one only
requires that $\fib_{\phi}\all_W$ and $\all_V\fib_{\phi\times\Om}$ are
naturally isomorphic as functors $\fib_{W\times\Om}\ii\fib_V$. In this
case, condition (\ref{eqn-nat-aV}) is replaced by the so-called {\defit
Beck-Chevalley condition\index{Beck-Chevalley condition}}. In our setting,
the Beck-Chevalley condition and (\ref{eqn-nat-aV}) are equivalent.
\end{remarks}

\noindent
The adjunction $\dummy{V}\adjoint\all_V$ can be described concretely in
terms of its co-unit $\dummy{V}\all_VD\catarrow{\allcounit_{V,D}}D$ by the
following property: for every object $C\in\fib_V$ and every morphism
$g:\dummy{V}C\ii D$, there exists a unique $h=\allnat_V{g}:C\ii\all_VD$
such that
\[	\xymatrix{
	{\dummy{V}\all_VD}
	\ar[r]^<>(.5){\allcounit_{V,D}}
&	D
\\	{\dummy{V}C.}
	\ar[u]^{\dummy{V}h}
	\ar[ur]_{g}
	}
\]
In analogy to product diagrams and exponential diagrams (see
Section~\ref{subsec-definition-ccc}), we call a diagram of the form
$\dummy{V}E\catarrow{f}D$ with the above universal property a {\defit
$\all$-diagram\index{all-diagram@$\all$-diagram}\index{diagram!all-diagram@$\all$-diagram}}.
Condition (\ref{eqn-nat-aV}) is equivalent to the requirement that
$\fib_{\phi}$ preserves $\all$-diagrams, {\ie}
$\fib_{\phi}\allcounit_{W,D}=\allcounit_{V,\fib_{\phi}D}$ for all
$\phi:V\ii W$ and $D\in\fib_{W\times\Om}$.

\begin{definition}
Let $\calB=\tuple{\base,\Om,\fib,\fibnat,\all,\allnat}$ and
$\calB'=\tuple{\base',\Om',\fib',\fibnat',\all',\allnat'}$ be
{\PL}-categories.  A {\defit
{\PL}-re\-pre\-sen\-ta\-tion}\index{pl-category@{\PL}-category!representation
of}\index{functor!pl-representation@{\PL}-representation}\index{representation!of
pl-categories@of {\PL}-categories} $\tuple{B,\ffib}:\calB\ii\calB'$ is a
finite product preserving functor $B:\base\ii\base'$ together with a
natural transformation $\ffib:\fib\ii\fib'\cp B$, such that $B\Om=\Om'$ and
for all $V\in\base$, $C\in\fib_V$, and $D\in\fib_{V\times\Om}$:
\[	\vcenter{\xymatrix{
	{\homof{\base}{V,\Om}}
	\ar[r]^<>(.5){\fibnat_V}_<>(.5){\sim}
	\ar[d]_{B}
&	{\Obj{\fib_V}}
	\ar[d]^{\Obj{\ffib_V}}
\\	{\homof{\base'}{BV,\Om'}}
	\ar[r]_<>(.5){\fibnat'_{BV}}^<>(.5){\sim}
&	{\Obj{\fib'_{BV}},}
	}}
\ssep\microfilm{\hspace{-1em}}
	\vcenter{\xymatrix{
	{\fib_{V\times\Om}}
	\ar[r]^<>(.5){\all_V}
	\ar[d]_{\ffib_{V\times\Om}}
&	{\fib_V}
	\ar[d]^{{\ffib_V}}
\\	{\fib'_{BV\times\Om'}}
	\ar[r]_<>(.5){\all'_{BV}}
&	{\fib'_{BV},}
	}}
\ssep\microfilm{\hspace{-1em}}
	\vcenter{\xymatrix{
	{\homfib{V\times\Om}{\dummy{V}C,D}}
	\ar[r]^<>(.5){\allnat_{V,C,D}}_<>(.5){\sim}
	\ar[d]_{\ffib_{V\times\Om}}
&	{\homfib{V}{C,\all_VD}}
	\ar[d]^{{\ffib_V}}
\\	{\homfib{BV\times\Om'}{\dummyp{BV}C',D'}}
	\ar[r]_<>(.5){\allnat'_{BV,C',D'}}^<>(.5){\sim}
&	{\homfib{BV}{C',\all_{BV}D'},}
	}}
\]
where $C'=\ffib_VC$ and $D'=\ffib_{V\times\Om}D$. The condition that
$\ffib$ preserves $\allnat$ can be equivalently expressed in terms of
$\all$-diagrams by requiring
$\ffib_{V\times\Om}(\allcounit_{V,D})=\allcounit'_{BV,D'}$.

Notice that $\ffib$ is a natural transformation of functors $\base\ii\Ccc$;
in particular, each $\ffib_V:\fib_V\ii\fib'_{BV}$ is a ccc-representation.

Small {\PL}-categories and {\PL}-representations form a category, which we
denote by $\CatPL$. 
\end{definition}

\noindent 
We will now consider a notion of congruence relation on a
{\PL}-category.  We are only concerned about congruences on the
morphisms of the fibers, and not on the morphisms or objects of the
base.

\begin{definition}
A {\defit
{\PL}-congruence\index{pl-category@{\PL}-category!congruence}\index{congruence!on
pl-category@on
{\PL}-category}\index{pl-category@{\PL}-category!congruence}} $\sim$ on a
{\PL}-category $\calB$ is given by a family of equivalence relations on the
hom-set of the fibers, {\ie}, an equivalence relation $\sim_{V,C,D}$ on
$\homfib{V}{C,D}$ for each $V\in\base$ and $C,D\in\fib_V$, such that for
each $V$, $\sim_V$ is a ccc-congruence on $\fib_V$ (see
Definition~\ref{def-ccc-cong}), and in addition:
\[	\deriv{f\sim_{V\times\Om,\dummy{V}C,D}f'}
		{\allnat_V{f}\sim_{V,C,\all_VD}\allnat_V{f'}}
\]
\end{definition}

\noindent
If $\pair{B,\ffib}:\calB\ii\calB'$ is a {\PL}-representation, then its
{\defit kernel\index{kernel!of a pl-representation@of a
{\PL}-representation}} is a {\PL}-congruence on $\calB$, defined by
$f\sim_{V,C,D}g$ iff $\ffib_Vf=\ffib_Vg$, for all $f,g\in\homfib{V}{C,D}$.

Conversely, let $\sim$ be a {\PL}-congruence on $\calB$. One can define the
{\defit quotient} $\calB/{\sim}$ by taking the quotient
$\homfib{V}{C,D}/{\sim_{V,C,D}}$ at each hom-set of the fibers; one checks
that this is a well-defined {\PL}-category with the same base category as
$\calB$.

%----------------------------------------------------------------------
\subsection{Henkin-{\PL}-representations}\label{subsec-henkin-pl}

A {\defit pre-structure\index{pre-structure}} $\prestr=\pair{\Mbase,\Mfib}$
consists of a base category $\Mbase$ with finite products and a
contravariant functor $\Mfib:\Mbase^{\op}\ii\Ccc$. For any pair of objects
$V,W\in\Mbase$, we consider the first projection $\proj_{V,W}:V\times W\ii
V$, and the associated functor
$\Mfib_{\proj_{V,W}}:\Mfib_V\ii\Mfib_{V\times W}$, which we again call the
{\defit dummy functor\index{dummy functor}}, and which we denote by
$\dummy{V,W}$. We say that a diagram $\dummy{V,W}C\catarrow{f}D$ in
$\Mfib_{V\times W}$ is a {\defit partial $\all$-diagram\index{partial
all-diagram@partial $\all$-diagram}\index{diagram!partial
all-diagram@partial $\all$-diagram}} if for every object $C'\in\Mfib_V$ and
every morphism $g:\dummy{V,W}C'\ii D$, there exists {\em at most} one
$h:C'\ii C$ such that
\[	\xymatrix{
	{\dummy{V,W}C}
	\ar[r]^<>(.5){f}
&	D
\\	{\dummy{V,W}C'.}
	\ar[u]^{\dummy{V,W}h}
	\ar[ur]_{g}
	}
\]
A {\defit Henkin natural transformation\index{Henkin natural
transformation}\index{natural transformation!Henkin}} between functors
$F,G:\base\ii\Ccc$ is a natural transformation $H:\ucat F\ii\ucat G$ such
that for each $V\in\base$, $H_V$ is a Henkin representation of ccc's.

Analogous to Henkin representations of cartesian-closed categories, we can
now define Henkin representations of {\PL}-categories:

\begin{definition}
Let $\calB=\tuple{\base,\Om,\fib,\fibnat,\all,\allnat}$ be a {\PL}-category
and $\prestr=\pair{\Mbase,\Mfib}$ be a pre-structure.  A {\defit
Henkin-{\PL}-representation}%
\index{Henkin-pl-representation@Henkin-{\PL}-representation}%
\index{representation!Henkin-pl@Henkin-{\PL}}%
\index{functor!Henkin-pl-representation@Henkin-{\PL}-representation}%
\index{pl-category@{\PL}-category!representation of!Henkin-pl-representation@Henkin-{\PL}-representation}%
$\pair{B,H}:\calB\ii\prestr$ is a finite product preserving functor
$B:\base\ii\Mbase$ together with a Henkin natural transformation
$H:\ucat{\fib}\ii\ucat{\Mfib\cp B}$, such that for all $V\in\base$ and
$D\in\fib_{V\times\Om}$,
\[	\dummy{BV,B\Om}(H_V\all_VD) =
	H_{V\times\Om}\dummy{V}\all_VD
	\catarrow{H_{V\times\Om}\allcounit_{V,D}}
	H_{V\times\Om}D
\]
is a partial $\all$-diagram. Notice that, by naturality of $H$,
\[	\xymatrix{
	{\fib_V}\ar[r]^<>(.5){H_V}\ar[d]_{\dummy{V}=\fib_{\proj_V}}
&	{M_{BV}}\ar[d]^{\dummy{BV,B\Om}=M_{B\proj_V}}
\\	{\fib_{V\times\Om}}\ar[r]_<>(.5){H_{V\times\Om}}
&	{M_{BV\times B\Om}.}
	}
\]
\end{definition}

\begin{lemma}\label{lem-kernel-henkin-pl}\index{kernel!of a 
Henkin-pl-representation@of a Henkin-{\PL}-representation} The kernel of a
Henkin-{\PL}-representation $\pair{B,H}:\calB\ii\prestr$, defined for all
$f,g\in\homfib{V}{C,D}$ by $f\sim_{V,C,D}g$ iff $H_Vf=H_Vg$, is a
{\PL}-congruence on $\calB$.
\end{lemma}

\begin{proof}
For each $V\in\base$, $H_V:\fib_V\ii\Mfib_{BV}$ is a Henkin representation
of ccc's, and hence $\sim_V$ is a ccc-congruence on $\fib_V$ by
Lemma~\ref{lem-kernel-henkin-ccc}. It remains to be seen that for
$C\in\fib{V}$ and $D\in\fib{V\times\Om}$, $f\sim_{V\times\Om
,\dummy{V}C,D}f'$ implies $\allnat_V{f}\sim_{V,C,\all_VD}\allnat_V{f'}$.
Suppose $f,f'\in\homfib{V\times\Om}{\dummy{V}C,D}$ with
$H_{V\times\Om}f=H_{V\times\Om}f'$. One has
\[	\vcenter{\xymatrix{
	{\dummy{V}\all_VD}
	\ar[r]^<>(.5){\allcounit_{V,D}}
&	{D}
\\	{\dummy{V}C}
	\ar[u]^{\dummy{V}\allnat_V f}
	\ar[ur]_{f}
	}}
\ssep\imp\ssep
	\vcenter{\xymatrix@C+1em{
	{\dummy{BV,B\Om}H_V\all_VD}
	\ar@{=}[r]
&	{H_{V\times\Om}\dummy{V}\all_VD}
	\ar[r]^<>(.5){H_{V\times\Om}\allcounit_{V,D}}
&	{H_{V\times\Om}D}
\\	{\dummy{BV,B\Om}H_VC}
	\ar@{=}[r]
	\ar[u]^{\dummy{BV,B\Om}H_V\allnat_V f}
&	{H_{V\times\Om}\dummy{V}C.}
	\ar[u]^{H_{V\times\Om}\dummy{V}\allnat_V f}
	\ar[ur]_{H_{V\times\Om}f}
	}}
\]
The top row is a partial $\all$-diagram, hence the arrow $H_V\allnat_{V}f$
is uniquely determined by $H_{V\times\Om}f$.  Since there is an identical
diagram for $f'$, and since $H_{V\times\Om}f=H_{V\times\Om}f'$ by
assumption, one has $H_V\allnat_{V}f=H_V\allnat_{V}f'$.\eot
\end{proof}

\begin{definition}
We say that a Henkin-{\PL}-representation $\pair{B,H}$ is a {\defit
Henkin-{\PL}-embedding}\index{Henkin-pl-embedding@Henkin-{\PL}-embedding}\index{embedding!Henkin-pl@Henkin-{\PL}}
if its kernel is the trivial congruence, {\ie} if $H_V$ is a Henkin
embedding for each $V$. Notice that we do not require $B$ to be an
embedding of the base; it seems unnecessary to do so since we are only
concerned with equality in the fibers.
\end{definition}

%----------------------------------------------------------------------
\subsection{Standard structures}

Consider a cartesian-closed category $\Dd$. Let
$\stan{\Dd}$\index{category!standard structure@standard structure
$\stan{\Dd}$} be the pre-structure $\pair{\Set,M}$, where the base category
is the category of sets, and the functor $M:\Set\ii\Ccc$ maps a set $X$ to
$\Dd^X$, the $X$-fold power of $\Dd$. We call this pre-structure the
{\defit standard structure over $\Dd$\index{standard structure}}.

For a ccc, we considered the point functor $\Gamma:\Cc\ii\Set$. We now
consider an analogue to this functor for {\PL}-categories. Consider a
{\PL}-category $\calB=\tuple{\base,\Om,\fib,\fibnat,\all,\allnat}$,
together with a functor $H^0:\fib_1\ii\Dd$. We define
$\Gamma_{H^0}=\pair{B,H}$, where $B:\base\ii\Set$ is the point functor of
the base category, mapping $V$ to the hom-set $\homof{\base}{1,V}$, and
$H:\fib_V\ii_V M_{BV}=\Dd^{BV}$ is the natural transformation defined on
objects by $H_V{C}(x)=H^0(\fib_xC)$, where $C\in\fib_V$ and $x\in
BV=\hom{1,V}$. The following proposition gives a sufficient condition for
$\pair{B,H}$ to be Henkin-{\PL}-embedding.

\begin{proposition}\label{pro-standard-embedding}
The pair $\pair{B,H}$ is a Henkin-{\PL}-embedding $\calB\ii\stan{\Dd}$ if
the following hold:
\begin{enumerate}
\item $H^0$ is a Henkin embedding,
\item $H^0$ preserves monic cones, and
\item the functors $\fib_x:\fib_V\ii\fib_1$, where $x:1\ii V$, form a
collective embedding for each $V\in\base$.
\end{enumerate}
\end{proposition}

\begin{proof}
Clearly $B$ preserves products and $H$ is natural. What remains to be shown
is that each $H_V$ is a Henkin embedding, and that the condition on
$\all$-diagrams is satisfied.  First, notice that $H_V:\F_V\ii\Cc^{BV}$
factors as
\[	\xymatrix{
	{F_V}
	\ar[d]_{\family{F_x}{x\in BV}}
	\ar[dr]^{H_V}
\\	{F_1^{BV}}
	\ar[r]_<>(.5){(H^0)^{BV}}
&	{\Cc^{BV}.}
	}
\]
Clearly, $\family{F_x}{x\in BV}$ is a ccc representation; by assumption 3,
it is also an embedding. Assumption 1 implies that $(H^0)^{BV}$ is a Henkin
embedding, hence $H_V$ is a Henkin embedding for every $V$. Now suppose
$\dummy{V}\all_VD\catarrow{\allcounit_{V,D}}D$ is a $\all$-diagram in
$\calB$. We need to show that
\[	\dummy{BV,B\Om}(H_V\all_VD) =
	H_{V\times\Om}\dummy{V}\all_VD
	\catarrow{H_{V\times\Om}\allcounit_{V,D}}
	H_{V\times\Om}D
\]
is a partial $\all$-diagram. Unraveling the definitions, this amounts to
showing that for each $y\in BV$, the collection of morphisms
\[	\family{
	H^0\all_1 C
	\catarrow{H^0\fib_z\allcounit_{1,C}}
	H^0\fib_z C
	}{z:1\ii\Om}
\]
is collectively monic, where $C=F_{y\times\Om}D$. Since $H^0$ preserves
monic cones by assumption 2, it suffices to show that for every
$C\in\fib_{\Om}$, the family 
\[	\family{\all_1 C\catarrow{\fib_z\allcounit_{1,C}}\fib_z C}{z:1\ii\Om}
\] 
is collectively monic. Let $f\neq g:A\ii\all_1C$. Then
$\allnat^{-1}f\neq\allnat^{-1}g:\dummy{1}A\ii C$.  By assumption 3, there
is $z:1\in\Om$ with $F_z\allnat^{-1}f\neq F_z\allnat^{-1}g$, {\ie}
$F_z(\allcounit_{1,C}\cp\dummy{1}f)\neq F_z(\allcounit_{1,C}\cp
\dummy{1}g)$. But $F_z\dummy{1}=\id_{\fib_1}$, hence
$(F_z\allcounit_{1,C})\cp f\neq (F_z\allcounit_{1,C})\cp g$, which proves
the claim.\eot
\end{proof}

%----------------------------------------------------------------------
\subsection{Freely adjoining arrows to the base of a {\PL}-category}

Given a {\PL}-category $\calB=\tuple{\base,\Om,\fib,\fibnat,\all,\allnat}$,
we may freely adjoin an arrow $x:1\ii U$ to the base as follows: Let
$\base'$ be the Kleisli category of the comonad $T(V)=U\times V$, {\ie}
$\base'$ has the same objects as $\base$ and
$\homof{\base'}{V,W}=\homof{\base}{U\times V,W}$ (compare
Section~\ref{subsec-ccxa}). Define $\fib':{\base'}^{\op}\ii\Ccc$ by
$\fib'_V=\fib_{U\times V}$; this is natural in $V$. Define $\Om'=\Om$,
$\fibnat'_V=\fibnat_{U\times V}$, $\all'_V=\all_{U\times V}$, and
$\allnat'_{V,C,D}=\allnat_{U\times V,C,D}$. It is trivial to check that
$\calB'=\tuple{\base',\Om',\fib',\fibnat',\all',\allnat'}$ is indeed a
{\PL}-category; for instance $\all'_V=\all_{U\times V}:\fib_{U\times
V\times\Om}\ii\fib_{U\times V}$ is indeed right adjoint to
$\dummyp{V}=\dummy{U\times V}:\fib_{U\times V}\ii\fib_{U\times
V\times\Om}$.  Let $\jota=\pair{B_0,G_0}:\calB\ii\calB'$ be the natural
{\PL}-representation, defined by $B_0{\phi}=\phi\cp\projb$ and
$(G_0)_V=\dummy{V}:\fib_V\ii\fib'_V=\fib_{U\times V}$. Let
$x\in\homof{\base'}{1,U}$ be $\id\in\homof{\base}{U,U}$.  We write $\calB'$
as $\polynom{\calB}{\adjpoint{x}{U}}$, which is justified by its universal
property:

\begin{proposition}
$\polynom{\calB}{\adjpoint{x}{U}}$ has the following universal property:
for any {\PL}-representation
$\pair{B,\microfilm{\linebreak}\ffib}:\calB\ii{\cal D}$ and any arrow
$\psi:1\ii BU$ in ${\cal D}$, there is a unique {\PL}-representation
$\pair{\extension{B},\extension{\ffib}}:\polynom{\calB}{\adjpoint{x}{U}}\ii{\cal
D}$ such that
\[	\xymatrix{
	{\calB}
	\ar[r]^<>(.5){\jota}
	\ar[dr]_{\pair{B,\ffib}}
&	{\polynom{\calB}{\adjpoint{x}{U}}}
	\ar[d]^{\pair{\extension{B},\extension{\ffib}}}
\\&	{\cal D}}
\]
and $\extension{B}x=\psi$. 
\end{proposition}

\begin{proof}
Let $B'$ map an object $V$ to $BV$ and a morphism
$\phi\in\homof{\base'}{V,W}=\homof{\base}{U\times V,W}$ to
$BV\catarrow{\psi\times\id}BU\times BV\catarrow{B\phi}BW$. Define
$\ffib'_V$ by
\[	\xymatrix{
	{\fib'_V}
	\ar[r]_<>(.5){\ffib'_V}
	\ar@{=}[d]
&	{D_{BV}.}
\\	{\fib_{U\times V}}
	\ar[r]_<>(.5){\ffib_{U\times V}}
&	{D_{BU\times BV}}
	\ar[u]_{D_{\psi\times\id}}
	}
\]
It is readily checked that this is the unique {\PL}-representation with the
desired properties.\eot
\end{proof}

\begin{lemma}\label{lem-adj-base-embedding}
The canonical {\PL}-representation
$\jota:\calB\ii\polynom{\calB}{\adjpoint{x}{\Om}}$ is a {\PL}-embedding.
\end{lemma}

\begin{proof}
In $\calB$, there is always a point $\psi:1\in\Om$, for instance
$\fibnat^{-1}1$. The unique extension
$\polynom{\calB}{\adjpoint{x}{\Om}}\ii\calB$ of the identity that sends $x$
to $\psi$ is a left inverse to $\jota$.\eot
\end{proof}

\begin{proposition}\label{pro-wellp-base-embedding}
Any {\PL}-category $\calB$ can be {\PL}-embedded in a {\PL}-category
$\calB'$ such that the functors $\fib'_z:\fib'_{{\Om}^n}\ii\fib'_1$, where
$z:1\ii{\Om}^n$, form a collective embedding for each $n$.
\end{proposition}

\begin{proof}
To $\calB$, adjoin countably many arrows $1\ii\Om$ by constructing a
sequence $\calB=\calB_0\catarrow{\jota_0}\calB_1\catarrow{\jota_1}\cdots$
of {\PL}-categories, where
$\calB_{i+1}=\polynom{\calB_i}{\adjpoint{x_i}{\Om}}$ and $\jota_i$ is the
canonical embedding.  Notice that the $n$-fiber of $\calB_i$ is the
$n+i$-fiber of $\calB$. Let $\calB'$ be the colimit of this sequence, {\ie}
the objects of the base are the same as for each $\calB_i$, and the
hom-sets of the base and objects and hom-sets of the fibers are constructed
as the directed unions of the respective parts of the $\calB_i$. It is
easily checked that $\calB'$ is a {\PL}-category with a canonical
{\PL}-embedding $\jota:\calB\ii\calB'$.  To show that the functors
$\fib'_z:\fib'_{{\Om}^n}\ii\fib'_1$ form a collective embedding, it suffices
to show that for every $V$, the functors $\fib'_{V\times
x}:\fib'_{V\times\Om}\ii\fib'_V$ form a collective embedding, where
$x:1\ii\Om$. Consider two morphisms $f\neq g:C\ii D$ in
$\fib'_{V\times\Om}$. Then $C,D,f$, and $g$ already exist in some
$\calB_i$. Consider $x_i:1\ii\Om$ in $\calB_{i+1}$. Writing $F^i$ for the
fiber functor of $\calB_i$, one has
\[	\xymatrix{
	{\fib^i_{V\times\Om}}		
	\ar[dr]^{\id}	\arembed[d]_{\jota_i}
\\	{\fib^{i+1}_{V\times\Om}}	
	\ar[r]_<>(.5){\fib^{i+1}_{V\times x_i}}
&	{\fib^{i+1}_V,}	
	}
\]
hence $\fib^{i+1}_{V\times x_i}\jota_if\neq \fib^{i+1}_{V\times
x_i}\jota_ig$, which implies $\fib'_{V\times x_i}f\neq\fib'{V\times x_i}g$.
\eot
\end{proof}

%----------------------------------------------------------------------
\subsection{Henkin-{\PL}-representation theorems}

\subsubsection{Henkin-{\PL}-representations in $\stan{\neSet}$}
\index{Henkin-pl-representation@Henkin-{\PL}-representation!in setplusx@in
$\stan{\neSet}$}

\begin{lemma}\label{lem-epics-lift}
If the 0-fiber of a {\PL}-category has the property that $A\iiepic1$ for
every object $A$, then the same is true for any $n$-fiber.
\end{lemma}

\begin{proof}
Let $\all_n:\fib_{\Om^n}\ii\fib_1$ be the right adjoint of the canonical
functor $\dummy{n}=\fib_{\termarrow}:\fib_1\ii\fib_{\Om^n}$. Let $C,D$ be
objects of $\fib_{\Om^n}$ and consider $f,g:1\ii D$ such that
\[\begin{array}{cr}
&	\xymatrix{
	{C}\ar@{->}[r]
&	{1}\ar@<1ex>[r]^<>(.5)f\ar@<-1ex>[r]_<>(.5)g
	\ar@{}[r]|<>(.5){\nocommute}
& 	{D}
	}
\\\imp&
	\xymatrix{
	{\all_nC}\arepic[r]
&	{1=\all_n1}
	\ar@<1ex>[r]^<>(.5){\all_nf}\ar@<-1ex>[r]_<>(.5){\all_ng}
	\ar@{}[r]|<>(.5){\nocommute}
& 	{\all_nD}
	}
\\\imp&
	\xymatrix{
	{\dummy{n}\all_n1}\ar@{->}[r]
&	{1}\ar@<1ex>[r]^<>(.5)f\ar@<-1ex>[r]_<>(.5)g
	\ar@{}[r]|<>(.5){\nocommute}
& 	{D.}
	}
\end{array}\]
But both $\dummy{n}$ and $\all_n$ preserve
terminators, hence $\dummy{n}\all_n1=1$ and $f=g$.
\eot
\end{proof}

\begin{theorem}\label{thm-henkin-pl-repr-ne}
Let $\calB$ be a {\PL}-category whose base is generated by $\Om$. Then
$\calB$ can be Henkin-{\PL}-embedded in $\stan{\neSet}$, the standard
structure over $\neSet$, if and only if for every object $A$ of the
0-fiber, the morphism $A\iiepic 1$ is epic.
\end{theorem}

\begin{proof}
\begin{caselist}
\caseimp Trivial, because  a Henkin-{\PL}-embedding
$\calB\ii\stan{\neSet}$ gives rise to a Henkin embedding $\fib_1\ii\neSet$,
and embeddings reflect epics.
\casepmi By Lemma~\ref{lem-epics-lift}, $C\iiepic 1$ holds for all objects
of all fibers. By Proposition~\ref{pro-wellp-base-embedding}, $\calB$ can
be embedded in a {\PL}-category $\calB'$ such that the functors
$\fib'_z:\fib'_{V}\ii\fib'_1$ form a collective embedding, for every
$V\in\base$. Note that in the sequence of {\PL}-categories
$\family{\calB_i}{i}$ constructed in the proof of
Proposition~\ref{pro-wellp-base-embedding}, the $0$-fiber of $\calB_i$ is
the $n$-fiber of $\calB$. Hence, $C\iiepic 1$ holds for all objects of
$\fib^i_1$, and therefore for all objects of $\fib'_1$ as well.  By
Theorem~\ref{thm-henkin-repr-neset}, there is a Henkin embedding
$H^0:\fib'_1\catarrow{F_{\calA}}\Dd\catarrow{\Point}\neSet$. By
Lemma~\ref{lem-prop-cc-ccxa}, $F_{\calA}$ preserves monic cones, and so
does the point functor $\Point$. Therefore,
Proposition~\ref{pro-standard-embedding} is applicable and we obtain a
Henkin-{\PL}-embedding $\calB'\ii\stan{\neSet}$. \eot
\end{caselist}
\end{proof}

\subsubsection{Henkin-{\PL}-representations in $\stan{\Set^P}$}
\index{Henkin-pl-representation@Henkin-{\PL}-representation!in setP@in
$\stan{\Set^P}$}

\begin{theorem}\label{thm-henkin-pl-repr-kripke}
Any {\PL}-category $\calB$ can be Henkin-{\PL}-embedded in $\stan{\Set^P}$,
for some poset $P$.
\end{theorem}

\begin{proof}
By Proposition~\ref{pro-wellp-base-embedding}, $\calB$ can
be embedded in a {\PL}-category $\calB'$ such that the functors
$\fib'_z:\fib'_{V}\ii\fib'_1$ form a collective embedding, for every
$V\in\base$. By Theorem~\ref{thm-henkin-repr-presheaf}, there is a Henkin
embedding $H^0:\fib'_1\ii\Set^P$, for some poset $P$, such that $H^0$
preserves monic cones. With Proposition~\ref{pro-standard-embedding}, one
obtains a Henkin-{\PL}-embedding of $\calB'$ in $\stan{\Set^P}$. \eot
\end{proof}

%======================================================================
\section{The interpretation of the polymorphic lambda calculus}
\label{sec-henkin-5}

%......................................................................
\begin{table*}[tbp]
\caption{Typing rules for the polymorphic lambda calculus}
\label{tab-poly-lambda-terms}
\[
\begin{array}{rc}
	\tjApp
&	\deriv{\Gamma\tj M:\all\alpha.\tau}
		{\Gamma\tj M\sigma:\subst{\tau}{\sigma}{\alpha}}
\nl	\tjLam
&	\deriv{\Gamma\tj M:\tau\sep\alpha\not\in\FTVTof{\Gamma}}
		{\Gamma\tj\Lamabs{\alpha}{M}:\all\alpha.\tau}
\end{array}
\]
\end{table*}
%......................................................................
\begin{table*}[tbp]
\caption{Equational rules for the polymorphic lambda calculus}
\label{tab-poly-equations}
\[
\begin{array}{rc}
	\plcongf
&	\deriv{\Gamma\eqj M=M':\all\alpha.\tau}
		{\Gamma\eqj M\sigma=M'\sigma:\tau}
\nl	\plcongg
&	\deriv{\Gamma\eqj M=M':\tau\sep\alpha\not\in\FTVTof{\Gamma}} 	
	  {\Gamma\eqj\Lamabs{\alpha}{M}=\Lamabs{\alpha}{M'}:\all\alpha.\tau}
\end{array}
\begin{array}{rc}
	\plBeta
&	\deriv{}{\Gamma\eqj(\Lamabs{\alpha}{M})\sigma=\subst{M}{\sigma}{\alpha}:\tau}
\nl	\plEta
&	\deriv{\alpha\not\in\FTVof{M}}
		{\Gamma\eqj\Lamabs{\alpha}{(M\alpha)}=M:\all\alpha.\tau}
\end{array}
\]
\end{table*}
%......................................................................

%----------------------------------------------------------------------
\subsection{The polymorphic lambda calculus}\index{lambda
	calculus!polymorphic}\index{polymorphic lambda
	calculus}\index{typed lambda calculus} 

The polymorphic lambda calculus was independently introduced by Girard
{\cite{Gir71}} and Reynolds {\cite{Rey74}}. Here, we describe a version of
the second order lambda calculus with surjective pairing and a unit type.

Let $\TVars$ be an infinite set of {\defit type
variables\index{type!variable}\index{variable!type}} $\alpha,\beta,\ldots$,
and let $\TConst$ be a set of {\defit type constants\index{type!constant}}
$t,u,\ldots$.  {\defit Polymorphic types\index{type!polymorphic}}
$\sigma,\tau,\ldots$ are given by the grammar:
\[	\sigma\bnf\alpha \bor t \bor 1 \bor\sigma\times\tau
	\bor\sigma\ii\tau \bor\all\alpha.\sigma.
\]
Let $\Vars$ be an infinite set of {\defit individual
variables\index{individual variable}\index{variable!individual}}
$x,y,\ldots$. For each closed type $\sigma$, let $\Const_{\sigma}$ be a set
of {\defit individual constants\index{individual
constant}\index{constant!individual}} $c^{\sigma},d^{\sigma},\ldots$.  The
collection $\pair{\TConst,\family{\Const_{\sigma}}{\sigma}}$ is also called
a {\defit polymorphic signature\index{polymorphic
signature}\index{signature!polymorphic}}.  {\defit Raw polymorphic lambda
terms\index{raw lambda term!polymorphic}\index{lambda term!raw}}
$M,N,\ldots$ are given by the grammar:
\[	M\bnf x \bor c^{\sigma} \bor\unit \bor\pair{M,N} \bor\lpra{M}
	\bor\lprb{M} \bor MN \bor\lamabs{x}{\sigma}{M}\bor
	M\sigma \bor\Lamabs{\alpha}{M}.
\]
As usual, the individual variable $x$ is
bound\index{free!variable}\index{bound variable, in lambda
calculus}\index{variable!free and bound} in the term
$\lamabs{x}{\sigma}{M}$.  Moreover, the type variable $\alpha$ is bound in
the term $\Lamabs{\alpha}{M}$ and in the type $\all\alpha.\sigma$. All
other occurrences of variables are free, and we write $\FVof{M}$ for the
free individual variables and $\FTVof{M}$ for the free type variables of a
term $M$, as well as $\FTVTof{\sigma}$ for the free type variables of a
type $\sigma$.  We identify types, as well as raw terms, up to renaming of
bound variables.  There are three kinds of substitution: substitution of
types in types $\subst{\tau}{\sigma}{\alpha}$, substitution of types in
terms $\subst{M}{\sigma}{\alpha}$, and substitution of terms in terms
$\subst{M}{N}{x}$.

A {\defit type assignment\index{type assignment!polymorphic}}
$\Gamma=\typ{x_1}{\sigma_1},\typ{x_2}{\sigma_2}
,\ldots,\typ{x_m}{\sigma_m}$ is defined as for the simply-typed lambda
calculus.  We write $\FTVTof{\Gamma}=\FTVTof
{\sigma_1}\cup\ldots\cup\FTVTof{\sigma_m}$.  The {\defit valid typing
judgments\index{valid typing judgment!polymorphic}\index{typing
judgment!polymorphic}} $\Gamma\tj M:\sigma$ of the polymorphic lambda
calculus are derived by the rules in Tables~\ref{tab-simple-lambda-terms}
and {\ref{tab-poly-lambda-terms}}.  An {\defit equation\index{equation!of
polymorphic lambda calculus}} is again an expression of the form
$\Gamma\eqj M=N:\sigma$, where $\Gamma\tj M:\sigma$ and $\Gamma\tj
N:\sigma$ are valid typing judgments.  If $E$ is an equation and $\Eqns$ is
a set of equations, we write $\Eqns\entailspl E$ if $E$ can be derived from
$\Eqns$ by the rules for the simply-typed lambda calculus in
Table~\ref{tab-simple-equations}, together with the one for the polymorphic
lambda calculus in Table~\ref{tab-poly-equations}.  $\Eqns$ is called a
{\defit theory\index{theory!polymorphic}} if it is closed under
derivability.  The smallest theory of the polymorphic lambda calculus (for
a fixed polymorphic signature) is denoted by $\theorypl$.\index{pure lambda
theory!polymorphic}

%----------------------------------------------------------------------
\subsection{Strict interpretation in a {\PL}-category}

Fix a polymorphic signature. A {\defit (strict)
interpretation\index{interpretation!in
pl-category@in {\PL}-category}\index{strict
interpretation!of polymorphic lambda calculus}\index{model!of polymorphic
lambda calculus}\index{model!strict}} $I$ of the polymorphic lambda
calculus in a {\PL}-category $\calB$, which we schematically write as
$I:\theorypl\ii\calB$, consists of an interpretation of types and an
interpretation of typing judgments, both relative to a sequence
$\baral=\alpha_1,\ldots\\alpha_n$ of type variables. A type $\sigma$ with
$\FTVTof{\sigma}\seq\{\baral\}$ is interpreted as an object
$\semia{\sigma}$ of $\fib_{\Om^n}$. A valid typing judgment $\Gamma\tj
M:\tau$ with $\FTVTof{\Gamma,M,\tau}\seq\{\baral\}$ is interpreted as a
morphism $\semia{\Gamma\tj M:\tau}$ of $\fib_{\Om^n}$. Like for the
simply-typed lambda calculus, an interpretation $I$ is uniquely determined
by its values on type constants and individual constants.

Let $\constinterp:\TConst\ii\Obj{\fib_1}$ be an interpretation of type
constants as objects of the 0-fiber.  This extends uniquely to an
interpretation $\semi{\sigma}{\alpha_1,\ldots,\alpha_n}$ of every type.
Recall that $\fibnat$ is the natural isomorphism
$\hom{V,\Om}\iiso_V\Obj{\fib_V}$, and that
$\fib_{\termarrow}:\fib_1\ii\fib_{\Om^n}$ is the ccc-representation induced
by the unique morphism $\termarrow:\Om^n\ii 1$. We assume that bound
variables are renamed as necessary.
\[\begin{array}{rcl}
	\semia{\alpha_i}
&=&	\fibnat_{\Om^n}\proj_i\mbox{, where
	$\proj_i\in\hom{\Om^n,\Om}$ is the $i$th projection}
\\	\semia{t}
&=&	\fib_{\termarrow}\constinterp(t)
\\	\semia{1}
&=&	1
\\	\semia{\sigma\times\tau}
&=&	\semia{\sigma}\times
	\semia{\tau}
\\	\semia{\sigma\ii\tau}
&=&	(\semia{\tau})^{
	\semia{\sigma}}
\\	\semia{\all\alpha'.\sigma}
&=&	\all_{\Om^n}\semi{\sigma}{\baral,\alpha'}
\end{array}\]

\noindent
If $C$ is any object of $\fib_V$, then it corresponds, via $\fibnat$,
to a morphism of the base $\phi:V\ii\Om$. The morphism
$\pair{\id_V,\phi}:V\ii V\times\Om$ gives rise to a functor
$\fib_{\pair{\id_V,\phi}}:\fib_{V\times\Om}\ii\fib_{V}$, which we
denote by $\Substof{V}{C}$. We call this functor the {\defit
substitution functor}.

\begin{lemma}
The following are properties of the interpretation of polymorphic types:\rm
\begin{enumerate}
\item {\bf Permutation of Type Variables.}
The interpretation is independent of the ordering of the free type
variables, or of the addition of dummy variables, in the following
sense: If $s:\{1,\ldots,k\}\ii\{1,\ldots,n\}$ is injective and
$\FTVTof{\tau}\seq\{\alpha_{s1},\ldots,\alpha_{sk}\}$, then 
\[	\semi{\tau}{\alpha_1,\ldots,\alpha_n}=
	\fib_{\tuple{\proj_{s1},\ldots,\proj_{sk}}}
	\semi{\tau}{\alpha_{s1},\ldots,\alpha_{sk}}.
\]
In particular, if $\alpha'\not\in\FTVTof{\sigma}$, then
$\semi{\sigma}{\baral,\alpha'}=\dummy{\Om^n}\semia{\sigma}$. 
\item {\bf Type Substitution.}
For all types $\sigma$ and $\tau$ with $\FTVof{\sigma}\seq\{\baral\}$
and $\FTVof{\tau}\seq\{\baral,\alpha'\}$,
\[	\semia{\subst{\tau}{\sigma}{\alpha'}}
	= 
	\Substof{\Om^n}{\semia{\sigma}}\semi{\tau}{\baral,\alpha'}.
\]
\end{enumerate}
\eottwo
\end{lemma}

\noindent 
Notice that
$\Substof{V}{C}\cp\dummy{V}=\fib_{\pair{\id_V,\phi}}\cp\fib_{\proj_V}
=\id_{\fib_V}$. Therefore, applying $\Substof{V}{C}$ to the co-unit
$\allcounit_{V,D}:\dummy{V}\all_VD\ii D$ yields a natural
transformation $\inst_{V,C,D}:\all_VD\ii_D\Substof{V}{C}D$, which will
be useful for the interpretation of type application.

If $\Gamma=\typ{x_1}{\sigma_1},\ldots,\typ{x_m}{\sigma_m}$ is a type
assignment, we write
$\semia{\Gamma}=\semia{\sigma_1}\times\cdots\times\semia{\sigma_m}$. Let
$\constinterp_{\sigma}:\Const_{\sigma}\ii\homfib{1}{1,\semi{\sigma}{}}$ be
an interpretation of term constants as morphisms of the 0-fiber, for each
closed type $\sigma$. This extends uniquely to an interpretation
$\semia{\Gamma\tj M:\tau}$ of valid typing judgments:
{\microfilm{\small}\[\begin{array}{rcl} \semia{\Gamma\tj x_j:\sigma_j} &=&
\semia{\Gamma}\catarrow{\proj_j}\semia{\sigma_j} \mbox{, the $j$th
projection}
\\	\semia{\Gamma\tj c^{\sigma}:\sigma}
&=&	\semia{\Gamma}\catarrow{\termarrow}1
	\catarrow{\fib_{\termarrow}\constinterp_{\sigma}(c^{\sigma})}\semia{\sigma}
\\	\semia{\Gamma\tj\unit:1}
&=&	\semia{\Gamma}\catarrow{\termarrow}1=\semia{1}
\\	\semia{\Gamma\tj\pair{M,N}:\sigma\times\tau}
&=&	\semia{\Gamma}\catarrow{\pair{\semia{\Gamma\tj M:\sigma},
	\semia{\Gamma\tj N:\tau}}}\semia{\sigma}\times\semia{\tau}
	=\semia{\sigma\times\tau}
\\	\semia{\Gamma\tj\lpra M:\sigma}
&=&	\semia{\Gamma}\catarrow{\semia{\Gamma\tj M:\sigma\times\tau}}
	\semia{\sigma}\times\semia{\tau}\catarrow{\proja}
	\semia{\sigma}
\\	\semia{\Gamma\tj\lprb M:\tau}
&=&	\semia{\Gamma}\catarrow{\semia{\Gamma\tj M:\sigma\times\tau}}
	\semia{\sigma}\times\semia{\tau}\catarrow{\projb}
	\semia{\sigma}
\\	\semia{\Gamma\tj MN:\tau}
&=&	\semia{\Gamma}\catarrow{\pair{\semia{\Gamma\tj M:\sigma\ii\tau},
	\semia{\Gamma\tj N:\sigma}}}(\semia{\tau})^{\semia{\sigma}}\times
	\semia{\sigma}\catarrow{\appl}\semia{\tau}
\\	\semia{\Gamma\tj\lamabs{x}{\sigma}{M}:\sigma\ii\tau}
&=& 	\semia{\Gamma}
	\catarrow{\curry{(\semia{\Gamma,\typ{x}{\sigma}\tj M:\tau})}} 
	(\semia{\tau})^{\semia{\sigma}}=\semia{\sigma\ii\tau}
\\	\semia{\Gamma\tj M\sigma:\subst{\tau}{\sigma}{\alpha'}}
&=&	\semia{\Gamma}\catarrow{\semia{\Gamma\tj M:\all\alpha'.\tau}}
	\all_{\Om^n}\semi{\tau}{\baral,\alpha'}
	\catarrow{\inst\void{_{\Om^n,\semia{\sigma},\semi{\tau}{\baral
	,\alpha'}}}}
	\Substof{\Om^n}{\semia{\sigma}}\semi{\tau}{\baral,\alpha'}
	=\semia{\subst{\tau}{\sigma}{\alpha'}}
\\	\semia{\Gamma\tj\Lamabs{\alpha'}{M}:\all\alpha'.\tau}
&=&	\semia{\Gamma}\catarrow{\allnat_{\Om^n}(\semi{M}{\baral,\alpha'})}
	\all_{\Om^n}\semi{\tau}{\baral,\alpha'}=\semia{\all\alpha'.\tau}
\end{array}\]}

\begin{lemma} 
The interpretation of the polymorphic lambda calculus in a {\PL}-category,
defined inductively as above, has the expected properties:\rm
\begin{enumerate}
\item {\bf Permutation of Type Variables.}
If $s:\{1,\ldots,k\}\ii\{1,\ldots,n\}$ is injective and the free type
variables $\FTVof{\Gamma,M,\tau}\seq\{\alpha_{s1},\ldots,\alpha_{sk}\}$,
then
\[	\semi{\Gamma\tj M:\tau}{\alpha_1,\ldots,\alpha_n}=
	\fib_{\tuple{\proj_{s1},\ldots,\proj_{sk}}}
	\semi{\Gamma\tj M:\tau}{\alpha_{s1},\ldots,\alpha_{sk}}.
\]
\item {\bf Permutation of Individual Variables.}
If $s:\{1,\ldots,l\}\ii\{1,\ldots,m\}$ is injective and
$\FVof{M}\seq\{x_{s1},\ldots,x_{sl}\}$, and if
$\Gamma'=\typ{x_1}{\sigma_1},\ldots\typ{x_m}{\sigma_m}$ and
$\Gamma=\typ{x_{s1}}{\sigma_{s1}},\ldots\typ{x_{sl}}{\sigma_{sl}}$ 
then
\[	\xymatrix{
	{\semia{\Gamma'}}
	\ar[rr]^{\semia{\Gamma'\tj M:\tau}}
	\ar[dr]_{\tuple{\proj_{s1},\ldots,\proj_{sl}}}
&&	{\semia{\tau}.}
\\&	{\semia{\Gamma}}
	\ar[ur]_{\semia{\Gamma\tj M:\tau}}
	}
\]
\item {\bf Type Substitution.}
Whenever $\FTVof{\Gamma,M,\tau}\seq\{\baral,\alpha'\}$ and
$\FTVof{\sigma}\seq\{\baral\}$, then
\[	\semia{\subst{(\Gamma\tj M:\tau)}{\sigma}{\alpha'}}
	= 
	\Substof{\Om^n}{\semia{\sigma}}\semi{\Gamma\tj M:\tau}{\baral,\alpha'}.
\]
\item {\bf Term Substitution.}
Let $\Gamma=\typ{x_1}{\sigma_1},\ldots\typ{x_m}{\sigma_m}$ and
$\Gamma'=\typ{y_1}{\rho_1},\ldots\typ{y_l}{\rho_l}$, and suppose
$\Gamma\tj M:\tau$ and $\Gamma'\tj N_j:\sigma_j$ for
$j=1,\ldots,m$. Then
\[	\xymatrix{
	{\semia{\Gamma'}}
	\ar[rr]^{\semia{\Gamma'\tj\subst{M}{\bar{N}}{\bar{x}}:\tau}}
	\ar[dr]_<>(.3)*+{\labelstyle\tuple{\semia{\Gamma'\tj
	N_1:\sigma_1},\ldots,\semia{\Gamma'\tj N_n:\sigma_n}}}
&&	{\semia{\tau}.}
\\&	{\semia{\Gamma}}
	\ar[ur]_{\semia{\Gamma\tj M:\tau}}
	}
\]
\end{enumerate}
\eottwo
\end{lemma}

\noindent
As usual, we say that an interpretation $I$ {\defit satisfies} an equation
$\Gamma\eqj M=N:\tau$, in symbols $I\models\Gamma\eqj M=N:\tau$, if
$\semia{\Gamma\tj M:\tau}=\semia{\Gamma\tj N:\tau}$.  This notion is
independent of $\baral$, as long as $\FTVof{\Gamma,M,N ,\tau}\seq\baral$.
We write $\modelsclass$ for semantic consequence in a class
$\classofmodels$ of {\PL}-categories, meaning $\Eqns\modelsclass E$ if all
interpretations in a {\PL}-category in $\classofmodels$ that satisfy
$\Eqns$ also satisfy $E$.

\begin{proposition}[Seely {\cite{See87}}] {\bf Soundness.}
\[	\mbox{$\Eqns\entailspl E$ \ssep implies \ssep 
	$\Eqns\models_{\CatPL} E$.}
\]
\eottwo
\end{proposition}

\noindent
If $\Th$ is a theory and $I:\theorypl\ii\calB$ is an interpretation such
that $I\models\Th$, then we also write $I:\Th\ii\calB$.  An interpretation
can be post-composed with a {\PL}-representation in an evident way:
$\Th\lowcatarrow{I}\calB\lowcatarrow{G}\calB'$ is the interpretation $J$
defined by $\semsuper{\sigma}{\baral}{J}=G\semia{\sigma}$ and
$\semsuper{\Gamma\tj M:\tau}{\baral}{J}=G\semia{\Gamma\tj M:\tau}$.

%----------------------------------------------------------------------
\subsection{The {\PL}-category associated to a theory}

From a theory $\Th$ over a polymorphic signature, one constructs a
{\PL}-category
$\freepl{\Th}=\tuple{\base,\Om,\fib,\fibnat,\microfilm{\linebreak}\all,\allnat}$
as follows: Fix an enumeration $\alpha_1,\alpha_2,\ldots$ of type
variables, and fix an individual variable $x$. The base $\base$ has
countably many objects, which we denote $1,\Om,\Om^2,\ldots$; the hom-set
$\hom{\Om^n,\Om^k}$ is given by all $k$-tuples
$\tuple{\sigma_1,\ldots,\sigma_k}$ of polymorphic types with
$\FTVTof{\sigma_1,\ldots,\sigma_k}\seq\{\alpha_1,\ldots,\alpha_n\}$.
Composition is given by substitution:
\[	\Om^n\catarrow{\tuple{\sigma_1,\ldots,\sigma_k}}
	\Om^k\catarrow{\tuple{\tau_1,\ldots,\tau_l}}
	\Om^l
\ssep=\ssep
	\tuple{\subst{\tau_1}{\sigma_i}{\alpha_i}
	,\ldots,\subst{\tau_l}{\sigma_i}{\alpha_i}},
\]
where $\subst{\tau}{\sigma_i}{\alpha_i}$ denotes the simultaneous
substitution of $\sigma_1,\ldots,\sigma_k$ for $\alpha_1,\ldots,\alpha_k$.
The identity at $\Om^n$ is $\tuple{\alpha_1,\ldots,\alpha_n}$. One checks
that the base has finite products.

The objects of the $n$-fiber are defined via
$\Obj{\fib_{\Om^n}}=\hom{\Om^n,\Om}$, {\ie} they are polymorphic types
$\sigma$ with $\FTVTof{\sigma}\seq\{\alpha_1,\ldots,\alpha_n\}$.  The
morphisms $\morphnamed{M}\in\homfib{\Om^n}{\sigma,\tau}$ of the $n$-fiber
are named by terms $M$ such that $\typ{x}{\sigma}\tj M:\tau$ is a valid
typing judgment.  Two terms $M$ and $N$ name the same morphism if
$\Th\entailspl\typ{x}{\sigma}\eqj M=N:\tau$. Just as in the construction of
the ccc associated to a simply-typed theory (see
Section~\ref{subsec-free-ccc}), one checks that $\fib$ is indeed
cartesian-closed. The action of $\fib$ on morphisms $\phi:\Om^n\ii\Om^k$ of
the base is as follows: $\fib_{\tuple{\sigma_1,\ldots,\sigma_k}}$ maps
objects $\tau$ to $\subst{\tau}{\sigma_i}{\alpha_i}$ and morphisms
$\morphnamed{M}$ to $\morphnamed{\subst{M}{\sigma_i}{\alpha_i}}$. This
defines a ccc-representation $\fib_{\Om^k}\ii\fib_{\Om^n}$. Notice that
$\dummy{\Om^n}\sigma=\sigma$.  The right adjoint $\all_{\Om^n}$ acts on
objects as $\all_{\Om^n}\sigma=\all\alpha_{n+1}.\sigma$. The adjunction
$\allnat_{\Om^n,\sigma,\tau}:\homfib{\Om^{n+1}}{\sigma,\tau}\ii\homfib
{\Om^n}{\sigma,\all\alpha_{n+1}.\tau}$ is given by
$\allnat_{\Om^n,\sigma,\tau}\morphnamed{M}
=\morphnamed{\Lamabs{\alpha_{n+1}}{M}}$.

\begin{proposition}[Seely {\cite{See87}}]
The above construction yields a well-defined {\PL}-category $\freepl{\Th}$.
There is a canonical strict interpretation $I_0:\Th\ii\freepl{\Th}$ with
$\sema{\sigma}{I_0}=\sigma$ and $\sema{\typ{x}{\sigma}\tj
M:\tau}{I_0}=\morphnamed{M}:\sigma\ii\tau$.  Moreover, $I_0$ has the
following universal property: For any strict interpretation
$J:\Th\ii\calB$, there is a unique {\PL}-representation
${\ffib}:\freepl{\Th}\ii\calB$ such that
\[	\xymatrix{
	{\Th}
	\ar[d]_{I_0}
	\ar[dr]^{J}
\\	{\freepl{\Th}}
	\ar[r]_<>(.5){\ffib}
&	{\calB.}
	}
\]
\eottwo
\end{proposition}

\begin{corollary}{\bf Completeness of {\PL}-categories for the polymorphic
lambda calculus.} Each theory $\Th$ of the polymorphic lambda calculus
arises as the theory of some strict interpretation in a {\PL}-category. Hence,
\[	\mbox{$\Eqns\models_{\CatPL} E$ \ssep implies \ssep 
	$\Eqns\entailspl E$.}
\]
\eottwo
\end{corollary}

%----------------------------------------------------------------------
\subsection{The non-strict interpretation of the polymorphic lambda calculus}

A {\defit non-strict interpretation\index{non-strict interpretation!of
polymorphic lambda calculus}\index{model!of polymorphic lambda
calculus}\index{interpretation!in pl-category@in
{\PL}-category!non-strict}\index{model!non-strict}\index{model!of
polymorphic lambda calculus}} of the polymorphic lambda calculus in a
pre-structure $\prestr$, denoted $I:\theorypl\ii\prestr$, is a
Henkin-{\PL}-representation $H:\freepl{\theorypl}\ii\prestr$. One defines
$\sema{\sigma}{I}=H\sema{\sigma}{I_0}$ and $\sema{\Gamma\tj
M:\tau}{I}=H\sema{\Gamma\tj M:\tau}{I_0}$.  The notations $I\models E$, as
well as $\Eqns\modelsnsclass E$, have their usual meanings. The following
Soundness Theorem is a consequence of
Lemma~\ref{lem-kernel-henkin-pl}. Again, completeness is evident, since the
class of non-strict interpretations includes the class of strict ones.

\begin{proposition}{\bf Soundness of the Non-Strict Interpretation.}
\[	\mbox{$\Eqns\entailspl E$ \ssep implies \ssep 
	$\Eqns\modelsns_{\CatPL}E$.}
\]
\eottwo
\end{proposition}

\noindent
A non-strict interpretation of the polymorphic lambda calculus in a
standard structure $\stan{\Dd}$ is called a {\defit standard
model\index{standard model}\index{model!standard models of
polymorphism}}. The case $\Dd=\neSet$ gives rise to set-theoretic models
with non-empty types which are closely related to the environment-style
models that were described by Bruce and Meyer {\cite{BM84}}. The case
$\Dd=\Set^P$ gives rise to polymorphic Kripke models. Finally, the case
$\Dd=\Set$ gives rise to set-theoretic models of polymorphism with possibly
empty types. We will leave the discussion of the latter class of models for
elsewhere.

%======================================================================
\section{From Henkin-{\PL}-representation theorems to polymorphic
completeness theorems}
\label{sec-henkin-6}

%----------------------------------------------------------------------
\subsection{Set-theoretic models with non-empty types}
\label{subsec-compl-pl-ne}
\index{model!with empty types}
\index{set-theoretic model!with empty types}
\index{empty types}

A {\defit set-theoretic model of polymorphism with non-empty
types\index{set-theoretic model!of polymorphism}\index{set-theoretic
model!with non-empty types}\index{model!set-theoretic}\index{model!with
non-empty types}\index{non-empty types}} is a non-strict interpretation in
the standard structure $\stan{\neSet}$. Write $\modelsnsnepl$ for semantic
consequence with respect to this class of models.

\begin{theorem}{\bf Soundness and Completeness for set-theoretic models 
of polymorphism with non-emp\-ty types.}  The rule $\plne$ is sound for
set-theoretic models of polymorphism with non-empty types. Moreover, any
theory that is closed under $\plne$ arises from such an
interpretation. Consequently, 
\[	\mbox{$\Eqns\modelsnsnepl E$ \ssep if and only if \ssep
	$\Eqns\entailsplne E$.}
\]
\end{theorem}

\begin{proof}
Soundness follows from Lemma~\ref{lem-epics-lift} and the remarks in
Section~\ref{subsec-categorical-nonempty}. For completeness, let $\Th$ be a
theory that is closed under $\plne$. Let $I_0:\Th\ii\freepl{\Th}$ be the
canonical interpretation. Because of the rule $\plne$, one has $C\iiepic1$
for all objects of the base, hence, by Theorem~\ref{thm-henkin-pl-repr-ne},
there is a Henkin-{\PL}-embedding $H:\freepl{\Th}\ii\stan{\neSet}$. Then
the interpretation $I=H\cp I_0$ satisfies exactly $\Th$.\eot
\end{proof}

%----------------------------------------------------------------------
\subsection{Polymorphic Kripke models}
\label{subsec-compl-pl-kripke}

A {\defit polymorphic Kripke model\index{polymorphic Kripke
model}\index{model!Kripke}\index{Kripke lambda model!polymorphic}} is a non-strict interpretation in a standard
structure $\stan{\Set^P}$ where $P$ is a poset. Semantic consequence for
this class of models is denoted by $\modelsnsPpl$.

\begin{theorem}{\bf Soundness and Completeness for polymorphic Kripke models.} 
Each polymorphic lamb\-da the\-o\-ry is the theory of some polymorphic Kripke
model. Therefore, 
\[	\mbox{$\Eqns\modelsnsPpl E$ \ssep if and only if \ssep 
	$\Eqns\entailspl E$.}
\]
\end{theorem}

\begin{proof}
This is a direct consequence of
Theorem~\ref{thm-henkin-pl-repr-kripke}.\eot
\end{proof}

%======================================================================
\cleardoublepage
\chapter{First-Order Axioms for Asynchrony}\label{cha-asynch}

The distinction between {\em synchronous} and {\em asynchronous}
communication is a relevant issue in the design and analysis of distributed
and concurrent networks.  Intuitively, communication is said to be
synchronous\index{synchrony}\index{communication!synchronous}\index{channel!synchronous}
if messages are sent and received simultaneously, via a `handshake' or
`rendez-vous' of sender and receiver.  It is asynchronous%
\index{asynchrony}\index{communication!asynchronous}%
\index{channel!asynchronous}
if messages travel through a communication medium with possible delay, such
that the sender cannot be certain if or when a message has been received.

Asynchronous communication is often studied in the framework of concurrent
process pa\-ra\-digms such as the asynchronous $\pi$-calculus, which was
originally introduced by Honda and Tokoro {\cite{HT91}}, and which was
independently discovered by Boudol {\cite{Bou92}} as a result of his work
with Berry on chemical abstract machines {\cite{BB92}}. Another such
asynchronous paradigm is the join calculus, which was recently proposed by
Fournet and Gonthier as a calculus of mobile agents in distributed networks
with locality and failure {\cite{FG96,FGLMR96}}.

In this chapter, we study properties of asynchronous communication in
general, not with regard to any particular process calculus. We give a
general-purpose, mathematically rigorous definition of asynchrony, and then
we show that this notion can be equivalently characterized by a small number
of first-order axioms. We model processes by labeled transition systems
with input and output, a framework that is sufficiently general to fit
concurrent process paradigms such as the $\pi$-calculus or the join
calculus, as well as data flow models and other such formalisms.  These
transition systems are similar to Lynch and Stark's input/output automata
{\cite{LS89}}, but our treatment is more category-theoretic and close in
spirit to Abramsky's interaction categories {\cite{Abr94,AGN94}}.

Various properties of asynchrony have been exploited in different contexts
by many authors.  For instance, Lynch and Stark {\cite{LS89}} postulate a
form of {\em input receptivity} for their automata. Palamidessi
{\cite{Pal97}} makes use of a certain {\em confluence} property to prove
that the expressive power of the asynchronous $\pi$-calculus is strictly
less than that of the synchronous $\pi$-calculus. Axioms similar to the
ones that are presented here have been postulated by Shields {\cite{Shi85}}
and Bednarczyk {\cite{Bed88}} for a notion of asynchronous labeled
transition systems, but without the input/output distinction which is
central to the present approach.

The main novelty of our approach is that the axioms are not postulated
{\apriori}, but derived from more primitive notions. We define asynchrony in
elementary terms: an agent is asynchronous if its input and/or output is
filtered through a communication medium, such as a buffer or a queue,
possibly with feedback. We then show that our first- and second-order
axioms precisely capture each of these notions. This characterization
justifies the axioms {\aposteriori}.  As a testbed and for illustration, we
apply these axioms to an asynchronous version of Milner's CCS, and to the
core join calculus.


%============================================================================
\section{An elementary definition of asynchrony}\label{sec-def}

If $R$ is a binary relation, we write $R^{-1}$ for the inverse
relation and $R^*$ for the reflexive, transitive closure of $R$. We
also write $\ired{}$ for $\red{}^{-1}$, etc. The binary identity
relation on a set is denoted $\idrel$. The composition of two binary
relations $R$ and $Q$ is written $R\cp Q$ or simply $RQ$, {\ie} $xRQz$
if there exists $y$ such that $xRyQz$. We write $xR$ for the unary
relation $\{y|xRy\}$, and similarly $Ry$ for $\{x|xRy\}$. The disjoint
union of sets $X$ and $Y$ is denoted by $X+Y$.

%----------------------------------------------------------------------------
\subsection{Labeled transition systems and bisimulation}

To keep this chapter self-contained, we summarize the standard
definitions for labeled transition systems and weak and strong
bisimulation. 

\begin{definition}
A {\defit labeled transition system (\lts)\/}\index{labeled transition
system}\index{transition system|see{labeled transition
system}}\index{lts@\lts|see{labeled transition system}} is a tuple
$\Ss=\tuple{S,A,{\red{}}_{\Ss},s_0}$, where $S$ is a set of {\defit
states}\index{state!of labeled transition system}, $A$ is a set of {\defit
actions}\index{action}, ${\red{}}_{\Ss}\seq S\times A\times S$ is a {\defit
transition relation}\index{transition relation} and $s_0\in S$ is an
{\defit initial state}\index{initial state of labeled transition
system}\index{state!initial}.  We call $A$ the {\defit type}\index{type!of
a labeled transition system} of $\Ss$, and we write $\Ss\from A$.
\end{definition}

\noindent We often omit the subscript on ${\red{}}_{\Ss}$, and we write
$\abs{\Ss}$ for the set of states $S$. For $\alpha\in A$, we regard
$\rea $ as a binary relation on $\abs{\Ss}$ via $s\rea s'$ iff
$\tuple{s,\alpha,s'}\in{\red{}}$.
The definitions of strong and weak bisimulation rely on the following
principle of co-inductive definition:

\begin{principle}\label{prin-1}
Let $X$ be a set and $\Pred$ a property of subsets of $X$. If
$\Pred(R)$ is defined by clauses of the form $\Ff_i(R)\seq\Gg_i(R)$,
where $\Ff_i$ and $\Gg_i$ are set-valued, monotone operators, and if
$\Ff_i$ preserves unions, then $\Pred$ is closed under unions. In
particular, there is a maximal $R_{\it max}\seq X$ with $\Pred(R_{\it
max})$.
\end{principle}

\begin{proof}
Since $\Ff_i$ preserves unions, it has a right adjoint $\Ff'_i$. Then
$\Pred(R)\iff\forall i.\Ff_i(R)\seq\Gg_i(R)\iff
R\seq\bigcap_i\Ff'_i\Gg_i(R)$. Hence $\Pred$ is the set of
pre-fixpoints of a monotone operator and therefore closed under least
upper bounds. Let $R_{\it max}=\bigcup\{R\such\Pred(R)\}$. \eot
\end{proof}

\begin{definition}
Let $\Ss$ and $\Tt$ be {\ltss} of type $A$.  A binary relation
$R\seq\abs{\Ss}\times\abs{\Tt}$ is a {\defit strong
bisimulation}\index{strong bisimulation}\index{bisimulation!strong} if for
all $\alpha\in A$, $R{\red{\alpha}}\seq{\red{\alpha}}R$ and
$R^{-1}{\red{\alpha}}\seq{\red{\alpha}}R^{-1}$.  In diagrams:
\[	\diagxc {s} {R} {t} {\alpha} {t'} 
\imp 	\exists s'.
	\diagcc {s} {R} {t} {\alpha} {\alpha} {s'} {R} {t'}
\sep{\rm and}\sep
	\diagcx {s} {R} {t} {\alpha} {s'}
\imp 	\exists t'.
	\diagcc {s} {R} {t} {\alpha} {\alpha} {s'} {R} {t'}
\]
Next, we consider {\ltss} with a distinguished action $\tau\in A$, called
the {\defit silent}\index{silent action}\index{action!silent or
unobservable}\index{agent!silent action} or the {\defit unobservable}\index{unobservable action}
action. Let $\Redt$ be the relation $\sred{\tau}$.  For $a\in
A\setminus{\tau}$, let $\Red{a}$ be the relation
${\sred{\tau}}{\red{a}}{\sred{\tau}}$.  A binary relation
$R\seq\abs{\Ss}\times\abs{\Tt}$ is a {\defit weak bisimulation}\index{weak
bisimulation}\index{bisimulation!weak} if for all $\alpha\in A$,
$R{\red{\alpha}}\seq{\Red{\alpha}}R$ and
$R^{-1}{\red{\alpha}}\seq{\Red{\alpha}}R^{-1}$.  In diagrams:
\[	\diagxc {s} {R} {t} {\alpha} {t'} 
\imp 	\exists s'.
	\diagCc {s} {R} {t} {\alpha} {\alpha} {s'} {R} {t'}
\sep{\rm and}\sep
	\diagcx {s} {R} {t} {\alpha} {s'}
\imp 	\exists t'.
	\diagcC {s} {R} {t} {\alpha} {\alpha} {s'} {R} {t'}
\]
By Principle~\ref{prin-1}, it follows that there is a { maximal} strong
bisimulation, which we denote by $\sbis$, and a maximal weak bisimulation,
which we denote by $\wbis$. We say that $s\in\abs{\Ss}$ and $t\in\abs{\Tt}$
are {\defit strongly (weakly) bisimilar} if $s\sbis t$ ($s\wbis t$).
Finally, $\Ss$ and $\Tt$ are said to be strongly (weakly) bisimilar if
$s_0\sbis t_0$ ($s_0\wbis t_0$).
\end{definition}

\begin{remark}
Note that $R\seq\abs{\Ss}\times\abs{\Tt}$ is a weak bisimulation if
and only if for all $\alpha\in A$,
$R{\Red{\alpha}}\seq{\Red{\alpha}}R$ and
$R^{-1}{\Red{\alpha}}\seq{\Red{\alpha}}R^{-1}$.
\end{remark}

\noindent If $\Ss,\Tt,\Uu$ are {labeled transition systems} and if
$R\seq\abs{\Ss}\times\abs{\Tt}$ and $Q\seq\abs{\Tt}\times\abs{\Uu}$
are weak (respectively, strong) bisimulations, then so are the
identity relation $\idrel\seq\abs{\Ss}\times\abs{\Ss}$, the inverse
$R^{-1}\seq\abs{\Tt}\times\abs{\Ss}$, and the composition $R\cp
Q\seq\abs{\Ss}\times\abs{\Uu}$. Hence weak and strong bisimilarity
each define a {\em global} equivalence relation on the class of all
states of all possible labeled transition systems.
 
In particular, $\sbis$ and $\wbis$, as binary relations on an {\lts} $\Ss$,
are equivalence relations. We denote the respective equivalence classes of
a state $s$ by $[s]_{\sbis}$ and $[s]_{\wbis}$.  On the quotient
$\Ss/{\sbis}$, we define transitions $[s]_{\sbis}\red{a}[t]_{\sbis}$ iff
$s\red{a}\sbis t$, making it into a well-defined transition
system. Similarly, on $\Ss/{\wbis}$, we define
$[s]_{\wbis}\red{a}[t]_{\wbis}$ iff $s\red{a}\wbis t$. For all $s\in\Ss$,
one has $s\sbis[s]_{\sbis}$ and $s\wbis[s]_{\wbis}$, and hence
$\Ss\sbis(\Ss/{\sbis})$ and $\Ss\wbis(\Ss/{{\wbis}})$. We say that $\Ss$ is
{\defit $\sbis$-reduced}\index{reduced agent@$\sbis$-reduced agent} if
$\Ss=\Ss/{\sbis}$, and {\defit
$\wbis$-reduced}\index{reduced agent@$\wbis$-reduced agent} if $\Ss=\Ss/{\wbis}$.

%----------------------------------------------------------------------------
\subsection{Input, output and sequential composition}
\label{subsec-io-comp}

So far we have distinguished only one action: the silent action $\tau$. We
will now add further structure to the set of actions by distinguishing
input and output actions. Let $\lin$ and $\lout$ be constants.  For any
sets $X$ and $Y$, define a set of {\defit input actions}\index{input
actions}\index{action!input and output}\index{agent!input and output
action} $\Ain{X}\eqdef\{\lin\}\times X$, and a set of {\defit output
actions}\index{output actions}\index{agent!output action}
$\Aout{Y}\eqdef\{\lout\}\times Y$. Note that $\Ain{X}$ and $\Aout{Y}$ are
disjoint. We will write input and output actions as $\ain{x}$ and
$\aout{x}$ instead of $\pair{\lin,x}$ and $\pair{\lout,x}$,
respectively. Let $\B$ be a set whose elements are not of the form
$\ain{x}$, $\aout{y}$ or $\tau$. The elements of $\Bb+\{\tau\}$ are called
{\defit internal actions}\index{internal
actions}\index{action!internal}\index{agent!internal action}.

\begin{definition}
We define $X\jjB Y$ to be the set $\Ain{X}+\Aout{Y}+\B+\{\tau\}$. A labeled
transition system $\Ss$ of type $X\jjB Y$ is called an {\defit
{\lts}}\index{labeled transition system!with input and
output|see{agent}}\index{input and output!labeled transition system
with|see{agent}}, or simply an {\defit agent}\index{agent}.  If $\B$ is
empty, we will omit the subscript in $X\jjB Y$.
\end{definition}

\noindent The traditional CCS notation is ``$x$'' for input actions and
``$\bar{x}$'' for output actions. We use $\ain{x}$ and $\aout{x}$
instead to emphasize the distinction between a message $\ain{x}$ and
its content $x$.

Our labeled transition systems with input and output
are similar to the input/output automata of Lynch and Stark
{\cite{LS89}}.  However, we consider a notion of sequential
composition that is more in the spirit of Abramsky's interaction
categories {\cite{Abr94,AGN94}}.  Given two agents $\Ss\from X\jjB Y$
and $\Tt\from Y\jjB Z$, we define $\Ss;\Tt\from X\jjB Z$ by feeding
the output of $\Ss$ into the input of $\Tt$. This is a special case of
parallel composition and hiding. Notice that this notion of sequential
composition is different from the one of CSP or ACP, where $\Tt$
cannot start execution until $\Ss$ is finished.

Sequential composition, together with certain other agent constructors
that we will investigate in Section~\ref{subsec-operations}, can be
used to build arbitrary networks of agents.

\begin{n-definition}\label{def-composition}
Let $\Ss\from X\jjB Y$ and $\Tt\from Y\jjB Z$ be agents with respective
initial states $s_0$ and $t_0$. The {\defit sequential
composition}\index{sequential
composition}\index{composition!sequential}\index{agent!sequential
composition} $\Ss;\Tt$ is of type $X\jjB Z$. It has states
$\abs{\Ss}\times\abs{\Tt}$ and initial state $\pair{s_0,t_0}$.  The
transitions are given by the following rules:
\[	\deriv{s\rea_{\Ss} s'\sep\mbox{$\alpha$ not output}}
		{\pair{s,t}\brea_{\Ss;\Tt}\pair{s',t}} % boxed rea (for height)
\sep	\deriv{t\rea_{\Tt} t'\sep\mbox{$\alpha$ not input}}
		{\pair{s,t}\brea_{\Ss;\Tt}\pair{s,t'}}
\sep	\deriv{s\rout{y}_{\Ss} s'\sep t\rin{y}_{\Tt} t'}
		{\pair{s,t}\bredt_{\Ss;\Tt}\pair{s',t'}}
\]
\end{n-definition}

\begin{example}
For any set $X$, define an agent $\One_X$ of type $X\jj X$ with states
$X+\{\bot\}$, initial state $\bot$ and transitions $\bot\rin{x}x$
and $x\rout{x}\bot$, for all $x\in X$.  $\One_X$ acts as a buffer of
capacity one: A possible sequence of transitions is
\[ \bot\rin{x}x\rout{x}\bot\rin{y}y\rout{y}\bot\rin{z}z\rout{z}\bot\ldots
\]
Let $X=\{x\}$.  Then $\One_X$ and $\One_X;\One_X$ are the following
agents:
\[	\One_X=\xymatrix{
		*+[o][F-]{\bot}	\ar@/^/[r]^{\ain{x}}
&	*+{x}		\ar@/^/[l]^{\aout{x}}}
\sep
	\One_X;\One_X=\vcenter{\xymatrix{
*++[o][F-]{\pair{\bot,\bot}}	\ar[d]_{\ain{x}}
&	*+{\pair{\bot,x}}	\ar[l]_{\aout{x}}\ar[d]^{\ain{x}}
\\	*+{\pair{x,\bot}}	\ar[ur]_{\tau}
&	*+{\pair{x,x}}		\ar[l]^{\aout{x}} 	}}
\]
Here the initial state of each agent is circled. When representing
agents in diagrams like these, it is often convenient to omit the
names of the states, and to identify weakly bisimilar states. With
that convention, we write:
\[
	\One_X=\xymatrix{ *+[o][F-]{\bullet}	\ar@/^/[r]^{\ain{x}}
&	*+{\bullet}			\ar@/^/[l]^{\aout{x}}}
\sep
	\One_X;\One_X\wbis\xymatrix{
*+[o][F-]{\bullet}	\ar@/^/[r]^{\ain{x}}
&	*+{\bullet}	\ar@/^/[l]^{\aout{x}}\ar@/^/[r]^{\ain{x}}
&	*+{\bullet}	\ar@/^/[l]^{\aout{x}}}
\]
Note that $\One_X;\One_X$ is a queue of capacity 2. Let $Y=\{y,z\}$.
The following diagrams represent $\One_Y$ and $\One_Y;\One_Y$:
\[
	\One_Y=\xymatrix{ *+{\bullet}	\ar@/^/[r]^{\aout{z}}
&	*+[o][F-]{\bullet}\ar@/^/[l]^{\ain{z}}\ar@/^/[r]^{\ain{y}}
&	*+{\bullet}\ar@/^/[l]^{\aout{y}}}
\sep
	\One_Y;\One_Y\wbis\vcenter{\xymatrix{ 	&&	*+{\bullet}
\ar@/^/[dr]^{\aout{z}} 	\\	*+{\bullet}
\ar@/^/[r]^{\aout{z}} 	&	*+{\bullet}
\ar@/^/[r]^{\aout{z}} 			\ar@/^/[ur]^{\ain{y}}
\ar@/^/[l]^{\ain{z}} 	&	*+[o][F-]{\bullet}
\ar@/^/[r]^{\ain{y}} 			\ar@/^/[l]^{\ain{z}}
&	*+{\bullet} 			\ar@/^/[r]^{\ain{y}}
\ar@/^/[dl]^{\ain{z}} 			\ar@/^/[l]^{\aout{y}}
&	*+{\bullet} 			\ar@/^/[l]^{\aout{y}}
\\&&	*+{\bullet} 			\ar@/^/[ul]^{\aout{y}} 	}}
\]
Again, $\One_Y;\One_Y$ is a queue of capacity 2. Notice that it is
first-in, first-out.
\end{example}

\noindent Two {\ltss} $\Ss$ and $\Tt$ of type $A$ are {\defit
isomorphic}\index{isomorphism!of labeled transition
systems}\index{agent!isomorphism of} if there is a bijection between
$\abs{\Ss}$ and $\abs{\Tt}$ preserving ${\red{}}$ and initial states.

\begin{lemma}
\begin{enumerate}
\item Sequential Composition of {labeled transition systems} is associative
up to isomorphism.
\item\label{lem-rules-1} The following hold for the composition $\Ss;\Tt$:
\[	\deriv{s\Rea_{\Ss} s'\sep\mbox{$\alpha$ not output}}
		{\pair{s,t}\bRea_{\Ss;\Tt}\pair{s',t}}
\sep	\deriv{t\Rea_{\Tt} t'\sep\mbox{$\alpha$ not input}}
		{\pair{s,t}\bRea_{\Ss;\Tt}\pair{s,t'}}
\sep	\deriv{s\Rout{y}_{\Ss} s'\sep t\Rin{y}_{\Tt} t'}
		{\pair{s,t}\bRedt_{\Ss;\Tt}\pair{s',t'}}
\]
\item\label{lem-rules-2} Sequential Composition of agents respects both
weak and strong bisimulation, {\ie}
\[ 	\deriv{\Ss_1\wbis\Ss_2\sep\Tt_1\wbis\Tt_2}{\Ss_1;\Tt_1\wbis\Ss_2;\Tt_2}
\sep{\rm and}\sep
	\deriv{\Ss_1\sbis\Ss_2\sep\Tt_1\sbis\Tt_2}{\Ss_1;\Tt_1\sbis\Ss_2;\Tt_2}
\]
\end{enumerate}
\end{lemma}

\begin{proof}
\begin{nienumerate}
\item
It is easy to check that $\pair{\pair{s,t},u}\rea
\pair{\pair{s',t'},u'}$ if and only if $\pair{s,\pair{t,u}}\rea
\pair{s',\pair{t',u'}}$.
\item The first two statements are trivial from
Definition~\ref{def-composition}.  For the third one, assume
$s\sred{\tau}s_1\rout{y}s_2\sred{\tau}s'$ and
$t\sred{\tau}t_1\rin{y}t_2\sred{\tau}t'$. Then $\pair{s,t}\sred{\tau}
\pair{s_1,t}\sred{\tau}\pair{s_1,t_1}\redt 
\pair{s_2,t_2}\sred{\tau}\pair{s',t_2}\sred{\tau}\pair{s',t'}$.
\item
Let $\Ss_1,\Ss_2\from X\jjB Y$ and $\Tt_1,\Tt_2\from Y\jjB Z$.
Suppose $Q\seq\abs{\Ss_1}\times\abs{\Ss_2}$ and
$R\seq\abs{\Tt_1}\times\abs{\Tt_2}$ are weak bisimulations. We show
that $Q\times R=\{\pair{\pair{s_1,t_1},\pair{s_2,t_2}}\such s_1Qs_2
\mbox{ and }t_1Rt_2\}\seq\abs{\Ss_1;\Tt_1}\times\abs{\Ss_2;\Tt_2}$ is
a weak bisimulation. It suffices {\wloss} to show one of the two
directions.  Suppose
\[	\diagcx	{\pair{s_1,t_1}}	{Q\times R}	{\pair{s_2,t_2}}
		{\alpha} 		{\pair{s'_1,t'_1}}
\]
for some $\alpha\in X\jjB Z$. There are three cases, depending on
which of the three rules in Definition~\ref{def-composition} was used
to derive $\pair{s_1,t_1}\rea\pair{s'_1,t'_1}$:
\begin{caselist}
\case $s_1\rea s'_1$, $t_1=t'_1$ and $\alpha$ is not output: 
 By $Q$ there is $s'_2$ such that $s_2\Rea s'_2$ and $s'_1Qs'_2$. Let
$t'_2=t_2$.
\case $t_1\rea t'_1$, $s_1=s'_1$ and $\alpha$ is not input:
 By $R$ there is $t'_2$ such that $t_2\Rea t'_2$ and $t'_1Rt'_2$. Let
$s'_2=s_2$.
\case $s_1\rout{y}s'_1$, $t_1\rin{y}t'_1$ and $\alpha=\tau$:
 By $Q$ and $R$, there are $s'_2$ and $t'_2$ such that
$s_2\Rout{y}s'_2$, $s'_1Qs'_2$, $t_2\Rin{y}t'_2$ and $t'_1Rt'_2$.
\end{caselist}
In each case, by {\ref{lem-rules-1}}., 
\[
	\diagcC {\pair{s_1,t_1}}  {Q\times R}  {\pair{s_2,t_2}} 
		{\tau}				{\alpha}
		{\pair{s'_1,t'_1}}{Q\times R} {\pair{s'_2,t'_2}.}
\]
For strong bisimulation, the proof is similar.\eot
\end{nienumerate}
\end{proof}

\noindent Unfortunately, agents do not form a category under sequential
composition: there are no identity morphisms. In
Section~\ref{sec-cats}, we will introduce two categories of agents,
one of which has unbounded buffers as its identity morphisms, and
the other one queues. 

%----------------------------------------------------------------------------
\subsection{Buffers and queues}\label{sec-buf-que}

For any set $X$, let $\fm{X}$ be the free monoid and $\fcm{X}$ the
free commutative monoid generated by $X$. The elements of $\fm{X}$ are
finite sequences. The empty sequence is denoted by $\eword$. The
elements of $\fcm{X}$ are finite multisets. The empty multiset is
denoted by $\eset$.  We define the following agents of type $X\jjB X$:
\begin{enumerate}
\item The {\defit buffer}\index{buffer b@buffer $\Buf$}\index{agent!buffer b@buffer $\Buf$} $\Buf_X$ 
has states $\fcm{X}$, initial state $\eset$, and transitions $w\rin{x}wx$
and $xw\rout{x}w$, for all $w\in\fcm{X}$ and $x\in X$.
\item The {\defit queue}\index{queue q@queue $\Que$}\index{agent!queue q@queue $\Que$} $\Que_X$ has 
states $\fm{X}$, initial state $\eword$, and transitions $w\rin{x}wx$ and
$xw\rout{x}w$, for all $w\in\fm{X}$ and $x\in X$.
\end{enumerate}

\noindent The only difference between the definitions of $\Buf_X$ and $\Que_X$
is whether the states are considered as sequences or multisets. We
will write $\Buf$ and $\Que$ without subscript if $X$ is clear from
the context.  $\Buf$ acts as an infinite capacity buffer which does
not preserve the order of messages. For example, one possible sequence
of transitions is
\[ \emptyset\rin{x}x\rin{y}xy\rin{z}xyz\rout{y}xz\rout{x}z\rin{w}wz\ldots
\]
$\Que$ acts as an infinite capacity first-in, first-out queue. A
possible sequence of transitions is
\[ \epsilon\rin{x}x\rin{y}xy\rout{x}y\rin{z}yz\rin{w}yzw\rout{y}zw\ldots
\]

\begin{lemma}\label{lem-idem}
\begin{enumerate}
\item $\Buf;\Buf\wbis\Buf$ and $\Buf;\Buf\not\sbis\Buf$. 
\item $\Que;\Que\wbis\Que$ and $\Que;\Que\not\sbis\Que$.
\item $\Que;\Buf\wbis\Buf$ and $\Que;\Buf\not\sbis\Buf$.
\item If $|X|\geq 2$, then $\Buf;\Que\not\wbis\Buf$ and 
	$\Buf;\Que\not\wbis\Que$.
\end{enumerate}
\end{lemma}

\begin{proof}
\begin{caselist}
\case[1.-3.:] Define $\pair{u,v}Rw$ iff $vu=w$, where $u$, $v$ and $w$ are
multisets or sequences, as appropriate. In each case, $R$ is a weak
bisimulation.  To see that strong bisimilarity does not hold, observe
that in each case, the composite agent has silent actions, while
$\Buf$ and $\Que$ do not.
\case[4.:] Observe that $\Buf;\Que$ has a transition
$s_0\Rin{x}\Rin{y}s_1$ from its initial state such that
$s_1\Rout{y}\Rout{x}$ is possible, but $s_1\Rout{x}\Rout{y}$ is not.
This is not the case for either $\Buf$ or $\Que$.  Such properties are
preserved under weak bisimulation.
\eot
\end{caselist}
\end{proof}

\noindent The remainder of this chapter is devoted to examining the effect of
composing arbitrary agents with buffers and queues.

%----------------------------------------------------------------------------
\subsection{Notions of asynchrony}\label{subsec-notions}\label{sec-cats}

In the asynchronous model of communication, messages are assumed to
travel through a communication medium or {\em ether}.  Sometimes, the
medium is assumed to be first-in, first-out (a queue); sometimes, as
in the asynchronous $\pi$-calculus, messages might be received in any
order (a buffer).

Our approach is simple: we model the medium explicitly.  An {asynchronous
agent} is one whose output and/or input behaves as if filtered through
either a buffer $\Buf$ or a queue $\Que$. 

\begin{n-definition}\label{def-asynch}
An agent $\Ss\from X\jjB Y$ is
\[\mbox{\begin{tabular}{rcl}
	{\defit out-buffered}\index{out-buffered
	agent}\index{agent!out-buffered} &if& $\Ss\wbis\Ss;\Buf$
\\	{\defit in-buffered}\index{in-buffered agent}\index{agent!in-buffered}
	&if& $\Ss\wbis\Buf;\Ss$
\\	{\defit buffered}\index{buffered agent}\index{agent!buffered}	&if& $\Ss\wbis\Buf;\Ss;\Buf$
\end{tabular}}
\sep
\mbox{\begin{tabular}{rcl}
	{\defit out-queued}\index{out-queued agent}\index{agent!out-queued}
	&if& $\Ss\wbis\Ss;\Que$
\\	{\defit in-queued}\index{in-queued agent}\index{agent!in-queued}
	&if& $\Ss\wbis\Que;\Ss$
\\	{\defit queued}\index{queued agent}\index{agent!queued}
		&if& $\Ss\wbis\Que;\Ss;\Que$
\end{tabular}}
\]
We use the word {\defit asynchrony}\index{asynchrony}\index{communication!asynchronous}\index{channel!asynchronous}
as a generic term to stand for any such property. The reason we distinguish
six different notions is that, although it is probably most common to think
of asynchrony as part of the {\em output} behavior of an agent, it is
equally sensible to regard it as part of the {\em input} behavior, or
both. Since input and output behave somewhat differently, we will study
them separately. Yet another notion of asynchrony, incorporating feedback,
will be defined in Section~\ref{sec-feedback}.
\end{n-definition}

\begin{remark}
Because of Lemma~\ref{lem-idem}, the operation of pre- or post-composing an
agent with $\Buf$ or $\Que$ is idempotent up to $\wbis$. Consequently, any
agent of the form $\Ss;\Buf$ is out-buffered, any agent of the form
$\Buf;\Ss$ is in-buffered, an agent is buffered iff it is in- and
out-buffered, and so on.  Also, each of the six properties is invariant
under weak bisimulation.

Notice that it is almost never the case that an agent $\Ss$ is
strongly bisimilar to $\Ss;\Buf$ or to $\Buf;\Ss$. This will be clear
from the examples in Section~\ref{subsec-examples-buffer-queue}. Weak
bisimulation appears to be the finest equivalence relation that is
sensible for studying asynchrony.  It is also possible to consider
coarser equivalences; the results of this chapter generalize in a
straightforward way to any equivalence on processes that contains weak
bisimulation; see Remark~\ref{rem-other-equivalences}.
\end{remark}

\noindent Let $\B$ be a set. Buffered agents $\Ss\from X\jjB Y$ form
the morphisms of a category $\BUF_\B$, whose objects are sets $X$,
$Y$, etc.; the identity morphism on $X$ is given by the buffer
$\Buf_X$. Similarly, queued agents form a category $\QUE_\B$.  These
categories have a symmetric monoidal structure, which will be
described, along with other constructions on agents, in
Section~\ref{subsec-operations}.

%----------------------------------------------------------------------------
\subsection{Examples}\label{subsec-examples-buffer-queue}

\begin{example}
The first example shows the effect of post-composing different agents
with the buffer $\Buf$.  Notice that although $\Buf$ has infinitely
many states, $\Ss;\Buf$ may have only finitely many states up to weak
bisimulation.

\[
	\Ss=\vcenter{\xymatrix{ *+[o][F-]{s}\ar[d]^{\aout{y}}
\\	*+{t}\ar[d]^{\ain{x}}
\\	*+{u} 	}}
\sep
	\Ss;\Buf_{\{y\}}=\vcenter{\xymatrix{
	*++[o][F-]{\pair{s,\emptyset}}\ar[rd]^{\tau}
&	*+{\pair{s,y}}\ar[l]_{\aout{y}}\ar[rd]^{\tau}
&	*+{\pair{s,y^2}}\ar[l]_{\aout{y}}\ar@{}[r]|{\mbox{$\cdots$}}
&\\	*+{\pair{t,\emptyset}}\ar[d]_{\ain{x}}
&	*+{\pair{t,y}}\ar[l]_{\aout{y}}\ar[d]_{\ain{x}}
&	*+{\pair{t,y^2}}\ar[l]_{\aout{y}}\ar@{}[r]|{\mbox{$\cdots$}}
	\ar[d]_{\ain{x}} 	
&\\	*+{\pair{u,\emptyset}}
&	*+{\pair{u,y}}\ar[l]_{\aout{y}}
&	*+{\pair{u,y^2}}\ar[l]_{\aout{y}}\ar@{}[r]|{\mbox{$\cdots$}}
&	}}
\wbis
	\vcenter{\xymatrix{
	*+[o][F-]{\bullet}\ar[d]_{\ain{x}}\ar[r]^{\aout{y}}
&	*+{\bullet}\ar[d]^{\ain{x}}
\\	*+{\bullet}\ar[r]_{\aout{y}} 	
&	*+{\bullet} 	}}
\]
\end{example}

\begin{example}
\[	
	\Ss=\vcenter{\xymatrix{
	*+[o][F-]{\bullet}\ar[d]_{\ain{x}}\ar[r]^{\aout{y}}\ar[dr]^{\aout{z}} 
&	*+{\bullet}
\\	*+{\bullet}
&	*+{\bullet} 	}}
\sep
	\Ss;\Buf\wbis\vcenter{\xymatrix{
	*+[o][F-]{\bullet}\ar[d]_{\ain{x}}\ar[r]^{\tau}\ar[dr]^{\tau}
&	*+{\bullet}\ar[r]^{\aout{y}} 	
&	*+{\bullet}
\\	*+{\bullet}
&	*+{\bullet}\ar[r]^{\aout{z}} 	
&	*+{\bullet}  	}}
\]
\end{example}

\begin{example}\label{exa-ib1}
Here is an example on in-bufferedness.  Notice that an input action is
possible at every state of $\Buf;\Ss$.
\[	\Ss=\vcenter{\xymatrix@ur{
		*+[o][F-]{\bullet}\ar[d]_{\ain{x}}\ar[r]^{\ain{x}}
&	*+{\bullet}\ar[d]^{\aout{y}}
\\	*+{\bullet}\ar[r]_{\aout{z}} 	
&	*+{\bullet} 	}}
\sep
	\Buf_{\{x\}};\Ss\wbis\vcenter{\xymatrix{
&&	{\bullet}\ar[dr]^{\aout{y}}\ar@(ur,dr)[]^{\ain{x}}
\\	*+[o][F-]{\bullet}\ar[r]^{\ain{x}}
&	{\bullet}\ar[ur]^{\tau}\ar[dr]_{\tau}\ar@(ur,dr)[]^{\ain{x}}
&&	{\bullet}\ar@(ur,dr)[]^{\ain{x}}
\\&&	{\bullet}\ar[ur]_{\aout{z}}\ar@(ur,dr)[]^{\ain{x}} 	}}
\]
\end{example}

% ===========================================================================

%..........................................................................
\microfilm{\begin{table*}[tbp]}
\nomicrofilm{\begin{table*}[t]}
\caption{First-order axioms for out-buffered agents}
\index{out-buffered agent!first-order axioms for}
\label{tab-ob}
\begin{center}
\property{output-commutativity\index{output-commutativity}\index{commutativity!output} {\OBcom}}{}{
	\vcenter{\diage{s}{\aout{y}}{s'}{\alpha}{t}}
\imp 	\vcenter{\diagf{s}{\aout{y}}{s'}{\alpha}{\alpha}{s''}{\aout{y}}{t}}}
\property{output-confluence\index{output-confluence}\index{confluence!output} {\OBcon}}{where $\alpha\neq\aout{y}$}{
	\vcenter{\diagd{s}{\aout{y}}{s'}{\alpha}{s''} }
\imp 	\vcenter{\diagf{s}{\aout{y}}{s'}{\alpha}{\alpha}{s''}{\aout{y}}{t}}}
\propertynoside{output-determinacy\index{output-determinacy}\index{determinacy!output} {\OBdet}}{
	\vcenter{\diagd{s}{\aout{y}}{s'}{\aout{y}}{s''}}
\imp 	s'=s''}
\end{center}
\end{table*}

%..........................................................................
\begin{table*}[p]\caption{First-order axioms for in-buffered agents}
\index{in-buffered agent!first-order axioms for}
\label{tab-ib}
\begin{center}
\propertynoside{input-commutativity\index{input-commutativity}\index{commutativity!input} {\IBcom}}{
	\vcenter{\diage{s}{\alpha}{s'}{\ain{x}}{t}}
\imp	\vcenter{\diagf{s}{\alpha}{s'}{\ain{x}}{\ain{x}}{s''}{\alpha}{t}}}
\propertynoside{input-confluence\index{input-confluence}\index{confluence!input} {\IBcon}}{
	\vcenter{\diagd{s}{\ain{x}}{s'}{\alpha}{s''}}
\imp	\vcenter{\diagf{s}{\ain{x}}{s'}{\alpha}{\alpha}{s''}{\ain{x}}{t}}}
\propertynoside{input-determinacy\index{input-determinacy}\index{determinacy!input} {\IBdet}}{
	\vcenter{\diagd{s}{\ain{x}}{s'}{\ain{x}}{s''}}
\imp	s'=s''}
\propertynoside{input-receptivity\index{input-receptivity}\index{receptivity} {\IBacc}}{
	s \ssep\imp\ssep s\rin{x}t}
\end{center}
\end{table*}

%..........................................................................
\begin{table*}[p]\caption{First-order axioms for out-queued agents}
\index{out-queued agent!first-order axioms for}
\label{tab-oq}
\begin{center}
\property{output-commutativity' {\OQcom}}{where $\alpha$ not output}{
	\vcenter{\diage{s}{\aout{y}}{s'}{\alpha}{t}}
\imp 	\vcenter{\diagf{s}{\aout{y}}{s'}{\alpha}{\alpha}{s''}{\aout{y}}{t}}}
\property{output-confluence' {\OQcon}}{where $\alpha$ not output}{
	\vcenter{\diagd{s}{\aout{y}}{s'}{\alpha}{s''} }
\imp 	\vcenter{\diagf{s}{\aout{y}}{s'}{\alpha}{\alpha}{s''}{\aout{y}}{t}}}
\propertynoside{output-determinacy' {\OQdet}}{
	\vcenter{\diagd{s}{\aout{y}}{s'}{\aout{z}}{s''}}
\imp 	\begin{array}{@{}c@{}}y=z\\\mbox{and}\\s'=s''\end{array}}
\end{center}
\end{table*}

%..........................................................................
\begin{table*}[p]\caption{First-order axioms for in-queued agents}
\index{in-queued agent!first-order axioms for}
\label{tab-iq}
\begin{center}
\property{input-commutativity' {\IQcom}}{where $\alpha$ not input}{
	\vcenter{\diage{s}{\alpha}{s'}{\ain{x}}{t}}
\imp	\vcenter{\diagf{s}{\alpha}{s'}{\ain{x}}{\ain{x}}{s''}{\alpha}{t}}}
\property{input-confluence' {\IQcon}}{where $\alpha$ not input}{
	\vcenter{\diagd{s}{\ain{x}}{s'}{\alpha}{s''}}
\imp	\vcenter{\diagf{s}{\ain{x}}{s'}{\alpha}{\alpha}{s''}{\ain{x}}{t}}}
\propertynoside{input-determinacy {\IQdet}}{
	\vcenter{\diagd{s}{\ain{x}}{s'}{\ain{x}}{s''}}
\imp	s'=s''}
\propertynoside{input-receptivity {\IQacc}}{
	s \ssep
\imp\ssep	s\rin{x}t}
\end{center}
\end{table*}
%..........................................................................

%============================================================================
\section{First-order axioms for asynchrony}
\label{sec-axioms}

In this section, we will give necessary and sufficient conditions for each
of the notions of asynchrony from Definition~\ref{def-asynch}.  These
conditions are in the form of {\em first-order axioms}, by which we mean
axioms that use quantification only over states and actions, but not over
subsets of states or actions.  The axioms, which are shown in
Tables~\ref{tab-ob} through \ref{tab-iq}, characterize each of our notions
of asynchrony {\em up to weak bisimulation}; this means, an {\lts} is
asynchronous iff it is weakly bisimilar to one satisfying the
axioms. It is
possible to lift the condition ``up to weak bisimulation'' at the cost of
introducing second-order axioms; this is the subject of
Section~\ref{sec-non-ele}.

%----------------------------------------------------------------------------
\subsection{Out-buffered agents}

Table~\ref{tab-ob} lists three axioms for out-buffered agents. We use the
convention that variables are implicitly existentially quantified if they
occur only on the right-hand-side of an implication, and all other
variables are implicitly universally quantified. Thus the axioms are:
\begin{description}
\item[\OBcom] {\em Output-commutativity\/}\index{output-commutativity}\index{commutativity!output}: output actions can always be
delayed. 
\item[\OBcon] {\em Output-confluence\/}\index{output-confluence}\index{confluence!output}: when an output action and
some other action are possible, then they can be performed in either
order with the same result. In particular, neither action precludes
the other. 
\item[\OBdet] {\em Output-determinacy\/}\index{output-determinacy}\index{determinacy!output}: from any state $s$, there is
at most one transition $\aout{y}$ for each $y\in Y$.
\end{description} 
Each of these axioms is plausible for the behavior of a buffer.
Output-determinacy is maybe the least intuitive of the three
properties; the idea is that once an output action is stored in a
buffer, there is only one way of retrieving it.  Together, these
axioms characterize out-bufferedness up to weak bisimulation:

\begin{theorem}[Characterization of out-buffered agents]\label{thm-ob}
An agent $\Ss$ is out-buffered if and only if $\Ss\wbis\Tt$ for some
$\Tt$ satisfying {\OB}.
\end{theorem}

\noindent This is a direct consequence of the following proposition:

\begin{proposition}\label{pro-ob}
~\begin{enumerate}
\item Every agent of the form $\Ss;\Buf$ satisfies {\OB}.
\item If $\Ss$ satisfies {\OB}, then $\Ss\wbis\Ss;\Buf$.
\end{enumerate}
\end{proposition}

\begin{proof}
\begin{nienumerate}
\item Clearly, the buffer $\Buf$ satisfies {\OB}.  Moreover, these
conditions are preserved by arbitrary sequential composition from the
left. We show this for {\OBcom}; the other cases are similar.  Suppose
$\Bb$ satisfies {\OBcom}. To show that $\Ss;\Bb$ satisfies {\OBcom},
consider transitions
\[	\diage{\pair{u,s}}{\aout{y}}{\pair{u,s'}}{\alpha}{\pair{u',t}.}
\]
Then $s\rout{y}s'$ in $\Bb$. By Definition~\ref{def-composition}, there are
three cases for ${\pair{u,s'}}\rea {\pair{u',t}}$:
\begin{caselist}
\case $s'=t$, $u\rea u'$, $\alpha$ not output.  \case
$u=u'$, $s'\rea t$, $\alpha$ not input. Hence, by hypothesis there is
$s''$ such that $s\rea s''\rout{y}t$.  \case $\alpha=\tau$,
$u\rout{x}u'$, $s'\rin{x}t$. Hence, by hypothesis there is $s''$ such
that $s\rin{x}s''\rout{y}t$.
\end{caselist}
In each of the three cases, the diagram can be completed:
\[	\begin{array}{cc}\mbox{Case 1:}
\\	\diagf	{\pair{u,s}}	{\aout{y}}	{\pair{u,t}}
{\alpha}			{\alpha}
{\pair{u',s}}	{\aout{y}}	{\pair{u',t}}
\end{array}
\ssep	\begin{array}{cc}\mbox{Case 2:}
\\	\diagf	{\pair{u,s}}	{\aout{y}}	{\pair{u,s'}}
{\alpha}			{\alpha}
{\pair{u,s''}}	{\aout{y}}	{\pair{u,t}}
\end{array}
\ssep	\begin{array}{cc}\mbox{Case 3:}
\\	\diagf	{\pair{u,s}}	{\aout{y}}	{\pair{u,s'}}
{\tau}				{\tau}
{\pair{u',s''}}{\aout{y}}	{\pair{u',t}}
\end{array}
\]
\item Suppose $\Ss\from X\jjB Y$ satisfies {\OB}. For any sequence
$w=y_1y_2\cdots y_n\in\fm{Y}$, we write $s\wout{w}t$ if
$s\rout{y_1}\rout{y_2}\cdots\rout{y_n}t$ ($n\geq 0$).  Note that if
$w'\in\fm{Y}$ is a permutation of $w$, then $s\wout{w'}t$ iff $s\wout{w}t$
by {\OBcom}. Consider the relation $R\seq\abs{\Ss}\times\abs{\Ss;\Buf}$
given by $sR\pair{t,w}$ iff $s\wout{w}t$. Clearly, $R$ relates initial
states.  We show that $R$ is a weak bisimulation.  In one direction,
suppose
\[	\diagcx{s}{R}{\pair{t,w}}{\alpha}{s'.}
\]
Two cases arise:
\begin{caselist}
\case $\alpha=\aout{y}$ for some $y\in w$. By the definition of $R$,
$s\rout{y}s''\wout{w'}t$, where $w=yw'$. By {\OBdet}, we have $s'=s''$.
Therefore $s'R\pair{t,w'}$, and also $\pair{t,w}\rea
\pair{t,w'}$.{\chk} \case $\alpha\neq\aout{y}$ for all $y\in w$. From
$s\wout{w}t$ and $s\rea s'$, we get $s'\wout{w}t'$ and $t\rea t'$ by
repeated application of {\OBcon}. Therefore $s'R\pair{t',w}$ and
$\pair{t,w}\Rea \pair{t',w}$ (notice the use of $\Red{}$ here, which
is necessary in case $\alpha$ is an output action).{\chk}
\end{caselist}

\noindent In the other direction, suppose
\[	\diagxc	{s}	{R}	{\pair{t,w}}
				{\alpha} {\pair{t',w'}.}
\]
We distinguish three cases for ${\pair{t,w}}\rea {\pair{t',w'}}$,
depending on which rule in Definition~\ref{def-composition} was used.
\begin{caselist}
\case $t\rea t'$, $w=w'$ and $\alpha$ not output.
Then $s\wout{w}t\rea t'$, which implies $s\rea s'\wout{w}t'$ by
repeated application of {\OBcom}, {\ie} $s\rea s'R\pair{t',w}$.{\chk}
\case $t=t'$, $w\rea w'$ and $\alpha$ not input.
Since $\Buf$ has only input and output transitions, $\alpha$ must be
$\aout{y}$ for some $y\in Y$ with $w=yw'$. Then $s\rout{y}s'\wout{w'}t$,
{\ie} $s\rea s'R\pair{t,w'}$.{\chk}
\case $t\rout{y}t'$, $w\rin{y}w'$ and $\alpha=\tau$.
In this case, $w'=wy$ and $s\wout{w}t\rout{y}t'$, hence
$sR\pair{t',w'}$.{\chk}\eot
\end{caselist}
\end{nienumerate}
\end{proof}

\begin{n-remark}\label{rem-other-equivalences}
Theorem~\ref{thm-ob} generalizes to other notions of equivalence of
processes, as long as they are coarser than weak bisimulation.
Indeed, if $\cong$ is an equivalence of processes such that
${\wbis}\seq\mbox{$\cong$}$, then for any agent $\Ss$, there exists
some out-buffered $\Tt$ with $\Ss\cong\Tt$ iff there exists $\Tt'$
satisfying {\OB} and $\Ss\cong\Tt'$. This is a trivial consequence of
Theorem~\ref{thm-ob}. Similar remarks apply to the other results in
this section and in Section~\ref{sec-cons-fee-app}.
\end{n-remark}

%----------------------------------------------------------------------------
\subsection{In-buffered agents}

The axioms for in-buffered agents are listed in Table~\ref{tab-ib}.
The main difference to the out-buffered case is the property {\em
input-receptivity}: an in-buffered agent can perform any input action
at any time. This was illustrated in Example~\ref{exa-ib1}. The
input/output automata of Lynch and Stark {\cite{LS89}} have this
property, and so does Honda and Tokoro's original version of the
asynchronous $\pi$-calculus {\cite{HT91}}.

\begin{remark}
Somewhat surprisingly, the axioms in Table~\ref{tab-ib} are not
independent. In fact, {\IBcom} and {\IBcon} are equivalent in the
presence of {\IBdet} and {\IBacc}. We present all four axioms in order
to highlight the analogy to the output case.
\end{remark}

\begin{theorem}[Characterization of in-buffered agents]\label{thm-ib}
An agent $\Ss$ is in-buffered if and only if $\Ss\wbis\Tt$ for some
$\Tt$ satisfying {\IB}.
\end{theorem}

\noindent This is a consequence of the following proposition:

\begin{proposition}\label{pro-ib}
~\begin{enumerate}
\item Every agent of the form $\Buf;\Ss$ satisfies {\IB}.
\item If $\Ss$ satisfies {\IB}, then $\Ss\wbis\Buf;\Ss$.
\end{enumerate}
\end{proposition}

\begin{proof}
The proof is much like the proof of Theorem~\ref{pro-ob}. We give the
details of 2.\ to demonstrate how each of the properties {\IB} is
used.
\begin{nienumerate}
\item[2.] Suppose $\Ss\from X\jjB Y$ satisfies {\IB}.  For any
sequence $w=x_1x_2\cdots x_n\in\fm{X}$ we write $s\win{w}t$ if
$s\rin{x_1}\rin{x_2}\cdots\rin{x_n}t$ ($n\geq 0$). Again, notice that if
$w'\in\fm{X}$ is a permutation of $w$, then $s\win{w'}t$ iff $s\win{w}t$ by
{\IBcom}.  Consider the relation $R\seq\abs{\Buf;\Ss}\times\abs{\Ss}$ given
by $\pair{w,s}Rt$ iff $s\win{w}t$. $R$ relates initial states, and we show
that it is a weak bisimulation.  In one direction, suppose
\[	\diagxc{\pair{w,s}}{R}{t}{\alpha}{t'.}
\]
Then $s\win{w}t$, hence $\pair{w,s}\Redt\pair{\eset,t}\Rea
\pair{\eset,t'}$. But clearly $\pair{\eset,t'}Rt'$.

In the other direction, suppose
\[	\diagcx	{\pair{w,s}}	{R}	{t}
		{\alpha} 		{\pair{w',s'}.}
\]
We distinguish the usual three cases by Definition~\ref{def-composition}.
\begin{caselist}
\case $s=s'$, $w\rea w'$ and $\alpha$ not output.
In this case, $\alpha=\ain{x}$ for some $x\in X$ with $w'=wx$.  By
definition of $R$, $s\win{w}t\rin{x}t'$, hence $\pair{w',s}Rt'$.{\chk}
\case $s\rea s'$, $w=w'$ and $\alpha$ not input. To
$s\rea s'$ and $s\rin{w}t$ repeatedly apply {\IBcon} to get $t\rea t'$
and $s'\rin{w}t'$, hence $\pair{w,s'}Rt'$.{\chk}
\case $w\rout{x}w'$, $s\rin{x}s'$ and $\alpha=\tau$.
Then $w=xw'$ and $s\rin{x}s''\rin{w'}t$. But by {\IBdet}, $s'=s''$, hence
$s'\rin{w'}t$, therefore $\pair{w',s'}Rt$.{\chk}\eot
\end{caselist}
\end{nienumerate}
\end{proof}

%----------------------------------------------------------------------------
\subsection{Out-queued and in-queued agents}

The results for buffers are easily adapted to queues. The relevant
properties are given in Tables~\ref{tab-oq} and~\ref{tab-iq}. Notice
that the conditions for {\em commutativity} and {\em confluence}
differ from the respective rules in the buffered case only in their
side conditions.  Different outputs (respectively, different inputs)
no longer commute or conflow. {\em Output-determinacy} is
strengthened: from each state, there is at most one possible output
transition.

Note that {\IB} imply {\IQ}. This is due to the fact that every in-buffered
agent is also in-queued as a consequence of Lemma~\ref{lem-idem}(3). On the
other hand, no implication holds between {\OQ} and {\OB}, since
out-bufferedness and out-queuedness are incomparable notions due to
Lemma~\ref{lem-idem}(4).

Just like in the buffered case, the axioms for input are not
independent: we have {\IQcom}$\iff${\IQcon} in the presence of the
other axioms.

\begin{theorem}[Characterization of in- and out-queued agents]\label{thm-ioq}
An agent $\Ss$ is out-queued if and only if $\Ss\wbis\Tt$ for some
$\Tt$ satisfying {\OQ}. Moreover, $\Ss$ is in-queued if and only if
$\Ss\wbis\Tt$ for some $\Tt$ satisfying {\IQ}.\eot
\end{theorem}

%============================================================================
\section{More agent constructors and asynchrony with feedback}
\label{sec-cons-fee-app}

\subsection{Some operations on agents}\label{subsec-operations}

In this section, we will introduce some operations on
agents\index{agent!operations on}, such as renaming and hiding of actions,
parallel composition and feedback.

\begin{enumerate}
\item {\em Domain extension.}\index{domain extension and restriction}\index{agent!domain extension and restriction} If $\Ss$ is an {\lts}
of type $A$, and if $A\seq A'$, then $\Ss$ can also be regarded as an
{\lts} of type $A'$.
\item {\em Domain restriction (hiding).}\index{hiding}\index{agent!hiding}
If $\Ss$ is an {\lts} of type $A$, and if $\tau\in A'\seq A$, then
$\Ss\rest{A'}$ is defined to be the {\lts} of type $A'$ which has the same
states as $\Ss$, and whose transitions are those of $\Ss$ restricted to
$\abs{\Ss}\times A'\times\abs{\Ss}$.
\item {\em Composition with functions.}\index{composition!agent and
function}\index{agent!composition with function}  Let $\Ss\from X\jjB Y$, and
let $f\from X'\ii X$ and $g\from Y\ii Y'$ be functions. By $f;\Ss;g$ we
denote the agent of type $X'\jjB Y'$ with the same states as $\Ss$, and
with input transitions $s\rin{x'}_{f;\Ss;g}t$ if $s\rin{fx'}_{\Ss}t$,
output transitions $s\rout{gy}_{f;\Ss;g}t$ if $s\rout{y}_{\Ss}t$, and with
$s\rea_{f;\Ss;g}t$ iff $s\rea_{\Ss}t$ when $\alpha$ is an internal action.
\suspendenumerate
\end{enumerate}
Domain extension, domain restriction and composition with functions are
special cases of the following, general renaming construct:
\begin{enumerate}
\resumeenumerate
\item {\em General renaming and
hiding.}\index{hiding}\index{agent!hiding}\index{agent!renaming} 
Let $\Ss$ be an {\lts} of type $A$ and let $r\seq A\times A'$ be a
relation such that $\tau r\alpha'$ iff $\tau=\alpha'$. Define $\Ss_r$
to be the {\lts} of type $A'$ that has the same states and initial
state as $\Ss$ and transitions $s\rea_{\Ss_r}t$ iff
$s\red{\alpha'}_{\Ss}t$ for some $\alpha r\alpha'$.
\suspendenumerate
\end{enumerate}
Let us now turn to various forms of parallel composition.
\begin{enumerate}
\resumeenumerate
\item {\em Parallel composition without interaction.}\index{agent!parallel
composition!without interaction}\index{parallel composition!without
interaction}\index{composition!parallel!without interaction} Let $\Ss$ and
$\Tt$ be {\ltss} of type $A$. Then $\Ss\pcp\Tt$ is the {\lts} of type $A$
with states $\abs{\Ss}\times\abs{\Tt}$ and initial state $\pair{s_0,t_0}$,
and whose transitions are given by the rules
\[	\deriv{s\rea_{\Ss}s'}{\pair{s,t}\brea_{\Ss\pcp\Tt}\pair{s',t}}
\sep	\deriv{t\rea_{\Tt}t'}{\pair{s,t}\brea_{\Ss\pcp\Tt}\pair{s,t'}}.
\]
\item {\em Symmetric monoidal structure.}\index{agent!symmetric monoidal structure} 
Let $X\oplus X'$ be the disjoint union of sets. For $\Ss\from X\jjB Y$ and
$\Tt\from X'\jjB Y'$, define $\Ss\oplus\Tt\from X\oplus X'\jjB Y\oplus Y'$
to be the agent $\Ss_r\pcp\Tt_q$, where $r$ and $q$ are the inclusions of
$X\jjB Y$, respectively $X'\jjB Y'$ into $X\oplus X'\jjB Y\oplus Y'$.  Then
$\oplus$ defines a symmetric monoidal structure on the categories $\BUF$
and $\QUE$. The tensor unit is given by the agent $\tensorunit$ of type
$\emptyset\:\jj\:\emptyset$ with one state and no transitions.
\suspendenumerate
\end{enumerate}
The constructors we have considered so far, including sequential
composition, are not sufficient to build arbitrary networks. What is
missing is the ability to construct loops. The next constructor allows the
output of an agent to be connected to its own input:
\begin{enumerate}
\resumeenumerate
\item {\em Self-composition
(feedback).}\index{feedback}\index{self-composition of
agent}\index{agent!feedback}\index{agent!self-composition} Let $\Ss\from
X\jjB Y$. Let $O\seq Y\times X$ be a set of pairs. Define
$\Ss\feedback{O}$, the self-composition of $\Ss$ along $O$, to be the
{\lts} of type $X\jjB Y$ whose states are identical with those of $\Ss$,
and whose transitions are given by the rules
\[	\deriv{s\lrea_{\Ss}t}{s\blrea_{\Ss\feedback{O}}t}
\sep	\deriv{s\rout{y}\Redt\rin{x}_{\Ss}t\sep\pair{y,x}\in O}
		{s\blredt_{\Ss\feedback{O}} t}.
\]
In the common case where $\Ss\from X\jjB X$ and $O=\{\pair{x,x}\such
x\in X\}$, we will write $\fee{\Ss}$ instead of $\Ss\feedback{O}$.
\suspendenumerate
\end{enumerate}
We can use self-composition to define both sequential and parallel
composition.
\begin{enumerate}
\resumeenumerate
\item {\em Sequential composition.}\index{sequential composition}\index{composition!sequential}  The sequential composition of
agents was defined in Definition~\ref{def-composition}. Alternatively, one
can define it from the more primitive notions of direct sum, feedback and
hiding: Let $\Ss\from X\jjB Y$ and $\Tt\from Y\jjB Z$. Then
$\Ss\oplus\Tt\from X\oplus Y\jjB Y\oplus Z$, and with $\Delta
Y=\{\pair{y,y}\such y\in Y\}$, one gets
$\Ss;\Tt\wbis((\Ss\oplus\Tt)\feedback{\Delta Y})\rest{X\jjB Z}$.
\item {\em Parallel composition (with interaction).}\index{parallel
composition!with interaction}\index{composition!parallel!with
interaction}\index{agent!parallel composition!with interaction} Let
$\Ss,\Tt\from X\jjB X$.  The parallel composition $\Ss\pcpf\Tt$ is defined
to be the agent $\fee{(\Ss\pcp\Tt)}$.
\end{enumerate}

\begin{proposition}
All of the agent constructors in this section respect weak bisimulation.
For instance, if $\Ss\wbis\Ss'$ and $\Tt\wbis\Tt'$, then $\Ss_r\wbis\Ss'_r$
and $\Ss\pcp\Tt\wbis\Ss'\pcp\Tt'$, etc. \eot
\end{proposition}

%----------------------------------------------------------------------------
\subsection{Asynchrony with feedback}\label{sec-feedback}

In concurrent process calculi such as CCS or the $\pi$-calculus, we do
not think of channels as edges in a data flow graph, but rather we
think of a single global ether through which all messages travel. This
idea is most visible in the {\em chemical semantics} of these calculi
{\cite{BB92}}. There the ether is modeled as a ``chemical solution'',
which is a multiset of processes, some of which are transient
messages.  As a consequence, messages that are emitted from a process
are immediately available as input to all processes, including the
sending process itself. In our setting, this is best modeled by
requiring that all processes are of type $X\jj X$ for one fixed set
$X$, and by using self-composition to feed the output back to the
input.

In the presence of feedback, out-bufferedness takes a slightly different
form, which is expressed in the following definition.

\begin{definition}
An agent $\Ss\from X\jjB X$ is {\defit out-buffered with
feedback}\index{out-buffered agent!with
feedback}\index{feedback}\index{agent!out-buffered with feedback} if
$\Ss\wbis\fee{\Rr}$ for some out-buffered agent $\Rr$.
\end{definition}

\begin{example}
The following agent $\Ss$ is out-buffered with feedback, but not
out-buffered:
\[	\Ss=\vcenter{\xymatrix{
	*+[o][F-]{\bullet}\ar[d]_{\ain{x}}\ar[r]^{\aout{x}}\ar[dr]^{\tau}
&	{\bullet}\ar[d]^{\ain{x}}\ar[r]^{\aout{x}}\ar[dr]^{\tau}
&	{\bullet}\ar[d]^{\ain{x}}
\\	{\bullet}\ar[r]_{\aout{x}}
&	{\bullet}\ar[r]_{\aout{x}}
&	{\bullet.}	
	}}
\]
\end{example}

%..........................................................................
\begin{table*}[tbp]
\caption{First-order axioms for out-buffered agents with feedback}
\index{out-buffered agent!with feedback!first-order axioms for}
\label{tab-obfb}
\begin{center}
\property{output-commutativity {\FBcom}}{}{
	\vcenter{\diage{s}{\aout{x}}{s'}{\alpha}{t}}
\imp 	\vcenter{\diagf{s}{\aout{x}}{s'}{\alpha}{\alpha}{s''}{\aout{x}}{t}}}
\property{output-confluence {\FBcon}}{where $\alpha\neq\aout{x}$ and 
	$\alpha\neq\tau$}{
	\vcenter{\diagd{s}{\aout{x}}{s'}{\alpha}{s''} }
\imp 	\vcenter{\diagf{s}{\aout{x}}{s'}{\alpha}{\alpha}{s''}{\aout{x}}{t}}}
\propertynoside{output-determinacy {\FBdet}}{
	\vcenter{\diagd{s}{\aout{x}}{s'}{\aout{x}}{s''}}
\imp 	s'=s''}
\propertynoside{feedback {\FBfee}}{
	\vcenter{\diage{s}{\aout{x}}{s'}{\ain{x}}{t}}
\imp	\vcenter{\diagh{s}{\aout{x}}{s'}{\tau}{\ain{x}}{t}}}
\propertynoside{output-tau {\FBtau}}{
	\vcenter{\diagd{s}{\aout{x}}{s'}{\tau}{s''} }
\imp	\vcenter{\diagf{s}{\aout{x}}{s'}{\tau}{\tau}{s''}{\aout{x}}{t}}
\mbox{ or }
	\vcenter{\diagg{s}{\aout{x}}{s'}{\tau}{\ain{x}}{s''} } }
\end{center}
\end{table*}
%..........................................................................

\begin{remark} 
Recently, Amadio, Castellani and Sangiorgi {\cite{ACS96}} have given a
definition of asynchronous bisimulation, which accounts for the fact
that an agent of type $X\jj X$ might receive a message, and then
immediately send it again, without this interaction being observable
on the outside. Feedback is concerned with the dual phenomenon, namely
a process that sends a message and then immediately receives it again.
\end{remark}

\noindent Out-bufferedness with feedback is characterized up to weak
bisimulation by the first-order axioms that are listed in
Table~\ref{tab-obfb}.

\begin{theorem}[Characterization of out-buffered agents with feedback]
\label{thm-obfb}
An agent $\Ss\from X\jjB X$ is out-buf\-fer\-ed with feedback if and only if
$\Ss\wbis\Tt$ for some agent $\Tt$ satisfying {\FB}.
\end{theorem}

\noindent Before we prove this theorem, we need two lemmas. The first
one gives a useful consequence of the axioms for out-bufferedness with
or without feedback.

\begin{lemma}\label{lem-ob-backdet}\label{lem-obfb-backdet}
Suppose an agent $\Ss$ satisfies either {\OB} or {\FB}. Then it satisfies
the following property, which we call {\defit backwards
output-determinacy}%
\index{backwards output-determinacy}\index{output-determinacy!backwards}%
\index{determinacy!output!backwards}:
\[	\diagu{s}{s'}{\aout{x}}{\aout{x}}{t}{\wbis}{t'}
\imp	s\wbis s'.
\]
\end{lemma}

\begin{proof}
The proof is straightforward. The relation $R\eqdef\{\pair{s,s'}\such
s\wbis s'\mbox{ or }(\exists t,t') s\rout{x}t\wbis
t'\ired{aout{x}}s'\}$ is weak bisimulation that relates $s$ and
$s'$.\eot
\end{proof}

\noindent The next lemma establishes a technical property needed in
the proof of Theorem~\ref{thm-obfb}. Recall that an agent $\Tt$ is {\defit
$\wbis$-reduced}\index{reduced agent@$\wbis$-reduced agent} if
$\Tt=\Tt/{\wbis}$.

\begin{lemma}\label{lem-stA}
Assume $\Tt$ is $\wbis$-reduced and satisfies {\FB}. Define a subset
$A\seq\{\pair{s,t}\nomicrofilm{\such}\microfilm{|}s\redt t\}$ as follows:
$\pair{s,t}\in A$ iff for all sequences $w\in\fm{X}$,
\[	\vcenter{\diagd{s}{\aout{w}}{u}{\tau}{t} }
\imp 	\vcenter{\diagf{s}{\aout{w}}{u}{\tau}{\tau}{t}{\aout{w}}{v.}}
\]
Then the following hold: 
\begin{enumerate}
\item Whenever $s\redt t\rout{x}t'$ and $s\rout{x}s'\redt t'$,
then $\pair{s,t}\in A$ iff $\pair{s',t'}\in A$.
\item If $s\redt t$ and $\pair{s,t}\not\in A$, then
$s\rout{x}\rin{x}t$ for some $x\in X$.
\end{enumerate}
\end{lemma}

\begin{proof}
\begin{itemlist}
\case[1. $\imp$:] Assume $\pair{s,t}\in A$ and $s'\wout{w}u$. Then
there are $v$ and $t''$ with $u\redt v$ and $t\rout{x}s''\wout{w}v$.
By {\FBdet}, $s'=s''$, hence $s'\wout{w}v$ and $u\redt v$. This
shows $\pair{s',t'}\in A$.
\casepmi
Conversely, assume $\pair{s',t'}\in A$ and $s\wout{w}u$. We show that there
exists $v$ with $u\redt v$ and $t\wout{w}v$.
\begin{caselist}
\case 
$x\not\in w$. We get $s'\wout{w}u'$ and $u\rout{x}u'$ by {\FBcon}, and
$t'\wout{w}v'$ and $u'\redt v'$ by the assumption that $\pair{s',t'}\in A$,
then $u\redt v_1\rout{x}v'$ and also $t\wout{w}v_2\rout{x}v'$ by
{\FBcom}. By Lemma~\ref{lem-obfb-backdet}, $v_1\wbis v_2$, hence,
since $\Tt$ is $\wbis$-reduced, $v_1=v_2$. We can take
$v=v_1$.
\case
$x\in w$. Let $xw'$ be a permutation of $w$ that begins with $x$. By
{\FBcom}, $s\rout{x}s''\wout{w'}u$, and by {\FBdet},
$s'=s''$. Since $\pair{s',t'}\in A$, one has $u\redt v$ and
$t'\wout{w'}v$ for some $v$, hence $t\wout{xw'}v$ and again by {\FBdet},
$t\wout{w}v$.
\end{caselist}
\case[2.]
Assume $s\redt t$ and $\pair{s,t}\not\in A$.  By definition of $A$, there
exists $w\in\fm{X}$ with $s\wout{w}u$ such that there exists no $v$ with
$t\wout{w}v$ and $u\redt v$. Choose such a $w$ of minimal length, and let
$w=w'x$ (note $w$ cannot be the empty sequence). Then
$s\wout{w'}s'\rout{x}u$, $t\wout{w'}t'$, and $s'\redt t'$, and there is no
$v$ with $t'\rout{x}v$ and $u\redt v$. By {\FBtau}, there is a transition
$u\rin{x}t'$.  From $s\wout{w'}s'\rout{x}u\rin{x}t'$ and {\FBcom}, one
gets $s\rout{x}\rin{x}t''\wout{w'}t'$. By
Lemma~\ref{lem-obfb-backdet}, $t''\wbis t$, hence $t''=t$ since $\Tt$
is $\wbis$-reduced. This shows $s\rout{x}\rin{x}t$.
\eot
\end{itemlist}
\end{proof}

\begin{proofof}{Theorem~\ref{thm-obfb}}
Consider the following auxiliary operation on agents: For
$\Rr\from X\jjB X$, define $\varfee{\Rr}$ by
\[	\deriv{s\rea_{\Rr}t}{s\brea_{\varfee{\Rr}}t}
\sep	\deriv{s\rout{x}_{\Rr}\rin{x}_{\Rr}t}{s\bredt_{\varfee{\Rr}}t}.
\]
In general, $\varfee{(-)}$ does not respect weak bisimulation. Notice
that if $\Rr$ satisfies {\OBcom} or {\IBcom}, then
$\fee{\Rr}\wbis\varfee{\Rr}$.
\begin{caselist}
\caseimp
Suppose $\Ss\from X\jjB X$ is out-buffered with feedback. Then there is
some $\Rr$ satisfying {\OB}, such that $\Ss\wbis\fee{\Rr}$.  It is
straightforward to verify that $\varfee{\Rr}$ satisfies {\FB}, and we can
take $\Tt=\varfee{\Rr}\wbis\fee{\Rr}\wbis\Ss$.
\casepmi
Suppose $\Tt\from X\jjB X$ satisfies {\FB}. We will show $\Tt$ is
out-buffered with feedback. Notice that $\Tt/{\wbis}$ also satisfies
{\FB}, hence we can {\wloss} assume that $\Tt$ is $\wbis$-reduced.
Define a subset $A\seq\{\pair{s,t}\such s\redt t\}$ as in
Lemma~\ref{lem-stA}. Let $\Rr\from X\jjB X$ be the agent obtained
from $\Tt$ by removing all transitions of the 
form $s\redt t$ where $\pair{s,t}\not\in A$. More precisely,
$\abs{\Rr}=\abs{\Tt}$ and $s\rea_{\Rr}t$ iff $\alpha\neq\tau$ and
$s\rea_{\Tt}t$, or $\alpha=\tau$ and $\pair{s,t}\in A$. We claim that $\Rr$
satisfies {\OB}. Indeed, {\OBcom} and {\OBcon} follow from the respective
properties of $\Tt$ in the case where $\alpha\neq\tau$. In the case where
$\alpha=\tau$, {\OBcom} for $\Rr$ follows from {\FBcom} for $\Tt$ and
Lemma~\ref{lem-stA}(1,$\pmi$); whereas {\OBcon} follows from the definition
of $A$ and Lemma~\ref{lem-stA}(1,$\imp$). Finally, {\OBdet} for $\Rr$
follows directly from {\FBdet} for $\Tt$.

We now show that $\Tt=\varfee{\Rr}$. The two agents have the same
states. For transitions, first note that
${\red{}}_{\Rr}\seq{\red{}}_{\Tt}$, and hence
${\red{}}_{\varfee{\Rr}}\seq{\red{}}_{\varfee{\Tt}}={\red{}}_{\Tt}$, with
the latter equality holding because of {\FBfee}. For the converse,
assume $s\rea_{\Tt}t$. If $\alpha\neq\tau$ or $\pair{s,t}\in A$, then
$s\rea_{\Rr}t$ and we are done. Else $\alpha=\tau$ and
$\pair{s,t}\not\in A$, and by Lemma~\ref{lem-stA}(2),
$s\rout{x}\rin{x}t$ holds in $\Tt$, hence in $\Rr$. This shows
$s\redt_{\varfee{\Rr}}t$.

We have shown that $\Tt=\varfee{\Rr}=\fee{\Rr}$ for some $\Rr$ satisfying
{\OB}. Hence, $\Tt$ is out-buffered with feedback, which finishes the proof
of Theorem~\ref{thm-obfb}.
\eot
\end{caselist}
\end{proofof}

%===========================================================================
\section{Example: Asynchronous CCS}\label{sec-ccs}

In this section, we will show that an asynchronous version of Milner's
calculus of communicating systems\index{calculus of communicating
systems} (CCS)\index{CCS}\index{asynchronous CCS}
{\cite{Mil80,Mil90}} fits into the framework of out-buffered labeled
transition systems with feedback.

Let $X=\{a,b,c,\ldots\}$ be an infinite set of {\defit names}\index{name!in
CCS}, and let $\bar{X}=\{\bar{a},\bar{b},\bar{c},\ldots\}$ be a
corresponding set of {\defit co-names}\index{co-name, in CCS}, such that $X$
and $\bar{X}$ are disjoint and in one-to-one correspondence via
$(\bar{~})$. We also write $\bar{\bar{a}}=a$. Names correspond to
input-actions, and co-names to output-actions. Let $\tau\not\in X+\bar{X}$,
and let $\Act=X+\bar{X}+\{\tau\}$ be the set of {\defit
actions}\index{action!in CCS}. We use the letters $\alpha,\beta,\ldots$ for
actions. We use the letter $L$ for sets of names, and we write $\bar{L}$
for $\{\bar{a}\such a\in L\}$. We use the letter $f$ for {\defit relabeling
functions}\index{relabeling function in CCS}, which are functions $f:X\ii
X$.  Any relabeling function extends to $f:\Act\ii\Act$ by letting
$f\bar{a}=\overline{fa}$ and $f\tau=\tau$.

%..........................................................................
\begin{table*}[tb]\caption{Transitions rules for asynchronous CCS}
\label{tab-ccs}
\[
\begin{array}{rc}
	\act	&	\deriv{\vstrut}{\alpha.P\brea P}
\nl	\suma 	&	\deriv{G\rea P}{G+G'\brea P}
\nl	\sumb	&	\deriv{G'\rea P}{G+G'\brea P}
\nl	\comp	&	\deriv{P\rea P'}{P|Q\brea P'|Q}
\nl	\compb	&	\deriv{Q\rea Q'}{P|Q\brea P|Q'}
\end{array}\sep\begin{array}{rc}
	\synch	&	\deriv{P\red{{\alpha}} P'\sep Q\red{\bar{\alpha}} Q'}
				{P|Q\bredt P'|Q'}
\nl	\res	&	\deriv{P\rea P'\sep\alpha\not\in
			L\cup\bar{L}}{P\ccsrest L\brea P'\ccsrest L}
\nl	\rel	&	\deriv{P\rea P'}{P[f]\bred{f\alpha}P'[f]}
\nl	\rec	&	\deriv{P\rea P'\sep A\defeqn P}{A\brea P'}
\end{array}
\]
\end{table*}
%..........................................................................

Let $A,B,C,\ldots$ range over a fixed set of {\defit process
constants}\index{process constant in
CCS}\index{constant!process}. Asynchronous CCS
{\defit processes}\index{process!in CCS}
$P,Q,\ldots$ and {\defit guards}\index{guard in CCS}
$G,H,\ldots$ are given by the following grammars:
\[\begin{array}{l}
	P\bnf\bar{a}.0\bor
		P|P\bor Q\ccsrest L\bor P[f]\bor A\bor G
\nl	G\bnf a.P\bor\tau.P\bor G+H\bor\pinull
\end{array}\]
Notice that the choice operator $+$ is restricted to input- and
$\tau$-guarded processes. Output-guarded choice is traditionally
disallowed in asynchronous process calculi. This is in accordance with
the results of this chapter, since output-guarded choice violates the
two asynchronous principles of output-determinacy and
output-confluence. For the $\pi$-calculus, Nestmann and Pierce
{\cite{NP96}} have recently shown that input-guarded choice can be
encoded from the other constructs; hence they include it in their
version of the asynchronous $\pi$-calculus, and we include it here for
asynchronous CCS as well.

Assume a set of {\defit defining equations}\index{equation!defining CCS
process} $A\defeqn P$, one for each process constant $A$. The operational
semantics of asynchronous CCS is given in terms of a labeled transition
system $\SSccs=\tuple{S,\Act,{\red{}}}$, which is defined in
Table~\ref{tab-ccs}. The states are CCS processes.  Notice that we have not
specified a distinguished initial state; this is more convenient in this
context, and no harm is done. Also notice that there is no rule for
$\pinull$. This is because the process $\pinull$ is inert, {\ie} there are
no transitions $\pinull\rea P$.

\begin{lemma}\label{lem-guard-not-output}
If $G\rea P$ for a guard $G$, then $\alpha\not\in\bar{X}$, {\ie} $\alpha$
is not an output action.
\end{lemma}

\begin{proof}
By induction on the derivation of $G\rea P$.\eot
\end{proof}

\noindent To fit the labeled transition system $\SSccs$ into our framework of
labeled transition systems with input and output, we simply identify
the set $X$ of names with $\Ain{X}$, and the set $\bar{X}$ of co-names
with $\Aout{X}$. Then $\SSccs$ is a labeled transition system of type
$X\jj X$. Before we prove that this system is out-buffered with
feedback, observe that output-determinacy fails for $\SSccs$:
\[	\diagd	{\bar{a}.\pinull|\bar{a}.\pinull}
		{\bar{a}}	{\pinull|\bar{a}}
		{\bar{a}}	{\bar{a}|\pinull,}
\]
and $\pinull|\bar{a}\neq\bar{a}|\pinull$. The following lemma helps to
remedy the situation:

\begin{lemma}\label{lem-detweak-fb}
An agent $\Ss$ is out-buffered with feedback if it satisfies {\FBcom},
{\FBcon}, {\FBtau}, {\FBfee} and the following property {\FBwdet}, which we
call {\defit weak output-determinacy}\index{weak
output-determinacy}\index{output-determinacy!weak}\index{determinacy!output!weak}:
\[	\vcenter{\diagd{s}{\aout{y}}{s'}{\aout{y}}{s''}}
\imp	\vcenter{\diagf{s}{\aout{y}}{s'}{\aout{y}}{\aout{y}}{s''}{\aout{y}}{t}}
\ssep\mbox{\rm or}\ssep	s'=s''
\]
\end{lemma}

\begin{proof}
First notice that if $\Ss$ satisfies the hypothesis, then so does
$\Ss/{\wbis}$, hence one can {\wloss} assume that $\Ss$ is
$\wbis$-reduced. Next, one shows backwards output-determinacy as in
Lemma~\ref{lem-ob-backdet}. For a $\wbis$-reduced process, backwards
output-determinacy and {\FBwdet} already implies {\FBdet}, and
therefore $\Ss$ is out-buffered with feedback by
Theorem~\ref{thm-obfb}.  \eot
\end{proof}

\begin{theorem}
The labeled transition system $\SSccs$ is out-buffered with feedback.
\end{theorem}

\begin{proof}
By Lemma~\ref{lem-detweak-fb}, it suffices to show that $\SSccs$
satisfies the axioms {\FBcom}, {\FBcon}, {\FBwdet}, {\FBtau},
and {\FBfee}. Each of these is proved in a similar fashion.
{\FBcom}, {\FBcon}, {\FBwdet} and {\FBfee} can be proved
independently, while {\FBtau} relies on {\FBcon} and {\FBwdet}
as hypotheses. Since this is the most interesting case, we show only
the proof of {\FBtau}.
Suppose therefore that {\FBcon} and {\FBwdet} have already been
proved. We want to show
\[	\vcenter{\diagd{P}{\bar{b}}{Q}{\tau}{R} }
\imp	\vcenter{\diagf{P}{\bar{b}}{Q}{\tau}{\tau}{R}{\bar{b}}{S}}
\mbox{ or }
	\vcenter{\diagg{P}{\bar{b}}{Q}{\tau}{b}{R}}.
\]
We show this by induction on the derivation of $P\redbb Q$. We distinguish
six cases based on the last rule in that derivation. Remember that this
last rule cannot have been {\suma} or {\sumb} by
Lemma~\ref{lem-guard-not-output}.
\begin{itemlist}
\case[\act:] 
$P=\barb.\pinull$ and $Q=\pinull$.  This is impossible, since
$\barb.\pinull\not\redt R$.
\case[\comp:]
$P=P'|P''$ and $Q=Q'|P''$, where $P'\redbb Q'$. Then $P\redt R$ must
have been inferred by one of the rules {\comp}, {\compb} or
{\synch}. Therefore, $R=R'|R''$, and one of the following holds:
\begin{caselist}
\case $P'\redt R'$ and $P''=R''$. By induction hypothesis on $P'\redt R'$
and $P'\redbb Q'$, either there is $S'$ with $R'\redbb S'$ and $Q'\redt
S'$, in which case we can choose $S=S'|P''$; or else $Q'\red{b} R'$, and
hence $Q=Q'|P''\red{b}R'|P''=R$.
\case $P'=R'$ and $P''\redt R''$. Then one can choose $S=Q'|R''$.
\case $P'\rea R'$ and $P''\red{\bar{\alpha}}R''$. In case $\alpha\neq\barb$, we
can use {\FBcon} to get $R'\redbb S'$ and $Q'\rea S'$, and we let
$S=S'|R''$. In case $\alpha=\barb$, we can use {\FBwdet} to get either
$R'\redbb S'$ and $Q'\redbb S'$, and we let again $S=S'|R''$; or else
$R'=Q'$, and hence $Q=Q'|P''\red{b=\bar{\alpha}} Q'|R''=R$.
\end{caselist}
\case[\compb:] 
This case is symmetric to the previous one.
\case[\res:]
$P=P'\ccsrest L$ and $Q=Q'\ccsrest L$, where $P'\redbb Q'$ and
$b\not\in L$. Then $R=R'\ccsrest L$ and $P'\redt R'$. By induction
hypothesis, we get either $Q'\redt S'$ and $R'\redbb S'$ for some
$S'$, and we can let $S=S'\ccsrest L$. Or else we get $Q'\red{b} R'$,
hence $Q\red{b}R$.
\case[\rel:]
$P=P'[f]$ and $Q=Q'[f]$, where $P'\red{\bar{c}} Q'$ and
$\barb=f\bar{c}$. Then $R=R'[f]$ and $P'\redt R'$. By induction hypothesis,
we get either $Q'\redt S'$ and $R'\red{\bar{c}} S'$ for some $S'$, and we
can let $S=S'[f]$. Or else we get $Q'\red{c} R'$, hence $Q\red{b}R$.
\case[\rec:]
$P=A$ where $A\defeqn P'$ and $P'\redbb Q$. Since $A\redt R$, we must also
have $P'\redt R$, and the claim follows by induction hypothesis.
\eot
\end{itemlist}
\end{proof}

%----------------------------------------------------------------------------
\section{Example: The core join calculus}\label{sec-join}

The join calculus\index{join calculus}\index{core join calculus} was
introduced by Fournet and Gonthier in {\cite{FG96}} and further developed
in {\cite{FGLMR96}}. It is a concurrent, message passing calculus like the
$\pi$-calculus.  However, the reaction rule is simpler and closer to the
semantics of a chemical abstract machine. Moreover, the scoping rules of
the join calculus are such that locality can be easily modeled. The full
join calculus deals with a distributed system of locations, and it contains
features that deal with such issues as migration and failure. Here, we will
only be concerned with the {\em core} join calculus, which is the fragment
of the join calculus that pertains to a single location.

Let $\Nn$ be a countable set of {\defit names}\index{name!in join
calculus}. We use $x,y,\ldots$ to denote names,
and $\tilde{x},\tilde{y},\ldots$ to denote sequences of names.  Core join
calculus {\defit processes}\index{process!in join calculus} $P,Q,\ldots$
and {\defit rule}\index{rule, in join
calculus} $R,S,\ldots$ are given by the following
grammars:
\[	P\bnf x\tuple{\tilde{y}}
	\bor	P|Q \bor \joindef{R_1\wedge\ldots\wedge R_m}{P}
\sep	R\bnf x_1\rtuple{\tilde{v}_1}|\ldots|x_n\rtuple{\tilde{v}_n}\rhd P
\]
A process of the form $x\tuple{\tilde{v}}$ is called a {\defit
message}\index{message, in join calculus}. In the rule
$R=x_1\rtuple{\tilde{v}_1}|\ldots|x_n\rtuple{\tilde{v}_n}\rhd P$, the names
$\tilde{v}_1\ldots\tilde{v}_n$ are bound\index{name!free and
bound}\index{bound name, in join calculus}, and they are assumed to be
distinct. The names $x_1\ldots x_n$ are called the {\defit defined
names}\index{name!defined}\index{defined name, in join calculus} of $R$,
denoted $\dn{R}$. Finally, all of the defined names of $R_1,\ldots,R_m$ are
bound in the process $\joindef{R_1\wedge\ldots\wedge R_m}{P}$.  For a more
comprehensive treatment, see {\cite{FG96,FGLMR96}}.

The semantics of the core join calculus is given in the style of a chemical
abstract machine.  A {\defit state}\index{state!in join calculus}
$\Delta\vdash_N\Pi$ is a multiset $\Delta$ of rules together with a
multiset $\Pi$ of processes. $N$ is a set of names, such that
$\fn{\Delta,\Pi}\seq N$.  We identify states up to $\alpha$-equivalence,
{\ie} up to renaming of bound variables. The transitions of this machine
follow a simple idea: the processes on the right hand side evolve according
to the rules on the left-hand side. There are two kinds of transitions:
{\defit structural}\index{structural transition in join
calculus}\index{transition relation!in join calculus} transitions, denoted
$\melt$, and {\defit reactions}\index{reaction in join calculus}, denoted
$\react$. The transition rules are shown in Table~\ref{tab-join-rules}.
The rule $\it(join)$ is of course only applicable is the length of
$\tilde{y_i}$ and $\tilde{v}_i$ are the same, for all $i$. Note that in the
rule $\it(str2)$, the sets $N$ and $\dn{R_1,\ldots,R_m}$ must be disjoint;
this may necessitate renaming some bound variables in
$\joindef{R_1\wedge\ldots\wedge R_m}{P}$.

%..........................................................................
\begin{table*}[tb]\caption{Transitions rules for the core join calculus}
\label{tab-join-rules}
\[
	\begin{array}{rrcl}
	{\it(str1)}	 
&	\Delta\vdash_N\Pi,P|Q 
& 	\melt
&	\Delta\vdash_N\Pi,P,Q
\nl	{\it(str2)}\rule{0mm}{3ex}
&	\Delta\vdash_N\Pi,\joindef{R_1\wedge\ldots\wedge R_m}{P} 
& 	\melt 
& 	\Delta, R_1,\ldots, R_m\vdash_{N'}\Pi, P
\nl &	\multicolumn{3}{r}{\mbox{where $N'=N+\dn{R_1,\ldots,R_m}$}}
\nl	{\it(join)}\rule{0mm}{3ex}
&	\Delta\vdash_N\Pi,x_1\tuple{\tilde{y_1}},\ldots,x_n\tuple{\tilde{y_n}}
& 	\react
&	\Delta\vdash_N\Pi,[\tilde{y_1}/\tilde{v}_1,\ldots,
\tilde{y_n}/\tilde{v}_n]P
\nl &	\multicolumn{3}{r}{\mbox{where $(x_1\rtuple{\tilde{v}_1}|
	\ldots|x_n\rtuple{\tilde{v}_n}\rhd P)\in\Delta$}}
	\end{array}
\]
\end{table*}
%..........................................................................

\begin{remark}
In the original formulation of the join-calculus
{\cite{FG96,FGLMR96}}, the structural rules are assumed to be
reversible.  We adopt a different convention here. Especially the
inverse of rule $\it{str2}$ causes problems in our setting, as it
allows a state under certain conditions to rename its free names.
\end{remark}

\noindent To make make the join calculus into a labeled transition system with
input and output, let $X=\{x\tuple{\tilde{y}}\such
x\in\Nn,\tilde{y}\in\fm{\Nn}\}$ be the set of messages. We add input
and output transitions:
\[\begin{array}{rrcl}
	{\it(in)}
&	\Delta\vdash_N\Pi
&	\rin{x\tuple{\tilde{y}}}
&	\Delta\vdash_{N\cup\{x,\tilde{y}\}}\Pi,x\tuple{\tilde{y}}
\nl	{\it(out)}
&	\Delta\vdash_N\Pi,x\tuple{\tilde{y}}
&	\rout{x\tuple{\tilde{y}}}
&	\Delta\vdash_N\Pi
\end{array}\]
Further, we let ${\red{\tau}}=\mbox{$\melt$}\cup\mbox{$\react$}$. With
these definitions, the join calculus defines a labeled transition
system $\SSjoin\from X\jj X$.

\begin{theorem}
The labeled transition system $\SSjoin$ defined by the core join calculus
is out-buffered with feedback.
\end{theorem}

%============================================================================
\section{Other characterizations of asynchrony}
\label{sec-non-ele}

In Sections~\ref{sec-axioms} and {\ref{sec-cons-fee-app}}, we have
characterized notions of asynchrony by first-order axioms {\em up to
weak bisimulation}. It is possible to remove the words ``up to weak
bisimulation'', {\ie} to characterize asynchrony directly. This
happens at the cost of introducing second-order axioms. The shift to
second-order seems to be inevitable, since weak bisimulation itself is
a second-order notion.

%----------------------------------------------------------------------------
\subsection{Out-buffered agents}

Consider the two different output transitions in
\[	\Ss=\vcenter{\xymatrix{
		*+[o][F-]{s}\ar[d]_{\ain{x}}
		\ar[r]_{\tau}\ar@/^/[rr]^{\aout{y}} 	
	&	*+{t}\ar[r]_{\aout{y}}
	&	*+{u.} 	
	\\	*+{v} 	}}
\]
The transition $s\rout{y}u$ has the implicit effect of disabling the
action $\ain{x}$. The transition $t\rout{y}u$ has no such side effect.
Roughly, out-bufferedness is characterized by the fact that every
output transition $\rout{y}$ factors into a silent part $\Redt$ and a
part ${\atob{y}}$ without side effects.

The second-order axioms for out-buffered agents are given in
Table~\ref{tab-so-ob}. A state $s$ in an {\lts} $\Ss$ is {\defit
reachable}\index{reachable state}\index{state!reachable} if there exist
transitions $s_0\red{\alpha_1}\ldots\red{\alpha_n}s$ from the initial state
$s_0$.  If $\Ss\wbis\Tt$, then for every reachable $s\in\Ss$, there is
reachable $t\in\Tt$ with $s\wbis t$.

%..........................................................................
\begin{table*}[t]\caption{Second-order axioms for out-buffered agents}
\index{out-buffered agent!second-order axioms for}
\label{tab-so-ob}
\begin{center}
\property{\nOBii}{where $\alpha\neq\aout{y}$}{ 
	\diagCx{s}{\atob{y}}{t}{\alpha}{s'} 
\imp	\diagCC{s}{\atob{y}}{t}{\alpha}{\alpha}{s'}{\atob{y}}{t'}}
\property{\nOBi}{where $\alpha\neq\aout{y}$}{
	\diagxC{s}{\atob{y}}{t}{\alpha}{t'} 
\imp 	\diagCC{s}{\atob{y}}{t}{\alpha}{\alpha}{s'}{\atob{y}}{t'}}
\propertynoside{\nOBiv}{
	\diagCx{s}{\atob{y}}{t}{\aout{y}}{s'} 
\imp	\diagCC{s}{\atob{y}}{t}{\aout{y}}{\tau}{s'}{\wbis}{t'}}
\propertynoside{\nOBiii}{
	s\atob{y}t 
\ssep \imp\ssep \ s\Rout{y}\wbis t }
\property{\nOBx}{where $s$ reachable}{
	s\rout{y}t 
\ssep\imp\ssep 	s\Redt\atob{y}t}
\end{center}
\end{table*}
%..........................................................................

\begin{theorem}\label{thm-nob}
An agent $\Ss\from X\jj_B Y$ is out-buffered if and only if there
exists a binary relation ${\atob{y}}\seq\abs{\Ss}\times\abs{\Ss}$ for
each $y\in Y$, satisfying {\nOB}.
\end{theorem}

\begin{proof}
\begin{caselist}
\caseimp Suppose $\Ss$ is out-buffered. By Theorem~\ref{thm-ob},
$\Ss\wbis\Tt$ for some $\Tt$ satisfying {\OB}. For $s,t\in\abs{\Ss}$,
define $s\atob{y}t$ iff there exist $s',t'\in\abs{\Tt}$ with $s\wbis
s'\rout{y}t'\wbis t$. It is easy to verify that ${\atob{y}}$ satisfies
{\nOB}.  
\casepmi Suppose $\Ss$ satisfies {\nOB}. Notice that if a relation
${\atob{y}}$ satisfies {\nOB}, then so does
${\wbis}\cp{\atob{y}}\cp{\wbis}$. Hence assume {\wloss} that ${\atob{y}}$
is invariant under weak bisimulation. For any sequence $w=y_1y_2\cdots
y_n\in\fm{Y}$, write $s\atob{w}t$ if
$s\atob{y_1}\atob{y_2}\cdots\atob{y_n}\wbis t$. Note that in the case
$n=0$ this means $s\wbis t$.  Consider the relation
$R\seq\abs{\Ss}\times\abs{\Ss;\Buf}$ defined by
$R=\{\pair{s,\pair{t,w}}\such s\atob{w}t\mbox{ and $t$ reachable}\}$.
Clearly, $R$ relates initial states: $s_0R\pair{s_0,\emptyset}$. We
show that $R$ is a weak bisimulation. Suppose
\[	\diagcx{s}{R}{\pair{t,w}}{\alpha}{s',}
\]
where $w=y_1\cdots y_n$.
\begin{caselist}
\case $\alpha$ is $\aout{y_i}$ for some $1\leq i\leq n$. Take the
minimal such $i$. Then
\[	\settowidth{\diaglen}{$\atob{y_{i+1}}$}
	\xymatrix@R=1.5em@C=\diaglen{
		*+!{s}\ar@{}[r]|<>(.5)*+!{\atob{y_1}}
		\ar@{->}[d]_<>(.5){\aout{y_i}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atob{y_{i-1}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atob{y_{i}}}
		\ar@{=>}[d]_<>(.5){\aout{y_i}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atob{y_{i+1}}}
		\ar@{=>}[d]_<>(.5){\tau}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atob{y_{n}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
		\ar@{=>}[d]_<>(.5){\tau}
	& 	*+!{t}\ar@{=>}[d]_<>(.5){\tau}
	\\	*+!{s'}\ar@{}[r]|<>(.5)*+!{\atob{y_1}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atob{y_{i-1}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atob{y_{i+1}}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atob{y_{n}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
	& 	*+!{t'}
	}
\]
by {\nOBii} and {\nOBiv}. With $w'=y_1\cdots y_{i-1}y_{i+1}\cdots y_n$
 we hence have $s'R\pair{t',w'}$, and also
 $\pair{t,w}\Rout{y_i}\pair{t',w'}$.{\chk} \case
 $\alpha\neq\aout{y_i}$ for all $i$. From $s\rea s'$ and
 $s\atob{w}t$, by repeated application of {\nOBiv}, we get
 $s'\atob{w}t'$ and $t\Rea t'$ for some $t'$, hence
 $s'R\pair{t',w}$ and $\pair{t,w}\Rea \pair{t',w}$.{\chk} 
\end{caselist}
Now suppose
\[	\diagxc{s}{R}{\pair{t,w}}{\alpha}{\pair{t',w'}.}
\]
We distinguish three cases for $\pair{t,w}\rea\pair{t',w'}$ by
Definition~\ref{def-composition}:
\begin{caselist}
\case $t\rea t'$, $w=w'$ and $\alpha$ not output.
Then $s\atob{w}t\rea t'$ implies $s\Rea s'\atob{w}t'$
by repeated application of {\nOBi}, {\ie}
$s\Rea s'R\pair{t',w}$.{\chk}
\case $t=t'$, $w\rea w'$ and $\alpha$ not input. If $w=y_1\cdots y_n$,
then $\alpha=\aout{y_i}$ for some $1\leq i\leq n$. Let $i$ be the
minimal such index. Then
\[	\settowidth{\diaglen}{$\atob{y_{i+1}}$}
	\xymatrix@R=1.5em@C=\diaglen{
		*+!{s}\ar@{}[r]|<>(.5)*+!{\atob{y_1}}
		\ar@{=>}[d]_<>(.5){\aout{y}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atob{y_{i-1}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atob{y_{i}}}
		\ar@{=>}[d]_<>(.5){\aout{y}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atob{y_{i+1}}}
		\ar@{=}[d]
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atob{y_{n}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
	& 	*+!{t}
	\\	*+!{s'}\ar@{}[r]|<>(.5)*+!{\atob{y_1}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atob{y_{i-1}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
	&	*+!{\bullet}
	}
\]	 
by {\nOBiii} and {\nOBi}, hence $s\Rout{y}s'R\pair{t,w'}$.{\chk}
\case $t\rout{y}t'$, $w\rin{y}w'$ and $\alpha=\tau$.  Then
$w'=wy$. By {\nOBx}, since $t$ is reachable, there is $t''$ with
$t\Redt t''\atob{y}t'$. Then $s\atob{w}t$ and repeated application
of {\nOBi} give $s\Redt s'\atob{w}t''\atob{y}t'$, hence
$sR\pair{t',w'}$.{\chk}\eot
\end{caselist}
\end{caselist}
\end{proof}

\begin{remark}
Notice that Principle~\ref{prin-1} can be applied to obtain a
unique maximal relation ${\atob{y}}$, for every $y$, satisfying
{\nOBcoind}. Thus, $\Ss$ is out-buffered if this unique relation also
satisfies {\nOBx}. Notice in particular how {\nOBii} and {\nOBi}
resemble the definition of weak bisimulation; one may think of the
relation ${\atob{y}}$ as a weak bisimulation up to a suspended output. 
\end{remark}

%----------------------------------------------------------------------------
\subsection{In-buffered agents}

The second-order axioms for in-buffered agents are given in
Table~\ref{tab-so-ib}. This is similar to the axioms for out-buffered
agents, but notice that there is no analogue to {\nOBi}. This reflects
the fact that unlike output transitions, input transitions can {\em
enable}, but not {\em disable} other transitions. 

%..........................................................................
\begin{table*}[p]\caption{Second-order axioms for in-buffered agents}
\index{in-buffered agent!second-order axioms for}
\label{tab-so-ib}
\begin{center}
\property{\nIBiii}{where $\alpha\neq\ain{x}$}{ 
	\diagCx{s}{{\atib{x}}}{t}{\alpha}{s'} 
\imp	\diagCC{s}{{\atib{x}}}{t}{\alpha}{\alpha}{s'}{{\atib{x}}}{t'}}
\propertynoside{\nIBii}{
	\diagCx{s}{{\atib{x}}}{t}{\ain{x}}{s'} 
\imp	\diagCC{s}{{\atib{x}}}{t}{\ain{x}}{\tau}{s'}{\wbis}{t'}}
\begin{tabular}{c}
\propertynoside{\nIBi}{
	s{\atib{x}}t
\ssep \imp\ssep s\Rin{x}s'\wbis t}
\nl
\property{\nIBx}{where $s$ reachable}
	{s\ssep\imp\ssep s\atib{x}s'}
\end{tabular}
\end{center}
\end{table*}
%..........................................................................
\begin{table*}[p]\caption{Second-order axioms for out-queued agents}
\index{out-queued agent!second-order axioms for}
\label{tab-so-oq}
\begin{center}
\property{\nOQii}{where $\alpha$ not output}{ 
	\diagCx{s}{{\atoq{y}}}{t}{\alpha}{s'} 
\imp	\diagCC{s}{{\atoq{y}}}{t}{\alpha}{\alpha}{s'}{{\atoq{y}}}{t'}}
\property{\nOQi}{where $\alpha$ not output}{
	\diagxC{s}{{\atoq{y}}}{t}{\alpha}{t'} 
\imp 	\diagCC{s}{{\atoq{y}}}{t}{\alpha}{\alpha}{s'}{{\atoq{y}}}{t'}}
\propertynoside{\nOQiv}{
	\diagCx{s}{{\atoq{y}}}{t}{\aout{z}}{s'} 
\imp	y=z\mbox{ and }\diagCC{s}{{\atoq{y}}}{t}{\aout{z}}{\tau}{s'}{\wbis}{t'}}
\propertynoside{\nOQiii}{
	s{\atoq{y}}t 
\ssep \imp\ssep s\Rout{y}\wbis t }
\property{\nOQx}{where $s$ reachable}{
	s\rout{y}t 
\ssep\imp\ssep 	s\Redt\atoq{y}t}
\end{center}
\end{table*}
%..........................................................................
\microfilm{\begin{table*}[tp]\caption{Second-order axioms for in-queued agents}}
\nomicrofilm{\begin{table*}[p]\caption{Second-order axioms for in-queued agents}}
\index{in-queued agent!second-order axioms for}
\label{tab-so-iq}
\begin{center}
\property{\nIQiii}{where $\alpha$ not input}{ 
	\diagCx{s}{{\atiq{x}}}{t}{\alpha}{s'} 
\imp	\diagCC{s}{{\atiq{x}}}{t}{\alpha}{\alpha}{s'}{{\atiq{x}}}{t'}}
\propertynoside{\nIQii}{
	\diagCx{s}{{\atiq{x}}}{t}{\ain{x}}{s'} 
\imp	\diagCC{s}{{\atiq{x}}}{t}{\ain{x}}{\tau}{s'}{\wbis}{t'}}
\begin{tabular}{c}
\propertynoside{\nIQi}{
	s{\atiq{x}}t
\ssep \imp\ssep s\Rin{x}\wbis t}
\nl
\property{\nIQx}{where $s$ reachable}
	{s\ssep\imp\ssep s\atiq{x}s'}
\end{tabular}
\end{center}
\end{table*}
%..........................................................................

\begin{theorem}\label{thm-nib}
An agent $\Ss\from X\jj_B Y$ is in-buffered if and only if there
exists a binary relation ${\atib{x}}$ for each $x\in X$, satisfying
{\nIB}.
\end{theorem}

\begin{proof}
\begin{caselist}
\caseimp As in the proof of Theorem~\ref{thm-nob}.
\casepmi Suppose $\Ss$ satisfies {\nIB}. Again, we can
{\wloss} assume that ${\atib{x}}$ is invariant under weak
bisimulation. For any sequence $w=x_1x_2\cdots
x_n\in\fm{X}$, write $s\atib{w}t$ if
$s\atib{x_1}\atib{x_2}\cdots\atib{x_n}\wbis t$ $(n\geq 0)$.  Consider
the relation $R\seq\abs{\Buf;\Ss}\times\abs{\Ss}$ defined by
$R=\{\pair{\pair{w,s},t}\such s\atib{w}t\mbox{ and $t$ reachable}\}$.
Notice that $R$ relates initial states: $\pair{\emptyset,s_0}Rs_0$. To
see that $R$ is a weak bisimulation, suppose
\[	\diagxc{\pair{w,s}}{R}{t}{\alpha}{t',}
\]
where $w=x_1\cdots x_n$.  From $s\atib{w}t$, with {\nIBi} and weak
bisimulation we get $s\Rin{w}s'\wbis t$, hence $s'\Rea s''$ for
some $s''\wbis t'$. Consequently $\pair{w,s}\Redt\pair{\emptyset,s'}
\Rea \pair{\emptyset,s''}Rt'$.  Conversely, suppose
\[	\diagcx{\pair{w,s}}{R}{t}{\alpha}{\pair{w',s'}.}
\]
Again, we distinguish three cases: 
\begin{caselist}
\case $s=s'$, $w\rea w'$ and $\alpha$ not output. Then
$\alpha=\ain{x}$ and $w'=wx$ for some $x\in X$. By {\nIBx},
$t\atib{x}t''$ for some $t''$, and by {\nIBi}, $t\Rin{x}t'\wbis t''$,
hence also $t\atib{x}t'$, and we get $s\atib{w}t\atib{x}t'$, {\ie}
$\pair{w',s}Rt'$ and $t\Rin{x}t'$.{\chk} \case $s\rea s'$,
$w=w'$ and $\alpha$ not input.  From $s\atib{w}t$ by repeated
application of {\nIBiii}, we get $t\Rea t'$ and $s'\atib{w}t'$,
{\ie} $\pair{w,s'}Rt'$.{\chk} \case $w\rout{x}w'$, $s\rin{x}s'$ and
$\alpha=\tau$.  If $w=x_1x_2\cdots x_n$, then $x$ must be $x_i$ for
some $1\leq i\leq n$. Let such $i$ be minimal and construct
\[	\settowidth{\diaglen}{$\atib{x_{i+1}}$}
	\xymatrix@R=1.5em@C=\diaglen{
		*+!{s}\ar@{}[r]|<>(.5)*+!{\atib{x_1}}
		\ar@{->}[d]_<>(.5){\ain{x}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atib{x_{i-1}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atib{x_{i}}}
		\ar@{=>}[d]_<>(.5){\ain{x}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atib{x_{i+1}}}
		\ar@{=>}[d]_<>(.5){\tau}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atib{x_{n}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
		\ar@{=>}[d]_<>(.5){\tau}
	& 	*+!{t}\ar@{=>}[d]_<>(.5){\tau}
	\\	*+!{s'}\ar@{}[r]|<>(.5)*+!{\atib{x_1}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atib{x_{i-1}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\atib{x_{i+1}}}
	&	*+!{\cdots}\ar@{}[r]|<>(.5)*+!{\atib{x_{n}}}
	&	*+!{\bullet}\ar@{}[r]|<>(.5)*+!{\wbis}
	& 	*+!{t'}
	}
\]
by {\nIBiii} and {\nIBii}. This shows $\pair{s',w'}Rt'$.{\chk}\eot
\end{caselist}
\end{caselist}
\end{proof}

%----------------------------------------------------------------------------
\subsection{Out-queued and in-queued agents}

The second-order axioms for out- and in-queued agents are given in
Tables~\ref{tab-so-oq} and {\ref{tab-so-iq}}, respectively. Notice
that the only difference to the buffered case are the side
conditions. 

\begin{theorem}
An agent $\Ss\from X\jj_B Y$ is out-queued if and only if there are
relations ${\atoq{y}}$ satisfying {\nOQ}. $\Ss$ is in-queued if and
only if there are relations ${\atiq{x}}$ satisfying {\nIQ}.
\eot
\end{theorem}

%======================================================================
\cleardoublepage
\begin{thebibliography}{10}

\bibitem{Abr94}
S.~Abramsky.
\newblock Interaction categories and communicating sequential processes.
\newblock In A.~W. Roscoe, editor, {\em A Classical Mind: Essays in honour of
  {C. A. R. Hoare}}, pages 1--16. Prentice Hall International, 1994.

\bibitem{AGN94}
S.~Abramsky, S.~Gay, and R.~Nagarajan.
\newblock Interaction categories and typed concurrent programming.
\newblock In {\em Proceedings of the 1994 Marktoberdorf Summer School}.
  Springer, 1994.

\bibitem{AJ94}
S.~Abramsky and A.~Jung.
\newblock Domain theory.
\newblock In S.~Abramsky, D.~M. Gabbay, and T.~S.~E. Maibaum, editors, {\em
  Handbook of Logic in Computer Science}, volume~3, pages 1--168. Clarendon
  Press, 1994.

\bibitem{ACS96}
R.~M. Amadio, I.~Castellani, and D.~Sangiorgi.
\newblock On bisimulations for the asynchronous $\pi$-calculus.
\newblock In {\em Proc. CONCUR~'96}, Springer LNCS 1119, pages 147--162, 1996.

\bibitem{Bar84}
H.~P. Barendregt.
\newblock {\em The Lambda Calculus, its Syntax and Semantics}.
\newblock North-Holland, 2nd edition, 1984.

\bibitem{Bed88}
M.~A. Bednarczyk.
\newblock {\em Categories of asynchronous systems}.
\newblock PhD thesis, University of Sussex, 1988.

\bibitem{Ber78}
G.~Berry.
\newblock Stable models of typed $\lambda$-calculi.
\newblock In {\em Proceedings of the 5th International Colloquium on Automata,
  Languages and Programming}, Springer LNCS 62, pages 72--89, 1978.

\bibitem{BB92}
G.~Berry and G.~Boudol.
\newblock The chemical abstract machine.
\newblock {\em Theoretical Computer Science}, 96:217--248, 1992.

\bibitem{Bou92}
G.~Boudol.
\newblock Asynchrony and the $\pi$-calculus.
\newblock Technical Report 1702, INRIA, Sophia-Antipolis, 1992.

\bibitem{BM84}
K.~B. Bruce and A.~R. Meyer.
\newblock The semantics of second-order polymorphic lambda calculus.
\newblock In G.~Kahn, D.~B. MacQueen, and G.~Plotkin, editors, {\em Proc. Conf.
  on Semantics of Data Types, Sophia-Antipolis, 1984}, Springer LNCS 173, pages
  131--144, 1984.

\bibitem{BFT76}
S.~Bulman-Fleming and W.~Taylor.
\newblock Union-indecomposable varieties.
\newblock {\em Colloquium Mathematicum}, 35:189--199, 1976.

\bibitem{CR36}
A.~Church and J.~B. Rosser.
\newblock Some properties of conversion.
\newblock {\em Transactions of the American Mathematical Society}, 39:472--482,
  1936.

\bibitem{Coh81}
P.~M. Cohn.
\newblock {\em Universal Algebra, {\rm Revised Edition}}.
\newblock D. Reidel Publishing, Holland, 1981.

\bibitem{Cub95}
D.~{\v{C}}ubri{\'c}.
\newblock Embedding of a free cartesian closed category into the category of
  sets.
\newblock {\em Journal of Pure and Applied Algebra}, 1995.

\bibitem{Cub97}
D.~{\v{C}}ubri{\'c}.
\newblock On the semantics of the universal quantifier.
\newblock {\em Annals of Pure and Applied Logic}, 1997.
\newblock To appear.

\bibitem{DHP94}
P.~{Di Gianantonio}, F.~Honsell, S.~Liani, and G.~D. Plotkin.
\newblock Countable non-determinism and uncountable limits.
\newblock In {\em Proceedings of CONCUR~'94}, Springer LNCS 836, 1994.
\newblock See also: Uncountable limits and the Lambda Calculus, {\it Nordic
  Journal of Computing\/}~2, 1995.

\bibitem{FG96}
C.~Fournet and G.~Gonthier.
\newblock The reflexive cham and the join-calculus.
\newblock In {\em POPL~'96: Proceedings of the 23rd Annual ACM SIGPLAN-SIGACT
  Symposium on Principles of Programming Languages}, 1996.

\bibitem{FGLMR96}
C.~Fournet, G.~Gonthier, J.-J. Levy, L.~Maranget, and D.~Remy.
\newblock A calculus of mobile agents.
\newblock In {\em Proceedings of CONCUR~'96}, Springer LNCS 1119, pages
  406--421, 1996.

\bibitem{Fre89}
P.~J. Freyd.
\newblock Combinators.
\newblock In {\em Proc.\ Mathematical Applications to Computer Science}.
  American Mathematical Society, 1989.

\bibitem{FrS89}
P.~J. Freyd and A.~Scedrov.
\newblock {\em Categories, Allegories}.
\newblock North-Holland, 1989.

\bibitem{Fri75}
H.~Friedman.
\newblock Equality between functionals.
\newblock In R.~Parikh, editor, {\em Proceedings of the Logic Colloquium~'73},
  Springer Lecture Notes in Mathematics 453, pages 22--37, 1975.

\bibitem{Gir71}
J.-Y. Girard.
\newblock {Une extension de l'interpretation de G\"odel \`a l'analyse, et son
  application a l'elimination des coupures dans l'analyse et la th\'eorie des
  types}.
\newblock In J.~E. Fenstad, editor, {\em Proceedings of the Second Scandinavian
  Logic Symposium}, pages 63--92. North-Holland, 1971.

\bibitem{Gir86}
J.-Y. Girard.
\newblock The system {$F$} of variable types, fifteen years later.
\newblock {\em Theoretical Computer Science}, 45:159--192, 1986.

\bibitem{Gra68}
G.~Gr{\"a}tzer.
\newblock {\em Universal Algebra}.
\newblock D. Van Nostrand, 1968.

\bibitem{HaM73}
J.~Hagemann and A.~Mitschke.
\newblock On $n$-permutable congruences.
\newblock {\em Algebra Universalis}, 3:8--12, 1973.

\bibitem{HT91}
K.~Honda and M.~Tokoro.
\newblock An object calculus for asynchronous communication.
\newblock In {\em Proc. ECOOP 91, Geneve}, 1991.

\bibitem{HRDR92}
F.~Honsell and S.~{Ronchi Della Rocca}.
\newblock An approximation theorem for topological lambda models and the
  topological incompleteness of lambda calculus.
\newblock {\em Journal of Computer and System Sciences}, 45(1), 1992.

\bibitem{Hue90}
G.~Huet, editor.
\newblock {\em Logical Foundations of Functional Programming}.
\newblock Addison-Wesley, 1990.

\bibitem{Hyl76}
M.~Hyland.
\newblock A syntactic characterization of the equality in some models for the
  lambda calculus.
\newblock {\em J. London Math. Soc.}, 12:361--370, 1976.

\bibitem{JMZ92}
B.~Jacobs, I.~Margaria, and M.~Zacchi.
\newblock Filter models with polymorphic types.
\newblock {\em Theoretical Computer Science}, 95:143--158, 1992.

\bibitem{Koy82}
C.~P.~J. Koymans.
\newblock Models of the lambda calculus.
\newblock {\em Information and Control}, 52:306--332, 1982.

\bibitem{Kri93}
J.-L. Krivine.
\newblock {\em Lambda-calculus, types and models}.
\newblock Masson, 1993.

\bibitem{Lam80b}
J.~Lambek.
\newblock From $\lambda$-calculus to cartesian closed categories.
\newblock In J.~P. Seldin and J.~R. Hindley, editors, {\em To {H.~B. Curry}:
  Essays on Combinatory Logic, Lambda Calculus and Formalism}, pages 375--402.
  Academic Press, London, New York, 1980.

\bibitem{LaS86}
J.~Lambek and P.~J. Scott.
\newblock {\em An Introduction to Higher Order Categorical Logic}.
\newblock Cambridge Studies in Advanced Mathematics 7. Cambridge University
  Press, New York, 1986.

\bibitem{LS89}
N.~A. Lynch and E.~W. Stark.
\newblock A proof of the {Kahn} principle for input/output automata.
\newblock {\em Information and Computation}, 82:81--92, 1989.

\bibitem{Mac71}
S.~MacLane.
\newblock {\em Categories for the Working Mathematician}.
\newblock Springer GTM 5. 1971.

\bibitem{Mal54}
A.~I. Mal\hspace{-.2ex}'\hspace{-.3ex}cev.
\newblock {K ob\v{s}\v{c}e\v{\i} teorii algebrai\v{c}eskih sistem}.
\newblock {\em {Mat. Sb. N. S. 35 (77)}}, pages 3--20, 1954.

\bibitem{Mey82}
A.~R. Meyer.
\newblock What is a model of the lambda calculus?
\newblock {\em Information and Control}, 52:87--122, 1982.

\bibitem{MMMS87}
A.~R. Meyer, J.~C. Mitchell, E.~Moggi, and R.~Statman.
\newblock Empty types in polymorphic lambda calculus.
\newblock In {\em Proceedings of the 14th ACM Symposium on Principles of
  Programming Languages}, pages 253--262, 1987.
\newblock Reprinted in \cite{Hue90}.

\bibitem{Mil80}
R.~Milner.
\newblock {\em A Calculus of Communicationg Systems}.
\newblock Springer LNCS 92. 1980.

\bibitem{Mil90}
R.~Milner.
\newblock Operational and algebraic semantics of concurrent processes.
\newblock In J.~van Leeuwen, editor, {\em Handbook of Theoretical Computer
  Science}, volume~B. Elsevier, 1990.

\bibitem{MM91}
J.~C. Mitchell and E.~Moggi.
\newblock Kripke-style models for typed lambda calculus.
\newblock {\em Annals of Pure and Applied Logic}, 51:99--124, 1991.

\bibitem{FM89}
J.~Myhill and R.~Flagg.
\newblock A type-free system extending {(ZFC)}.
\newblock {\em Annals of Pure and Applied Logic 43}, pages 79--97, 1989.

\bibitem{NP96}
U.~Nestmann and B.~C. Pierce.
\newblock Decoding choice encodings.
\newblock In {\em Proceedings of CONCUR~'96}, Springer LNCS 1119, pages
  179--194, 1996.

\bibitem{Pal97}
C.~Palamidessi.
\newblock Comparing the expressive power of the synchronous and the
  asynchronous $\pi$-calculus.
\newblock In {\em POPL~'97: Proceedings of the 24th Annual ACM SIGPLAN-SIGACT
  Symposium on Principles of Programming Languages (Paris)}, 1997.

\bibitem{Plo74}
G.~D. Plotkin.
\newblock The $\lambda$-calculus is $\omega$-incomplete.
\newblock {\em The Journal of Symbolic Logic}, 39:313--317, 1974.

\bibitem{Plo83}
G.~D. Plotkin.
\newblock {\em Domains}.
\newblock Department of Computer Science, University of Edinburgh, 1983.

\bibitem{Plo93}
G.~D. Plotkin.
\newblock Set-theoretical and other models of the lambda-calculus.
\newblock {\em Theoretical Computer Science}, 121:351--409, 1993.

\bibitem{Plo94}
G.~D. Plotkin.
\newblock A semantics for static type inference.
\newblock {\em Information and Computation}, 109:256--299, 1994.

\bibitem{Plo96}
G.~D. Plotkin.
\newblock On a question of {H.~Friedman}.
\newblock {\em Information and Computation}, 126(1):74--77, 1996.

\bibitem{Rey74}
J.~C. Reynolds.
\newblock Towards a theory of type structure.
\newblock In {\em Proceedings, Colloque sur la Programmation}, Springer LNCS
  19, pages 408--425, 1974.

\bibitem{Rey84}
J.~C. Reynolds.
\newblock Polymorphism is not set-theoretic.
\newblock In {\em International Symposium on Semantics of Data Types}, Springer
  LNCS 173, pages 145--156, 1984.

\bibitem{Sco72}
D.~S. Scott.
\newblock Continuous lattices, toposes, algebraic geometry and logic.
\newblock In F.~W. Lawvere, editor, {\em Proc.\ 1971 Dalhousie Conference},
  Springer Lecture Notes in Mathematics 274, pages 97--136, 1972.

\bibitem{Sco80}
D.~S. Scott.
\newblock Relating theories of the $\lambda$-calculus.
\newblock In {\em To {H.~B. Curry}: Essays on Combinatory Logic, Lambda
  Calculus and Formalism}, pages 403--450. Academic Press, London, New York,
  1980.

\bibitem{See83}
R.~A.~G. Seely.
\newblock Hyperdoctrines, natural deduction and the {Beck} condition.
\newblock {\em Zeitschrift f{\"u}r mathematische Logik und Grundlagen der
  Mathematik}, 29:505--542, 1983.

\bibitem{See87}
R.~A.~G. Seely.
\newblock Categorical semantics for higher order polymorphic lambda calculus.
\newblock {\em The Journal of Symbolic Logic}, 52(4), Dec. 1987.

\bibitem{Sel96}
P.~Selinger.
\newblock Order-incompleteness and finite lambda models. {E}xtended abstract.
\newblock In {\em Proceedings of the Eleventh Annual IEEE Symposium on Logic in
  Computer Science}, pages 432--439, 1996.

\bibitem{Sel97b}
P.~Selinger.
\newblock First-order axioms for asynchrony.
\newblock In {\em Proceedings of CONCUR~'97}, Springer LNCS, 1997.
\newblock To appear.

\bibitem{Shi85}
M.~W. Shields.
\newblock Concurrent machines.
\newblock {\em Theoretical Computer Science}, 28:449--465, 1985.

\bibitem{Sim95}
A.~K. Simpson.
\newblock Categorical completeness results for the simply-typed
  lambda-calculus.
\newblock In {\em Proc.\ TLCA~'95}, Springer LNCS 902, pages 414--427, 1995.

\bibitem{SP82}
M.~B. Smyth and G.~D. Plotkin.
\newblock The category-theoretic solution of recursive domain equations.
\newblock {\em SIAM Journal on Computing}, 11(4):761--783, 1982.

\bibitem{Str67}
C.~Strachey.
\newblock Fundamental concepts in programming languages.
\newblock Unpublished lecture notes, International Summer School in Computer
  Programming, Copenhagen, Aug. 1967.

\bibitem{Tay74}
W.~Taylor.
\newblock Structures incompatible with varieties, {Abstract {74T-A224}}.
\newblock {\em Notices of the American Mathematical Society}, 21:A\dash529,
  1974.

\bibitem{Wad76}
C.~P. Wadsworth.
\newblock The relation between computational and denotational properties for
  {Scott}'s {$D_{\infty}$}-models of the lambda-calculus.
\newblock {\em SIAM Journal on Computing}, 5:488--521, 1976.

\end{thebibliography}

%======================================================================
% Index

\singlespaced
\cleardoublepage
\printindex

\end{document}
