arXiv reader

Normalization by Evaluation with Substitutions as Operations

Jason Z. S. Hu

arXiv
2610.21131v1 · PDF · 15 October 2026
Categories
cs.PL, math.LO
Licence
CC BY 4.0 The site shows the text.

Abstract

In previous works on normalization by evaluation (NbE) with an untyped domain model, explicit substitutions are a major decision choice, which, in retrospect, is taken to simplify subsequent semantic proofs. This choice hence is taken for a purely technical reason. In addition, there is no obvious lemma to test the completeness of the definition or the laws for explicit substitutions. In this technical report, we investigate NbE in a typical setting, i.e. defining substitutions as operations. We show that this setting brings simplifications in proving syntactic properties and soundness of NbE, though complications are introduced in the completeness proof of NbE.

Items 316

Notation

Notation

UVSF

We use \mathbb{N} for the type of natural numbers at the meta-level. Contexts are snoc-lists written \Gamma, x : T. Application of a substitution \sigma to a term t is written t[\sigma], and composition of substitutions is written \sigma \circ \tau (meaning first \sigma, then \tau).

Definition

Definition 2.1 (Raw Expressions)

YKPA

The set \textsf{Exp} of raw expressions is generated by the following grammar:

\begin{array}{rcll} t, s, S, T \in \textsf{Exp} & ::= & x & \text{(variable)} \\ & \mid & \ensuremath{\texttt{Ty}_{i}} & \text{(universe at level $i$)} \\ & \mid & \ensuremath{\texttt{Nat}} & \text{(natural number type)} \\ & \mid & \Pi(x : S).\, T & \text{(dependent function type, $x$ bound in $T$)} \\ & \mid & \textsf{zero} & \text{(zero)} \\ & \mid & \textsf{succ}~t & \text{(successor)} \\ & \mid & \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t} & \text{(natural number eliminator)} \\ & \mid & \lambda x.\, t & \text{(lambda abstraction, $x$ bound in $t$)} \\ & \mid & r~s & \text{(application)} \end{array}
Definition

Definition 2.2 (Contexts)

W3JJ

Contexts \Gamma, \Delta \in \textsf{Ctx} are ordered lists of variable-type pairs:

\Gamma \in \textsf{Ctx} \quad ::= \quad \cdot \quad \mid \quad \Gamma, x : S

where \cdot is the empty context and \Gamma, x : S extends \Gamma with a fresh variable x of type S \in \textsf{Exp}. We write |\Gamma| for the length of \Gamma.

Used by Proof, Proof, Proof
Definition

Definition 2.3 (Weakenings)

5WQZ

A weakening is a function \phi : \mathbb{N} \to \mathbb{N}. The key operations on weakenings are:

\begin{aligned} \ensuremath{\textsf{id}} &: \mathbb{N} \to \mathbb{N} & \ensuremath{\textsf{id}}(x) &= x \\ {\Uparrow} &: \mathbb{N} \to \mathbb{N} & {\Uparrow}(x) &= x + 1 \\ q(\phi) &: \mathbb{N} \to \mathbb{N} & q(\phi)(0) &= 0 \\ && q(\phi)(x+1) &= \phi(x) + 1 \end{aligned}

The shift \Uparrow increments all indices by one (corresponding to introducing one new binding). The operation q(\phi) extends a weakening under a binder: it fixes index 0 (the newly bound variable) and applies \phi followed by a successor to all other indices.

Definition

Definition 2.4 (Weakening Application)

GLZJ

The application of a weakening \phi to a term t, written t[\phi], is defined by recursion on the structure of t:

\begin{aligned} x[\phi] &= \phi(x) \\ \ensuremath{\texttt{Ty}_{i}}[\phi] &= \ensuremath{\texttt{Ty}_{i}} \\ \ensuremath{\texttt{Nat}}[\phi] &= \ensuremath{\texttt{Nat}} \\ (\Pi(x : S).\, T)[\phi] &= \Pi(x : S[\phi]).\, (T[q(\phi)]) \\ \textsf{zero}[\phi] &= \textsf{zero} \\ (\textsf{succ}~t)[\phi] &= \textsf{succ}~(t[\phi]) \\ (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t})[\phi] &= \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\phi)])~z[\phi]~(x,y.\, s[q^2(\phi)])~t[\phi]} \\ (\lambda x.\, t)[\phi] &= \lambda x.\, t[q(\phi)] \\ (r\; s)[\phi] &= (r[\phi])\; (s[\phi]) \end{aligned}

Whenever we pass under a binder, we extend the weakening with q. The successor case of the eliminator binds two variables (x for the predecessor, y for the inductive hypothesis), hence q is applied twice.

Lemma

Lemma 2.5 (q-Identity)

DZGX

q(\ensuremath{\textsf{id}}) = \ensuremath{\textsf{id}}.

Proof of Lemma 2.5

By case analysis on the argument:

\begin{aligned} q(\ensuremath{\textsf{id}})(0) &= 0 = \ensuremath{\textsf{id}}(0) \\ q(\ensuremath{\textsf{id}})(x+1) &= \ensuremath{\textsf{id}}(x) + 1 = x + 1 = \ensuremath{\textsf{id}}(x+1) \end{aligned}
Lemma

Lemma 2.6 (Identity Weakening)

8R0N

For all t \in \textsf{Exp}, t[\ensuremath{\textsf{id}}] = t.

Proof of Lemma 2.6

By induction on t. We show a few representative cases.

    t = x (variable).

    \begin{aligned} x[\ensuremath{\textsf{id}}] = \ensuremath{\textsf{id}}(x) = x \end{aligned}

    t = \lambda x.\, t'.

    \begin{aligned} (\lambda x.\, t')[\ensuremath{\textsf{id}}] &= \lambda x.\, (t'[q(\ensuremath{\textsf{id}})]) \\ &= \lambda x.\, (t'[\ensuremath{\textsf{id}}]) \tag{by \Cref{lem:wk-q-id}} \\ &= \lambda x.\, t' \end{aligned}

    t = \Pi(x : S).\, T.

    \begin{aligned} (\Pi(x : S).\, T)[\ensuremath{\textsf{id}}] &= \Pi(x : S[\ensuremath{\textsf{id}}]).\, (T[q(\ensuremath{\textsf{id}})]) \\ &= \Pi(x : S).\, (T[\ensuremath{\textsf{id}}]) \tag{by IH and \Cref{lem:wk-q-id}} \\ &= \Pi(x : S).\, T \end{aligned}

All other cases follow the same pattern.

Lemma

Lemma 2.7 (q Distributes over Composition)

AMXN

For all weakenings \phi, \psi: q(\phi) \circ q(\psi) = q(\phi \circ \psi).

Proof of Lemma 2.7

By case analysis on the argument:

\begin{aligned} (q(\phi) \circ q(\psi))(0) &= q(\psi)(q(\phi)(0)) = q(\psi)(0) = 0 = q(\phi \circ \psi)(0) \\ (q(\phi) \circ q(\psi))(x+1) &= q(\psi)(\phi(x) + 1) = \psi(\phi(x)) + 1 \\ &= (\phi \circ \psi)(x) + 1 = q(\phi \circ \psi)(x+1) \end{aligned}
Lemma

Lemma 2.8 (q^n Distributes over Composition)

JH3N

For all weakenings \phi, \psi: q^n(\phi) \circ q^n(\psi) = q^n(\phi \circ \psi).

Lemma

Lemma 2.9 (Composition of Weakening Application)

252S

For all t \in \textsf{Exp} and weakenings \phi, \psi: t[\phi][\psi] = t[\phi \circ \psi].

Proof of Lemma 2.9

By induction on t. We show a few representative cases.

    t = x (variable).

    \begin{aligned} x[\phi][\psi] = (\phi(x))[\psi] = \psi(\phi(x)) = (\phi \circ \psi)(x) = x[\phi \circ \psi] \end{aligned}

    t = \lambda x.\, t'.

    \begin{aligned} (\lambda x.\, t')[\phi][\psi] &= (\lambda x.\, (t'[q(\phi)]))[\psi] \\ &= \lambda x.\, (t'[q(\phi)][q(\psi)]) \\ &= \lambda x.\, (t'[q(\phi) \circ q(\psi)]) \\ &= \lambda x.\, (t'[q(\phi \circ \psi)]) \tag{by \Cref{lem:wk-q-comp}} \\ &= (\lambda x.\, t')[\phi \circ \psi] \end{aligned}

    t = \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t'}.

    \begin{aligned} & (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t'})[\phi][\psi] \\ &= (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\phi)])~z[\phi]~(x, y.\, s[q^2(\phi)])~t'[\phi]})[\psi] \\ &= \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\phi)][q(\psi)])~z[\phi][\psi]~(x, y.\, s[q^2(\phi)][q^2(\psi)])~t'[\phi][\psi]} \\ &= \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\phi) \circ q(\psi)])~z[\phi \circ \psi]~(x, y.\, s[q^2(\phi) \circ q^2(\psi)])~t'[\phi \circ \psi]} \\ &= \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\phi \circ \psi)])~z[\phi \circ \psi]~(x, y.\, s[q^2(\phi \circ \psi)])~t'[\phi \circ \psi]} \tag{by \Cref{lem:wk-qn-comp}} \\ &= (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t'})[\phi \circ \psi] \end{aligned}

The cases for \textsf{succ}~t, r\; s, \Pi, \ensuremath{\texttt{Nat}}, \ensuremath{\texttt{Ty}_{i}}, and \textsf{zero} are similar or immediate.

Lemma

Lemma 2.10 (Categorical Laws for Weakenings)

CPI5

Weakenings satisfy:

    (Left identity) \ensuremath{\textsf{id}} \circ \phi = \phi. (Right identity) \phi \circ \ensuremath{\textsf{id}} = \phi. (Associativity) (\phi \circ \psi) \circ \chi = \phi \circ (\psi \circ \chi).

Proof of Lemma 2.10

All three are immediate from the definition of composition as function composition on \mathbb{N}:

\begin{aligned} (\ensuremath{\textsf{id}} \circ \phi)(x) &= \phi(\ensuremath{\textsf{id}}(x)) = \phi(x) \\ (\phi \circ \ensuremath{\textsf{id}})(x) &= \ensuremath{\textsf{id}}(\phi(x)) = \phi(x) \\ ((\phi \circ \psi) \circ \chi)(x) &= \chi(\psi(\phi(x))) = (\phi \circ (\psi \circ \chi))(x) \end{aligned}
Definition

Definition 2.11 (Substitution Operations)

6VWC

We define the following operations on substitutions:

    Identity. \ensuremath{\textsf{id}} : \textsf{Subst}, defined by \ensuremath{\textsf{id}}(x) = x. Extension (cons). Given a substitution \sigma, a variable x, and a term s, we write (\sigma, s/x) for the substitution:

    (\sigma, s/x)(0) = s \qquad (\sigma, s/x)(x+1) = \sigma(x)

    Here x is a visual mnemonic for the variable at de Bruijn index 0; under the hood, the extension always targets index 0. Lifting under a binder. Given a substitution \sigma, we define q(\sigma) : \textsf{Subst} by:

    q(\sigma)(0) = 0 \qquad q(\sigma)(x+1) = (\sigma(x))[\Uparrow]

    This fixes index 0 and applies \sigma to the remaining indices, weakening the results by one to account for the new binder. Applying a weakening to a substitution. Given a substitution \sigma and a weakening \phi, we define \sigma[\phi] : \textsf{Subst} pointwise:

    (\sigma[\phi])(x) = (\sigma(x))[\phi]

    Composition. Given substitutions \sigma and \tau, their composition is:

    (\sigma \circ \tau)(x) = (\sigma(x))[\tau]
Definition

Definition 2.12 (Substitution Application)

MJWR

The function ({-})[{-}] : \textsf{Exp} \to \textsf{Subst} \to \textsf{Exp} is defined by recursion on the structure of the expression:

\begin{aligned} x[\sigma] &= \sigma(x) \\ \ensuremath{\texttt{Ty}_{i}}[\sigma] &= \ensuremath{\texttt{Ty}_{i}} \\ \ensuremath{\texttt{Nat}}[\sigma] &= \ensuremath{\texttt{Nat}} \\ (\Pi(x : S).\, T)[\sigma] &= \Pi(x : S[\sigma]).\, (T[q(\sigma)]) \\ \textsf{zero}[\sigma] &= \textsf{zero} \\ (\textsf{succ}~t)[\sigma] &= \textsf{succ}~(t[\sigma]) \\ (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t})[\sigma] &= \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x,y.\, s[q^2(\sigma)])~t[\sigma]} \\ (\lambda x.\, t)[\sigma] &= \lambda x.\, t[q(\sigma)] \\ (r\; s)[\sigma] &= (r[\sigma])\; (s[\sigma]) \end{aligned}

Whenever we pass under a binder, we lift \sigma with q. The successor case of the eliminator binds two variables, hence q is applied twice.

Definition

Definition 2.13 (Embedding of Weakenings into Substitutions)

6192

Every weakening \phi can be regarded as a substitution via the embedding:

\iota(\phi) : \textsf{Subst} \qquad \iota(\phi)(x) = \phi(x)

That is, \iota(\phi) maps each index n to the variable \phi(x).

Lemma

Lemma 2.14 (Embedding Correctness)

PPTR

For all t \in \textsf{Exp} and weakenings \phi: t[\phi] = t[\iota(\phi)].

Proof of Lemma 2.14

By induction on t. The key observation is that q(\iota(\phi)) = \iota(q(\phi)):

\begin{aligned} q(\iota(\phi))(0) &= 0 = \iota(q(\phi))(0) \\ q(\iota(\phi))(x+1) &= \iota(\phi)(x)[\Uparrow] = \phi(x)[\Uparrow] = \phi(x) + 1 = \iota(q(\phi))(x+1) \end{aligned}

With this fact, the induction is straightforward: at each binding form, we use q(\iota(\phi)) = \iota(q(\phi)) to relate the substitution side to the weakening side. For example:

\begin{aligned} (\lambda x.\, t')[\iota(\phi)] &= \lambda x.\, (t'[q(\iota(\phi))]) \\ &= \lambda x.\, (t'[\iota(q(\phi))]) \\ &= \lambda x.\, (t'[q(\phi)]) \\ &= (\lambda x.\, t')[\phi] \end{aligned}
Lemma

Lemma 2.15 (Structural Properties of \iota)

D2C8

The embedding \iota preserves all weakening structure:

    \iota(\ensuremath{\textsf{id}}) = \ensuremath{\textsf{id}}. \iota(\Uparrow) = \Uparrow (as substitutions, i.e. \iota(\Uparrow)(x) = x + 1). \iota(q(\phi)) = q(\iota(\phi)). \iota(\phi \circ \psi) = \iota(\phi) \circ \iota(\psi).

Proof of Lemma 2.15

    \iota(\ensuremath{\textsf{id}})(x) = \ensuremath{\textsf{id}}(x) = x = \ensuremath{\textsf{id}}(x). \iota(\Uparrow)(x) = \Uparrow(x) = x + 1. As a substitution, this is the variable x+1, which equals \Uparrow viewed as a substitution. Already shown in the proof of ?: q(\iota(\phi))(0) = 0 = \iota(q(\phi))(0) and q(\iota(\phi))(x+1) = \phi(x) + 1 = \iota(q(\phi))(x+1). We verify pointwise:

    \begin{aligned} (\iota(\phi) \circ \iota(\psi))(x) &= \iota(\phi)(x)[\iota(\psi)] \\ &= \phi(x)[\iota(\psi)] \\ &= \psi(\phi(x)) \tag{by \Cref{lem:wk-embed-correct}} \\ &= (\phi \circ \psi)(x) \\ &= \iota(\phi \circ \psi)(x) \end{aligned}
Lemma

Lemma 2.16 (q-Identity for Substitutions)

5JXJ

q(\ensuremath{\textsf{id}}) = \ensuremath{\textsf{id}}.

Proof of Lemma 2.16

By case analysis:

\begin{aligned} q(\ensuremath{\textsf{id}})(0) &= 0 = \ensuremath{\textsf{id}}(0) \\ q(\ensuremath{\textsf{id}})(x+1) &= \ensuremath{\textsf{id}}(x)[\Uparrow] = x[\Uparrow] = x + 1 = \ensuremath{\textsf{id}}(x+1) \end{aligned}
Lemma

Lemma 2.17 (Identity Substitution)

M33S

For all t \in \textsf{Exp}: t[\ensuremath{\textsf{id}}] = t.

Proof of Lemma 2.17

By induction on t.

    t = x (variable). x[\ensuremath{\textsf{id}}] = \ensuremath{\textsf{id}}(x) = x. t = \lambda x.\, t'.

    \begin{aligned} (\lambda x.\, t')[\ensuremath{\textsf{id}}] &= \lambda x.\, (t'[q(\ensuremath{\textsf{id}})]) \\ &= \lambda x.\, (t'[\ensuremath{\textsf{id}}]) \tag{by \Cref{lem:subst-q-id}} \\ &= \lambda x.\, t' \end{aligned}

    t = \Pi(x:S).\, T.

    \begin{aligned} (\Pi(x:S).\, T)[\ensuremath{\textsf{id}}] &= \Pi(x : S[\ensuremath{\textsf{id}}]).\, (T[q(\ensuremath{\textsf{id}})]) \\ &= \Pi(x : S).\, (T[\ensuremath{\textsf{id}}]) \tag{by IH and \Cref{lem:subst-q-id}} \\ &= \Pi(x : S).\, T \end{aligned}

All other cases are similar.

Lemma

Lemma 2.18 (Action of q^n on Indices)

JEPA

For all n and weakenings \phi:

    If x < n, then q^n(\phi)(x) = x. q^n(\phi)(x) = \phi(0) + x. If x > n, then q^n(\phi)(x) = \phi(x - n) + n.

In particular, for \phi = \Uparrow:

    If x < n, then q^n(\Uparrow)(x) = x. q^n(\Uparrow)(x) = x + 1. If x > n, then q^n(\Uparrow)(x) = x + 1.

Proof of Lemma 2.18

By induction on n.

    n = 0: (1) vacuous. (2) q^0(\phi)(0) = \phi(0) = \phi(0) + 0. (3) q^0(\phi)(x) = \phi(x) = \phi(x - 0) + 0. n + 1: We use q^{n+1}(\phi) = q(q^n(\phi)).

      If x < n+1: either x = 0 (then q(q^n(\phi))(0) = 0 = x) or x = y + 1 with y < n (then q(q^n(\phi))(y+1) = q^n(\phi)(y) + 1 = y + 1 = x by the IH). x = n + 1: q(q^n(\phi))(n+1) = q^n(\phi)(n) + 1 = (\phi(0) + n) + 1 = \phi(0) + (n+1) by the IH. x > n + 1: x = y + 1 with y > n. q(q^n(\phi))(y+1) = q^n(\phi)(y) + 1 = (\phi(y - n) + n) + 1 = \phi((y+1) - (n+1)) + (n+1) by the IH.

Lemma

Lemma 2.19 (Action of q^n on Substitution Indices)

S6DH

For all n and substitutions \sigma:

    If x < n, then q^n(\sigma)(x) = x. q^n(\sigma)(n) = \sigma(0)[\Uparrow^n] (where \Uparrow^n denotes n-fold shift). If x > n, then q^n(\sigma)(x) = \sigma(x - n)[\Uparrow^n].

Proof of Lemma 2.19

By induction on n.

    n = 0: (1) vacuous. (2) q^0(\sigma)(0) = \sigma(0) = \sigma(0)[\Uparrow^0]. (3) q^0(\sigma)(x) = \sigma(x) = \sigma(x-0)[\Uparrow^0]. n + 1: We use q^{n+1}(\sigma) = q(q^n(\sigma)).

      If x < n+1: either x = 0 (then q(q^n(\sigma))(0) = 0 = x) or x = y + 1 with y < n (then q(q^n(\sigma))(y+1) = (q^n(\sigma)(y))[\Uparrow] = y[\Uparrow] = y + 1 = x by the IH (1)). x = n + 1:

      \begin{aligned} q(q^n(\sigma))(n+1) &= (q^n(\sigma)(n))[\Uparrow] \\ &= (\sigma(0)[\Uparrow^n])[\Uparrow] \\ &= \sigma(0)[\Uparrow^{n+1}] \tag{by \Cref{lem:wk-comp}} \end{aligned}

      x > n+1: x = y + 1 with y > n.

      \begin{aligned} q(q^n(\sigma))(y+1) &= (q^n(\sigma)(y))[\Uparrow] \\ &= (\sigma(y - n)[\Uparrow^n])[\Uparrow] \\ &= \sigma(y - n)[\Uparrow^{n+1}] \tag{by \Cref{lem:wk-comp}} \\ &= \sigma((y+1) - (n+1))[\Uparrow^{n+1}] \end{aligned}
Lemma

Lemma 2.20 (Weakening–Substitution Commutation (Generalized)

75EI

For all t \in \textsf{Exp}, n \in \mathbb{N}, and substitutions \sigma:

(t[q^n(\Uparrow)])[q^{1+n}(\sigma)] = t[q^n(\sigma)][q^n(\Uparrow)]
Proof

Proof

82SN

By induction on t, generalizing over n.

    t = x (variable). We must show (q^n(\Uparrow)(x))[q^{1+n}(\sigma)] = (q^n(\sigma)(x))[q^n(\Uparrow)]. We case-split on the position of x relative to n.

      If x < n:

      \begin{aligned} \text{LHS} &= (q^n(\Uparrow)(x))[q^{1+n}(\sigma)] \\ &= x[q^{1+n}(\sigma)] \tag{by \Cref{lem:qn-index}(a): $q^n(\Uparrow)(x) = x$ since $x < n$} \\ &= x \tag{by \Cref{lem:qn-subst-index}(1): $q^{1+n}(\sigma)(x) = x$ since $x < n < 1+n$} \end{aligned}
      \begin{aligned} \text{RHS} &= (q^n(\sigma)(x))[q^n(\Uparrow)] \\ &= x[q^n(\Uparrow)] \tag{by \Cref{lem:qn-subst-index}(1): $q^n(\sigma)(x) = x$ since $x < n$} \\ &= x \tag{by \Cref{lem:qn-index}(a)} \end{aligned}

      If x = n:

      \begin{aligned} \text{LHS} &= (q^n(\Uparrow)(n))[q^{1+n}(\sigma)] \\ &= (n + 1)[q^{1+n}(\sigma)] \tag{by \Cref{lem:qn-index}(b)} \\ &= q^{1+n}(\sigma)(1+n) \\ &= \sigma(0)[\Uparrow^{1+n}] \tag{by \Cref{lem:qn-subst-index}(2) at iteration $1+n$} \end{aligned}
      \begin{aligned} \text{RHS} &= (q^n(\sigma)(n))[q^n(\Uparrow)] \\ &= (\sigma(0)[\Uparrow^n])[q^n(\Uparrow)] \tag{by \Cref{lem:qn-subst-index}(2)} \\ &= \sigma(0)[\Uparrow^n \circ q^n(\Uparrow)] \tag{by \Cref{lem:wk-comp}} \\ &= \sigma(0)[\Uparrow^{1+n}] \tag{since $(\Uparrow^n \circ q^n(\Uparrow))(x) = q^n(\Uparrow)(x + n) = x + 1 + n = \Uparrow^{1+n}(x)$} \end{aligned}

      If x > n: Let x = 1 + n + k.

      \begin{aligned} \text{LHS} &= (q^n(\Uparrow)(1 + n + k))[q^{1+n}(\sigma)] \\ &= (2 + n + k)[q^{1+n}(\sigma)] \tag{by \Cref{lem:qn-index}(c)} \\ &= q^{1+n}(\sigma)(2 + n + k) \\ &= \sigma(1+k)[\Uparrow^{1+n}] \tag{by \Cref{lem:qn-subst-index}(3): $(2+n+k) - (1+n) = 1+k$} \end{aligned}
      \begin{aligned} \text{RHS} &= (q^n(\sigma)(1 + n + k))[q^n(\Uparrow)] \\ &= (\sigma(1+k)[\Uparrow^n])[q^n(\Uparrow)] \tag{by \Cref{lem:qn-subst-index}(3): $(1+n+k) - n = 1+k$} \\ &= \sigma(1+k)[\Uparrow^n \circ q^n(\Uparrow)] \tag{by \Cref{lem:wk-comp}} \\ &= \sigma(1+k)[\Uparrow^{1+n}] \end{aligned}

    t = \lambda y.\, t'.

    \begin{aligned} (\lambda y.\, t')[q^n(\Uparrow)][q^{1+n}(\sigma)] &= (\lambda y.\, t'[q^{1+n}(\Uparrow)])[q^{1+n}(\sigma)] \\ &= \lambda y.\, (t'[q^{1+n}(\Uparrow)][q^{2+n}(\sigma)]) \\ &= \lambda y.\, (t'[q^{1+n}(\sigma)][q^{1+n}(\Uparrow)]) \\ &= (\lambda y.\, t'[q^{1+n}(\sigma)])[q^n(\Uparrow)] \\ &= (\lambda y.\, t')[q^n(\sigma)][q^n(\Uparrow)] \end{aligned}

    t = \Pi(y : S).\, T.

    \begin{aligned} (\Pi(y:S).\,T)[q^n(\Uparrow)][q^{1+n}(\sigma)] &= (\Pi(y : S[q^n(\Uparrow)]).\, (T[q^{1+n}(\Uparrow)]))[q^{1+n}(\sigma)] \\ &= \Pi(y : S[q^n(\Uparrow)][q^{1+n}(\sigma)]).\, (T[q^{1+n}(\Uparrow)][q^{2+n}(\sigma)]) \\ &= \Pi(y : S[q^n(\sigma)][q^n(\Uparrow)]).\, (T[q^{1+n}(\sigma)][q^{1+n}(\Uparrow)]) \\ &= (\Pi(y : S[q^n(\sigma)]).\, (T[q^{1+n}(\sigma)]))[q^n(\Uparrow)] \\ &= (\Pi(y:S).\,T)[q^n(\sigma)][q^n(\Uparrow)] \end{aligned}

The remaining cases follow the same pattern, applying the IH at increased n for each binder.

Lemma

Lemma 2.21 (q Distributes over Composition)

HEW8

For all substitutions \sigma, \tau: q(\sigma) \circ q(\tau) = q(\sigma \circ \tau).

Proof of Lemma 2.21

By case analysis:

    At index 0:

    \begin{aligned} (q(\sigma) \circ q(\tau))(0) = q(\sigma)(0)[q(\tau)] = 0[q(\tau)] = q(\tau)(0) = 0 = q(\sigma \circ \tau)(0) \end{aligned}

    At index x+1:

    \begin{aligned} (q(\sigma) \circ q(\tau))(x+1) &= (q(\sigma)(x+1))[q(\tau)] \\ &= (\sigma(x))[\Uparrow][q(\tau)] \\ &= (\sigma(x))[\tau][\Uparrow] \tag{by \Cref{lem:wk-subst-comm}} \\ &= ((\sigma \circ \tau)(x))[\Uparrow] \\ &= q(\sigma \circ \tau)(x+1) \end{aligned}
Lemma

Lemma 2.22 (Composition of Substitution Application)

2EKO

For all t \in \textsf{Exp} and substitutions \sigma, \tau: t[\sigma][\tau] = t[\sigma \circ \tau].

Proof of Lemma 2.22

By induction on t.

    t = x (variable). x[\sigma][\tau] = \sigma(x)[\tau] = (\sigma \circ \tau)(x) = x[\sigma \circ \tau]. t = \lambda x.\, t'.

    \begin{aligned} (\lambda x.\, t')[\sigma][\tau] &= (\lambda x.\, t'[q(\sigma)])[\tau] \\ &= \lambda x.\, (t'[q(\sigma)][q(\tau)]) \\ &= \lambda x.\, (t'[q(\sigma) \circ q(\tau)]) \\ &= \lambda x.\, (t'[q(\sigma \circ \tau)]) \tag{by \Cref{lem:subst-q-comp}} \\ &= (\lambda x.\, t')[\sigma \circ \tau] \end{aligned}

    t = \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x,y.\,s)~t'}.

    \begin{aligned} &(\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x,y.\,s)~t'})[\sigma][\tau] \\ &= (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x,y.\,s[q^2(\sigma)])~t'[\sigma]})[\tau] \\ &= \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)][q(\tau)])~z[\sigma][\tau]~(x,y.\,s[q^2(\sigma)][q^2(\tau)])~t'[\sigma][\tau]} \\ &= \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma \circ \tau)])~z[\sigma \circ \tau]~(x,y.\,s[q^2(\sigma \circ \tau)])~t'[\sigma \circ \tau]} \tag{by IH and \Cref{lem:subst-q-comp}} \\ &= (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x,y.\,s)~t'})[\sigma \circ \tau] \end{aligned}

Other cases are similar.

Lemma

Lemma 2.23 (q Commutes with Pointwise Weakening)

71PS

For all substitutions \sigma and weakenings \phi: q(\sigma[\phi]) = q(\sigma)[q(\phi)].

Proof of Lemma 2.23

Since \sigma[\phi] = \sigma \circ \phi (treating \phi as a substitution), we have:

\begin{aligned} q(\sigma[\phi]) &= q(\sigma \circ \phi) \\ &= q(\sigma) \circ q(\phi) \tag{by \Cref{lem:subst-q-comp}} \\ &= q(\sigma)[q(\phi)] \end{aligned}
Lemma

Lemma 2.24 (Weakening–Substitution Interaction)

E4PR

The following two properties hold:

    For all t \in \textsf{Exp}, weakening \phi, and substitution \sigma: (t[\phi])[\sigma] = t[\phi \circ \sigma]. For all t \in \textsf{Exp}, substitution \sigma, and weakening \phi: (t[\sigma])[\phi] = t[\sigma[\phi]].

Proof of Lemma 2.24

Statement (1) is a corollary of ?, ?. Since we elide the embedding, treating \phi as a substitution:

\begin{aligned} (t[\phi])[\sigma] &= t[\phi \circ \sigma] \tag{by \Cref{lem:subst-assoc}} \end{aligned}

Statement (2) also follows from ?:

\begin{aligned} (t[\sigma])[\phi] &= t[\sigma \circ \phi] \tag{by \Cref{lem:subst-assoc}} \end{aligned}

We verify: (\sigma \circ \phi)(x) = \sigma(x)[\phi] = (\sigma[\phi])(x), which is exactly the definition of \sigma[\phi]. Hence \sigma \circ \phi = \sigma[\phi] and the claim holds.

Lemma

Lemma 2.25 (Shift–Extension Cancellation)

2EAD

For all substitutions \sigma and terms s: \Uparrow \circ (\sigma, s/x) = \sigma.

Proof of Lemma 2.25

Pointwise:

\begin{aligned} (\Uparrow \circ (\sigma, s/x))(y) &= \Uparrow(y)[(\sigma, s/x)] \\ &= (y+1)[(\sigma, s/x)] \\ &= (\sigma, s/x)(y+1) \\ &= \sigma(y) \end{aligned}
Lemma

Lemma 2.26 (Extension–Composition Distribution)

GWJG

For all substitutions \sigma, \tau and terms s: (\sigma, s/x) \circ \tau = (\sigma \circ \tau,\; s[\tau]/x).

Proof of Lemma 2.26

Pointwise:

\begin{aligned} ((\sigma, s/x) \circ \tau)(0) &= (\sigma, s/x)(0)[\tau] \\ &= s[\tau] \\ &= (\sigma \circ \tau,\; s[\tau]/x)(0) \end{aligned}
\begin{aligned} ((\sigma, s/x) \circ \tau)(y+1) &= (\sigma, s/x)(y+1)[\tau] \\ &= \sigma(y)[\tau] \\ &= (\sigma \circ \tau)(y) \\ &= (\sigma \circ \tau,\; s[\tau]/x)(y+1) \end{aligned}
Lemma

Lemma 2.27 (q–Extension Interaction)

A2Q8

For all t \in \textsf{Exp}, substitutions \sigma, and terms s:

t[q(\sigma)][\ensuremath{\textsf{id}}, s/x] = t[\sigma, s/x]
Proof of Lemma 2.27

By ?, it suffices to show q(\sigma) \circ (\ensuremath{\textsf{id}}, s/x) = (\sigma, s/x). Recall q(\sigma) = (\sigma[\Uparrow], 0/x). By ?:

\begin{aligned} q(\sigma) \circ (\ensuremath{\textsf{id}}, s/x) &= (\sigma[\Uparrow], 0/x) \circ (\ensuremath{\textsf{id}}, s/x) \\ &= (\sigma[\Uparrow] \circ (\ensuremath{\textsf{id}}, s/x),\; 0[(\ensuremath{\textsf{id}}, s/x)]/x) \tag{by \Cref{lem:ext-comp}} \\ &= ((\sigma \circ \Uparrow) \circ (\ensuremath{\textsf{id}}, s/x),\; s/x) \\ &= (\sigma \circ (\Uparrow \circ (\ensuremath{\textsf{id}}, s/x)),\; s/x) \\ &= (\sigma \circ \ensuremath{\textsf{id}},\; s/x) \tag{by \Cref{lem:shift-ext}} \\ &= (\sigma, s/x) \tag{by \Cref{lem:subst-id}} \end{aligned}
Lemma

Lemma 2.28 (Generalized q–Extension Interaction)

F6NO

For all t \in \textsf{Exp}, substitution \sigma, weakening \phi, and term s:

t[q(\sigma)][\phi, s/x] = t[\sigma[\phi], s/x]
Proof of Lemma 2.28

By ?, it suffices to show q(\sigma) \circ (\phi, s/x) = (\sigma[\phi], s/x). Recall q(\sigma) = (\sigma[\Uparrow], 0/x).

\begin{aligned} q(\sigma) \circ (\phi, s/x) &= (\sigma[\Uparrow], 0/x) \circ (\phi, s/x) \\ &= (\sigma[\Uparrow] \circ (\phi, s/x),\; 0[(\phi, s/x)]/x) \tag{by \Cref{lem:ext-comp}} \\ &= ((\sigma \circ \Uparrow) \circ (\phi, s/x),\; s/x) \\ &= (\sigma \circ (\Uparrow \circ (\phi, s/x)),\; s/x) \tag{by \Cref{lem:subst-cat} associativity} \\ &= (\sigma \circ \phi,\; s/x) \tag{by \Cref{lem:shift-ext}} \\ &= (\sigma[\phi],\; s/x) \end{aligned}
Lemma

Lemma 2.29 (Categorical Laws for Substitutions)

XVJC

Substitutions satisfy:

    (Left identity) \ensuremath{\textsf{id}} \circ \sigma = \sigma for all \sigma. (Right identity) \sigma \circ \ensuremath{\textsf{id}} = \sigma for all \sigma. (Associativity) (\sigma \circ \tau) \circ \delta = \sigma \circ (\tau \circ \delta).

Proof of Lemma 2.29

    (\ensuremath{\textsf{id}} \circ \sigma)(x) = \ensuremath{\textsf{id}}(x)[\sigma] = x[\sigma] = \sigma(x). (\sigma \circ \ensuremath{\textsf{id}})(n) = \sigma(x)[\ensuremath{\textsf{id}}] = \sigma(x) by ?. By pointwise calculation:

    \begin{aligned} ((\sigma \circ \tau) \circ \delta)(x) &= ((\sigma \circ \tau)(x))[\delta] \\ &= (\sigma(x)[\tau])[\delta] \\ &= \sigma(x)[\tau \circ \delta] \tag{by \Cref{lem:subst-assoc}} \\ &= (\sigma \circ (\tau \circ \delta))(x) \end{aligned}
Lemma

Lemma 2.30 (Substitution–Extension Commutation)

94VI

For all t \in \textsf{Exp}, substitutions \sigma, and terms s:

t[q(\sigma)][s[\sigma]/x] = t[s/x][\sigma]
Proof of Lemma 2.30

We show both sides equal t[\sigma, s[\sigma]/x].

\begin{aligned} t[q(\sigma)][s[\sigma]/x] &= t[q(\sigma)][\ensuremath{\textsf{id}}, s[\sigma]/x] \\ &= t[\sigma, s[\sigma]/x] \tag{by \Cref{lem:q-ext}} \end{aligned}
\begin{aligned} t[s/x][\sigma] &= t[\ensuremath{\textsf{id}}, s/x][\sigma] \\ &= t[(\ensuremath{\textsf{id}}, s/x) \circ \sigma] \tag{by \Cref{lem:subst-assoc}} \\ &= t[\ensuremath{\textsf{id}} \circ \sigma, s[\sigma]/x] \tag{by \Cref{lem:ext-comp}} \\ &= t[\sigma, s[\sigma]/x] \tag{by \Cref{lem:subst-cat} (left identity)} \end{aligned}
Lemma

Lemma 2.31 (Expansion of Substitutions)

HRFM

For all substitutions \sigma: \sigma = (\Uparrow \circ \sigma,\; x_0[\sigma]/x), where x_0 denotes the variable at index 0.

Proof of Lemma 2.31

Pointwise:

\begin{aligned} (\Uparrow \circ \sigma,\; x_0[\sigma]/x)(0) &= x_0[\sigma] = \sigma(0) \\ (\Uparrow \circ \sigma,\; x_0[\sigma]/x)(y+1) &= (\Uparrow \circ \sigma)(y) \\ &= \Uparrow(y)[\sigma] \\ &= (y+1)[\sigma] \\ &= \sigma(y+1) \end{aligned}

Hence both sides agree at every index.

Definition

Definition 3.1 (Judgment Forms)

DZUH

The judgments of our type theory are:

\begin{array}{lll} \vdash \Gamma & & \text{$\Gamma$ is a well-formed context} \\[4pt] \typing[\Gamma]{t}{T} & & \text{$t$ has type $T$ in $\Gamma$} \\[4pt] \tyequiv[\Gamma]{t}{t'}{T} & & \text{$t$ and $t'$ are equal terms of type $T$ in $\Gamma$} \\[4pt] \IfNoValueTF {S} {\Gamma \vdash T \subseteq &} {S \vdash T \subseteq &} & \text{$S$ is a subtype of $T$ in $\Gamma$} \end{array}

Additionally, we have a derived judgment for substitution typing:

\judge[\Gamma]{\sigma : \Delta} \qquad\qquad \text{$\sigma$ is a well-typed substitution from $\Delta$ to $\Gamma$}
Lemma

Lemma 3.2

6E7B

x_{|\Gamma|} : T[\Uparrow]^{1 + |\Gamma|} \in \Delta, x:T, \Gamma

Lemma

Lemma 3.3 (Identity Weakening)

1MEJ

If \vdash \Gamma, then \wkjudge[\ensuremath{\textsf{id}}]{\Gamma : .

Proof of Lemma 3.3

We must show: for all x : T \in \Gamma, \ensuremath{\textsf{id}}(x) : T[\ensuremath{\textsf{id}}] \in \Gamma. Since \ensuremath{\textsf{id}}(x) = x and T[\ensuremath{\textsf{id}}] = T (by ?), this is immediate from x : T \in \Gamma.

Lemma

Lemma 3.4 (Shift Weakening)

VA7X

If \vdash \Gamma and \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}, then \weakening[\Gamma, x_0 : S] \Uparrow \Gamma.

Proof of Lemma 3.4

We must show: for all y : T \in \Gamma, \Uparrow(y) : T[\Uparrow] \in \Gamma, x_0 : S. We have \Uparrow(y) = 1 + y. From y : T \in \Gamma, the lookup rule gives 1{+}y : T[\Uparrow] \in \Gamma, x_0 : S.

Lemma

Lemma 3.5 (q Preserves Weakening Typing)

ONZT

If \wkjudge[\phi]{\Delta : and \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}}, then \weakening[\Gamma, x_0 : S[\phi]] {q(\phi)} {\Delta, x_0 : S}.

Proof of Lemma 3.5

We must show: for all y : T \in \Delta, x_0 : S, q(\phi)(y) : T[q(\phi)] \in \Gamma, x_0 : S[\phi]. We case-split on the lookup y : T \in \Delta, x_0 : S:

    x_0 : S[\Uparrow] \in \Delta, x_0 : S: Then q(\phi)(x_0) = x_0 and S[\Uparrow][q(\phi)] = S[\phi][\Uparrow] (by ?). We have x_0 : S[\phi][\Uparrow] \in \Gamma, x_0 : S[\phi] by lookup. 1{+}z : T'[\Uparrow] \in \Delta, x_0 : S where z : T' \in \Delta: Then q(\phi)(1{+}z) = 1{+}\phi(z) and T'[\Uparrow][q(\phi)] = T'[\phi][\Uparrow] (by ?). From \wkjudge[\phi]{\Delta : , we have \phi(z) : T'[\phi] \in \Gamma, so 1{+}\phi(z) : T'[\phi][\Uparrow] \in \Gamma, x_0 : S[\phi] by lookup.

Lemma

Lemma 3.6 (Composition Preserves Weakening Typing)

WG1D

If \wkjudge[\psi]{\Delta : and \weakening[\Delta] \phi \Theta, then \wkjudge[\phi \circ \psi]{\Theta : .

Proof of Lemma 3.6

We must show: for all x : T \in \Theta, (\phi \circ \psi)(x) : T[\phi \circ \psi] \in \Gamma.

\begin{aligned} &\phi(x) : T[\phi] \in \Delta && \text{(from $\weakening[\Delta] \phi \Theta$ and $x : T \in \Theta$)} \\ &\psi(\phi(x)) : T[\phi][\psi] \in \Gamma && \text{(from $ \wkjudge[\psi]{\Delta : $} and $\phi(x) : T[\phi] \in \Delta$)} \\ &(\phi \circ \psi)(x) = \psi(\phi(x)) && \text{(by definition of composition)} \\ &T[\phi \circ \psi] = T[\phi][\psi] && \text{(by \Cref{lem:wk-comp})} \end{aligned}

Hence (\phi \circ \psi)(x) : T[\phi \circ \psi] \in \Gamma.

Lemma

Lemma 4.1 (Weakening Preserves Typing)

4YK3

The following are proved by mutual induction on the syntactic judgments:

    If \typing[\Gamma]{t}{T} and \weakening[\Delta] \phi \Gamma, then \typing[\Delta]{t[\phi]}{T[\phi]}. If \tyequiv[\Gamma]{t}{t'}{T} and \weakening[\Delta] \phi \Gamma, then \tyequiv[\Delta]{t[\phi]}{t'[\phi]}{T[\phi]}. If \subty[\Gamma]{S}{T} and \weakening[\Delta] \phi \Gamma, then \subty[\Delta]{S[\phi]}{T[\phi]}.

Proof of Lemma 4.1

By mutual induction on the derivation of the syntactic judgment. We show representative cases for statement (1).

Case

Mathpar.

y : T yT

Then y[\phi] = \phi(y). By the definition of \weakening[\Delta] \phi \Gamma, \phi(y) : T[\phi] \in \Delta. By Var, \typing[\Delta]{\phi(y)}{T[\phi]}.

Case

Mathpar.

S’Ty_i
tT y. t(y:S’). T

We must show \typing[\Delta]{(\lambda y.\,t)[\phi]}{(\Pi(y:S').\,T)[\phi]}, i.e. \typing[\Delta]{\lambda y.\,(t[q(\phi)])}{\Pi(y:S'[\phi]).\,(T[q(\phi)])}.

\begin{aligned} &\typing[\Delta]{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on first premise)} \\ &\weakening[\Delta, y:S'[\phi]] {q(\phi)} {\Gamma, y:S'} && \text{(by \Cref{lem:wk-q-wt})} \\ &\typing[\Delta, y:S'[\phi]]{t[q(\phi)]}{T[q(\phi)]} && \text{(by IH on second premise)} \\ &\typing[\Delta]{\lambda y.\,(t[q(\phi)])}{\Pi(y:S'[\phi]).\,(T[q(\phi)])} && \text{(by \textsc{$\lambda$-I})} \end{aligned}

Case

Mathpar.

S’Ty_i
TTy_i
r(y:S’). T
sS’ r sT[s/y]

\begin{aligned} &\typing[\Delta]{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Delta, y:S'[\phi]]{T[q(\phi)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH, using \Cref{lem:wk-q-wt})} \\ &\typing[\Delta]{r[\phi]}{\Pi(y:S'[\phi]).\,(T[q(\phi)])} && \text{(by IH)} \\ &\typing[\Delta]{s[\phi]}{S'[\phi]} && \text{(by IH)} \\ &\typing[\Delta]{r[\phi]\;s[\phi]}{T[q(\phi)][s[\phi]/y]} && \text{(by \textsc{$\lambda$-E})} \end{aligned}

It remains to show T[q(\phi)][s[\phi]/y] = T[s/y][\phi], which is ?.

Case

Mathpar.

TTy_i
tS
ST tT

\begin{aligned} &\typing[\Delta]{T[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Delta]{t[\phi]}{S[\phi]} && \text{(by IH)} \\ &\subty[\Delta]{S[\phi]}{T[\phi]} && \text{(by IH, statement (3))} \\ &\typing[\Delta]{t[\phi]}{T[\phi]} && \text{(by \textsc{Subsump})} \end{aligned}

We now show representative cases for statement (2).

Case

Mathpar.

S’Ty_i
T’Ty_i
tT’
sS’ (x. t) st[s/x]T’[s/x]

We must show \tyequiv[\Delta]{((\lambda x.\,t)\;s)[\phi]}{t[s/x][\phi]}{T'[s/x][\phi]}.

\begin{aligned} &((\lambda x.\,t)\;s)[\phi] = (\lambda x.\,(t[q(\phi)]))\;(s[\phi]) \end{aligned}

Now:

\begin{aligned} &\typing[\Delta]{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Delta, x:S'[\phi]]{T'[q(\phi)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH, using \Cref{lem:wk-q-wt})} \\ &\typing[\Delta, x:S'[\phi]]{t[q(\phi)]}{T'[q(\phi)]} && \text{(by IH, using \Cref{lem:wk-q-wt})} \\ &\typing[\Delta]{s[\phi]}{S'[\phi]} && \text{(by IH)} \\ &\tyequiv[\Delta]{(\lambda x.\,(t[q(\phi)]))\;(s[\phi])}{t[q(\phi)][s[\phi]/x]}{T'[q(\phi)][s[\phi]/x]} && \text{(by \textsc{$\Pi$-$\beta$})} \end{aligned}

By ?: t[q(\phi)][s[\phi]/x] = t[s/x][\phi] and T'[q(\phi)][s[\phi]/x] = T'[s/x][\phi].

Case

Mathpar.

S’Ty_i
T’Ty_i
t(x:S’). T’ tx. (t[] x)(x:S’). T’

We must show \tyequiv[\Delta]{t[\phi]}{(\lambda x.\,(t[\Uparrow]\;x))[\phi]}{(\Pi(x:S').\,T')[\phi]}. Unfolding the right-hand side:

\begin{aligned} (\lambda x.\,(t[\Uparrow]\;x))[\phi] &= \lambda x.\,((t[\Uparrow]\;x)[q(\phi)]) \\ &= \lambda x.\,(t[\Uparrow][q(\phi)]\;x) \\ &= \lambda x.\,(t[\phi][\Uparrow]\;x) \tag{by \Cref{lem:wk-subst-comm}} \end{aligned}
\begin{aligned} &\typing[\Delta]{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Delta, x:S'[\phi]]{T'[q(\phi)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH, using \Cref{lem:wk-q-wt})} \\ &\typing[\Delta]{t[\phi]}{\Pi(x:S'[\phi]).\,(T'[q(\phi)])} && \text{(by IH)} \\ &\weakening[\Delta, x:S'[\phi]] \Uparrow \Delta && \text{(by \Cref{lem:wk-shift-wt})} \\ &\tyequiv[\Delta]{t[\phi]}{\lambda x.\,(t[\phi][\Uparrow]\;x)}{\Pi(x:S'[\phi]).\,(T'[q(\phi)])} && \text{(by \textsc{$\Pi$-$\eta$})} \end{aligned}

We show a case for statement (3).

Case

Mathpar.

STy_i
S’Ty_i
SS’Ty_i
TTy_i
T’Ty_i
TT’ (x:S). T(x:S’). T’

\begin{aligned} &\typing[\Delta]{S[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Delta]{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\tyequiv[\Delta]{S[\phi]}{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH, statement (2))} \\ &\typing[\Delta, x:S[\phi]]{T[q(\phi)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH, using \Cref{lem:wk-q-wt})} \\ &\typing[\Delta, x:S'[\phi]]{T'[q(\phi)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH, using \Cref{lem:wk-q-wt})} \\ &\subty[\Delta, x:S[\phi]]{T[q(\phi)]}{T'[q(\phi)]} && \text{(by IH, statement (3), using \Cref{lem:wk-q-wt})} \\ &\subty[\Delta]{\Pi(x:S[\phi]).\,(T[q(\phi)])}{\Pi(x:S'[\phi]).\,(T'[q(\phi)])} && \text{(by \textsc{Sub-Pi})} \end{aligned}

This is \subty[\Delta]{(\Pi(x:S).\,T)[\phi]}{(\Pi(x:S').\,T')[\phi]}.

The remaining cases (U-Wf, N-Wf, \Pi-Wf, Ze-I, Su-I, N-E, congruence rules, Sub-Univ, Sub-Trans, Sub-Eq) are analogous: apply the IH to each premise, using ? to construct the weakening for extended contexts, and re-apply the rule.

Lemma

Lemma 4.2 (Identity Substitution is Well-Typed)

2CBR

If \vdash \Gamma, then \judge[\Gamma]{\ensuremath{\textsf{id}} : \Gamma}.

Proof of Lemma 4.2

We must show: for all x : T \in \Gamma, \typing[\Gamma]{\ensuremath{\textsf{id}}(x)}{T[\ensuremath{\textsf{id}}]}. Since \ensuremath{\textsf{id}}(x) = x and T[\ensuremath{\textsf{id}}] = T (by ?), this reduces to \typing[\Gamma]{x}{T}, which holds by Var.

Lemma

Lemma 4.3 (Extension is Well-Typed)

67FJ

If \judge[\Gamma]{\sigma : \Delta}, \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}}, and \typing[\Gamma]{s}{S[\sigma]}, then \judge[\Gamma]{(\sigma, s/x) : (\Delta, x : S)}.

Proof of Lemma 4.3

We must show: for all y : T \in \Delta, x : S, \typing[\Gamma]{(\sigma, s/x)(y)}{T[(\sigma, s/x)]}.

    x_0 : S[\Uparrow] \in \Delta, x : S: Then (\sigma, s/x)(x_0) = s and S[\Uparrow][(\sigma, s/x)] = S[\sigma] (by ?, ?). We have \typing[\Gamma]{s}{S[\sigma]} by assumption. 1{+}z : T'[\Uparrow] \in \Delta, x : S with z : T' \in \Delta: Then (\sigma, s/x)(1{+}z) = \sigma(z) and T'[\Uparrow][(\sigma, s/x)] = T'[\sigma] (by ?, ?). From \judge[\Gamma]{\sigma : \Delta}, \typing[\Gamma]{\sigma(z)}{T'[\sigma]}.

Lemma

Lemma 4.4 (Single Substitution is Well-Typed)

MRCL

If \vdash \Gamma, \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}, and \typing[\Gamma]{s}{S}, then \judge[\Gamma]{(\ensuremath{\textsf{id}}, s/x) : (\Gamma, x : S)}.

Proof of Lemma 4.4

By ? and ?: \ensuremath{\textsf{id}} is well-typed by ?, and \typing[\Gamma]{s}{S} = \typing[\Gamma]{s}{S[\ensuremath{\textsf{id}}]} by ?.

Lemma

Lemma 4.5 (Weakening of Substitution is Well-Typed)

U5OV

If \judge[\Gamma]{\sigma : \Delta} and \weakening[\Gamma'] \phi \Gamma, then \judge[\Gamma']{\sigma[\phi] : \Delta}.

Proof of Lemma 4.5

We must show: for all x : T \in \Delta, \typing[\Gamma']{(\sigma[\phi])(x)}{T[\sigma[\phi]]}. From \judge[\Gamma]{\sigma : \Delta}, \typing[\Gamma]{\sigma(x)}{T[\sigma]}. By ?, \typing[\Gamma']{\sigma(x)[\phi]}{T[\sigma][\phi]}. Now (\sigma[\phi])(x) = \sigma(x)[\phi] and T[\sigma[\phi]] = T[\sigma][\phi] (by ?).

Lemma

Lemma 4.6 (q Preserves Substitution Typing)

R7NO

If \judge[\Gamma]{\sigma : \Delta}, \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}}, and \typing[\Gamma]{S[\sigma]}{\ensuremath{\texttt{Ty}_{i}}}, then \judge[\Gamma, x_0 : S[\sigma]]{q(\sigma) : (\Delta, x_0 : S)}.

Proof of Lemma 4.6

We must show that q(\sigma) maps each variable in (\Delta, x_0 : S) to a well-typed term in (\Gamma, x_0 : S[\sigma]). We case-split on the lookup in (\Delta, x_0 : S):

    x_0 : S[\Uparrow] \in \Delta, x_0 : S:

    \begin{aligned} &q(\sigma)(x_0) = x_0 \\ &S[\Uparrow][q(\sigma)] = S[\sigma][\Uparrow] && \text{(by \Cref{lem:wk-subst-comm})} \\ &x_0 : S[\sigma][\Uparrow] \in \Gamma, x_0 : S[\sigma] && \text{(by lookup)} \end{aligned}

    Hence \typing[\Gamma, x_0 : S[\sigma]]{x_0}{S[\Uparrow][q(\sigma)]} by Var. 1{+}y : T[\Uparrow] \in \Delta, x_0 : S where y : T \in \Delta:

    \begin{aligned} &q(\sigma)(1{+}y) = \sigma(y)[\Uparrow] \\ &\typing[\Gamma]{\sigma(y)}{T[\sigma]} && \text{(from $\judge[\Gamma]{\sigma : \Delta}$)} \\ &\typing[\Gamma, x_0 : S[\sigma]]{\sigma(y)[\Uparrow]}{T[\sigma][\Uparrow]} && \text{(by \Cref{lem:wk-typing} using \Cref{lem:wk-shift-wt})} \\ &T[\Uparrow][q(\sigma)] = T[\sigma][\Uparrow] && \text{(by \Cref{lem:wk-subst-comm})} \end{aligned}

    Hence \typing[\Gamma, x_0 : S[\sigma]]{\sigma(y)[\Uparrow]}{T[\Uparrow][q(\sigma)]}.

Lemma

Lemma 4.7 (Substitution Preserves Judgments)

O1ZS

The following are proved by mutual induction on the syntactic judgments:

    If \typing[\Delta]{t}{T} and \judge[\Gamma]{\sigma : \Delta}, then \typing[\Gamma]{t[\sigma]}{T[\sigma]}. If \tyequiv[\Delta]{t}{t'}{T} and \judge[\Gamma]{\sigma : \Delta}, then \tyequiv[\Gamma]{t[\sigma]}{t'[\sigma]}{T[\sigma]}. If \subty[\Delta]{S}{T} and \judge[\Gamma]{\sigma : \Delta}, then \IfNoValueTF {S[\sigma]} {\Gamma \vdash T[\sigma] \subseteq S[] T[] $ .

Proof of Lemma 4.7

By mutual induction on the derivation of the syntactic judgment. We show representative cases for statement (1).

Case

Mathpar.

x : T xT

Then t[\sigma] = x[\sigma] = \sigma(x). By the definition of \judge[\Gamma]{\sigma : \Delta}, we have \typing[\Gamma]{\sigma(x)}{T[\sigma]}, which is the goal.

Case

Mathpar.

STy_i
t’T x. t’(x:S). T

We must show \typing[\Gamma]{(\lambda x.\,t')[\sigma]}{(\Pi(x:S).\,T)[\sigma]}. Unfolding:

\begin{aligned} (\lambda x.\,t')[\sigma] &= \lambda x.\,(t'[q(\sigma)]) \\ (\Pi(x:S).\,T)[\sigma] &= \Pi(x:S[\sigma]).\,(T[q(\sigma)]) \end{aligned}

Now:

\begin{aligned} &\typing[\Gamma]{S[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on first premise)} \\ &\judge[\Gamma, x:S[\sigma]]{q(\sigma) : (\Delta, x:S)} && \text{(by \Cref{lem:q-subst-typing})} \\ &\typing[\Gamma, x:S[\sigma]]{t'[q(\sigma)]}{T[q(\sigma)]} && \text{(by IH on second premise)} \\ &\typing[\Gamma]{\lambda x.\,(t'[q(\sigma)])}{\Pi(x:S[\sigma]).\,(T[q(\sigma)])} && \text{(by \textsc{$\lambda$-I})} \end{aligned}

Case

Mathpar.

STy_i
TTy_i
r(x:S). T
sS r sT[s/x]

We must show \typing[\Gamma]{(r\;s)[\sigma]}{(T[s/x])[\sigma]}. Unfolding: (r\;s)[\sigma] = r[\sigma]\;s[\sigma].

\begin{aligned} &\typing[\Gamma]{S[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on first premise)} \\ &\typing[\Gamma, x:S[\sigma]]{T[q(\sigma)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on second premise using \Cref{lem:q-subst-typing})} \\ &\typing[\Gamma]{r[\sigma]}{\Pi(x:S[\sigma]).\,(T[q(\sigma)])} && \text{(by IH on third premise)} \\ &\typing[\Gamma]{s[\sigma]}{S[\sigma]} && \text{(by IH on fourth premise)} \\ &\typing[\Gamma]{r[\sigma]\;s[\sigma]}{T[q(\sigma)][s[\sigma]/x]} && \text{(by \textsc{$\lambda$-E})} \end{aligned}

It remains to show T[q(\sigma)][s[\sigma]/x] = (T[s/x])[\sigma], which is ?.

Case

Mathpar.

TTy_i
tS
ST tT

\begin{aligned} &\typing[\Gamma]{T[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on first premise)} \\ &\typing[\Gamma]{t[\sigma]}{S[\sigma]} && \text{(by IH on second premise)} \\ & \IfNoValueTF {S[\sigma]} {\Gamma \vdash T[\sigma] \subseteq &} {S[\sigma] \vdash T[\sigma] \subseteq &} & \text{(by IH, statement (3))} \\ &\typing[\Gamma]{t[\sigma]}{T[\sigma]} && \text{(by \textsc{Subsump})} \end{aligned}

The remaining cases (U-Wf, N-Wf, Ze-I, Su-I) are straightforward applications of the IH.

We now show representative cases for statement (2). The congruence cases follow directly from the IH. We show the computation and uniqueness rules.

Case

Mathpar.

STy_i
TTy_i
tT
sS (x. t) st[s/x]T[s/x]

We must show \tyequiv[\Gamma]{((\lambda x.\,t)\;s)[\sigma]}{t[s/x][\sigma]}{T[s/x][\sigma]}. Unfolding:

\begin{aligned} &((\lambda x.\,t)\;s)[\sigma] = (\lambda x.\,(t[q(\sigma)]))\;(s[\sigma]) \\ t[s/x][\sigma] &= t[(\ensuremath{\textsf{id}},s/x) \circ \sigma] \tag{by \Cref{lem:subst-assoc}} \\ &= t[\ensuremath{\textsf{id}} \circ \sigma, s[\sigma]/x] \tag{by \Cref{lem:ext-comp}} \\ &= t[\sigma, s[\sigma]/x] \tag{by \Cref{lem:subst-cat} (left identity)} \end{aligned}

Now:

\begin{aligned} &\typing[\Gamma]{S[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Gamma, x:S[\sigma]]{T[q(\sigma)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH using \Cref{lem:q-subst-typing})} \\ &\typing[\Gamma, x:S[\sigma]]{t[q(\sigma)]}{T[q(\sigma)]} && \text{(by IH using \Cref{lem:q-subst-typing})} \\ &\typing[\Gamma]{s[\sigma]}{S[\sigma]} && \text{(by IH)} \\ &\tyequiv[\Gamma]{(\lambda x.\,(t[q(\sigma)]))\;(s[\sigma])}{t[q(\sigma)][s[\sigma]/x]}{T[q(\sigma)][s[\sigma]/x]} && \text{(by \textsc{$\Pi$-$\beta$})} \end{aligned}

By ?: t[q(\sigma)][s[\sigma]/x] = (t[s/x])[\sigma] and T[q(\sigma)][s[\sigma]/x] = (T[s/x])[\sigma].

Case

Mathpar.

STy_i
TTy_i
t(x:S). T tx. (t[] x)(x:S). T

We must show \tyequiv[\Gamma]{t[\sigma]}{(\lambda x.\,(t[\Uparrow]\;x))[\sigma]}{(\Pi(x:S).\,T)[\sigma]}. Unfolding the right-hand side:

\begin{aligned} (\lambda x.\,(t[\Uparrow]\;x))[\sigma] &= \lambda x.\,((t[\Uparrow]\;x)[q(\sigma)]) \\ &= \lambda x.\,(t[\Uparrow][q(\sigma)]\;x) \\ &= \lambda x.\,(t[\sigma][\Uparrow]\;x) \tag{by \Cref{lem:wk-subst-comm}} \end{aligned}

Now:

\begin{aligned} &\typing[\Gamma]{S[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Gamma, x:S[\sigma]]{T[q(\sigma)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH using \Cref{lem:q-subst-typing})} \\ &\typing[\Gamma]{t[\sigma]}{\Pi(x:S[\sigma]).\,(T[q(\sigma)])} && \text{(by IH)} \\ &\tyequiv[\Gamma]{t[\sigma]}{\lambda x.\,(t[\sigma][\Uparrow]\;x)}{\Pi(x:S[\sigma]).\,(T[q(\sigma)])} && \text{(by \textsc{$\Pi$-$\eta$})} \end{aligned}

We now show representative cases for statement (3).

Case

Mathpar.

i j Ty_iTy_j

Then \ensuremath{\texttt{Ty}_{i}}[\sigma] = \ensuremath{\texttt{Ty}_{i}} and \ensuremath{\texttt{Ty}_{j}}[\sigma] = \ensuremath{\texttt{Ty}_{j}}. From \judge[\Gamma]{\sigma : \Delta}, we have \vdash \Gamma. By Sub-Univ, \IfNoValueTF {\ensuremath{\texttt{Ty}_{i}}} {\Gamma \vdash \ensuremath{\texttt{Ty}_{j}} \subseteq Ty_i Ty_j } . \medskip\noindent \textbf{Case} \begin{mathpar} \inferrule {\typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} \\ \typing[\Delta]{S'}{\ensuremath{\texttt{Ty}_{i}}} \\ \tyequiv[\Delta]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}} \\ \typing[\Delta, x:S]{T}{\ensuremath{\texttt{Ty}_{i}}} \\ \typing[\Delta, x:S']{T'}{\ensuremath{\texttt{Ty}_{i}}} \\ \subty[\Delta, x:S]{T}{T'}} {\subty[\Delta]{\Pi(x:S).\,T}{\Pi(x:S').\,T'}} \end{mathpar} \begin{align*} &\typing[\Gamma]{S[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\typing[\Gamma]{S'[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH)} \\ &\tyequiv[\Gamma]{S[\sigma]}{S'[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH, statement (2))} \\ &\typing[\Gamma, x:S[\sigma]]{T[q(\sigma)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH using \Cref{lem:q-subst-typing})} \\ &\typing[\Gamma, x:S'[\sigma]]{T'[q(\sigma)]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH using \Cref{lem:q-subst-typing})} \\ &\subty[\Gamma, x:S[\sigma]]{T[q(\sigma)]}{T'[q(\sigma)]} && \text{(by IH, statement (3), using \Cref{lem:q-subst-typing})} \\ & \IfNoValueTF {\Pi(x:S[\sigma]).\,(T[q(\sigma)])} {\Gamma \vdash \Pi(x:S'[\sigma]).\,(T'[q(\sigma)]) \subseteq &} {\Pi(x:S[\sigma]).\,(T[q(\sigma)]) \vdash \Pi(x:S'[\sigma]).\,(T'[q(\sigma)]) \subseteq &} & \text{(by \textsc{Sub-Pi})} \end{align*} This is ((x:S). T)[] ((x:S’). T’)[] } {(\Pi(x:S).\,T)[\sigma] \vdash (\Pi(x:S').\,T')[\sigma] \subseteq .

Case Sub-Trans: By two applications of the IH and Sub-Trans.

Case Sub-Eq: By statement (2) and Sub-Eq.

Lemma

Lemma 4.8 (Composition of Substitutions is Well-Typed)

OJJ2

If \judge[\Gamma]{\sigma : \Delta} and \judge[\Gamma']{\tau : \Gamma}, then \judge[\Gamma']{\sigma \circ \tau : \Delta}.

Proof of Lemma 4.8

We must show: for all x : T \in \Delta, \typing[\Gamma']{(\sigma \circ \tau)(x)}{T[\sigma \circ \tau]}.

\begin{aligned} &\typing[\Gamma]{\sigma(x)}{T[\sigma]} && \text{(from $\judge[\Gamma]{\sigma : \Delta}$)} \\ &\typing[\Gamma']{\sigma(x)[\tau]}{T[\sigma][\tau]} && \text{(by \Cref{lem:subst-preserves})} \\ &(\sigma \circ \tau)(x) = \sigma(x)[\tau] && \text{(by definition)} \\ &T[\sigma \circ \tau] = T[\sigma][\tau] && \text{(by \Cref{lem:subst-assoc})} \end{aligned}
Corollary

Corollary 4.9 (Single Substitution Lemma)

9YAI

If \typing[\Gamma, x : S]{t}{T} and \typing[\Gamma]{s}{S}, then \typing[\Gamma]{t[s/x]}{T[s/x]}.

Proof of Corollary 4.9

By ? and ?, noting t[s/x] = t[\ensuremath{\textsf{id}}, s/x].

Lemma

Lemma 4.10

72EY

    If \typing[\Gamma]{t}{T}, then \vdash \Gamma and \typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}} for some i. If \tyequiv[\Gamma]{t}{t'}{T}, then \vdash \Gamma, \typing[\Gamma]{t}{T}, \typing[\Gamma]{t'}{T}, and \typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}} for some i. If \IfNoValueTF {S} {\Gamma \vdash T \subseteq S T } , then,STy_iandTTy_ifor somei$.

Proof of Lemma 4.10

By mutual induction on the derivation.

Case

Mathpar.

x : T xT

We have \vdash \Gamma immediately from the premise. For \typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}}, we do induction on x : T \in \Gamma. If \Gamma = \Gamma', x : T, then \vdash \Gamma', x : T was derived by Ctx-Ext from \typing[\Gamma']{T}{\ensuremath{\texttt{Ty}_{i}}}; weakening gives \typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}}. If \Gamma = \Gamma', y : S and x : T \in \Gamma', then by IH on the smaller context \typing[\Gamma']{T}{\ensuremath{\texttt{Ty}_{i}}}; weakening gives \typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}}.

Case

Mathpar.

Ty_iTy_1+i

We have \vdash \Gamma from the premise. The type of the conclusion is \ensuremath{\texttt{Ty}_{1+i}}, and \typing[\Gamma]{\ensuremath{\texttt{Ty}_{1+i}}}{\ensuremath{\texttt{Ty}_{2+i}}} by another application of U-Wf.

Case

Mathpar.

STy_i
TTy_i (x:S). TTy_i

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma]{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{1+i}}} && \text{(by \textsc{U-Wf})} \end{aligned}

Case

Mathpar.

STy_i
tT x. t(x:S). T

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma, x:S]{T}{\ensuremath{\texttt{Ty}_{j}}} \text{ for some } j && \text{(by IH on second premise)} \\ &\typing[\Gamma]{\Pi(x:S).\,T}{\ensuremath{\texttt{Ty}_{\max(i,j)}}} && \text{(by \textsc{$\Pi$-Wf} + \textsc{Subsump})} \end{aligned}

Case

Mathpar.

STy_i
TTy_i

r(x:S). T
sS r sT[s/x]

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma, x:S]{T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(directly from second premise)} \\ &\judge[\Gamma]{(\ensuremath{\textsf{id}}, s/x) : (\Gamma, x:S)} && \text{(by \Cref{lem:single-subst-wt})} \\ &\typing[\Gamma]{T[s/x]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:subst-preserves})} \end{aligned}

Case

Mathpar.

TTy_i
zT[zero/x]
sT[, succ x_1/x]
tNat elim_Nat (x. T) z (x,y. s) tT[t/x]

\begin{aligned} &\vdash \Gamma && \text{(by IH on last premise)} \\ &\judge[\Gamma]{(\ensuremath{\textsf{id}}, t/x) : (\Gamma, x:\ensuremath{\texttt{Nat}})} && \text{(by \Cref{lem:single-subst-wt})} \\ &\typing[\Gamma]{T[t/x]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:subst-preserves} on first premise)} \end{aligned}

Case

Mathpar.

TTy_i
tS
ST tT

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(directly from first premise)} \end{aligned}

Case

Mathpar.

x : T xxT

We have \vdash \Gamma from the premise. \typing[\Gamma]{x}{T} by Var. \typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}} by the same argument as the Var typing case above.

Case

Mathpar.

STy_i
TTy_i
tT
sS (x. t) st[s/x]T[s/x]

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma]{(\lambda x.\,t)\;s}{T[s/x]} && \text{(by \textsc{$\lambda$-E} on \textsc{$\lambda$-I})} \\ &\typing[\Gamma]{t[s/x]}{T[s/x]} && \text{(by \Cref{cor:single-subst} on third premise)} \\ &\typing[\Gamma]{T[s/x]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{cor:single-subst} on second premise)} \end{aligned}

Case

Mathpar.

STy_i
TTy_i
t(x:S). T tx. (t[] x)(x:S). T

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma]{t}{\Pi(x:S).\,T} && \text{(directly from third premise)} \\ &\weakening[\Gamma, x:S] \Uparrow \Gamma && \text{(by \Cref{lem:wk-shift-wt})} \\ &\typing[\Gamma, x:S]{t[\Uparrow]}{\Pi(x:S[\Uparrow]).\,(T[q(\Uparrow)])} && \text{(by \Cref{lem:wk-typing})} \\ &x_0 : S[\Uparrow] \in \Gamma, x_0 : S && \text{(by lookup)} \\ &\typing[\Gamma, x:S]{x}{S[\Uparrow]} && \text{(by \textsc{Var})} \\ &\typing[\Gamma, x:S]{t[\Uparrow]\;x}{T[q(\Uparrow)][x/x]} && \text{(by \textsc{$\lambda$-E})} \\ &T[q(\Uparrow)][x/x] = T[q(\Uparrow)][\ensuremath{\textsf{id}}, x/x] = T[\Uparrow, x/x] && \text{(by \Cref{lem:q-ext})} \\ &(\Uparrow, x/x) = \ensuremath{\textsf{id}} && \text{(by \Cref{lem:subst-ext-eta} at $\sigma = \ensuremath{\textsf{id}}$)} \\ &T[\Uparrow, x/x] = T[\ensuremath{\textsf{id}}] = T && \text{(by \Cref{lem:subst-id})} \\ &\typing[\Gamma, x:S]{t[\Uparrow]\;x}{T} \\ &\typing[\Gamma]{\lambda x.\,(t[\Uparrow]\;x)}{\Pi(x:S).\,T} && \text{(by \textsc{$\lambda$-I})} \\ &\typing[\Gamma]{\Pi(x:S).\,T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \textsc{$\Pi$-Wf} on first two premises)} \end{aligned}

Case

Mathpar.

TTy_i
tt’S
ST tt’T

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma]{t}{S} \text{ and } \typing[\Gamma]{t'}{S} && \text{(by IH on second premise)} \\ &\typing[\Gamma]{t}{T} \text{ and } \typing[\Gamma]{t'}{T} && \text{(by \textsc{Subsump} with third premise)} \\ &\typing[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(directly from first premise)} \end{aligned}

Case

Mathpar.

STy_i
S’Ty_i
SS’Ty_i
TTy_i
T’Ty_i
TT’ (x:S). T(x:S’). T’

\begin{aligned} &\vdash \Gamma && \text{(by IH on first premise)} \\ &\typing[\Gamma]{\Pi(x:S).\,T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \textsc{$\Pi$-Wf} on premises 1 and 4)} \\ &\typing[\Gamma]{\Pi(x:S').\,T'}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \textsc{$\Pi$-Wf} on premises 2 and 5, using \textsc{Subsump})} \end{aligned}

Case

Mathpar.

i j Ty_iTy_j

\begin{aligned} &\vdash \Gamma && \text{(directly from premise)} \\ &\typing[\Gamma]{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{1+i}}} && \text{(by \textsc{U-Wf})} \\ &\typing[\Gamma]{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{1+j}}} && \text{(by \textsc{U-Wf})} \\ &\typing[\Gamma]{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{1+j}}} \text{ and } \typing[\Gamma]{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{1+j}}} && \text{(by \textsc{Subsump} with \textsc{Sub-Univ}, since $1+i \le 1+j$)} \end{aligned}

The remaining cases follow similar patterns.

Definition

Definition 4.11 (Substitution Equivalence)

YUT0

\judge[\Gamma]{\sigma \approx \sigma' : \Delta} holds when:

    \judge[\Gamma]{\sigma : \Delta} and \judge[\Gamma]{\sigma' : \Delta}, and for every x : T \in \Delta, \tyequiv[\Gamma]{\sigma(x)}{\sigma'(x)}{T[\sigma]}.

Used by Proof, Proof
Lemma

Lemma 4.12 (q Preserves Substitution Equivalence)

YOP2

If \judge[\Gamma]{\sigma \approx \sigma' : \Delta} and \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}}, then \judge[\Gamma, x:S[\sigma]]{q(\sigma) \approx q(\sigma') : (\Delta, x:S)}.

Proof of Lemma 4.12

By ?, \judge[\Gamma, x:S[\sigma]]{q(\sigma) : (\Delta, x:S)}. We need \judge[\Gamma, x:S[\sigma]]{q(\sigma') : (\Delta, x:S)} as well: from \tyequiv[\Gamma]{S[\sigma]}{S[\sigma']}{\ensuremath{\texttt{Ty}_{i}}} (by ? statement (2) applied to reflexivity on \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}}), the contexts \Gamma, x:S[\sigma] and \Gamma, x:S[\sigma'] are equivalent, so \judge[\Gamma, x:S[\sigma]]{q(\sigma') : (\Delta, x:S)} by ? and a context-conversion step.

We verify clause (2): for every y : T \in \Delta, x:S, \tyequiv[\Gamma, x:S[\sigma]]{q(\sigma)(y)}{q(\sigma')(y)} {T[q(\sigma)]}.

    y = x_0: T = S[\Uparrow], q(\sigma)(x_0) = x_0 = q(\sigma')(x_0). The required equality is reflexivity on x_0 at S[\Uparrow][q(\sigma)] = S[\sigma][\Uparrow] (by ?). y = 1{+}z where z : T' \in \Delta: q(\sigma)(1{+}z) = \sigma(z)[\Uparrow] and q(\sigma')(1{+}z) = \sigma'(z)[\Uparrow]. By clause (2) of ? on \sigma \approx \sigma', \tyequiv[\Gamma]{\sigma(z)}{\sigma'(z)}{T'[\sigma]}. By ? applied to \Uparrow, \tyequiv[\Gamma, x:S[\sigma]] {\sigma(z)[\Uparrow]}{\sigma'(z)[\Uparrow]} {T'[\sigma][\Uparrow]}, and T'[\sigma][\Uparrow] = T'[\Uparrow][q(\sigma)] by ?, which equals T[q(\sigma)].

Lemma

Lemma 4.13 (Equivalent Substitutions Preserve Judgments)

BW2M

The following are proved by mutual induction on the syntactic judgments:

    If \typing[\Delta]{t}{T} and \judge[\Gamma]{\sigma \approx \sigma' : \Delta}, then \tyequiv[\Gamma]{t[\sigma]}{t[\sigma']}{T[\sigma]}. If \tyequiv[\Delta]{t}{t'}{T} and \judge[\Gamma]{\sigma \approx \sigma' : \Delta}, then \tyequiv[\Gamma]{t[\sigma]}{t'[\sigma']}{T[\sigma]}. If \subty[\Delta]{S}{T} and \judge[\Gamma]{\sigma \approx \sigma' : \Delta}, then \subty[\Gamma]{S[\sigma]}{T[\sigma']}.

Proof of Lemma 4.13

By mutual induction on the syntactic derivation, parallel to ?. We show representative cases for statement (1).

Case

Mathpar.

x : T xT

Then x[\sigma] = \sigma(x) and x[\sigma'] = \sigma'(x).

\begin{aligned} &\tyequiv[\Gamma]{\sigma(x)}{\sigma'(x)}{T[\sigma]} && \text{(by clause~(2) of \Cref{def:subst-equiv})} \end{aligned}

Case

Mathpar.

STy_i
tT x. t(x:S). T

We must show \tyequiv[\Gamma]{(\lambda x.\,t)[\sigma]}{(\lambda x.\,t)[\sigma']} {(\Pi(x:S).\,T)[\sigma]}. We first lift the equivalence under q:

\begin{aligned} &\judge[\Gamma, x:S[\sigma]]{q(\sigma) \approx q(\sigma') : (\Delta, x:S)} && \text{(by \Cref{lem:q-subst-equiv})} \\ &\tyequiv[\Gamma, x:S[\sigma]]{t[q(\sigma)]}{t[q(\sigma')]} {T[q(\sigma)]} && \text{(by IH on the second premise)} \\ &\tyequiv[\Gamma]{S[\sigma]}{S[\sigma']}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on the first premise)} \\ &\tyequiv[\Gamma]{\lambda x.\,(t[q(\sigma)])} {\lambda x.\,(t[q(\sigma')])} {\Pi(x:S[\sigma]).\,(T[q(\sigma)])} && \text{(by \textsc{$\lambda$-Cong})} \\ &(\lambda x.\,t)[\sigma] = \lambda x.\,(t[q(\sigma)]),\; (\lambda x.\,t)[\sigma'] = \lambda x.\,(t[q(\sigma')]) && \text{(syntactic substitution)} \\ &(\Pi(x:S).\,T)[\sigma] = \Pi(x:S[\sigma]).\,(T[q(\sigma)]) && \text{(syntactic substitution)} \end{aligned}

Case

Mathpar.

STy_i
TTy_i

r(x:S). T
sS r sT[s/x]

We must show \tyequiv[\Gamma]{(r\;s)[\sigma]}{(r\;s)[\sigma']}{T[s/x][\sigma]}.

\begin{aligned} &\tyequiv[\Gamma]{r[\sigma]}{r[\sigma']} {(\Pi(x:S).\,T)[\sigma]} && \text{(by IH on the third premise)} \\ &\tyequiv[\Gamma]{s[\sigma]}{s[\sigma']}{S[\sigma]} && \text{(by IH on the fourth premise)} \\ &\tyequiv[\Gamma]{r[\sigma]\;s[\sigma]}{r[\sigma']\;s[\sigma']} {T[q(\sigma)][s[\sigma]/x]} && \text{(by \textsc{App-Cong})} \\ &(r\;s)[\sigma] = r[\sigma]\;s[\sigma],\; (r\;s)[\sigma'] = r[\sigma']\;s[\sigma'] && \text{(syntactic substitution on application)} \\ &T[q(\sigma)][s[\sigma]/x] = T[s/x][\sigma] && \text{(by \Cref{lem:subst-ext-comm})} \end{aligned}

Case

Mathpar.

Ty_iTy_1+i

\ensuremath{\texttt{Ty}_{i}}[\sigma] = \ensuremath{\texttt{Ty}_{i}} and \ensuremath{\texttt{Ty}_{i}}[\sigma'] = \ensuremath{\texttt{Ty}_{i}}.

\begin{aligned} &\vdash \Gamma && \text{(from $\judge[\Gamma]{\sigma : \Delta}$ inside \Cref{def:subst-equiv})} \\ &\tyequiv[\Gamma]{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{1+i}}} && \text{(by \textsc{U-Cong})} \end{aligned}

Case N-Wf: Analogous to U-Wf, with \ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}} = \ensuremath{\texttt{Nat}}[\sigma'] and reflexivity by N-Cong.

Case

Mathpar.

STy_i
TTy_i (x:S). TTy_i

\begin{aligned} &\tyequiv[\Gamma]{S[\sigma]}{S[\sigma']}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on first premise)} \\ &\judge[\Gamma, x:S[\sigma]]{q(\sigma) \approx q(\sigma') : (\Delta, x:S)} && \text{(by lifting, as in the $\lambda$-I case)} \\ &\tyequiv[\Gamma, x:S[\sigma]]{T[q(\sigma)]}{T[q(\sigma')]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on second premise)} \\ &\tyequiv[\Gamma]{\Pi(x:S[\sigma]).\,(T[q(\sigma)])} {\Pi(x:S[\sigma']).\,(T[q(\sigma')])}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \textsc{$\Pi$-Cong})} \\ &(\Pi(x:S).\,T)[\sigma] = \Pi(x:S[\sigma]).\,(T[q(\sigma)]) && \text{(syntactic substitution on $\Pi$)} \end{aligned}

Case Ze-I: \textsf{zero}[\sigma] = \textsf{zero} = \textsf{zero}[\sigma']; apply Ze-Cong. The type \ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}}.

Case

Mathpar.

tNat succ tNat

\begin{aligned} &\tyequiv[\Gamma]{t[\sigma]}{t[\sigma']}{\ensuremath{\texttt{Nat}}} && \text{(by IH on premise; using $\ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}}$)} \\ &\tyequiv[\Gamma]{\textsf{succ}~t[\sigma]}{\textsf{succ}~t[\sigma']}{\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Su-Cong})} \\ &(\textsf{succ}~t)[\sigma] = \textsf{succ}~t[\sigma],\; (\textsf{succ}~t)[\sigma'] = \textsf{succ}~t[\sigma'] && \text{(syntactic substitution on $\textsf{succ}~$)} \end{aligned}

Case N-E: analogous to \lambda-E, applying the IH to each premise (motive, zero branch, step branch, scrutinee), lifting via q(\sigma) \approx q(\sigma') and q^2(\sigma) \approx q^2(\sigma'), and concluding by N-E-Cong.

Case

Mathpar.

TTy_i
tS
ST tT

\begin{aligned} &\tyequiv[\Gamma]{t[\sigma]}{t[\sigma']}{S[\sigma]} && \text{(by IH on second premise)} \\ &\subty[\Gamma]{S[\sigma]}{T[\sigma]} && \text{(by IH on third premise via statement~(3),} \\ & && \text{instantiated at $\sigma \approx \sigma$, reflexive)} \\ &\typing[\Gamma]{T[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:subst-preserves} on first premise)} \\ &\tyequiv[\Gamma]{t[\sigma]}{t[\sigma']}{T[\sigma]} && \text{(by \textsc{Tm-Subsump})} \end{aligned}

Statement (2): term-equality preservation. By induction on the term-equality derivation.

Case (Congruence rules: Var-Cong, U-Cong, N-Cong, \Pi-Cong, Ze-Cong, Su-Cong, \lambda-Cong, App-Cong, N-E-Cong). Each follows by IH on the premises and the same congruence rule, with substitution-on-syntax computed exactly as in statement (1).

Case

Mathpar.

STy_i
TTy_i
tT
sS (x. t) st[s/x]T[s/x]

We must show \tyequiv[\Gamma]{((\lambda x.\,t)\;s)[\sigma]}{t[s/x][\sigma']} {T[s/x][\sigma]}.

By ? on \sigma \approx \sigma' at S: \judge[\Gamma, x:S[\sigma]]{q(\sigma) \approx q(\sigma') : (\Delta, x:S)}. Apply IH statement (1) to the third premise \typing[\Delta, x:S]{t}{T} and to the fourth premise \typing[\Delta]{s}{S}:

\begin{aligned} &\tyequiv[\Gamma, x:S[\sigma]]{t[q(\sigma)]}{t[q(\sigma')]} {T[q(\sigma)]} && \text{(by IH on third premise)} \\ &\tyequiv[\Gamma]{s[\sigma]}{s[\sigma']}{S[\sigma]} && \text{(by IH on fourth premise)} \end{aligned}

Build the head-extended substitution equivalence:

\begin{aligned} &\judge[\Gamma]{(\sigma, s[\sigma]/x) \approx (\sigma', s[\sigma']/x) : (\Delta, x:S)} && \text{(at every $y \in \Delta$, both yield $\sigma(y), \sigma'(y)$,} \\ & && \text{equated by \Cref{def:subst-equiv} clause~(2) on $\sigma \approx \sigma'$;} \\ & && \text{at $x$, the heads $s[\sigma], s[\sigma']$ are equated above)} \end{aligned}

Apply IH statement (1) on the third premise \typing[\Delta, x:S]{t}{T} at this equivalence:

\begin{aligned} &\tyequiv[\Gamma]{t[(\sigma, s[\sigma]/x)]} {t[(\sigma', s[\sigma']/x)]} {T[(\sigma, s[\sigma]/x)]} && \text{(by IH on third premise at the head-extended equivalence)} \\ &t[s/x][\sigma] = t[(\sigma, s[\sigma]/x)] && \text{(by \Cref{lem:subst-ext-comm})} \\ &t[s/x][\sigma'] = t[(\sigma', s[\sigma']/x)] && \text{(by \Cref{lem:subst-ext-comm})} \\ &T[s/x][\sigma] = T[(\sigma, s[\sigma]/x)] && \text{(by \Cref{lem:subst-ext-comm})} \\ &\tyequiv[\Gamma]{t[s/x][\sigma]}{t[s/x][\sigma']}{T[s/x][\sigma]} && \text{(rewriting the previous equality line)} \\ &\tyequiv[\Gamma]{((\lambda x.\,t)\;s)[\sigma]}{t[s/x][\sigma]} {T[s/x][\sigma]} && \text{(by \Cref{lem:subst-preserves} statement~(2) on the original $\beta$, at $\sigma$)} \\ &\tyequiv[\Gamma]{((\lambda x.\,t)\;s)[\sigma]}{t[s/x][\sigma']} {T[s/x][\sigma]} && \text{(by \textsc{Tm-Trans})} \end{aligned}

Case

Mathpar.

STy_i
TTy_i
t(x:S). T tx. (t[] x) (x:S). T

We must show \tyequiv[\Gamma]{t[\sigma]}{(\lambda x.\,(t[\Uparrow]\;x))[\sigma']} {(\Pi(x:S).\,T)[\sigma]}.

By IH statement (1) on the third premise:

\begin{aligned} &\tyequiv[\Gamma]{t[\sigma]}{t[\sigma']}{(\Pi(x:S).\,T)[\sigma]} && \text{(by IH on $\typing[\Delta]{t}{\Pi(x:S).\,T}$)} \end{aligned}

Apply ? statement (2) on the original \eta-rule at \sigma' (a well-typed substitution since \judge[\Gamma]{\sigma' : \Delta} by ? clause (1)):

\begin{aligned} &\tyequiv[\Gamma]{t[\sigma']}{(\lambda x.\,(t[\Uparrow]\;x))[\sigma']} {(\Pi(x:S).\,T)[\sigma']} && \text{(by \Cref{lem:subst-preserves} statement~(2) on $\eta$ at $\sigma'$)} \end{aligned}

Bridge the type from \sigma' to \sigma via the \Pi-Wf case of statement (1), already proved on \typing[\Delta]{\Pi(x:S).\,T}{\ensuremath{\texttt{Ty}_{i}}} (derivable from the first two \eta-premises by \Pi-Wf):

\begin{aligned} &\tyequiv[\Gamma]{(\Pi(x:S).\,T)[\sigma]}{(\Pi(x:S).\,T)[\sigma']} {\ensuremath{\texttt{Ty}_{i}}} && \text{(by the $\Pi$-Wf case of statement~(1))} \\ &\tyequiv[\Gamma]{t[\sigma']}{(\lambda x.\,(t[\Uparrow]\;x))[\sigma']} {(\Pi(x:S).\,T)[\sigma]} && \text{(by \textsc{Tm-Subsump} with \textsc{Sub-Eq})} \\ &\tyequiv[\Gamma]{t[\sigma]}{(\lambda x.\,(t[\Uparrow]\;x))[\sigma']} {(\Pi(x:S).\,T)[\sigma]} && \text{(by \textsc{Tm-Trans})} \end{aligned}

Case N-\beta-ze, N-\beta-su: analogous to \beta above. Apply ? statement (2) to the original reduction rule at \sigma to get equality at the contractum-substituted-by-\sigma. Then apply IH (statement (1)) to the typing of the contractum (derivable from the reduction rule and ?) to bridge the contractum from \sigma to \sigma'.

Case

Mathpar.

tt’T t’tT

By IH on the premise (with the roles of \sigma, \sigma' swapped): \tyequiv[\Gamma]{t[\sigma']}{t'[\sigma]}{T[\sigma']}. By ? statement (2), \tyequiv[\Gamma]{T[\sigma]} {T[\sigma']}{\ensuremath{\texttt{Ty}_{i}}} (from the reflexive closure on the type-formation of T via presupposition). By Tm-Subsump with Sub-Eq, transport to the goal type T[\sigma]: \tyequiv[\Gamma]{t'[\sigma]}{t[\sigma']}{T[\sigma]}, then apply Tm-Sym.

Case

Mathpar.

tt’T

t’t”T tt”T

By IH on the first premise: \tyequiv[\Gamma]{t[\sigma]}{t'[\sigma]}{T[\sigma]} (instantiated at \sigma \approx \sigma, reflexive). By IH on the second premise: \tyequiv[\Gamma]{t'[\sigma]}{t''[\sigma']}{T[\sigma]}. By Tm-Trans: \tyequiv[\Gamma]{t[\sigma]}{t''[\sigma']}{T[\sigma]}.

Case

Mathpar.

TTy_i

tt’S
ST tt’T

\begin{aligned} &\tyequiv[\Gamma]{t[\sigma]}{t'[\sigma']}{S[\sigma]} && \text{(by IH on the second premise)} \\ &\subty[\Gamma]{S[\sigma]}{T[\sigma]} && \text{(by IH on the third premise via statement~(3), instantiated} \\ & && \text{at $\sigma \approx \sigma$, reflexive)} \\ &\typing[\Gamma]{T[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:subst-preserves} on the first premise)} \\ &\tyequiv[\Gamma]{t[\sigma]}{t'[\sigma']}{T[\sigma]} && \text{(by \textsc{Tm-Subsump})} \end{aligned}

Statement (3): subtyping preservation. By induction on the subtyping derivation.

Case Sub-Univ: \ensuremath{\texttt{Ty}_{i}}[\sigma] = \ensuremath{\texttt{Ty}_{i}}, \ensuremath{\texttt{Ty}_{j}}[\sigma'] = \ensuremath{\texttt{Ty}_{j}}, and the conclusion follows from Sub-Univ at i \le j (the same hypothesis), with \vdash \Gamma from \judge[\Gamma]{\sigma : \Delta}.

Case

Mathpar.

STy_i
S’Ty_i
SS’Ty_i

TTy_i
T’Ty_i
TT’ (x:S). T(x:S’). T’

\begin{aligned} &\tyequiv[\Gamma]{S[\sigma]}{S'[\sigma']}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by IH on third premise, statement~(2))} \\ &\judge[\Gamma, x:S[\sigma]]{q(\sigma) \approx q(\sigma') : (\Delta, x:S)} && \text{(by lifting)} \\ &\subty[\Gamma, x:S[\sigma]]{T[q(\sigma)]}{T'[q(\sigma')]} && \text{(by IH on sixth premise)} \\ &\subty[\Gamma]{\Pi(x:S[\sigma]).\,(T[q(\sigma)])} {\Pi(x:S'[\sigma']).\,(T'[q(\sigma')])} && \text{(by \textsc{Sub-Pi} on the previous lines and IH on the well-formedness} \\ & && \text{premises 1, 2, 4, 5)} \\ &(\Pi(x:S).\,T)[\sigma] = \Pi(x:S[\sigma]).\,(T[q(\sigma)]) && \text{(syntactic)} \\ &(\Pi(x:S').\,T')[\sigma'] = \Pi(x:S'[\sigma']).\,(T'[q(\sigma')]) && \text{(syntactic)} \end{aligned}

Case Sub-Trans: by IH on both premises and Sub-Trans, using a shared middle subtype evaluated at \sigma on both sides.

Case Sub-Eq: by IH on the premise via statement (2) and Sub-Eq.

Corollary

Corollary 4.14 (Pointwise Equality at the Head Yields Type Equality)

06JH

If \typing[\Delta, x:S]{T}{\ensuremath{\texttt{Ty}_{i}}}, \judge[\Gamma]{\sigma : \Delta}, and \tyequiv[\Gamma]{s}{s'}{S[\sigma]}, then \tyequiv[\Gamma]{T[\sigma, s/x]}{T[\sigma, s'/x]}{\ensuremath{\texttt{Ty}_{i}}}.

Proof of Corollary 4.14

By ?, \typing[\Gamma]{s}{S[\sigma]} and \typing[\Gamma]{s'}{S[\sigma]} from \tyequiv[\Gamma]{s}{s'}{S[\sigma]}. Build the substitution equivalence \judge[\Gamma]{(\sigma, s/x) \approx (\sigma, s'/x) : (\Delta, x:S)}: at every y \in \Delta both sides yield \sigma(y), and at x the heads s, s' are equated at S[\sigma] by hypothesis. Apply ? statement (1) to \typing[\Delta, x:S]{T}{\ensuremath{\texttt{Ty}_{i}}}.

Definition

Definition 5.1 (Semantic Domain)

LL3T

The domain \ensuremath{\mathrm{D}}, neutral values \ensuremath{\mathrm{D}}_n, normal forms \ensuremath{\mathrm{D}}_f, and environments \textsf{Env} are defined mutually as follows:

\begin{array}{rrcl} \textit{Environments} & \rho & \in & \textsf{Env} = \mathbb{N} \to \ensuremath{\mathrm{D}} \\[6pt] \textit{Domain values} & a, b, A, B & \in & \ensuremath{\mathrm{D}} \\ & & ::= & U_i \mid N \mid \Pi(a, t, \rho) \mid \texttt{ze} \mid \texttt{su}(a) \mid \lambda(t, \rho) \mid {\uparrow^A(e)} \\[6pt] \textit{Neutral values} & e & \in & \ensuremath{\mathrm{D}}_n \\ & & ::= & \ell_n \mid e \; \$ \; d \mid \mathsf{rec}(T, a, s, \rho, e) \\[6pt] \textit{Normal forms} & d & \in & \ensuremath{\mathrm{D}}_f \\ & & ::= & {\downarrow}^A(a) \end{array}
Lemma

Lemma 5.2

9BH7

The follow evaluations hold:

    \ensuremath{\llbracket \iota(\psi) \rrbracket(\rho)} \searrow \ensuremath{\llbracket \psi \rrbracket(\rho)} \ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)} \searrow \rho, If \ensuremath{\llbracket \sigma \rrbracket(\rho)} \searrow \rho' and \ensuremath{\llbracket t \rrbracket(\rho)} \searrow a, then \ensuremath{\llbracket \sigma, t/x \rrbracket(\rho)} \searrow (\rho', a).

Lemma

Lemma 5.3 (Determinism)

8PA1

    If \ensuremath{\llbracket t \rrbracket(\rho)} \searrow a and \ensuremath{\llbracket t \rrbracket(\rho)} \searrow a', then a = a'. If f \cdot a \searrow b and f \cdot a \searrow b', then b = b'. If \mathsf{rec}(a, T, z, s, \rho) \searrow b and \mathsf{rec}(a, T, z, s, \rho) \searrow b', then b = b'. If \textsf{R}^{\textsf{Nf}}_n(d) \searrow w and \textsf{R}^{\textsf{Nf}}_n(d) \searrow w', then w = w'. If \textsf{R}^{\textsf{Ty}}_n(A) \searrow W and \textsf{R}^{\textsf{Ty}}_n(A) \searrow W', then W = W'. If \textsf{R}^{\textsf{Ne}}_n(e) \searrow u and \textsf{R}^{\textsf{Ne}}_n(e) \searrow u', then u = u'.

Proof of Lemma 5.3

By mutual induction on the derivations. In each case, the conclusion follows because the rules are syntax-directed: no two rules apply to the same configuration.

Definition

Definition 5.4 (Initial Environment)

ORA4

Given a context \Gamma, the initial environment {\uparrow}^\Gamma : \textsf{Env} is defined by induction on \Gamma:

\begin{array}{lcl} {\uparrow}^{\cdot}(x) & = & \texttt{ze} \\[4pt] {\uparrow}^{\Gamma, x : T} & = & ({\uparrow}^\Gamma,\; {\uparrow}^{\ensuremath{\llbracket T \rrbracket({\uparrow}^\Gamma)}}(\ell_{|\Gamma|})) \end{array}

Each variable x_i in \Gamma is mapped to a neutral value {\uparrow}^{A_i}(\ell_i) reflecting x_i at its evaluated type A_i. Here |\Gamma| denotes the length of \Gamma.

Used by Proof
Definition

Definition 5.5 (NbE)

W5O6

Given \judge[t]{T : , we define

\textsf{nbe}^T_\Gamma(t) := \textsf{R}^{\textsf{Nf}}_{|\Gamma|}({\downarrow}^{\ensuremath{\llbracket T \rrbracket(\uparrow^\Gamma)}}(\ensuremath{\llbracket t \rrbracket(\uparrow^\Gamma)}))
Used by Theorem 7.48
Definition

Definition 6.1 (PER \Nf — Normal Forms)

62DE

Two annotated normal forms d, d' \in \ensuremath{\mathrm{D}}_f are related in \textsf{Nf} if they read back to the same syntactic normal form at every name supply level:

d \approx d' \in \textsf{Nf} \;:=\; \forall\, n \in \mathbb{N}.\; \exists\, w.\; \textsf{R}^{\textsf{Nf}}_n(d) \searrow w \;\wedge\; \textsf{R}^{\textsf{Nf}}_n(d') \searrow w
Definition

Definition 6.2 (PER \Ne — Neutral Terms)

19YI

Two neutral domain values e, e' are related in \textsf{Ne} if they read back to the same neutral normal form at every name supply level:

e \approx e' \in \textsf{Ne} \;:=\; \forall\, n \in \mathbb{N}.\; \exists\, u.\; \textsf{R}^{\textsf{Ne}}_n(e) \searrow u \;\wedge\; \textsf{R}^{\textsf{Ne}}_n(e') \searrow u
Definition

Definition 6.3 (PER \textsf{Ty} — Types)

08WT

Two domain values A, A' representing types are related in \textsf{Ty} if they read back to the same type normal form:

A \approx A' \in \textsf{Ty} \;:=\; \forall\, n \in \mathbb{N}.\; \exists\, W.\; \textsf{R}^{\textsf{Ty}}_n(A) \searrow W \;\wedge\; \textsf{R}^{\textsf{Ty}}_n(A') \searrow W
Lemma

Lemma 6.4 (Base PERs are PERs)

1U3M

\textsf{Nf}, \textsf{Ne}, and \textsf{Ty} are symmetric and transitive (hence PERs).

Proof of Lemma 6.4

Symmetry is immediate (swap the two conjuncts). Transitivity follows from determinism of readback (?).

Case \textsf{Ne}. Suppose e \approx e' \in \textsf{Ne} and e' \approx e'' \in \textsf{Ne}.

\begin{aligned} &\forall\, n.\; \exists\, u.\; \textsf{R}^{\textsf{Ne}}_n(e) \searrow u \;\wedge\; \textsf{R}^{\textsf{Ne}}_n(e') \searrow u && \text{(by first hypothesis)} \\ &\forall\, n.\; \exists\, u'.\; \textsf{R}^{\textsf{Ne}}_n(e') \searrow u' \;\wedge\; \textsf{R}^{\textsf{Ne}}_n(e'') \searrow u' && \text{(by second hypothesis)} \\ &u = u' && \text{(by determinism of $\textsf{R}^{\textsf{Ne}}$, \Cref{lem:det})} \\ &\textsf{R}^{\textsf{Ne}}_n(e) \searrow u \;\wedge\; \textsf{R}^{\textsf{Ne}}_n(e'') \searrow u && \text{(combining above)} \end{aligned}

The cases for \textsf{Nf} and \textsf{Ty} are analogous, using determinism of \textsf{R}^{\textsf{Nf}} and \textsf{R}^{\textsf{Ty}} respectively.

Definition

Definition 6.5 (PER \textsf{Neu})

EOMG
{\uparrow}^A(e) \approx {\uparrow}^{A'}(e') \in \textsf{Neu} \;:=\; e \approx e' \in \textsf{Ne}
Lemma

Lemma 6.7 (\textsf{Nat} is a PER)

7757

\textsf{Nat} is symmetric and transitive.

Proof of Lemma 6.7

By induction on the derivation.

Case

Mathpar.

ze ze Nat

Symmetry and transitivity are immediate.

Case

Mathpar.

a a’ Nat su(a) su(a’) Nat

\begin{aligned} &a' \approx a \in \textsf{Nat} && \text{(by IH, symmetry)} \\ &\texttt{su}(a') \approx \texttt{su}(a) \in \textsf{Nat} && \text{(by \textsc{Nat-Su})} \end{aligned}

Transitivity: given additionally \texttt{su}(a') \approx \texttt{su}(a'') \in \textsf{Nat} (hence a' \approx a'' \in \textsf{Nat}), by the IH a \approx a'' \in \textsf{Nat}, so \texttt{su}(a) \approx \texttt{su}(a'') \in \textsf{Nat}.

Case

Mathpar.

e e’ Ne ^N(e) ^N(e’) Nat

\begin{aligned} &e' \approx e \in \textsf{Ne} && \text{(by symmetry of $\textsf{Ne}$, \Cref{lem:base-per})} \\ &{\uparrow}^N(e') \approx {\uparrow}^N(e) \in \textsf{Nat} && \text{(by \textsc{Nat-Ne})} \end{aligned}

Transitivity follows analogously from transitivity of \textsf{Ne}.

Lemma

Lemma 6.8 (\textsf{Nat} reads back correctly)

ZY5E

If a \approx a' \in \textsf{Nat}, then {\downarrow}^N(a) \approx {\downarrow}^N(a') \in \textsf{Nf}.

Proof of Lemma 6.8

By induction on the derivation of a \approx a' \in \textsf{Nat}.

Case

Mathpar.

ze ze Nat

Both sides read back to \textsf{zero} at every level n, so {\downarrow}^N(\texttt{ze}) \approx {\downarrow}^N(\texttt{ze}) \in \textsf{Nf}.

Case

Mathpar.

a a’ Nat su(a) su(a’) Nat

\begin{aligned} &{\downarrow}^N(a) \approx {\downarrow}^N(a') \in \textsf{Nf} && \text{(by IH)} \\ &\forall\, n.\; \exists\, w.\; \textsf{R}^{\textsf{Nf}}_n({\downarrow}^N(a)) \searrow w \;\wedge\; \textsf{R}^{\textsf{Nf}}_n({\downarrow}^N(a')) \searrow w && \text{(by definition of $\textsf{Nf}$)} \\ &\textsf{R}^{\textsf{Nf}}_n({\downarrow}^N(\texttt{su}(a))) \searrow \textsf{succ}~w \;\wedge\; \textsf{R}^{\textsf{Nf}}_n({\downarrow}^N(\texttt{su}(a'))) \searrow \textsf{succ}~w && \text{(by \textsc{Rf-su})} \end{aligned}

Case

Mathpar.

e e’ Ne ^N(e) ^N(e’) Nat

\begin{aligned} &e \approx e' \in \textsf{Ne} && \text{(by hypothesis)} \\ &\forall\, n.\; \exists\, u.\; \textsf{R}^{\textsf{Ne}}_n(e) \searrow u \;\wedge\; \textsf{R}^{\textsf{Ne}}_n(e') \searrow u && \text{(by definition of $\textsf{Ne}$)} \\ &\textsf{R}^{\textsf{Nf}}_n({\downarrow}^N({\uparrow}^N(e))) \searrow u \;\wedge\; \textsf{R}^{\textsf{Nf}}_n({\downarrow}^N({\uparrow}^N(e'))) \searrow u && \text{(by \textsc{Rf-ne})} \end{aligned}
Definition

Definition 6.9 (Universe PER \Uc_i)

LHTV

The relation A \approx A' \in \mathcal{U}_i \searrow R is defined inductively by the following four cases. The returned R is unique only up to \Leftrightarrow (not definitional equality).

Mathpar.

b b’ Ne
R Neu ^A(b) ^A’(b’) U_i R

j < i
R U_j U_j U_j U_i R

R Nat N N U_i R

A A’ U_i R_I
R_I is a PER

  D :: a a’ R_I. T (, a/x) T’ (’, a’/x) U_i R_O(D)

  f, f’. f f’ R (  D :: a a’ R_I. f a f’ a’ R_O(D)) (A, T, ) (A’, T’, ’) U_i R

In the \textsc{U-Pi} case, \Pi(A, T, \rho) is the closure form: the codomain fiber at input b is obtained by evaluating T in (\rho, b/x). The notation \ensuremath{\mathcal{D}} :: a \approx a' \in R_I means that \ensuremath{\mathcal{D}} is the proof/evidence that a \approx a' \in R_I holds; R_O(\ensuremath{\mathcal{D}}) may depend on this evidence. The fourth premise characterizes R as the PER on functions: f, f' are related in R if and only if applying them to related inputs yields related outputs. We write f \cdot a for semantic application (i.e., there exists c with f \cdot a \searrow c, and c participates in R_O(\ensuremath{\mathcal{D}})).

Remark

Remark Remark

RE42

Several points deserve emphasis:

    The returned R in each case is specified only up to \Leftrightarrow. This makes \mathcal{U}_i a weak partial functional relation, avoiding the need for propositional or functional extensionality. The premise “R_I is a PER” in \textsc{U-Pi} strengthens the induction principle: it allows proving that returned PERs are PERs without extra axioms. Once symmetry and transitivity of the returned PER are established (see below), the premise becomes logically redundant but is needed for the induction to go through.

Lemma

Lemma 6.10 (Cumulativity)

7XV8

If A \approx A' \in \mathcal{U}_i \searrow R and i \le j, then A \approx A' \in \mathcal{U}_j \searrow R.

Proof of Lemma 6.10

By induction on the derivation of A \approx A' \in \mathcal{U}_i \searrow R.

Case

Mathpar.

b b’ Ne
R Neu ^A(b) ^A’(b’) U_i R

The same derivation works at level j (neutrals are level-independent): {\uparrow}^A(b) \approx {\uparrow}^{A'}(b') \in \mathcal{U}_j \searrow R by U-Ne.

Case

Mathpar.

k < i
R U_k U_k U_k U_i R

\begin{aligned} &k < i \le j && \text{(by hypothesis)} \\ &U_k \approx U_k \in \mathcal{U}_j \searrow R && \text{(by \textsc{U-Univ}, since $k < j$)} \end{aligned}

Case

Mathpar.

R Nat N N U_i R

Level-independent: N \approx N \in \mathcal{U}_j \searrow R by U-Nat.

Case

Mathpar.

A A’ U_i R_I
R_I is a PER

  D :: a a’ R_I. T (, a/x) T’ (’, a’/x) U_i R_O(D)

  f, f’. f f’ R (  D :: a a’ R_I. f a f’ a’ R_O(D)) (A, T, ) (A’, T’, ’) U_i R

\begin{aligned} &A \approx A' \in \mathcal{U}_j \searrow R_I && \text{(by IH on domain)} \\ &\forall\, \ensuremath{\mathcal{D}} :: a \approx a' \in R_I.\; \ensuremath{\llbracket T \rrbracket(\rho, a/x)} \approx \ensuremath{\llbracket T' \rrbracket(\rho', a'/x)} \in \mathcal{U}_j \searrow R_O(\ensuremath{\mathcal{D}}) && \text{(by IH on codomain)} \\ &\Pi(A, T, \rho) \approx \Pi(A', T', \rho') \in \mathcal{U}_j \searrow R && \text{(by \textsc{U-Pi})} \end{aligned}
Definition

Definition 6.11 (Semantic Subtyping <:_i)

6FGY

The relation A \mathrel{<:_i} A' is defined inductively by:

Mathpar.

b b’ Ne ^A(b) <:_i ^A’(b’)

j k
k < i U_j <:_i U_k

N <:_i N

A A’ U_i R_I
  D :: a a’ R_I. T (, a/x) <:_i T’ (’, a’/x)

(A, T, ) (A, T, ) U_i
(A’, T’, ’) (A’, T’, ’) U_i (A, T, ) <:_i (A’, T’, ’)

Lemma

Lemma 6.12 (Right irrelevance of \Uc_i)

8BSG

If A \approx B \in \mathcal{U}_i \searrow R and A \approx B' \in \mathcal{U}_j \searrow R', then R \Leftrightarrow R'.

Proof of Lemma 6.12

By induction on the two derivations simultaneously. The cases are forced: N can only match \textsc{U-Nat}, a neutral can only match \textsc{U-Ne}, etc.

Case \textsc{U-Ne}.

Mathpar.

b b’ Ne
R Neu ^A(b) ^A’(b’) U_i R

Both derivations force R \Leftrightarrow \textsf{Neu} and R' \Leftrightarrow \textsf{Neu}, so R \Leftrightarrow R'.

Case \textsc{U-Nat}. Both derivations force R \Leftrightarrow \textsf{Nat} and R' \Leftrightarrow \textsf{Nat}, so R \Leftrightarrow R'.

Case \textsc{U-Univ}. Both derivations force R \Leftrightarrow \mathcal{U}_j and R' \Leftrightarrow \mathcal{U}_j, so R \Leftrightarrow R'.

Case \textsc{U-Pi}.

Mathpar.

A A’ U_i R_I
R_I is a PER

  D :: a a’ R_I. T (, a/x) T’ (’, a’/x) U_i R_O(D)

  f, f’. f f’ R (  D :: a a’ R_I. f a f’ a’ R_O(D)) (A, T, ) (A’, T’, ’) U_i R

From the second derivation we get R_I' with A \approx A' \in \mathcal{U}_i \searrow R_I'.

\begin{aligned} &R_I \Leftrightarrow R_I' && \text{(by IH on domain)} \\ &\forall\, \ensuremath{\mathcal{D}} :: a \approx a' \in R_I.\; R_O(\ensuremath{\mathcal{D}}) \Leftrightarrow R_O'(\ensuremath{\mathcal{D}}) && \text{(by IH on codomain at each input)} \\ &R \Leftrightarrow R' && \text{(by the biconditional characterizations and transitivity of $\Leftrightarrow$)} \end{aligned}
Lemma

Lemma 6.13 (Symmetry of \Uc_i)

Y9KO

If A \approx A' \in \mathcal{U}_i \searrow R, then:

    A' \approx A \in \mathcal{U}_i \searrow R, and a \approx a' \in R implies a' \approx a \in R.

Proof of Lemma 6.13

By induction on the derivation. We prove both statements simultaneously.

Case

Mathpar.

b b’ Ne
R Neu ^A(b) ^A’(b’) U_i R

For (1):

\begin{aligned} &b' \approx b \in \textsf{Ne} && \text{(by symmetry of $\textsf{Ne}$)} \\ &{\uparrow}^{A'}(b') \approx {\uparrow}^A(b) \in \mathcal{U}_i \searrow R && \text{(by \textsc{U-Ne})} \end{aligned}

For (2): Suppose a \approx a' \in R, i.e. a \approx a' \in \textsf{Neu} (since R \Leftrightarrow \textsf{Neu}). Then a = {\uparrow}^B(e) and a' = {\uparrow}^{B'}(e') with e \approx e' \in \textsf{Ne}. By symmetry of \textsf{Ne}, e' \approx e \in \textsf{Ne}, so a' \approx a \in \textsf{Neu}, i.e. a' \approx a \in R.

Case

Mathpar.

j < i
R U_j U_j U_j U_i R

For (1): Immediate (U_j \approx U_j is symmetric).

For (2): Suppose a \approx a' \in R, i.e. a \approx a' \in \mathcal{U}_j \searrow R_0 for some R_0. By the IH at level j (which is structurally smaller), a' \approx a \in \mathcal{U}_j \searrow R_0, so a' \approx a \in R.

Case

Mathpar.

R Nat N N U_i R

For (1): Immediate.

For (2): Suppose a \approx a' \in R, i.e. a \approx a' \in \textsf{Nat}. By symmetry of \textsf{Nat} (?), a' \approx a \in \textsf{Nat}, so a' \approx a \in R.

Case

Mathpar.

A A’ U_i R_I
R_I is a PER

  D :: a a’ R_I. T (, a/x) T’ (’, a’/x) U_i R_O(D)

  f, f’. f f’ R (  D :: a a’ R_I. f a f’ a’ R_O(D)) (A, T, ) (A’, T’, ’) U_i R

For (1): We construct a U-Pi derivation of \Pi(A', T', \rho') \approx \Pi(A, T, \rho) \in \mathcal{U}_i \searrow R. We verify the four premises.

Premise 1 (domain):

\begin{aligned} &A' \approx A \in \mathcal{U}_i \searrow R_I && \text{(by IH (1) on domain; same $R_I$ by \Cref{lem:univ-functional})} \end{aligned}

Premise 2: R_I is a PER (by hypothesis).

Premise 3 (codomain): Let \ensuremath{\mathcal{D}}' :: a' \approx a \in R_I.

\begin{aligned} &a \approx a' \in R_I && \text{(by symmetry of $R_I$; call this $\ensuremath{\mathrm{D}}_0$)} \\ &\ensuremath{\llbracket T \rrbracket(\rho, a/x)} \approx \ensuremath{\llbracket T' \rrbracket(\rho', a'/x)} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathrm{D}}_0) && \text{(original codomain premise at $\ensuremath{\mathrm{D}}_0$)} \\ &\ensuremath{\llbracket T' \rrbracket(\rho', a'/x)} \approx \ensuremath{\llbracket T \rrbracket(\rho, a/x)} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathrm{D}}_0) && \text{(by IH (1) on codomain; same $R_O(\ensuremath{\mathrm{D}}_0)$ returned)} \end{aligned}

Define R_O'(\ensuremath{\mathcal{D}}') := R_O(\ensuremath{\mathrm{D}}_0).

Premise 4 (biconditional): We must show

\forall\, f, f'.\; f \approx f' \in R \;\leftrightarrow\; (\forall\, \ensuremath{\mathcal{D}}' :: a' \approx a \in R_I.\; f \cdot a' \approx f' \cdot a \in R_O'(\ensuremath{\mathcal{D}}'))

Since R_I is a PER, the set of pairs \{(a, a') \mid a \approx a' \in R_I\} is closed under swapping: (a, a') \in R_I iff (a', a) \in R_I. By right irrelevance (?), R_O(\ensuremath{\mathcal{D}}) depends only on the pair (a, a'), not the specific evidence \ensuremath{\mathcal{D}}. Hence the right-hand side “\forall\, \ensuremath{\mathcal{D}}' :: a' \approx a \in R_I.\; f \cdot a' \approx f' \cdot a \in R_O'(\ensuremath{\mathcal{D}}')” is, after renaming bound variables (a' \mapsto b, a \mapsto b'), equivalent to “\forall\, \ensuremath{\mathcal{D}}'':: b \approx b' \in R_I.\; f \cdot b \approx f' \cdot b' \in R_O(\ensuremath{\mathcal{D}}'')” which is exactly the original right-hand side. Therefore the same R satisfies both biconditionals.

\begin{aligned} &\Pi(A', T', \rho') \approx \Pi(A, T, \rho) \in \mathcal{U}_i \searrow R && \text{(by \textsc{U-Pi})} \end{aligned}

For (2): Suppose f \approx f' \in R. We must show f' \approx f \in R, i.e. for all \ensuremath{\mathcal{D}} :: a \approx a' \in R_I, f' \cdot a \approx f \cdot a' \in R_O(\ensuremath{\mathcal{D}}).

\begin{aligned} &a' \approx a \in R_I && \text{(by symmetry of $R_I$)} \\ &\text{let } \ensuremath{\mathcal{D}}' :: a' \approx a \in R_I \\ &f \cdot a' \approx f' \cdot a \in R_O(\ensuremath{\mathcal{D}}') && \text{(from $f \approx f' \in R$, applied to $\ensuremath{\mathcal{D}}'$)} \\ &R_O(\ensuremath{\mathcal{D}}) \Leftrightarrow R_O(\ensuremath{\mathcal{D}}') && \text{(by \Cref{lem:univ-functional}: both have same left type $\ensuremath{\llbracket T \rrbracket(\rho, a/x)}$)} \\ &f' \cdot a \approx f \cdot a' \in R_O(\ensuremath{\mathcal{D}}') && \text{(by IH (2) on $R_O(\ensuremath{\mathcal{D}}')$)} \\ &f' \cdot a \approx f \cdot a' \in R_O(\ensuremath{\mathcal{D}}) && \text{(by $R_O(\ensuremath{\mathcal{D}}) \Leftrightarrow R_O(\ensuremath{\mathcal{D}}')$)} \end{aligned}
Lemma

Lemma 6.14 (Transitivity of \Uc_i)

Y4OA

If A_1 \approx A_2 \in \mathcal{U}_i \searrow R, then:

    A_2 \approx A_3 \in \mathcal{U}_j \searrow R' implies A_1 \approx A_3 \in \mathcal{U}_i \searrow R, and a_1 \approx a_2 \in R and a_2 \approx a_3 \in R implies a_1 \approx a_3 \in R.

Proof of Lemma 6.14

By induction on the two derivations. We must case-split on both; by the structure of the definition, matching cases are forced (e.g., N can only relate to N).

Case \textsc{U-Ne}.

Mathpar.

b b’ Ne
R Neu ^A(b) ^A’(b’) U_i R

and

Mathpar.

b’ b” Ne
R’ Neu ^A’(b’) ^A”(b”) U_i R’

\begin{aligned} &b \approx b'' \in \textsf{Ne} && \text{(by transitivity of $\textsf{Ne}$)} \\ &{\uparrow}^A(b) \approx {\uparrow}^{A''}(b'') \in \mathcal{U}_i \searrow R && \text{(by \textsc{U-Ne})} \\ &R \Leftrightarrow \textsf{Neu} \Leftrightarrow R' && \text{(hence $R \Leftrightarrow R'$)} \end{aligned}

Case \textsc{U-Nat} and \textsc{U-Univ}: immediate.

Case \textsc{U-Pi}. The first derivation is:

Mathpar.

A_1 A_2 U_i R_I
R_I is a PER

  D :: a a’ R_I. T_1 (_1, a/x) T_2 (_2, a’/x) U_i R_O(D)

  f, f’. f f’ R (  D :: a a’ R_I. f a f’ a’ R_O(D)) (A_1, T_1, _1) (A_2, T_2, _2) U_i R

The second derivation is:

Mathpar.

A_2 A_3 U_j R_I’
R_I’ is a PER

  D’ :: a a’ R_I’. T_2 (_2, a/x) T_3 (_3, a’/x) U_j R_O’(D’)

  f, f’. f f’ R’ (  D’ :: a a’ R_I’. f a f’ a’ R_O’(D’)) (A_2, T_2, _2) (A_3, T_3, _3) U_j R’

For (1): We construct a U-Pi derivation of \Pi(A_1, T_1, \rho_1) \approx \Pi(A_3, T_3, \rho_3) \in \mathcal{U}_i \searrow R.

Premise 1 (domain):

\begin{aligned} &R_I \Leftrightarrow R_I' && \text{(by \Cref{lem:univ-functional}: both have left type $A_2$)} \\ &A_1 \approx A_3 \in \mathcal{U}_i \searrow R_I && \text{(by IH (1) on domain)} \end{aligned}

Premise 2: R_I is a PER (by hypothesis).

Premise 3 (codomain): Let \ensuremath{\mathcal{D}} :: a \approx a' \in R_I. We must show \ensuremath{\llbracket T_1 \rrbracket(\rho_1, a/x)} \approx \ensuremath{\llbracket T_3 \rrbracket(\rho_3, a'/x)} \in \mathcal{U}_i \searrow R_O''(\ensuremath{\mathcal{D}}) for some R_O''.

\begin{aligned} &a \approx a \in R_I && \text{(by symmetry + transitivity of $R_I$; let this be $\ensuremath{\mathrm{D}}_1$)} \\ &\ensuremath{\llbracket T_1 \rrbracket(\rho_1, a/x)} \approx \ensuremath{\llbracket T_2 \rrbracket(\rho_2, a/x)} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathrm{D}}_1) && \text{(from first codomain at $\ensuremath{\mathrm{D}}_1$)} \\ &a \approx a' \in R_I' && \text{(by $R_I \Leftrightarrow R_I'$; let evidence in $R_I'$ be $\ensuremath{\mathcal{D}}'$)} \\ &\ensuremath{\llbracket T_2 \rrbracket(\rho_2, a/x)} \approx \ensuremath{\llbracket T_3 \rrbracket(\rho_3, a'/x)} \in \mathcal{U}_j \searrow R_O'(\ensuremath{\mathcal{D}}') && \text{(from second codomain at $\ensuremath{\mathcal{D}}'$)} \\ &\ensuremath{\llbracket T_1 \rrbracket(\rho_1, a/x)} \approx \ensuremath{\llbracket T_3 \rrbracket(\rho_3, a'/x)} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathrm{D}}_1) && \text{(by IH (1) on codomain)} \end{aligned}

Set R_O''(\ensuremath{\mathcal{D}}) := R_O(\ensuremath{\mathrm{D}}_1).

Premise 4 (biconditional): We must show f \approx f' \in R \;\leftrightarrow\; (\forall\, \ensuremath{\mathcal{D}} :: a \approx a' \in R_I.\; f \cdot a \approx f' \cdot a' \in R_O''(\ensuremath{\mathcal{D}})). Since R_O''(\ensuremath{\mathcal{D}}) = R_O(\ensuremath{\mathrm{D}}_1) and by right irrelevance R_O(\ensuremath{\mathrm{D}}_1) \Leftrightarrow R_O(\ensuremath{\mathcal{D}}) (both have the same left type \ensuremath{\llbracket T_1 \rrbracket(\rho_1, a/x)}), the right-hand side is equivalent to the original biconditional for R. Hence the same R works.

\begin{aligned} &\Pi(A_1, T_1, \rho_1) \approx \Pi(A_3, T_3, \rho_3) \in \mathcal{U}_i \searrow R && \text{(by \textsc{U-Pi})} \end{aligned}

For (2): Suppose f_1 \approx f_2 \in R and f_2 \approx f_3 \in R. We must show f_1 \approx f_3 \in R, i.e. for all \ensuremath{\mathcal{D}} :: a \approx a' \in R_I, f_1 \cdot a \approx f_3 \cdot a' \in R_O(\ensuremath{\mathcal{D}}).

\begin{aligned} &a \approx a \in R_I && \text{(by symmetry + transitivity of $R_I$; let this be $\ensuremath{\mathrm{D}}_1$)} \\ &f_1 \cdot a \approx f_2 \cdot a \in R_O(\ensuremath{\mathrm{D}}_1) && \text{(from $f_1 \approx f_2 \in R$ at $\ensuremath{\mathrm{D}}_1$)} \\ &f_2 \cdot a \approx f_3 \cdot a' \in R_O(\ensuremath{\mathcal{D}}) && \text{(from $f_2 \approx f_3 \in R$ at $\ensuremath{\mathcal{D}}$)} \\ &R_O(\ensuremath{\mathrm{D}}_1) \Leftrightarrow R_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:univ-functional}: same left type $\ensuremath{\llbracket T_1 \rrbracket(\rho_1, a/x)}$)} \\ &f_1 \cdot a \approx f_2 \cdot a \in R_O(\ensuremath{\mathcal{D}}) && \text{(by $R_O(\ensuremath{\mathrm{D}}_1) \Leftrightarrow R_O(\ensuremath{\mathcal{D}})$)} \\ &f_1 \cdot a \approx f_3 \cdot a' \in R_O(\ensuremath{\mathcal{D}}) && \text{(by IH (2) on $R_O(\ensuremath{\mathcal{D}})$: transitivity)} \end{aligned}
Lemma

Lemma 6.15 (Subtyping of \Uc_i)

J8Y8

If A \mathrel{<:_i} A', A \approx B \in \mathcal{U}_i \searrow R, and A' \approx B' \in \mathcal{U}_i \searrow R', then a \approx a' \in R implies a \approx a' \in R'.

Proof of Lemma 6.15

By induction on the derivation of A \mathrel{<:_i} A'.

Case

Mathpar.

b b’ Ne ^A(b) <:_i ^A’(b’)

\begin{aligned} &e \approx e \in \textsf{Ne} && \text{(by symmetry + transitivity of $\textsf{Ne}$)} \\ &{\uparrow}^{U_i}(e) \approx {\uparrow}^{U_i}(e) \in \mathcal{U}_i \searrow R \text{ with } R \Leftrightarrow \textsf{Neu} && \text{(by \textsc{U-Ne})} \\ &e' \approx e' \in \textsf{Ne} && \text{(by symmetry + transitivity of $\textsf{Ne}$)} \\ &{\uparrow}^{U_i}(e') \approx {\uparrow}^{U_i}(e') \in \mathcal{U}_i \searrow R' \text{ with } R' \Leftrightarrow \textsf{Neu} && \text{(by \textsc{U-Ne})} \\ &R \Leftrightarrow \textsf{Neu} \Leftrightarrow R' && \text{(hence $R \subseteq R'$)} \end{aligned}

Case

Mathpar.

j k
k < i U_j <:_i U_k

\begin{aligned} &U_j \approx U_j \in \mathcal{U}_i \searrow R \text{ with } R \Leftrightarrow (\lambda a\,a'.\, \exists R.\, a \approx a' \in \mathcal{U}_j \searrow R) && \text{(by \textsc{U-Univ}, $j < i$)} \\ &U_k \approx U_k \in \mathcal{U}_i \searrow R' \text{ with } R' \Leftrightarrow (\lambda a\,a'.\, \exists R.\, a \approx a' \in \mathcal{U}_k \searrow R) && \text{(by \textsc{U-Univ}, $k < i$)} \\ &R \subseteq R' && \text{(by cumulativity, \Cref{lem:cumul}, since $j \le k$)} \end{aligned}

Case

Mathpar.

N <:_i N

Both sides are in \mathcal{U}_i (via U-Nat) returning \textsf{Nat}, and \textsf{Nat} \subseteq \textsf{Nat}.

Case

Mathpar.

A A’ U_i R_I
  D :: a a’ R_I. T (, a/x) <:_i T’ (’, a’/x)

(A, T, ) (A, T, ) U_i
(A’, T’, ’) (A’, T’, ’) U_i (A, T, ) <:_i (A’, T’, ’)

The domain PERs coincide by hypothesis. For the function PERs:

\begin{aligned} &\text{Given } f \approx f' \in R && \text{(i.e., $\forall\, \ensuremath{\mathcal{D}} :: a \approx a' \in R_I.\; f \cdot a \approx f' \cdot a' \in R_O(\ensuremath{\mathcal{D}})$)} \\ &\text{Given } \ensuremath{\mathcal{D}} :: a \approx a' \in R_I \\ &f \cdot a \approx f' \cdot a' \in R_O(\ensuremath{\mathcal{D}}) && \text{(by above)} \\ &R_O(\ensuremath{\mathcal{D}}) \subseteq R_{O'}(\ensuremath{\mathcal{D}}) && \text{(by IH on codomain subtyping)} \\ &f \cdot a \approx f' \cdot a' \in R_{O'}(\ensuremath{\mathcal{D}}) && \text{(by inclusion)} \end{aligned}
Lemma

Lemma 6.16 (Transitivity of <:_i)

WW0J

If A \mathrel{<:_i} B and B \mathrel{<:_i} C, then A \mathrel{<:_i} C.

Proof of Lemma 6.16

By induction on the derivation of A \mathrel{<:_i} B, with case analysis on the constructor of B \mathrel{<:_i} C that must agree on the shape of B.

Case

Mathpar.

b b’ Ne ^A_0(b) <:_i ^B_0(b’)

Here B = {\uparrow}^{B_0}(b'), so B \mathrel{<:_i} C must also be by <:-Ne, with C = {\uparrow}^{C_0}(b'') and b' \approx b'' \in \textsf{Ne}. By transitivity of the neutral PER (?), b \approx b'' \in \textsf{Ne}. By <:-Ne, {\uparrow}^{A_0}(b) \mathrel{<:_i} {\uparrow}^{C_0}(b'').

Case

Mathpar.

j k
k < i U_j <:_i U_k

Here B = U_k, so B \mathrel{<:_i} C must be by <:-Univ, with C = U_{k'}, k \le k', and k' < i. By transitivity of \le on \mathbb{N}, j \le k', and k' < i by hypothesis. By <:-Univ, U_j \mathrel{<:_i} U_{k'}.

Case

Mathpar.

N <:_i N

Here B = N, so B \mathrel{<:_i} C must be by <:-Nat with C = N. By <:-Nat, N \mathrel{<:_i} N.

Case

Mathpar.

A_I B_I U_i R_I
  D :: a a’ R_I. T_A (_A, a/x) <:_i T_B (_B, a’/x)

(A_I, T_A, _A) (A_I, T_A, _A) U_i
(B_I, T_B, _B) (B_I, T_B, _B) U_i (A_I, T_A, _A) <:_i (B_I, T_B, _B)

Here B = \Pi(B_I, T_B, \rho_B), so B \mathrel{<:_i} C must be by <:-Pi, with C = \Pi(C_I, T_C, \rho_C) and:

\begin{aligned} &B_I \approx C_I \in \mathcal{U}_i \searrow R_I' && \text{(domain of the second derivation)} \\ &\forall\, \ensuremath{\mathcal{D}}' :: a \approx a' \in R_I'.\; \ensuremath{\llbracket T_B \rrbracket(\rho_B, a/x)} \mathrel{<:_i} \ensuremath{\llbracket T_C \rrbracket(\rho_C, a'/x)} && \text{(codomain)} \\ &\Pi(C_I, T_C, \rho_C) \approx \Pi(C_I, T_C, \rho_C) \in \mathcal{U}_i && \text{(self-relatedness)} \end{aligned}

Domain. By ? applied to A_I \approx B_I \in \mathcal{U}_i \searrow R_I and B_I \approx C_I \in \mathcal{U}_i \searrow R_I': A_I \approx C_I \in \mathcal{U}_i, with output PER (call it R_I^*) determined up to logical equivalence by ?; in particular, R_I^* \Leftrightarrow R_I \Leftrightarrow R_I'.

Codomain. Let \ensuremath{\mathcal{D}}^* :: a \approx a' \in R_I^* be given. By the equivalence R_I^* \Leftrightarrow R_I, \ensuremath{\mathcal{D}}^* also witnesses a \approx a' \in R_I, and by R_I^* \Leftrightarrow R_I' it also witnesses some \ensuremath{\mathcal{D}}' :: a \approx a' \in R_I'. Apply the codomain hypothesis of the first derivation at this \ensuremath{\mathcal{D}}^* (used as \ensuremath{\mathcal{D}} in R_I):

\begin{aligned} &\ensuremath{\llbracket T_A \rrbracket(\rho_A, a/x)} \mathrel{<:_i} \ensuremath{\llbracket T_B \rrbracket(\rho_B, a'/x)} && \text{(codomain of the first derivation)} \end{aligned}

Apply the codomain hypothesis of the second derivation at \ensuremath{\mathcal{D}}':

\begin{aligned} &\ensuremath{\llbracket T_B \rrbracket(\rho_B, a'/x)} \mathrel{<:_i} \ensuremath{\llbracket T_C \rrbracket(\rho_C, a''/x)} && \text{(codomain of the second derivation, with $a' \approx a'' \in R_I'$)} \end{aligned}

Since \ensuremath{\mathcal{D}}^* witnesses both pairs we have a' = a'' at this instantiation; the inductive hypothesis composes the two:

\begin{aligned} &\ensuremath{\llbracket T_A \rrbracket(\rho_A, a/x)} \mathrel{<:_i} \ensuremath{\llbracket T_C \rrbracket(\rho_C, a'/x)} && \text{(by IH on the codomain)} \end{aligned}

Self-relatedness. Already given: \Pi(A_I, T_A, \rho_A) \approx \Pi(A_I, T_A, \rho_A) \in \mathcal{U}_i from the first derivation and \Pi(C_I, T_C, \rho_C) \approx \Pi(C_I, T_C, \rho_C) \in \mathcal{U}_i from the second.

Conclusion. By <:-Pi with the four ingredients (domain in \mathcal{U}_i \searrow R_I^*, codomain pointwise subtyping at every \ensuremath{\mathcal{D}}^*, and the two self-relatedness facts):

\Pi(A_I, T_A, \rho_A) \mathrel{<:_i} \Pi(C_I, T_C, \rho_C). \qedhere
Lemma

Lemma 6.17 (\Uc_i implies \mathrel{<:_i})

KR27

If A \approx A' \in \mathcal{U}_i \searrow R, then A \mathrel{<:_i} A'.

Proof of Lemma 6.17

By induction on A \approx A' \in \mathcal{U}_i.

    U-Ne: A = {\uparrow}^{A_0}(b), A' = {\uparrow}^{A_0'}(b'), b \approx b' \in \textsf{Ne}. By <:-Ne. U-Univ: A = A' = U_j with j < i. By <:-Univ with j \le j. U-Nat: A = A' = N. By <:-Nat. U-Pi: A = \Pi(A_I, T, \rho), A' = \Pi(A_I', T', \rho'), domain A_I \approx A_I' \in \mathcal{U}_i \searrow R_I, codomain pointwise \ensuremath{\llbracket T \rrbracket(\rho, a/x)} \approx \ensuremath{\llbracket T' \rrbracket(\rho', a'/x)} \in \mathcal{U}_i, and self-relatedness of both Pi-types. By inner IH on the codomain \mathcal{U}_i-equality: \ensuremath{\llbracket T \rrbracket(\rho, a/x)} \mathrel{<:_i} \ensuremath{\llbracket T' \rrbracket(\rho', a'/x)}. By <:-Pi.

Lemma

Lemma 6.18 (Realizability of the PER model)

ARFP

Given A \approx A' \in \mathcal{U}_i \searrow R:

    (Elements of R read back) If a \approx a' \in R, then {\downarrow}^A(a) \approx {\downarrow}^{A'}(a') \in \textsf{Nf}. (Neutrals inhabit R) If e \approx e' \in \textsf{Ne}, then {\uparrow}^A(e) \approx {\uparrow}^{A'}(e') \in R. (Types read back) A \approx A' \in \textsf{Ty}.

Proof of Lemma 6.18

By simultaneous induction on the derivation of A \approx A' \in \mathcal{U}_i \searrow R. We also need an auxiliary lemma that a \approx a' \in \textsf{Nat} implies {\downarrow}^N(a) \approx {\downarrow}^N(a') \in \textsf{Nf}, which is ?.

Case

Mathpar.

b b’ Ne
R Neu ^A(b) ^A’(b’) U_i R

For (1): Since R \Leftrightarrow \textsf{Neu}, we have a = {\uparrow}^B(e) and a' = {\uparrow}^{B'}(e') with e \approx e' \in \textsf{Ne}. Reading back {\downarrow}^{{\uparrow}^A(b)}({\uparrow}^B(e)) at a neutral type reads e as a neutral (by Rf-ne), and both sides produce the same neutral normal form since e \approx e' \in \textsf{Ne}.

For (2): We need {\uparrow}^{{\uparrow}^A(b)}(e) \approx {\uparrow}^{{\uparrow}^{A'}(b')}(e') \in R. Since R \Leftrightarrow \textsf{Neu}, this reduces to e \approx e' \in \textsf{Ne}, which holds by hypothesis.

For (3): We must show {\uparrow}^A(b) \approx {\uparrow}^{A'}(b') \in \textsf{Ty}, i.e. reading back both sides as types produces the same result. Since b \approx b' \in \textsf{Ne}, reading both as neutrals produces the same neutral normal form.

Case

Mathpar.

j < i
R U_j U_j U_j U_i R

For (1): We have a \approx a' \in R, i.e. a \approx a' \in \mathcal{U}_j \searrow R_0 for some R_0. By IH (3) on the \mathcal{U}_j derivation (structurally smaller since j < i), a \approx a' \in \textsf{Ty}_j. Reading back {\downarrow}^{U_j}(a) as a normal form reads a as a type, hence {\downarrow}^{U_j}(a) \approx {\downarrow}^{U_j}(a') \in \textsf{Nf}.

For (2): We need {\uparrow}^{U_j}(e) \approx {\uparrow}^{U_j}(e') \in R, i.e. {\uparrow}^{U_j}(e) \approx {\uparrow}^{U_j}(e') \in \mathcal{U}_j \searrow R_0 for some R_0.

\begin{aligned} &e \approx e' \in \textsf{Ne} && \text{(by hypothesis)} \\ &{\uparrow}^{U_j}(e) \approx {\uparrow}^{U_j}(e') \in \mathcal{U}_j \searrow \textsf{Neu} && \text{(by \textsc{U-Ne}, taking $R_0 \Leftrightarrow \textsf{Neu}$)} \end{aligned}

For (3): A = A' = U_j. Both sides read back to \ensuremath{\texttt{Ty}_{j}}.

Case

Mathpar.

R Nat N N U_i R

For (1): Since R \Leftrightarrow \textsf{Nat}, we have a \approx a' \in \textsf{Nat}. By ?, {\downarrow}^N(a) \approx {\downarrow}^N(a') \in \textsf{Nf}.

For (2): We need {\uparrow}^N(e) \approx {\uparrow}^N(e') \in \textsf{Nat}.

\begin{aligned} &e \approx e' \in \textsf{Ne} && \text{(by hypothesis)} \\ &{\uparrow}^N(e) \approx {\uparrow}^N(e') \in \textsf{Nat} && \text{(by \textsc{Nat-Ne})} \end{aligned}

For (3): A = A' = N. Both sides read back to \ensuremath{\texttt{Nat}}.

Case

Mathpar.

A_0 A_0’ U_i R_I
R_I is a PER

  D :: a a’ R_I. T (, a/x) T’ (’, a’/x) U_i R_O(D)

  f, f’. f f’ R (  D :: a a’ R_I. f a f’ a’ R_O(D)) (A_0, T, ) (A_0’, T’, ’) U_i R

For (1): We have f \approx f' \in R, i.e. for all \ensuremath{\mathcal{D}} :: a \approx a' \in R_I, f \cdot a \approx f' \cdot a' \in R_O(\ensuremath{\mathcal{D}}). Reading back {\downarrow}^{\Pi(A_0,T,\rho)}(f) at level n:

\begin{aligned} &\ell_n \approx \ell_n \in \textsf{Ne} && \text{(a level variable reads back to itself)} \\ &{\uparrow}^{A_0}(\ell_n) \approx {\uparrow}^{A_0'}(\ell_n) \in R_I && \text{(by IH (2) on domain)} \\ &\text{Let } \ensuremath{\mathrm{D}}_n :: {\uparrow}^{A_0}(\ell_n) \approx {\uparrow}^{A_0'}(\ell_n) \in R_I \\ &f \cdot {\uparrow}^{A_0}(\ell_n) \approx f' \cdot {\uparrow}^{A_0'}(\ell_n) \in R_O(\ensuremath{\mathrm{D}}_n) && \text{(from $f \approx f' \in R$ at $\ensuremath{\mathrm{D}}_n$)} \\ &\ensuremath{\llbracket T \rrbracket(\rho, {\uparrow}^{A_0}(\ell_n)/x)} \approx \ensuremath{\llbracket T' \rrbracket(\rho', {\uparrow}^{A_0'}(\ell_n)/x)} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathrm{D}}_n) && \text{(codomain premise at $\ensuremath{\mathrm{D}}_n$)} \\ &{\downarrow}^{\ensuremath{\llbracket T \rrbracket(\rho, {\uparrow}^{A_0}(\ell_n)/x)}}(f \cdot {\uparrow}^{A_0}(\ell_n)) \approx {\downarrow}^{\ensuremath{\llbracket T' \rrbracket(\rho', {\uparrow}^{A_0'}(\ell_n)/x)}}(f' \cdot {\uparrow}^{A_0'}(\ell_n)) \in \textsf{Nf} && \text{(by IH (1) on codomain)} \end{aligned}

The readback rule for \Pi-types assembles these into \textsf{R}^{\textsf{Nf}}_n({\downarrow}^{\Pi(A_0,T,\rho)}(f)) \searrow \lambda x.\, w and \textsf{R}^{\textsf{Nf}}_n({\downarrow}^{\Pi(A_0',T',\rho')}(f')) \searrow \lambda x.\, w with the same body w.

For (2): By the biconditional, we must show that for all \ensuremath{\mathcal{D}} :: a \approx a' \in R_I, ({\uparrow}^{\Pi(A_0,T,\rho)}(e)) \cdot a \approx ({\uparrow}^{\Pi(A_0',T',\rho')}(e')) \cdot a' \in R_O(\ensuremath{\mathcal{D}}).

\begin{aligned} &\text{Let } \ensuremath{\llbracket T \rrbracket(\rho, a/x)} \searrow B \text{ and } \ensuremath{\llbracket T' \rrbracket(\rho', a'/x)} \searrow B' \\ &({\uparrow}^{\Pi(A_0,T,\rho)}(e)) \cdot a = {\uparrow}^B(e \;\$\; {\downarrow}^{A_0}(a)) && \text{(by \textsc{app-ne})} \\ &({\uparrow}^{\Pi(A_0',T',\rho')}(e')) \cdot a' = {\uparrow}^{B'}(e' \;\$\; {\downarrow}^{A_0'}(a')) && \text{(by \textsc{app-ne})} \\ &{\downarrow}^{A_0}(a) \approx {\downarrow}^{A_0'}(a') \in \textsf{Nf} && \text{(by IH (1) on domain: $a \approx a' \in R_I$)} \\ &e \;\$\; {\downarrow}^{A_0}(a) \approx e' \;\$\; {\downarrow}^{A_0'}(a') \in \textsf{Ne} && \text{(by $e \approx e' \in \textsf{Ne}$ and above)} \\ &B \approx B' \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}) && \text{(codomain premise at $\ensuremath{\mathcal{D}}$)} \\ &{\uparrow}^B(e \;\$\; {\downarrow}^{A_0}(a)) \approx {\uparrow}^{B'}(e' \;\$\; {\downarrow}^{A_0'}(a')) \in R_O(\ensuremath{\mathcal{D}}) && \text{(by IH (2) on codomain)} \end{aligned}

For (3): Reading back \Pi(A_0, T, \rho) as a type at level n:

\begin{aligned} &A_0 \approx A_0' \in \textsf{Ty} && \text{(by IH (3) on domain)} \\ &\ell_n \approx \ell_n \in \textsf{Ne} && \text{(reflexivity of level variable)} \\ &{\uparrow}^{A_0}(\ell_n) \approx {\uparrow}^{A_0'}(\ell_n) \in R_I && \text{(by IH (2) on domain)} \\ &\text{Let } \ensuremath{\mathrm{D}}_n :: {\uparrow}^{A_0}(\ell_n) \approx {\uparrow}^{A_0'}(\ell_n) \in R_I \\ &\ensuremath{\llbracket T \rrbracket(\rho, {\uparrow}^{A_0}(\ell_n)/x)} \approx \ensuremath{\llbracket T' \rrbracket(\rho', {\uparrow}^{A_0'}(\ell_n)/x)} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathrm{D}}_n) && \text{(codomain premise at $\ensuremath{\mathrm{D}}_n$)} \\ &\ensuremath{\llbracket T \rrbracket(\rho, {\uparrow}^{A_0}(\ell_n)/x)} \approx \ensuremath{\llbracket T' \rrbracket(\rho', {\uparrow}^{A_0'}(\ell_n)/x)} \in \textsf{Ty} && \text{(by IH (3) on codomain)} \end{aligned}

The type readback rule for \Pi-types reads back the domain and codomain separately; both agree by the above.

Definition

Definition 6.19 (Context PER)

1L1E

The relation \Gamma \approx \Gamma' \searrow R is defined inductively:

Mathpar.

’ R_T
R_T is a PER
  D :: ’ R_T. S () S’ (’) U_i R_H(D)

  , ’. ’ R (D :: ’[] R_T (0) ’(0) R_H(D)) , x : S ’, x : S’ R

Here \top is the total relation (any two environments are related), \rho[\Uparrow] is the weakened environment (dropping the head), and \rho(0) is the head value. The universe level i at which the heads are related is implicit in the conclusion.

Definition

Definition 6.20 (Semantic Subtyping for Contexts)

B2O7

The relation \Gamma <: \Gamma' is defined inductively:

Mathpar.

<:

<: ’
R_T
  D :: ’ R_T. S () <:_i S’ (’)

, x : S , x : S R_1
’, x : S’ ’, x : S’ R_2 , x : S <: ’, x : S’

Lemma

Lemma 6.21 (Right irrelevance of context PER)

OX2J

If \Gamma \approx \Gamma' \searrow R and \Gamma \approx \Gamma'' \searrow R', then R \Leftrightarrow R'.

Proof of Lemma 6.21

By induction on the first derivation.

Case

Mathpar.

The second derivation also concludes \cdot \approx \cdot \searrow \top, so R = R' = \top and \top \Leftrightarrow \top.

Case The first derivation is:

Mathpar.

’ R_T
R_T is a PER

  D :: ’ R_T. S () S’ (’) U_i R_H(D)

  , ’. ’ R (D :: ’[] R_T (0) ’(0) R_H(D)) , x : S ’, x : S’ R

The second derivation is:

Mathpar.

” R_T’
R_T’ is a PER

  D’ :: ’ R_T’. S () S” (’) U_j R_H’(D’)

  , ’. ’ R’ (D’ :: ’[] R_T’ (0) ’(0) R_H’(D’)) , x : S ”, x : S” R’

We show R \Leftrightarrow R', i.e. \rho \approx \rho' \in R iff \rho \approx \rho' \in R'.

\begin{aligned} &R_T \Leftrightarrow R_T' && \text{(by IH on the tails)} \end{aligned}

(\Rightarrow): Suppose \rho \approx \rho' \in R. By the first biconditional, we obtain \ensuremath{\mathcal{D}} :: \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T with \rho(0) \approx \rho'(0) \in R_H(\ensuremath{\mathcal{D}}).

\begin{aligned} &\rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T' && \text{(by $R_T \Leftrightarrow R_T'$; call this evidence $\ensuremath{\mathcal{D}}'$)} \\ &\ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket S' \rrbracket(\rho'[\Uparrow])} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathcal{D}}) && \text{(from the first head premise at $\ensuremath{\mathcal{D}}$)} \\ &\ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket S'' \rrbracket(\rho'[\Uparrow])} \in \mathcal{U}_j \searrow R_H'(\ensuremath{\mathcal{D}}') && \text{(from the second head premise at $\ensuremath{\mathcal{D}}'$)} \\ &R_H(\ensuremath{\mathcal{D}}) \Leftrightarrow R_H'(\ensuremath{\mathcal{D}}') && \text{(by \Cref{lem:univ-functional}: same left type $\ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])}$)} \\ &\rho(0) \approx \rho'(0) \in R_H'(\ensuremath{\mathcal{D}}') && \text{(by $R_H(\ensuremath{\mathcal{D}}) \Leftrightarrow R_H'(\ensuremath{\mathcal{D}}')$)} \\ &\rho \approx \rho' \in R' && \text{(by the second biconditional, with witness $\ensuremath{\mathcal{D}}'$)} \end{aligned}

(\Leftarrow): Symmetric, swapping the roles of the two derivations.

Lemma

Lemma 6.22 (Symmetry of context PER)

HXEU

If \Gamma \approx \Gamma' \searrow R, then:

    \Gamma' \approx \Gamma \searrow R, and \rho \approx \rho' \in R implies \rho' \approx \rho \in R.

Proof of Lemma 6.22

By induction on the derivation.

Case

Mathpar.

Both statements are immediate (\top is symmetric).

Case

Mathpar.

’ R_T
R_T is a PER

  D :: ’ R_T. S () S’ (’) U_i R_H(D)

  , ’. ’ R (D :: ’[] R_T (0) ’(0) R_H(D)) , x : S ’, x : S’ R

For (1): We construct a Ctx-Ext derivation of \Gamma', x : S' \approx \Gamma, x : S \searrow R. We verify each of the four premises.

Premise 1 (tail):

\begin{aligned} &\Gamma' \approx \Gamma \searrow R_T && \text{(by IH (1) on the tail; same $R_T$ by \Cref{lem:ctx-functional})} \end{aligned}

Premise 2: R_T is a PER (by hypothesis).

Premise 3 (head): Given \ensuremath{\mathcal{D}}' :: \rho' \approx \rho \in R_T, we must show \ensuremath{\llbracket S' \rrbracket(\rho')} \approx \ensuremath{\llbracket S \rrbracket(\rho)} \in \mathcal{U}_i \searrow R_H'(\ensuremath{\mathcal{D}}') for some R_H'.

\begin{aligned} &\rho \approx \rho' \in R_T && \text{(by IH (2) on the tail applied to $\ensuremath{\mathcal{D}}'$; call this $\ensuremath{\mathrm{D}}_0$)} \\ &\ensuremath{\llbracket S \rrbracket(\rho)} \approx \ensuremath{\llbracket S' \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathrm{D}}_0) && \text{(from the original head premise at $\ensuremath{\mathrm{D}}_0$)} \\ &\ensuremath{\llbracket S' \rrbracket(\rho')} \approx \ensuremath{\llbracket S \rrbracket(\rho)} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathrm{D}}_0) && \text{(by \Cref{lem:univ-sym} (1); same $R_H(\ensuremath{\mathrm{D}}_0)$ returned)} \end{aligned}

Set R_H'(\ensuremath{\mathcal{D}}') := R_H(\ensuremath{\mathrm{D}}_0).

Premise 4 (biconditional): We must verify

\forall\, \rho, \rho'.\; \rho \approx \rho' \in R \;\leftrightarrow\; (\ensuremath{\mathcal{D}}' :: \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T \;\wedge\; \rho(0) \approx \rho'(0) \in R_H'(\ensuremath{\mathcal{D}}'))

The original biconditional states:

\rho \approx \rho' \in R \;\leftrightarrow\; (\ensuremath{\mathcal{D}} :: \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T \;\wedge\; \rho(0) \approx \rho'(0) \in R_H(\ensuremath{\mathcal{D}}))

\ensuremath{\mathcal{D}} and \ensuremath{\mathcal{D}}' already discharge. Moreover R_H'(\ensuremath{\mathcal{D}}') = R_H(\ensuremath{\mathrm{D}}_0) \Leftrightarrow R_H(\ensuremath{\mathcal{D}}) by right irrelevance. Hence both biconditionals characterize the same R.

\begin{aligned} &\Gamma', x : S' \approx \Gamma, x : S \searrow R && \text{(by \textsc{Ctx-Ext})} \end{aligned}

For (2): Suppose \rho \approx \rho' \in R. By the biconditional, there exists \ensuremath{\mathcal{D}} :: \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T with \rho(0) \approx \rho'(0) \in R_H(\ensuremath{\mathcal{D}}). We must show \rho' \approx \rho \in R, i.e. exhibit evidence for \rho'[\Uparrow] \approx \rho[\Uparrow] \in R_T together with the heads being related.

\begin{aligned} &\rho'[\Uparrow] \approx \rho[\Uparrow] \in R_T && \text{(by IH (2) on tail applied to $\ensuremath{\mathcal{D}}$; call this $\ensuremath{\mathcal{D}}'$)} \\ &\rho'(0) \approx \rho(0) \in R_H(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:univ-sym} (2))} \\ &R_H(\ensuremath{\mathcal{D}}) \Leftrightarrow R_H(\ensuremath{\mathcal{D}}') && \text{(by \Cref{lem:univ-functional})} \\ &\rho'(0) \approx \rho(0) \in R_H(\ensuremath{\mathcal{D}}') && \text{(by equivalence)} \end{aligned}

The tail evidence \ensuremath{\mathcal{D}}' and the head relatedness \rho'(0) \approx \rho(0) \in R_H(\ensuremath{\mathcal{D}}') together witness \rho' \approx \rho \in R by the biconditional.

Lemma

Lemma 6.23 (Transitivity of context PER)

QD8A

If \Gamma_1 \approx \Gamma_2 \searrow R, then:

    \Gamma_2 \approx \Gamma_3 \searrow R' implies \Gamma_1 \approx \Gamma_3 \searrow R, and \rho_1 \approx \rho_2 \in R and \rho_2 \approx \rho_3 \in R implies \rho_1 \approx \rho_3 \in R.

Proof of Lemma 6.23

By induction on the first derivation.

Case

Mathpar.

Both statements are immediate (\top is transitive).

Case The first derivation is:

Mathpar.

_1 _2 R_T
R_T is a PER

  D :: ’ R_T. S_1 () S_2 (’) U_i R_H(D)

  , ’. ’ R (D :: ’[] R_T (0) ’(0) R_H(D)) _1, x : S_1 _2, x : S_2 R

The second derivation is:

Mathpar.

_2 _3 R_T’
R_T’ is a PER

  D’ :: ’ R_T’. S_2 () S_3 (’) U_j R_H’(D’)

  , ’. ’ R’ (D’ :: ’[] R_T’ (0) ’(0) R_H’(D’)) _2, x : S_2 _3, x : S_3 R’

For (1): We construct a Ctx-Ext derivation of \Gamma_1, x : S_1 \approx \Gamma_3, x : S_3 \searrow R.

Premise 1 (tail):

\begin{aligned} &\Gamma_1 \approx \Gamma_3 \searrow R_T && \text{(by IH (1) on the tail)} \end{aligned}

Premise 2: R_T is a PER (by hypothesis).

Premise 3 (head): Given \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R_T, we must show \ensuremath{\llbracket S_1 \rrbracket(\rho)} \approx \ensuremath{\llbracket S_3 \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_H''(\ensuremath{\mathcal{D}}).

\begin{aligned} &\rho \approx \rho \in R_T && \text{(by symmetry + transitivity of $R_T$)} \\ &\text{Let } \ensuremath{\mathrm{D}}_1 :: \rho \approx \rho \in R_T \\ &\ensuremath{\llbracket S_1 \rrbracket(\rho)} \approx \ensuremath{\llbracket S_2 \rrbracket(\rho)} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathrm{D}}_1) && \text{(from first head premise at $\ensuremath{\mathrm{D}}_1$)} \\ &R_T \Leftrightarrow R_T' && \text{(by \Cref{lem:univ-functional} on tails: same left context $\Gamma_2$)} \\ &\rho \approx \rho' \in R_T' && \text{(from $\rho \approx \rho' \in R_T$ and $R_T \Leftrightarrow R_T'$)} \\ &\text{Let } \ensuremath{\mathrm{D}}_2 :: \rho \approx \rho' \in R_T' \\ &\ensuremath{\llbracket S_2 \rrbracket(\rho)} \approx \ensuremath{\llbracket S_3 \rrbracket(\rho')} \in \mathcal{U}_j \searrow R_H'(\ensuremath{\mathrm{D}}_2) && \text{(from second head premise at $\ensuremath{\mathrm{D}}_2$)} \\ &\ensuremath{\llbracket S_1 \rrbracket(\rho)} \approx \ensuremath{\llbracket S_3 \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathrm{D}}_1) && \text{(by \Cref{lem:univ-trans} (1))} \end{aligned}

Set R_H''(\ensuremath{\mathcal{D}}) := R_H(\ensuremath{\mathrm{D}}_1).

Premise 4 (biconditional): The biconditional characterizes the same R. Since R_T is a PER, the quantification ranges over the same set of pairs. By ?, R_H''(\ensuremath{\mathcal{D}}) \Leftrightarrow R_H(\ensuremath{\mathcal{D}}) (both have the same left type \ensuremath{\llbracket S_1 \rrbracket(\rho[\Uparrow])}), so the biconditional is equivalent to the original.

\begin{aligned} &\Gamma_1, x : S_1 \approx \Gamma_3, x : S_3 \searrow R && \text{(by \textsc{Ctx-Ext})} \end{aligned}

For (2): Suppose \rho_1 \approx \rho_2 \in R and \rho_2 \approx \rho_3 \in R. We must show \rho_1 \approx \rho_3 \in R, i.e. exhibit \ensuremath{\mathcal{D}} :: \rho_1[\Uparrow] \approx \rho_3[\Uparrow] \in R_T with \rho_1(0) \approx \rho_3(0) \in R_H(\ensuremath{\mathcal{D}}).

By the biconditional, from \rho_1 \approx \rho_2 \in R we get \ensuremath{\mathrm{D}}_1 :: \rho_1[\Uparrow] \approx \rho_2[\Uparrow] \in R_T with \rho_1(0) \approx \rho_2(0) \in R_H(\ensuremath{\mathrm{D}}_1). From \rho_2 \approx \rho_3 \in R we get \ensuremath{\mathrm{D}}_2 :: \rho_2[\Uparrow] \approx \rho_3[\Uparrow] \in R_T with \rho_2(0) \approx \rho_3(0) \in R_H(\ensuremath{\mathrm{D}}_2).

\begin{aligned} &\rho_1[\Uparrow] \approx \rho_3[\Uparrow] \in R_T && \text{(by IH (2) on tail; call this $\ensuremath{\mathcal{D}}$)} \\ &R_H(\ensuremath{\mathrm{D}}_1) \Leftrightarrow R_H(\ensuremath{\mathrm{D}}_2) \Leftrightarrow R_H(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:univ-functional}: same left type)} \\ &\rho_2(0) \approx \rho_3(0) \in R_H(\ensuremath{\mathrm{D}}_1) && \text{(from $R_H(\ensuremath{\mathrm{D}}_2) \Leftrightarrow R_H(\ensuremath{\mathrm{D}}_1)$)} \\ &\rho_1(0) \approx \rho_3(0) \in R_H(\ensuremath{\mathrm{D}}_1) && \text{(by \Cref{lem:univ-trans} (2))} \\ &\rho_1(0) \approx \rho_3(0) \in R_H(\ensuremath{\mathcal{D}}) && \text{(by $R_H(\ensuremath{\mathrm{D}}_1) \Leftrightarrow R_H(\ensuremath{\mathcal{D}})$)} \end{aligned}

Hence \rho_1 \approx \rho_3 \in R by the biconditional (with witness \ensuremath{\mathcal{D}}).

Lemma

Lemma 6.24 (Transitivity of semantic subtyping for contexts)

ZRJR

If \Gamma <: \Gamma', \Gamma \approx \Gamma \searrow R, and \Gamma' \approx \Gamma' \searrow R', then \rho \approx \rho' \in R implies \rho \approx \rho' \in R'.

Proof of Lemma 6.24

By induction on the context subtyping derivation.

Case

Mathpar.

<:

Both R and R' are \top, so the inclusion is trivial.

Case

Mathpar.

<: ’
R_T

  D :: ’ R_T. S () <:_i S’ (’)

, x : S , x : S R_1
’, x : S’ ’, x : S’ R_2 , x : S <: ’, x : S’

Suppose \rho \approx \rho' \in R. By ?, R \Leftrightarrow R_1 (both derive from \Gamma, x : S \approx \Gamma, x : S), so \rho \approx \rho' \in R_1. We must show \rho \approx \rho' \in R'. By ?, R' \Leftrightarrow R_2, so it suffices to show \rho \approx \rho' \in R_2.

By the biconditional of R_1: from \rho \approx \rho' \in R_1 we obtain \ensuremath{\mathcal{D}} :: \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T with \rho(0) \approx \rho'(0) \in R_H(\ensuremath{\mathcal{D}}), where \ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket S \rrbracket(\rho'[\Uparrow])} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathcal{D}}).

By the IH on the tail: from \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T we get \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_T' (where R_T' is the tail PER of R_2; call this evidence \ensuremath{\mathcal{D}}').

By the subtyping premise: \ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])} \mathrel{<:_i} \ensuremath{\llbracket S' \rrbracket(\rho'[\Uparrow])}. By the head premise of R_2 at \ensuremath{\mathcal{D}}': \ensuremath{\llbracket S' \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket S' \rrbracket(\rho'[\Uparrow])} \in \mathcal{U}_i \searrow R_H'(\ensuremath{\mathcal{D}}').

\begin{aligned} &\rho(0) \approx \rho'(0) \in R_H(\ensuremath{\mathcal{D}}) && \text{(from above)} \\ &\rho(0) \approx \rho'(0) \in R_H'(\ensuremath{\mathcal{D}}') && \text{(by \Cref{lem:subty-respects}: $\ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])} \mathrel{<:_i} \ensuremath{\llbracket S' \rrbracket(\rho[\Uparrow])}$)} \end{aligned}

Hence \rho \approx \rho' \in R_2 by the biconditional of R_2 (with witness \ensuremath{\mathcal{D}}' and head \rho(0) \approx \rho'(0) \in R_H'(\ensuremath{\mathcal{D}}')), and thus \rho \approx \rho' \in R'.

Lemma

Lemma 6.25 (Initial environment is in context PER)

KQTZ

If \Gamma \approx \Gamma \searrow R, then {\uparrow}^\Gamma \approx {\uparrow}^\Gamma \in R.

Proof of Lemma 6.25

By induction on the derivation of \Gamma \approx \Gamma \searrow R.

Case Ctx-Emp: R = \top, so any two environments are related.

Case Ctx-Ext: By the biconditional, we must exhibit \ensuremath{\mathcal{D}} :: {\uparrow}^\Gamma[\Uparrow] \approx {\uparrow}^\Gamma[\Uparrow] \in R_T with ({\uparrow}^\Gamma)(0) \approx ({\uparrow}^\Gamma)(0) \in R_H(\ensuremath{\mathcal{D}}).

\begin{aligned} &{\uparrow}^\Gamma[\Uparrow] = {\uparrow}^\Delta && \text{(where $\Gamma = \Delta, x : S$)} \\ &{\uparrow}^\Delta \approx {\uparrow}^\Delta \in R_T && \text{(by IH on tail; this gives us $\ensuremath{\mathcal{D}}$)} \\ &\text{Let } A = \ensuremath{\llbracket S \rrbracket({\uparrow}^\Delta)} \\ &A \approx A \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathcal{D}}) && \text{(by the head premise at $\ensuremath{\mathcal{D}}$)} \\ &({\uparrow}^\Gamma)(0) = {\uparrow}^A(\ell_{|\Delta|}) \\ &\ell_{|\Delta|} \approx \ell_{|\Delta|} \in \textsf{Ne} && \text{(a level variable reads back to itself)} \\ &{\uparrow}^A(\ell_{|\Delta|}) \approx {\uparrow}^A(\ell_{|\Delta|}) \in R_H(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:ne-in-R})} \end{aligned}
Lemma

Lemma 6.27 (Identity is a Semantic Weakening)

ZSX1

If \Gamma \approx \Gamma \searrow R, then \singlejudge[\ensuremath{\textsf{id}}]{\vDash_w}{\Gamma : .

Proof of Lemma 6.27

Immediate because \ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)} = \rho for weakening.

Lemma

Lemma 6.28 (Shift is a Semantic Weakening)

A1Y2

If \Gamma, x : T \approx \Gamma, x : T \searrow R, then \semweak[\Gamma, x : T] \Uparrow \Gamma.

Proof of Lemma 6.28

Immediate by analyzing \Gamma, x : T \approx \Gamma, x : T \searrow R.

Lemma

Lemma 6.29 (Composition of Semantic Weakenings)

TX4J

If \singlejudge[\psi]{\vDash_w}{\Gamma' : and \semweak[\Gamma']{\phi}{\Gamma''}, then \singlejudge[\phi \circ \psi]{\vDash_w}{\Gamma'' : .

Proof of Lemma 6.29

Immediate by the definition of composition.

Definition

Definition 6.30 (Semantic Substitution Equality)

XRRT

The semantic judgment for substitutions asks substitutions to be related under any semantic weakenings:

Mathpar.

R
R_O
’ ’ R’. . ’ R’. {(), (()), ’ ((’)), ’[] (’)} R_O ’

Definition

Definition 6.31 (Semantic Judgment for Terms)

I00J

The semantic judgment for terms requires stability under semantic substitutions:

Mathpar.

R
i
0.95\forall \Gamma' \approx \Gamma' \searrow R'. \forall \semtyeq[\Gamma'] \sigma{\sigma'}\Gamma. \forall \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R'.
\{\ensuremath{\llbracket T[\sigma] \rrbracket(\rho)}, \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}, \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}, \ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T
\wedge \{\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)}, \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}, \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}, \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')}\} \subseteq R_T tt’T

Definition

Definition 6.32 (Semantic Judgment for Subtyping)

B7N0

The semantic subtyping judgment holds when the evaluations of the two types commute with their respective substitutions and are related by semantic subtyping:

Mathpar.

R
i

0.90\forall \Gamma' \approx \Gamma' \searrow R'. \forall \semtyeq[\Gamma'] \sigma{\sigma'}\Gamma. \forall \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R'.
\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in \mathcal{U}_i
\wedge\; \ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in \mathcal{U}_i
\wedge\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} S T

Definition

Definition 6.33 (Semantic Context Well-Formedness)

83KG

The judgment \ensuremath{\vDash \Gamma} is defined inductively:

Mathpar.

(, x : S) (, x : S) R
SSTy_i , x : S

Used by Proof, Proof, Proof
Lemma

Lemma 6.34 (Semantic context yields context PER)

C6KU

If \ensuremath{\vDash \Gamma}, then \Gamma \approx \Gamma \searrow R for some R.

Proof of Lemma 6.34

By induction on \ensuremath{\vDash \Gamma}. The empty case follows from Ctx-Emp, giving \cdot \approx \cdot \searrow \top. The extension case directly returns the packaged (\Gamma, x : S) \approx (\Gamma, x : S) \searrow R.

Lemma

Lemma 6.35 (Semantic weakening gives semantic substitution)

AKOV

If \semweak[\Delta]{\psi}{\Gamma}, then \semtyeq[\Delta]{\psi}{\psi}{\Gamma}.

Proof of Lemma 6.35

We must show: for all \Gamma' \approx \Gamma' \searrow R', all \semweak[\Gamma']{\phi}{\Delta}, and all \rho \approx \rho' \in R',

\{\ensuremath{\llbracket \psi[\phi] \rrbracket(\rho)},\; \ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})},\; \ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})},\; \ensuremath{\llbracket \psi[\phi] \rrbracket(\rho')}\} \subseteq R_\Gamma.

Recall from ? that the evaluation of a weakening \psi in an environment \rho is defined by \ensuremath{\llbracket \psi \rrbracket(\rho)}(n) = \rho(\psi(n)), i.e., it reindexes the environment according to \psi. We compute each of the four values:

\begin{aligned} &\ensuremath{\llbracket \psi[\phi] \rrbracket(\rho)} = \ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho)} && \text{(since $\psi[\phi] = \psi \circ \phi$ for weakenings)} \\ &\quad = \lambda n.\, \rho((\psi \circ \phi)(n)) = \lambda n.\, \rho(\phi(\psi(n))) && \text{(by definition of weakening evaluation)} \\[4pt] &\ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} = \lambda n.\, (\ensuremath{\llbracket \phi \rrbracket(\rho)})(\psi(n)) && \text{(by definition of weakening evaluation)} \\ &\quad = \lambda n.\, \rho(\phi(\psi(n))) && \text{(since $\ensuremath{\llbracket \phi \rrbracket(\rho)}(k) = \rho(\phi(k))$)} \end{aligned}

Hence \ensuremath{\llbracket \psi[\phi] \rrbracket(\rho)} = \ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} — the commutation is definitional for weakenings. Similarly \ensuremath{\llbracket \psi[\phi] \rrbracket(\rho')} = \ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})}. So all four values collapse to two:

\ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho)} \quad\text{and}\quad \ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho')}.

From \semweak[\Gamma']{\phi}{\Delta} and \rho \approx \rho' \in R', we have \ensuremath{\llbracket \phi \rrbracket(\rho)} \approx \ensuremath{\llbracket \phi \rrbracket(\rho')} \in R_\Delta. From \semweak[\Delta]{\psi}{\Gamma} and \ensuremath{\llbracket \phi \rrbracket(\rho)} \approx \ensuremath{\llbracket \phi \rrbracket(\rho')} \in R_\Delta, we have

\begin{aligned} &\ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})} \in R_\Gamma && \text{(by the definition of $\semweak[\Delta]{\psi}{\Gamma}$)} \end{aligned}

Since all four values equal \ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho)} or \ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho')} (which equal the inner two by the above computation), the four-way relatedness follows by symmetry (?) and transitivity (?) of R_\Gamma.

Lemma

Lemma 6.36 (Identity is semantic)

NCQA

If \Gamma \approx \Gamma \searrow R, then \semtyeq[\Gamma]{\ensuremath{\textsf{id}}}{\ensuremath{\textsf{id}}}{\Gamma}.

Proof of Lemma 6.36

By ? applied to \semweak[\Gamma]{\ensuremath{\textsf{id}}}{\Gamma} (which holds by ?).

Lemma

Lemma 6.37 (Shift is semantic)

7KIK

If \Gamma \approx \Gamma \searrow R_\Gamma and (\Gamma, x:S) \approx (\Gamma, x:S) \searrow R, then \semtyeq[\Gamma, x:S]{\Uparrow}{\Uparrow}{\Gamma}.

Proof of Lemma 6.37

By ? applied to \semweak[\Gamma, x:S]{\Uparrow}{\Gamma} (which holds by ?).

Lemma

Lemma 6.38 (Identity Instantiation of Semantic Typing)

3Z9W

If \semtyeq[\Gamma]{t}{t'}{T}, then for all \rho \approx \rho' \in R_\Gamma (where \Gamma \approx \Gamma \searrow R_\Gamma), there exists R such that:

\ensuremath{\llbracket T \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket(\rho')} \in \mathcal{U}_i \searrow R \;\wedge\; \ensuremath{\llbracket t \rrbracket(\rho)} \approx \ensuremath{\llbracket t' \rrbracket(\rho')} \in R
Proof of Lemma 6.38

Instantiate \semtyeq[\Gamma]{t}{t'}{T} at \Gamma (with R_\Gamma), the identity semantic substitution \semtyeq[\Gamma]{\ensuremath{\textsf{id}}}{\ensuremath{\textsf{id}}}{\Gamma} (?), and \rho \approx \rho' \in R_\Gamma. Since T[\ensuremath{\textsf{id}}] = T, t[\ensuremath{\textsf{id}}] = t, t'[\ensuremath{\textsf{id}}] = t', and \ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)} = \rho, the four-value patterns for the type and term collapse to \ensuremath{\llbracket T \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket(\rho')} \in \mathcal{U}_i \searrow R and \ensuremath{\llbracket t \rrbracket(\rho)} \approx \ensuremath{\llbracket t' \rrbracket(\rho')} \in R, respectively.

Lemma

Lemma 6.39 (Precomposition with weakening)

YVVR

If \semtyeq[\Delta]{\sigma}{\sigma'}{\Delta'} and \semweak[\Gamma]{\psi}{\Delta}, then \semtyeq[\Gamma]{\sigma[\psi]}{\sigma'[\psi]}{\Delta'}.

Proof of Lemma 6.39

Let \Gamma' \approx \Gamma' \searrow R' be given, with \semweak[\Gamma']{\phi}{\Gamma} and \rho \approx \rho' \in R'. We must show:

\{\ensuremath{\llbracket (\sigma[\psi])[\phi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})},\; \ensuremath{\llbracket (\sigma'[\psi])[\phi] \rrbracket(\rho')}\} \subseteq R_{\Delta'}.

We make two instantiations of the hypothesis \semtyeq[\Delta]{\sigma}{\sigma'}{\Delta'}.

First instantiation: at \Gamma', the composed semantic weakening \semweak[\Gamma']{\psi \circ \phi}{\Delta} (by ? from \semweak[\Gamma']{\phi}{\Gamma} and \semweak[\Gamma]{\psi}{\Delta}), and \rho \approx \rho' \in R':

\{\ensuremath{\llbracket \sigma[\psi \circ \phi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma'[\psi \circ \phi] \rrbracket(\rho')}\} \subseteq R_{\Delta'}.

Since (\sigma[\psi])[\phi] = \sigma[\psi \circ \phi] (by ?), the outer values are \ensuremath{\llbracket (\sigma[\psi])[\phi] \rrbracket(\rho)} and \ensuremath{\llbracket (\sigma'[\psi])[\phi] \rrbracket(\rho')}.

Second instantiation: at \Gamma with R_\Gamma, the semantic weakening \semweak[\Gamma]{\psi}{\Delta} (given), and \ensuremath{\llbracket \phi \rrbracket(\rho)} \approx \ensuremath{\llbracket \phi \rrbracket(\rho')} \in R_\Gamma (from \semweak[\Gamma']{\phi}{\Gamma} applied to \rho \approx \rho' \in R'):

\{\ensuremath{\llbracket \sigma[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})})},\; \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})}\} \subseteq R_{\Delta'}.

The outer values here are \ensuremath{\llbracket \sigma[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} and \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})} — exactly the inner values of our goal.

Now observe: since \ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho)} = \ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} (weakenings commute with evaluation definitionally), the inner values of both instantiations coincide: \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \circ \phi \rrbracket(\rho)})} = \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})})}.

From the first instantiation: \ensuremath{\llbracket (\sigma[\psi])[\phi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})})} \in R_{\Delta'}. From the second instantiation: \ensuremath{\llbracket \sigma[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})})} \in R_{\Delta'}. By symmetry and transitivity of R_{\Delta'}, all four goal values are related:

\begin{aligned} &\ensuremath{\llbracket (\sigma[\psi])[\phi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} \in R_{\Delta'} && \text{(by transitivity through the shared inner value)} \\ &\ensuremath{\llbracket \sigma'[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})} \approx \ensuremath{\llbracket (\sigma'[\psi])[\phi] \rrbracket(\rho')} \in R_{\Delta'} && \text{(similarly for the primed side)} \\ &\ensuremath{\llbracket \sigma[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})} \in R_{\Delta'} && \text{(from the second instantiation, outer-left $\approx$ outer-right)} \end{aligned}

Hence \{\ensuremath{\llbracket (\sigma[\psi])[\phi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})},\; \ensuremath{\llbracket (\sigma'[\psi])[\phi] \rrbracket(\rho')}\} \subseteq R_{\Delta'}.

Lemma

Lemma 6.40 (Precomposition of substitutions by \Uparrow)

IWMW

If \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta, x:T}, then \semtyeq[\Gamma]{\Uparrow \circ \sigma}{\Uparrow \circ \sigma'}{\Delta}.

Proof of Lemma 6.40

Let \Gamma' \approx \Gamma' \searrow R', \semweak[\Gamma']{\phi}{\Gamma}, and \rho \approx \rho' \in R' be given. We must show

\{\ensuremath{\llbracket (\Uparrow \circ \sigma)[\phi] \rrbracket(\rho)},\; \ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})},\; \ensuremath{\llbracket \Uparrow \circ \sigma' \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})},\; \ensuremath{\llbracket (\Uparrow \circ \sigma')[\phi] \rrbracket(\rho')}\} \subseteq R_\Delta.

By ? (2) and associativity (?): (\Uparrow \circ \sigma)[\phi] = (\Uparrow \circ \sigma) \circ \phi = \Uparrow \circ (\sigma \circ \phi) = \Uparrow \circ \sigma[\phi]. For any substitution \tau and any environment \rho_0, the pointwise definitions give

\begin{aligned} \ensuremath{\llbracket \Uparrow \circ \tau \rrbracket(\rho_0)}(y) &= \ensuremath{\llbracket (\Uparrow \circ \tau)(y) \rrbracket(\rho_0)} && \text{(pointwise definition of substitution evaluation)} \\ &= \ensuremath{\llbracket \Uparrow(y)[\tau] \rrbracket(\rho_0)} && \text{(definition of composition)} \\ &= \ensuremath{\llbracket \tau(y+1) \rrbracket(\rho_0)} && \text{(since $\Uparrow(y) = y+1$ is a variable)} \\ &= \ensuremath{\llbracket \tau \rrbracket(\rho_0)}(y+1) && \text{(pointwise definition again)} \\ &= (\ensuremath{\llbracket \tau \rrbracket(\rho_0)})[\Uparrow](y) && \text{(definition of $\rho[\Uparrow]$)} \end{aligned}

Hence \ensuremath{\llbracket \Uparrow \circ \tau \rrbracket(\rho_0)} = (\ensuremath{\llbracket \tau \rrbracket(\rho_0)})[\Uparrow] definitionally. Specialising:

\begin{aligned} \ensuremath{\llbracket (\Uparrow \circ \sigma)[\phi] \rrbracket(\rho)} &= \ensuremath{\llbracket \Uparrow \circ \sigma[\phi] \rrbracket(\rho)} = (\ensuremath{\llbracket \sigma[\phi] \rrbracket(\rho)})[\Uparrow], \\ \ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})} &= (\ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})})[\Uparrow], \end{aligned}

and analogously for the primed pair. So it suffices to show

\{(\ensuremath{\llbracket \sigma[\phi] \rrbracket(\rho)})[\Uparrow],\; (\ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})})[\Uparrow],\; (\ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})})[\Uparrow],\; (\ensuremath{\llbracket \sigma'[\phi] \rrbracket(\rho')})[\Uparrow]\} \subseteq R_\Delta.

Apply \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta, x:T} at \Gamma', \phi, and \rho \approx \rho' \in R': writing R_{\Delta,x:T} for the context PER of \Delta, x:T,

\{\ensuremath{\llbracket \sigma[\phi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \phi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma'[\phi] \rrbracket(\rho')}\} \subseteq R_{\Delta,x:T}.

By the biconditional of R_{\Delta,x:T} (from Ctx-Ext), every pair \rho_0 \approx \rho_0' \in R_{\Delta,x:T} satisfies \rho_0[\Uparrow] \approx \rho_0'[\Uparrow] \in R_\Delta. Applying this pairwise to the four R_{\Delta,x:T}-related values above yields the desired R_\Delta-relatedness of the four shifted values.

Lemma

Lemma 6.41 (Symmetry of semantic substitutions)

TS75

If \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta}, then \semtyeq[\Gamma]{\sigma'}{\sigma}{\Delta}.

Proof of Lemma 6.41

Let \Gamma' \approx \Gamma' \searrow R', \semweak[\Gamma']{\psi}{\Gamma}, and \rho \approx \rho' \in R' be given. We must show:

\{\ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho')}\} \subseteq R_\Delta.

From the hypothesis \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} applied at \Gamma', \psi, and \rho' \approx \rho \in R' (using symmetry of R', ?):

\{\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho')},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho)}\} \subseteq R_\Delta.

This gives us \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho')} \approx \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \in R_\Delta and \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho)} \in R_\Delta.

By symmetry of R_\Delta (?), we can reverse pairs. The four values \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho)}, \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}, \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}, \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho')} are then pairwise related in R_\Delta (by symmetry and transitivity), yielding the desired four-way relatedness.

Lemma

Lemma 6.42 (Transitivity of semantic substitutions)

D9Q6

If \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} and \semtyeq[\Gamma]{\sigma'}{\sigma''}{\Delta}, then \semtyeq[\Gamma]{\sigma}{\sigma''}{\Delta}.

Proof of Lemma 6.42

Let \Gamma' \approx \Gamma' \searrow R', \semweak[\Gamma']{\psi}{\Gamma}, and \rho \approx \rho' \in R' be given. From the first hypothesis:

\{\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')}\} \subseteq R_\Delta.

In particular, \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \in R_\Delta.

From the second hypothesis applied at the same \Gamma', \psi, and \rho \approx \rho':

\{\ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma'' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma''[\psi] \rrbracket(\rho')}\} \subseteq R_\Delta.

In particular, \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \sigma'' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \in R_\Delta.

By transitivity of R_\Delta (?), using \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \in R_\Delta and (after mediating through symmetry) \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \approx \ensuremath{\llbracket \sigma'' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \in R_\Delta, we get \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \approx \ensuremath{\llbracket \sigma'' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \in R_\Delta.

For the outer pair: by similar reasoning on the weakened substitutions, \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \in R_\Delta (from the first hypothesis) and \ensuremath{\llbracket \sigma'' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} \approx \ensuremath{\llbracket \sigma''[\psi] \rrbracket(\rho')} \in R_\Delta (from the second hypothesis). By transitivity, all four values are related in R_\Delta:

\{\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma'' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma''[\psi] \rrbracket(\rho')}\} \subseteq R_\Delta. \qedhere
Lemma

Lemma 6.43 (q Preserves Semantic Weakening)

WFLU

If \semweak[\Gamma]{\psi}{\Delta} and \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, then \semweak[\Gamma, x : S[\psi]]{q(\psi)}{\Delta, x : S}.

Proof of Lemma 6.43

From \semweak[\Gamma]{\psi}{\Delta} we have \Gamma \approx \Gamma \searrow R_\Gamma and \Delta \approx \Delta \searrow R_\Delta. By ? on \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}: for every \ensuremath{\mathcal{D}}_\Delta :: \rho_0 \approx \rho_0' \in R_\Delta, there is R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta) with \ensuremath{\llbracket S \rrbracket(\rho_0)} \approx \ensuremath{\llbracket S \rrbracket(\rho_0')} \in \mathcal{U}_i \searrow R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta). By Ctx-Ext, this gives (\Delta, x:S) \approx (\Delta, x:S) \searrow R_{\Delta,S}.

By ?, \psi gives \semtyeq[\Gamma]{\psi}{\psi}{\Delta}. Applying \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma with this semantic substitution and any \rho_0 \approx \rho_0' \in R_\Gamma, the type part gives in particular \ensuremath{\llbracket S[\psi] \rrbracket(\rho_0)} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho_0)})} \in \mathcal{U}_i \searrow R_H^\Gamma (commutation). By Ctx-Ext, this yields (\Gamma, x:S[\psi]) \approx (\Gamma, x:S[\psi]) \searrow R_{\Gamma,S[\psi]}.

We must show: for all \rho \approx \rho' \in R_{\Gamma, S[\psi]}, \ensuremath{\llbracket q(\psi) \rrbracket(\rho)} \approx \ensuremath{\llbracket q(\psi) \rrbracket(\rho')} \in R_{\Delta, S}. By the biconditional of R_{\Delta, S}, we must exhibit evidence \ensuremath{\mathcal{D}} :: (\ensuremath{\llbracket q(\psi) \rrbracket(\rho)})[\Uparrow] \approx (\ensuremath{\llbracket q(\psi) \rrbracket(\rho')})[\Uparrow] \in R_\Delta with (\ensuremath{\llbracket q(\psi) \rrbracket(\rho)})(0) \approx (\ensuremath{\llbracket q(\psi) \rrbracket(\rho')})(0) \in R_H^\Delta(\ensuremath{\mathcal{D}}).

Tail.

\begin{aligned} &(\ensuremath{\llbracket q(\psi) \rrbracket(\rho)})[\Uparrow] = \ensuremath{\llbracket \psi \rrbracket(\rho[\Uparrow])} && \text{(since $(\ensuremath{\llbracket q(\psi) \rrbracket(\rho)})[\Uparrow](n) = \rho(q(\psi)(n{+}1)) = \rho(\psi(n){+}1) = \rho[\Uparrow](\psi(n))$)} \end{aligned}

From \rho \approx \rho' \in R_{\Gamma, S[\psi]}, by the biconditional of R_{\Gamma, S[\psi]}: \rho[\Uparrow] \approx \rho'[\Uparrow] \in R_\Gamma. From \semweak[\Gamma]{\psi}{\Delta}: \ensuremath{\llbracket \psi \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket \psi \rrbracket(\rho'[\Uparrow])} \in R_\Delta. This gives evidence \ensuremath{\mathcal{D}}.

Head.

\begin{aligned} &(\ensuremath{\llbracket q(\psi) \rrbracket(\rho)})(0) = \rho(0) && \text{(since $q(\psi)(0) = 0$)} \end{aligned}

From \rho \approx \rho' \in R_{\Gamma, S[\psi]}, by the biconditional of R_{\Gamma, S[\psi]}, there exists evidence \ensuremath{\mathcal{D}}' such that \rho(0) \approx \rho'(0) \in R_H^\Gamma(\ensuremath{\mathcal{D}}'), where R_H^\Gamma comes from \ensuremath{\llbracket S[\psi] \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket S[\psi] \rrbracket(\rho'[\Uparrow])} \in \mathcal{U}_i \searrow R_H^\Gamma(\ensuremath{\mathcal{D}}').

By the head premise of R_{\Delta, S} at \ensuremath{\mathcal{D}} (using \ensuremath{\llbracket \psi \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket \psi \rrbracket(\rho'[\Uparrow])} \in R_\Delta): \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho[\Uparrow])})} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho'[\Uparrow])})} \in \mathcal{U}_i \searrow R_H^\Delta(\ensuremath{\mathcal{D}}).

From the semantic well-formedness \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, instantiated as above (at \Gamma, \semtyeq[\Gamma]{\psi}{\psi}{\Delta}, \rho[\Uparrow] \approx \rho'[\Uparrow]), the type part gives in particular the commutation \ensuremath{\llbracket S[\psi] \rrbracket(\rho[\Uparrow])} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho[\Uparrow])})} \in \mathcal{U}_i. By ?, R_H^\Gamma(\ensuremath{\mathcal{D}}') \Leftrightarrow R_H^\Delta(\ensuremath{\mathcal{D}}) (both have the same left-hand domain type up to \Leftrightarrow). Hence \rho(0) \approx \rho'(0) \in R_H^\Delta(\ensuremath{\mathcal{D}}).

Lemma

Lemma 6.44 (Extension is semantic)

OEOT

If \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta}, \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, and \semtyeq[\Gamma]{t}{t'}{S[\sigma]}, then \semtyeq[\Gamma]{(\sigma, t/x)}{(\sigma', t'/x)}{\Delta, x : S}.

Proof of Lemma 6.44

From \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} we have \Delta \approx \Delta \searrow R_\Delta. By ? on \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}: for every \ensuremath{\mathcal{D}}_\Delta :: \rho_0 \approx \rho_0' \in R_\Delta, there is R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta) with \ensuremath{\llbracket S \rrbracket(\rho_0)} \approx \ensuremath{\llbracket S \rrbracket(\rho_0')} \in \mathcal{U}_i \searrow R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta). By Ctx-Ext, this gives (\Delta, x:S) \approx (\Delta, x:S) \searrow R_{\Delta,x:S}.

Let \Gamma' \approx \Gamma' \searrow R', \semweak[\Gamma']{\psi}{\Gamma}, and \rho \approx \rho' \in R' be given. We must show:

\{\ensuremath{\llbracket (\sigma, t/x)[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket (\sigma, t/x) \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket (\sigma', t'/x) \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket (\sigma', t'/x)[\psi] \rrbracket(\rho')}\} \subseteq R_{\Delta, x:S}.

Each of the four environments has the form (tail, head): the tail is the value of the underlying substitution on \Delta, and the head is the value at position x. By the biconditional of R_{\Delta, x:S}, it suffices to show the tails are pairwise related in R_\Delta (yielding evidence \ensuremath{\mathcal{D}}) and the heads are related in R_H^\Delta(\ensuremath{\mathcal{D}}).

Tails. Since (\sigma, t/x)[\psi] = (\sigma[\psi], t[\psi]/x) (by ?), the four tail environments are:

\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)}, \quad \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}, \quad \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}, \quad \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')}.

From \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} instantiated at \Gamma', \psi, and \rho \approx \rho' \in R':

\{\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')}\} \subseteq R_\Delta.

In particular, the outer pair gives evidence \ensuremath{\mathcal{D}} :: \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')} \in R_\Delta.

Heads. The four heads are:

\ensuremath{\llbracket t[\psi] \rrbracket(\rho)}, \quad \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}, \quad \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}, \quad \ensuremath{\llbracket t'[\psi] \rrbracket(\rho')}.

We must show they are related in R_H^\Delta(\ensuremath{\mathcal{D}}), where R_H^\Delta(\ensuremath{\mathcal{D}}) comes from

\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')})} \in \mathcal{U}_i \searrow R_H^\Delta(\ensuremath{\mathcal{D}}).

From \semtyeq[\Gamma]{t}{t'}{S[\sigma]} at \Gamma', \psi, \rho \approx \rho' \in R', the type part gives some R_t with \ensuremath{\llbracket \rrbracket(\rho)} \approx \ensuremath{\llbracket S[\sigma] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \in \mathcal{U}_i \searrow R_t (and analogous primed versions), and the term part gives

\{\ensuremath{\llbracket t[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket t'[\psi] \rrbracket(\rho')}\} \subseteq R_t.

It remains to show R_t \Leftrightarrow R_H^\Delta(\ensuremath{\mathcal{D}}). Note that \ensuremath{\llbracket \rrbracket(\rho)} = \ensuremath{\llbracket S[\sigma[\psi]] \rrbracket(\rho)} (by ?). By ?, we have \semtyeq[\Gamma']{\sigma[\psi]}{\sigma'[\psi]}{\Delta}. Instantiating \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', this semantic substitution, and \rho \approx \rho' \in R': the type part gives the commutation

\ensuremath{\llbracket S[\sigma[\psi]] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})} \in \mathcal{U}_i.

Hence R_t (from \ensuremath{\llbracket S[\sigma[\psi]] \rrbracket(\rho)}) and R_H^\Delta(\ensuremath{\mathcal{D}}) (from \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})}) have related left-hand types in \mathcal{U}_i; by ?, R_t \Leftrightarrow R_H^\Delta(\ensuremath{\mathcal{D}}). Therefore the four heads are in R_H^\Delta(\ensuremath{\mathcal{D}}).

Lemma

Lemma 6.45 (Extension by precomposed term)

ECBK

If \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} and \semtyeq[\Delta]{t}{t'}{T}, then \semtyeq[\Gamma]{(\sigma, t[\sigma]/x)}{(\sigma', t'[\sigma']/x)}{\Delta, x : T}.

Proof of Lemma 6.45

By ? on \semtyeq[\Delta]{t}{t'}{T}, for any \rho_0 \approx \rho_0' \in R_\Delta: \ensuremath{\llbracket T \rrbracket(\rho_0)} \approx \ensuremath{\llbracket T \rrbracket(\rho_0')} \in \mathcal{U}_i \searrow R_H^\Delta. By Ctx-Ext, this yields (\Delta, x:T) \approx (\Delta, x:T) \searrow R_{\Delta,x:T}.

Let \Gamma' \approx \Gamma' \searrow R', \semweak[\Gamma']{\psi}{\Gamma}, and \rho \approx \rho' \in R' be given. We must show:

\{\ensuremath{\llbracket (\sigma, t[\sigma]/x)[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket (\sigma, t[\sigma]/x) \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket (\sigma', t'[\sigma']/x) \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket (\sigma', t'[\sigma']/x)[\psi] \rrbracket(\rho')}\} \subseteq R_{\Delta, x:T}.

By the biconditional of R_{\Delta, x:T} (with respect to the substitution extensions (\sigma, t[\sigma]/x), etc.), it suffices to exhibit evidence \ensuremath{\mathcal{D}} :: \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')} \in R_\Delta — relating the tails of the outer pair of substitution evaluations — and to show that the four head values \ensuremath{\llbracket t[\sigma][\psi] \rrbracket(\rho)}, \ensuremath{\llbracket t[\sigma] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}, \ensuremath{\llbracket t'[\sigma'] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}, \ensuremath{\llbracket t'[\sigma'][\psi] \rrbracket(\rho')} are pairwise related in the head PER R_H^\Delta(\ensuremath{\mathcal{D}}), which is the PER returned by \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')})} \in \mathcal{U}_i \searrow R_H^\Delta(\ensuremath{\mathcal{D}}).

Tails.

\begin{aligned} &(\sigma, t[\sigma]/x)[\psi] = (\sigma[\psi], t[\sigma][\psi]/x) && \text{(by \Cref{lem:wk-subst-interact})} \end{aligned}

So the four tails are \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)}, \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}, \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}, \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')}. By \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} at \Gamma', \psi, \rho \approx \rho':

\{\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)},\, \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\, \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\, \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')}\} \subseteq R_\Delta,

with witness \ensuremath{\mathcal{D}} :: \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')} \in R_\Delta.

Heads. We instantiate \semtyeq[\Delta]{t}{t'}{T} in two ways and bridge the resulting four-value patterns through a shared inner value.

First instantiation of \semtyeq[\Delta]{t}{t'}{T}: at \Gamma', the semantic substitution \semtyeq[\Gamma']{\sigma[\psi]}{\sigma'[\psi]}{\Delta} (?), and \rho \approx \rho' \in R'. The type part gives some R_t with

\ensuremath{\llbracket T[\sigma[\psi]] \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})} \in \mathcal{U}_i \searrow R_t,

and the term part gives

\{\ensuremath{\llbracket t[\sigma[\psi]] \rrbracket(\rho)},\, \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})},\, \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')})},\, \ensuremath{\llbracket t'[\sigma'[\psi]] \rrbracket(\rho')}\} \subseteq R_t.

By ? (same left type \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})}), R_t \Leftrightarrow R_H^\Delta(\ensuremath{\mathcal{D}}). By ?, t[\sigma][\psi] = t[\sigma[\psi]], so the outer values match: \ensuremath{\llbracket t[\sigma][\psi] \rrbracket(\rho)} = \ensuremath{\llbracket t[\sigma[\psi]] \rrbracket(\rho)} (and similarly for the primed side). Hence the outer pair of goal heads and the inner pair \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)})}, \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma'[\psi] \rrbracket(\rho')})} are all in R_H^\Delta(\ensuremath{\mathcal{D}}).

Second instantiation of \semtyeq[\Delta]{t}{t'}{T}: at \Gamma (with R_\Gamma, from \semweak[\Gamma']{\psi}{\Gamma}), the semantic substitution \sigma \approx \sigma' : \Delta (the hypothesis), and \ensuremath{\llbracket \psi \rrbracket(\rho)} \approx \ensuremath{\llbracket \psi \rrbracket(\rho')} \in R_\Gamma. The type part gives some R_t' with

\ensuremath{\llbracket T[\sigma] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})})} \in \mathcal{U}_i \searrow R_t',

and the term part gives

\{\ensuremath{\llbracket t[\sigma] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\, \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})})},\, \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})})},\, \ensuremath{\llbracket t'[\sigma'] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}\} \subseteq R_t'.

Since \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)} and \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} are both in R_\Delta (related by the tails part), by ? applied to the two type evaluations (the head premise of R_{\Delta, x:T} at the appropriate evidence), R_t' \Leftrightarrow R_H^\Delta(\ensuremath{\mathcal{D}}). This places the inner pair \ensuremath{\llbracket t[\sigma] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}, \ensuremath{\llbracket t'[\sigma'] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})} of goal heads in R_H^\Delta(\ensuremath{\mathcal{D}}).

Bridging the two instantiations. The shared inner value \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})})} appears in both R_t (as the inner-left of the first instantiation, after using \ensuremath{\llbracket \sigma[\psi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} \in R_\Delta and right irrelevance) and R_t' (as the inner-left of the second instantiation). Both R_t and R_t' are equivalent to R_H^\Delta(\ensuremath{\mathcal{D}}), so by transitivity of R_H^\Delta(\ensuremath{\mathcal{D}}) through this shared value, all four goal heads are related.

Lemma

Lemma 6.46 (Double extension by precomposed terms)

7V91

If \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta}, \semtyeq[\Delta]{t}{t'}{T}, and \semtyeq[\Delta, x : T]{s}{s'}{S}, then

\semtyeq[\Gamma] {(\sigma,\, t[\sigma]/x,\, s[\sigma,\, t[\sigma]/x]/y)} {(\sigma',\, t'[\sigma']/x,\, s'[\sigma',\, t'[\sigma']/x]/y)} {\Delta, x : T, y : S}.
Proof of Lemma 6.46

By ? on \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} and \semtyeq[\Delta]{t}{t'}{T}:

\semtyeq[\Gamma]{(\sigma, t[\sigma]/x)}{(\sigma', t'[\sigma']/x)}{\Delta, x : T}.

Apply ? again with this semantic substitution and \semtyeq[\Delta, x : T]{s}{s'}{S}:

\semtyeq[\Gamma] {(\sigma, t[\sigma]/x,\, s[\sigma, t[\sigma]/x]/y)} {(\sigma', t'[\sigma']/x,\, s'[\sigma', t'[\sigma']/x]/y)} {\Delta, x : T, y : S}.
Lemma

Lemma 6.47 (Lifting is semantic)

O9WP

If \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} and \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, then \semtyeq[\Gamma, x:S[\sigma]]{q(\sigma)}{q(\sigma')}{\Delta, x:S}.

Proof of Lemma 6.47

We first establish the context PER for \Gamma, x:S[\sigma]. From \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} we have \Gamma \approx \Gamma \searrow R_\Gamma. Apply \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma (with R_\Gamma), the semantic substitution \semtyeq[\Gamma]{\sigma}{\sigma}{\Delta} (the reflexive instance, obtained from \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} via symmetry and transitivity, ?, ?), and any \ensuremath{\mathcal{D}}_\Gamma :: \rho_0 \approx \rho_0' \in R_\Gamma: the type part gives, in particular, \ensuremath{\llbracket S[\sigma] \rrbracket(\rho_0)} \approx \ensuremath{\llbracket S[\sigma] \rrbracket(\rho_0')} \in \mathcal{U}_i \searrow R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) for some head family R_H^\Gamma. By Ctx-Ext, this yields (\Gamma, x:S[\sigma]) \approx (\Gamma, x:S[\sigma]) \searrow R_{\Gamma, x:S[\sigma]} with the biconditional

\begin{aligned} &\rho_1 \approx \rho_1' \in R_{\Gamma, x:S[\sigma]} \;\leftrightarrow\; (\ensuremath{\mathcal{D}}_\Gamma :: \rho_1[\Uparrow] \approx \rho_1'[\Uparrow] \in R_\Gamma \;\wedge\; \rho_1(0) \approx \rho_1'(0) \in R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma)). \end{aligned}

By an analogous construction (or directly by ? on \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} followed by Ctx-Ext), we also obtain (\Delta, x:S) \approx (\Delta, x:S) \searrow R_{\Delta, x:S} with head family R_H^\Delta, where for every \ensuremath{\mathcal{D}}_\Delta :: \rho_0 \approx \rho_0' \in R_\Delta, R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta) is determined by \ensuremath{\llbracket S \rrbracket(\rho_0)} \approx \ensuremath{\llbracket S \rrbracket(\rho_0')} \in \mathcal{U}_i \searrow R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta), with biconditional

\begin{aligned} &\rho_1 \approx \rho_1' \in R_{\Delta, x:S} \;\leftrightarrow\; (\ensuremath{\mathcal{D}}_\Delta :: \rho_1[\Uparrow] \approx \rho_1'[\Uparrow] \in R_\Delta \;\wedge\; \rho_1(0) \approx \rho_1'(0) \in R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta)). \end{aligned}

Here R_\Delta comes from the premise \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta} (which carries \Delta \approx \Delta \searrow R_\Delta).

We now show \semtyeq[\Gamma, x:S[\sigma]]{q(\sigma)}{q(\sigma')}{\Delta, x:S} by unfolding the conclusion. Recall q(\sigma) = (\sigma[\Uparrow], x_0/x). By ? (2), (\sigma[\Uparrow], x_0/x)[\psi] = (\sigma[\Uparrow][\psi], x_0[\psi]/x) = (\sigma[\Uparrow \circ \psi], \psi(0)/x) for any weakening \psi (using \sigma[\Uparrow][\psi] = \sigma[\Uparrow \circ \psi] by associativity of post-composition with weakenings, and x_0[\psi] = \psi(0)).

We must show: for every context \Gamma' with \Gamma' \approx \Gamma' \searrow R', every \semweak[\Gamma']{\psi}{\Gamma, x:S[\sigma]}, and every \rho \approx \rho' \in R', the four values

\ensuremath{\llbracket q(\sigma)[\psi] \rrbracket(\rho)},\; \ensuremath{\llbracket q(\sigma) \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket q(\sigma') \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket q(\sigma')[\psi] \rrbracket(\rho')}

lie in R_{\Delta, x:S}.

By definition of \semweak[\Gamma']{\psi}{\Gamma, x:S[\sigma]}, \ensuremath{\llbracket \psi \rrbracket(\rho)} \approx \ensuremath{\llbracket \psi \rrbracket(\rho')} \in R_{\Gamma, x:S[\sigma]}. By the biconditional of R_{\Gamma, x:S[\sigma]} established above, this gives

\begin{aligned} &\ensuremath{\mathcal{D}}_\Gamma :: (\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow] \approx (\ensuremath{\llbracket \psi \rrbracket(\rho')})[\Uparrow] \in R_\Gamma && \text{(tail)} \\ &(\ensuremath{\llbracket \psi \rrbracket(\rho)})(0) \approx (\ensuremath{\llbracket \psi \rrbracket(\rho')})(0) \in R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) && \text{(head)} \end{aligned}

By ?, \semweak[\Gamma, x:S[\sigma]]{\Uparrow}{\Gamma}. By ?, \semweak[\Gamma']{\Uparrow \circ \psi}{\Gamma}, where \Uparrow \circ \psi is the composition of weakenings.

We must show the goal four values lie in R_{\Delta, x:S}. By the biconditional of R_{\Delta, x:S} recalled above, this requires evidence \ensuremath{\mathcal{D}}_\Delta relating the four tails in R_\Delta and the four heads in R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta).

Tails. We compute the four tails using the pointwise identities above. For an extended substitution (\tau, t/x), the evaluation \ensuremath{\llbracket (\tau, t/x) \rrbracket(\rho_0)} is the environment with head \ensuremath{\llbracket t \rrbracket(\rho_0)} at index 0 and tail \ensuremath{\llbracket \tau \rrbracket(\rho_0)} at indices 1, 2, \ldots; hence (\ensuremath{\llbracket (\tau, t/x) \rrbracket(\rho_0)})[\Uparrow] = \ensuremath{\llbracket \tau \rrbracket(\rho_0)}. Applied to the four goal values:

\begin{aligned} &(\ensuremath{\llbracket q(\sigma)[\psi] \rrbracket(\rho)})[\Uparrow] = \ensuremath{\llbracket \sigma[\Uparrow \circ \psi] \rrbracket(\rho)}, \\ &(\ensuremath{\llbracket q(\sigma) \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})})[\Uparrow] = \ensuremath{\llbracket \sigma[\Uparrow] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}, \\ &(\ensuremath{\llbracket q(\sigma') \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})})[\Uparrow] = \ensuremath{\llbracket \sigma'[\Uparrow] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}, \\ &(\ensuremath{\llbracket q(\sigma')[\psi] \rrbracket(\rho')})[\Uparrow] = \ensuremath{\llbracket \sigma'[\Uparrow \circ \psi] \rrbracket(\rho')}. \end{aligned}

First instantiation of \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta}: at \Gamma', the semantic weakening \semweak[\Gamma']{\Uparrow \circ \psi}{\Gamma}, and \rho \approx \rho' \in R':

\{\ensuremath{\llbracket \sigma[\Uparrow \circ \psi] \rrbracket(\rho)},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \Uparrow \circ \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \Uparrow \circ \psi \rrbracket(\rho')})},\; \ensuremath{\llbracket \sigma'[\Uparrow \circ \psi] \rrbracket(\rho')}\} \subseteq R_\Delta.

Since \Uparrow \circ \psi is a weakening, by the definition of weakening evaluation, \ensuremath{\llbracket \Uparrow \circ \psi \rrbracket(\rho_0)} = (\ensuremath{\llbracket \psi \rrbracket(\rho_0)})[\Uparrow] for any \rho_0 (verified pointwise: \ensuremath{\llbracket \Uparrow \circ \psi \rrbracket(\rho_0)}(n) = \rho_0((\Uparrow \circ \psi)(n)) = \rho_0(\psi(n+1)) = (\ensuremath{\llbracket \psi \rrbracket(\rho_0)})[\Uparrow](n)). So this first instantiation gives the outer two tails of the goal, plus intermediate values \ensuremath{\llbracket \sigma \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow])} and \ensuremath{\llbracket \sigma' \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho')})[\Uparrow])}.

Second instantiation of \semtyeq[\Gamma]{\sigma}{\sigma'}{\Delta}: at \Gamma, x:S[\sigma] (using R_{\Gamma, x:S[\sigma]}), the semantic weakening \semweak[\Gamma, x:S[\sigma]]{\Uparrow}{\Gamma}, and the related environments \ensuremath{\llbracket \psi \rrbracket(\rho)} \approx \ensuremath{\llbracket \psi \rrbracket(\rho')} \in R_{\Gamma, x:S[\sigma]}:

\{\ensuremath{\llbracket \sigma[\Uparrow] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})},\; \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})})},\; \ensuremath{\llbracket \sigma' \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})})},\; \ensuremath{\llbracket \sigma'[\Uparrow] \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho')})}\} \subseteq R_\Delta.

Since \Uparrow is a weakening, \ensuremath{\llbracket \Uparrow \rrbracket(\rho_0)} = \rho_0[\Uparrow] for any \rho_0. So this second instantiation gives the inner two tails of the goal, plus the intermediate values \ensuremath{\llbracket \sigma \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow])} and \ensuremath{\llbracket \sigma' \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho')})[\Uparrow])}.

The intermediate inner-left value \ensuremath{\llbracket \sigma \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow])} appears in both instantiations (since \ensuremath{\llbracket \Uparrow \circ \psi \rrbracket(\rho)} = (\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow] = \ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}). By symmetry (?) and transitivity (?) of R_\Delta through this shared value, all four tails are pairwise related in R_\Delta. In particular, the outer pair gives evidence \ensuremath{\mathcal{D}}_\Delta :: \ensuremath{\llbracket \sigma[\Uparrow \circ \psi] \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma'[\Uparrow \circ \psi] \rrbracket(\rho')} \in R_\Delta.

Heads. The four heads of the goal four values are:

\begin{aligned} &\ensuremath{\llbracket q(\sigma)[\psi] \rrbracket(\rho)}(0) = \ensuremath{\llbracket \psi(0) \rrbracket(\rho)} = \rho(\psi(0)) = (\ensuremath{\llbracket \psi \rrbracket(\rho)})(0), \\ &\ensuremath{\llbracket q(\sigma) \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})}(0) = \ensuremath{\llbracket x_0 \rrbracket(\ensuremath{\llbracket \psi \rrbracket(\rho)})} = (\ensuremath{\llbracket \psi \rrbracket(\rho)})(0), \end{aligned}

and analogously for the primed pair. All four heads collapse to (\ensuremath{\llbracket \psi \rrbracket(\rho)})(0) and (\ensuremath{\llbracket \psi \rrbracket(\rho')})(0). By the head clause of the biconditional of R_{\Gamma, x:S[\sigma]} recalled above, (\ensuremath{\llbracket \psi \rrbracket(\rho)})(0) \approx (\ensuremath{\llbracket \psi \rrbracket(\rho')})(0) \in R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma).

Bridging head PERs. It remains to show R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) \Leftrightarrow R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta), so that the four heads all lie in R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta). Apply \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma (using R_\Gamma, available from \semweak[\Gamma, x:S[\sigma]]{\Uparrow}{\Gamma}), the semantic substitution \semtyeq[\Gamma]{\sigma}{\sigma}{\Delta} (a special case of the hypothesis — formally, applying the hypothesis along with reflexivity by symmetry/transitivity to obtain the reflexive instance), and the related environments (\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow] \approx (\ensuremath{\llbracket \psi \rrbracket(\rho')})[\Uparrow] \in R_\Gamma (from \ensuremath{\mathcal{D}}_\Gamma): the type part gives the commutation

\ensuremath{\llbracket S[\sigma] \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow])} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow])})} \in \mathcal{U}_i.

The right-hand side is \ensuremath{\llbracket S \rrbracket(\rho_0)} where \rho_0 = \ensuremath{\llbracket \sigma \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow])}, which is in R_\Delta via the second instantiation; by definition of R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta), this lands in \mathcal{U}_i \searrow R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta). The left-hand side \ensuremath{\llbracket S[\sigma] \rrbracket((\ensuremath{\llbracket \psi \rrbracket(\rho)})[\Uparrow])} lands in \mathcal{U}_i \searrow R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) by definition of R_H^\Gamma. By ?, R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) \Leftrightarrow R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta). Hence all four heads are in R_H^\Delta(\ensuremath{\mathcal{D}}_\Delta).

Combining tails and heads via the biconditional of R_{\Delta, x:S}, the four goal values are in R_{\Delta, x:S}.

Lemma

Lemma 6.48 (Fundamental — Tm-Sym)

XWMZ

If \semtyeq[\Gamma]{t}{t'}{T}, then \semtyeq[\Gamma]{t'}{t}{T}.

Proof of Lemma 6.48

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R'. From the hypothesis:

\{\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')}\} \subseteq R_T.

We need:

\{\ensuremath{\llbracket t'[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')}\} \subseteq R_T.

Apply the hypothesis at \sigma' \approx \sigma (using ?) and \rho' \approx \rho (using symmetry of R'):

\{\ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t'[\sigma] \rrbracket(\rho)}\} \subseteq R_T.

By symmetry of R_T (?), we can reverse the order:

\{\ensuremath{\llbracket t'[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')}\} \subseteq R_T. \qedhere
Lemma

Lemma 6.49 (Fundamental — Tm-Trans)

M8DG

If \semtyeq[\Gamma]{t}{t'}{T} and \semtyeq[\Gamma]{t'}{t''}{T}, then \semtyeq[\Gamma]{t}{t''}{T}.

Proof of Lemma 6.49

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R'.

Apply the first hypothesis at \sigma \approx \sigma', \rho \approx \rho':

\begin{aligned} &\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')} \in R_T && \text{(four-value pattern, outer-LHS vs outer-RHS)} \end{aligned}

Apply the second hypothesis at \sigma' \approx \sigma' (reflexive, by ?, ?) and \rho' \approx \rho' (reflexive, by symmetry of R'):

\begin{aligned} &\ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket t''[\sigma'] \rrbracket(\rho')} \in R_T && \text{(four-value pattern, outer-LHS vs outer-RHS)} \end{aligned}

By transitivity of R_T (?):

\begin{aligned} &\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket t''[\sigma'] \rrbracket(\rho')} \in R_T && \text{(transitivity)} \end{aligned}

This is the outer-LHS vs outer-RHS of the goal’s four-value pattern. The other three pairs follow by combining the first hypothesis (giving \ensuremath{\llbracket t[\sigma] \rrbracket(\rho)}, \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}, \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}, \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')} pairwise in R_T) with the above transitivity step.

Lemma

Lemma 6.51 (Fundamental — Ctx-Ext)

06W8

If \ensuremath{\vDash \Gamma} and \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, then \ensuremath{\vDash \Gamma, x:S}.

Proof of Lemma 6.51

By ? on \ensuremath{\vDash \Gamma}, \Gamma \approx \Gamma \searrow R_T for some R_T. By ? on \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, for any \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R_T, \ensuremath{\llbracket S \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathcal{D}}). By Ctx-Ext of ?, this gives (\Gamma, x:S) \approx (\Gamma, x:S) \searrow R for some R. By Sem-Ctx-Ext of ?, applied to \ensuremath{\vDash \Gamma}, this context PER, and \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, we conclude \ensuremath{\vDash \Gamma, x:S}.

Lemma

Lemma 6.52 (Fundamental — U-Wf)

V86Y

If \ensuremath{\vDash \Gamma}, then \semtyeq[\Gamma]{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{1+i}}}.

Proof of Lemma 6.52

By ?, \Gamma \approx \Gamma \searrow R for some R. Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. We must exhibit R_T such that

\{\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{1+i}}[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{1+i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{1+i}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{1+i}}[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_{2+i} \searrow R_T

and

\{\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}}[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}}[\sigma'] \rrbracket(\rho')}\} \subseteq R_T.

Type part. Since \ensuremath{\texttt{Ty}_{1+i}} is closed (it has no free variables), we compute:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{1+i}}[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{1+i}} \rrbracket(\rho)} && \text{(since $\ensuremath{\texttt{Ty}_{1+i}}[\sigma] = \ensuremath{\texttt{Ty}_{1+i}}$)} \\ &\quad = U_{1+i} && \text{(by evaluation of $\ensuremath{\texttt{Ty}_{1+i}}$)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{1+i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = U_{1+i} && \text{(by evaluation of $\ensuremath{\texttt{Ty}_{1+i}}$)} \end{aligned}

Identical computations apply to the other two type values. Hence all four type values collapse to U_{1+i}, and we need U_{1+i} \approx U_{1+i} \in \mathcal{U}_{2+i} \searrow R_T for some R_T.

\begin{aligned} &U_{1+i} \approx U_{1+i} \in \mathcal{U}_{2+i} \searrow R_T \text{ with } R_T \Leftrightarrow \mathcal{U}_{1+i} && \text{(by \textsc{U-Univ}, since $1{+}i < 2{+}i$)} \end{aligned}

Term part. Since \ensuremath{\texttt{Ty}_{i}} is closed, the same computation gives

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}}[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\rho)} = U_i && \text{(closed term, by evaluation)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = U_i && \text{(by evaluation)} \end{aligned}

and similarly for the primed values, so all four term values collapse to U_i. Since R_T \Leftrightarrow \mathcal{U}_{1+i}, it suffices to show U_i \approx U_i \in \mathcal{U}_{1+i}, i.e. \exists R_0.\; U_i \approx U_i \in \mathcal{U}_{1+i} \searrow R_0.

\begin{aligned} &U_i \approx U_i \in \mathcal{U}_{1+i} \searrow R_0 \text{ with } R_0 \Leftrightarrow \mathcal{U}_i && \text{(by \textsc{U-Univ}, since $i < 1{+}i$)} \end{aligned}

Hence U_i \approx U_i \in R_T, and the four-value pattern follows.

Lemma

Lemma 6.53 (Fundamental — N-Wf)

04JB

If \ensuremath{\vDash \Gamma}, then \semtyeq[\Gamma]{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{0}}}.

Proof of Lemma 6.53

By ?, \Gamma \approx \Gamma \searrow R for some R. Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. We must exhibit R_T such that

\{\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{0}}[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{0}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{0}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{0}}[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_1 \searrow R_T

and

\{\ensuremath{\llbracket \ensuremath{\texttt{Nat}}[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \ensuremath{\texttt{Nat}}[\sigma'] \rrbracket(\rho')}\} \subseteq R_T.

Type part. Since \ensuremath{\texttt{Ty}_{0}} is closed, we compute:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{0}}[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{0}} \rrbracket(\rho)} = U_0 && \text{(closed term, by evaluation)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{0}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = U_0 && \text{(by evaluation)} \end{aligned}

Identical computations give the same value for the other two type values. All four type values collapse to U_0, and we need U_0 \approx U_0 \in \mathcal{U}_1 \searrow R_T.

\begin{aligned} &U_0 \approx U_0 \in \mathcal{U}_1 \searrow R_T \text{ with } R_T \Leftrightarrow \mathcal{U}_0 && \text{(by \textsc{U-Univ}, since $0 < 1$)} \end{aligned}

Term part. Since \ensuremath{\texttt{Nat}} is closed, all four term values collapse to N:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Nat}}[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\rho)} = N && \text{(closed term, by evaluation)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = N && \text{(by evaluation)} \end{aligned}

Since R_T \Leftrightarrow \mathcal{U}_0, it suffices to show N \approx N \in \mathcal{U}_0, i.e. \exists R_0.\; N \approx N \in \mathcal{U}_0 \searrow R_0.

\begin{aligned} &N \approx N \in \mathcal{U}_0 \searrow R_0 \text{ with } R_0 \Leftrightarrow \textsf{Nat} && \text{(by \textsc{U-Nat})} \end{aligned}

Hence N \approx N \in R_T, and the four-value pattern follows.

Lemma

Lemma 6.54 (Fundamental — \Pi-Wf / \Pi-Cong)

RBSO

If \semtyeq[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}}, then \semtyeq[\Gamma]{\Pi(x:S).\,T}{\Pi(x:S').\,T'}{\ensuremath{\texttt{Ty}_{i}}}.

Proof of Lemma 6.54

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. We must show that the four type values

\{\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}}[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}}[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_{1+i} \searrow R_T

for some R_T with R_T \Leftrightarrow \mathcal{U}_i (as in ?), and that the four term values

\{\ensuremath{\llbracket (\Pi(x:S).\,T)[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \Pi(x:S).\,T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \Pi(x:S').\,T' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket (\Pi(x:S').\,T')[\sigma'] \rrbracket(\rho')}\} \subseteq R_T,

i.e. relate in \mathcal{U}_i \searrow R for some R.

Type part. As in ?, the four values of \ensuremath{\texttt{Ty}_{i}} collapse to U_i, and U_i \approx U_i \in \mathcal{U}_{1+i} \searrow R_T with R_T \Leftrightarrow \mathcal{U}_i by U-Univ.

Term part. We compute the four term values:

\begin{aligned} &\ensuremath{\llbracket (\Pi(x:S).\,T)[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \Pi(x:S[\sigma]).\,(T[q(\sigma)]) \rrbracket(\rho)} && \text{(by definition of substitution on $\Pi$)} \\ &\quad= \Pi(\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)},\; T[q(\sigma)],\; \rho) && \text{(by evaluation of $\Pi$)} \\[4pt] &\ensuremath{\llbracket \Pi(x:S).\,T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \\ & \quad = \Pi(\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; T,\; \ensuremath{\llbracket \sigma \rrbracket(\rho)}) && \text{(by evaluation of $\Pi$)} \end{aligned}

Analogous computations apply to the primed pair, yielding

\Pi(\ensuremath{\llbracket S' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}, T', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \quad \text{and} \quad \Pi(\ensuremath{\llbracket S'[\sigma'] \rrbracket(\rho')}, T'[q(\sigma')], \rho').

We construct a U-Pi derivation relating the outermost two values; the inner two follow analogously.

Domain. Apply \semtyeq[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', \sigma \approx \sigma' : \Gamma, and \rho \approx \rho' \in R':

\begin{aligned} &\{\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket S'[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_I && \text{(by hypothesis on $S, S'$)} \end{aligned}

Codomain via lifting. By ? on \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \semtyeq[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}} (using its reflexive instance \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} via ?, ? for the well-formedness premise of ?):

\semtyeq[\Gamma', x:S[\sigma]]{q(\sigma)}{q(\sigma')}{\Gamma, x:S}.

By the first premise of the semantic substitution judgment, this carries (\Gamma', x:S[\sigma]) \approx (\Gamma', x:S[\sigma]) \searrow R_{\Gamma',x:S[\sigma]} and (\Gamma, x:S) \approx (\Gamma, x:S) \searrow R_{\Gamma,x:S}.

Let \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I be given. By the biconditional of R_{\Gamma',x:S[\sigma]} from Ctx-Ext, (\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma',x:S[\sigma]} requires \rho \approx \rho' \in R' (which we have) and a \approx a' \in R_H'(\ensuremath{\mathcal{D}}') where R_H' is the head family for R_{\Gamma',x:S[\sigma]}, governed by \ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S[\sigma] \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_H'(\ensuremath{\mathcal{D}}') (with \ensuremath{\mathcal{D}}' :: \rho \approx \rho' \in R'). By ? on the same left type \ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} that governs both R_I (from the domain step) and R_H'(\ensuremath{\mathcal{D}}'), R_I \Leftrightarrow R_H'(\ensuremath{\mathcal{D}}'). Hence a \approx a' \in R_H'(\ensuremath{\mathcal{D}}'), and (\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma',x:S[\sigma]}.

Apply \semtyeq[\Gamma, x:S]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', x:S[\sigma] (with R_{\Gamma',x:S[\sigma]}), the lifted substitution \semtyeq[\Gamma', x:S[\sigma]]{q(\sigma)}{q(\sigma')}{\Gamma, x:S}, and (\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma',x:S[\sigma]}:

\begin{aligned} &\{\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))})},\\ &\quad \ensuremath{\llbracket T' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})},\; \ensuremath{\llbracket T'[q(\sigma')] \rrbracket((\rho', a'/x))}\} \subseteq \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I) && \text{(by hypothesis on $T, T'$)} \end{aligned}

The outer two values \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))} and \ensuremath{\llbracket T'[q(\sigma')] \rrbracket((\rho', a'/x))} are exactly the codomain expressions of the outer \Pi-values applied to a, a', satisfying the U-Pi codomain premise for the outer pair.

For the inner \Pi-values \Pi(\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}, T, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) (left) and \Pi(\ensuremath{\llbracket S' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}, T', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) (right), the codomain expressions applied to a, a' are \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x))} and \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))}. Applying the lifted-substitution four-value pattern (instantiated at the identity weakening on \Gamma', x:S[\sigma] with (\rho, a/x) \approx (\rho', a'/x)), we obtain in particular

\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x) \in R_{\Gamma, x:S}

(the outer-versus-inner relatedness in that four-value pattern). By ? on \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} applied to this related pair:

\ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))})} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x))} \in \mathcal{U}_i.

Combined with the inner-pair relatedness from the codomain four-value pattern

\ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))})} \approx \ensuremath{\llbracket T' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I)

and the analogous identity

\ensuremath{\llbracket T' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})} \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \in \mathcal{U}_i

on the primed side (by ? on the reflexive \semtyeq[\Gamma, x:S]{T'}{T'}{\ensuremath{\texttt{Ty}_{i}}} obtained from \semtyeq[\Gamma, x:S]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}} by symmetry/transitivity), symmetry and transitivity of \mathcal{U}_i yield

\ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x))} \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I).

This is the U-Pi codomain premise for the inner pair.

Function PER. Define R by the biconditional: f \approx f' \in R \;\leftrightarrow\; (\forall \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I.\; f \cdot a \approx f' \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I)).

Outer pair. By U-Pi applied with domain R_I (from Domain) and codomain R_O(\ensuremath{\mathcal{D}}_I) (from the outer pair of the codomain four-value pattern):

\Pi(\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)},\, T[q(\sigma)],\, \rho) \approx \Pi(\ensuremath{\llbracket S'[\sigma'] \rrbracket(\rho')},\, T'[q(\sigma')],\, \rho') \in \mathcal{U}_i \searrow R.

Inner pair. By U-Pi applied with domain R_I (the inner pair \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \approx \ensuremath{\llbracket S' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in \mathcal{U}_i from Domain also lands in R_I by ?) and codomain R_O(\ensuremath{\mathcal{D}}_I) (just derived for the inner pair):

\Pi(\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\, T,\, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) \approx \Pi(\ensuremath{\llbracket S' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\, T',\, \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \in \mathcal{U}_i \searrow R.

Cross-relations. We have established \Pi-relatedness for the outer pair and for the inner pair, both with element PER R. To get full four-way relatedness, we establish one cross-relation (outer-left versus inner-left) via a third U-Pi derivation; the remaining cross-relations follow by symmetry (?) and transitivity (?) of \mathcal{U}_i.

The third U-Pi derivation uses:

    Domain. From the Domain four-value pattern (in \mathcal{U}_i \searrow R_I), the cross relation

    \ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in \mathcal{U}_i

    holds, with element PER R_I by ?. Codomain. Let \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I. We must show

    \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a'/x))} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I).

    From the codomain four-value pattern, the cross relation

    \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I)

    holds (outer-left versus inner-right). By ? applied at the relatedness \ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a'/x) \in R_{\Gamma, x:S} (which holds by symmetry and transitivity in R_{\Gamma, x:S}, bridging through the inner-pair relatedness of the lifted substitution four-value pattern):

    \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a'/x))} \in \mathcal{U}_i.

    By transitivity of \mathcal{U}_i, \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a'/x))} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I).

By U-Pi with this domain and codomain:

\Pi(\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)},\, T[q(\sigma)],\, \rho) \approx \Pi(\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\, T,\, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) \in \mathcal{U}_i \searrow R.

This is the outer-left \approx inner-left cross-relation. By symmetry and transitivity of \mathcal{U}_i combined with the outer-pair and inner-pair relations, all six pairs among the four \Pi-values are related in \mathcal{U}_i \searrow R.

Hence all four \Pi-values lie pairwise in \mathcal{U}_i \searrow R.

Lemma

Lemma 6.55 (Lookup at fixed instantiation)

J6SH

Suppose \ensuremath{\vDash \Gamma}, \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R'. Then for every x : T \in \Gamma, there exists R_T such that

\begin{aligned} &\{\ensuremath{\llbracket T[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T \\ &\text{and}\quad \{\ensuremath{\llbracket x[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket x \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket x \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket x[\sigma'] \rrbracket(\rho')}\} \subseteq R_T. \end{aligned}
Proof of Lemma 6.55

By induction on the lookup derivation x : T \in \Gamma, with \Gamma', R', \sigma, \sigma', \rho, \rho', and the witness \ensuremath{\mathcal{D}} fixed throughout.

Case

Mathpar.

x_0 : S[] , x_0 : S

Here \Gamma = \Delta, x_0 : S, x = x_0, and T = S[\Uparrow]. Inverting \ensuremath{\vDash \Delta, x_0 : S} via Sem-Ctx-Ext gives \ensuremath{\vDash \Delta}, the packaged context PER (\Delta, x_0 : S) \approx (\Delta, x_0 : S) \searrow R_\Gamma, and \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} for some i. Inverting the context PER via Ctx-Ext gives \Delta \approx \Delta \searrow R_\Delta, a head family R_H with \ensuremath{\llbracket S \rrbracket(\rho_0)} \approx \ensuremath{\llbracket S \rrbracket(\rho_0')} \in \mathcal{U}_i \searrow R_H(\ensuremath{\mathcal{D}}_\Delta) for \ensuremath{\mathcal{D}}_\Delta :: \rho_0 \approx \rho_0' \in R_\Delta, and the biconditional

\begin{aligned} &\rho_1 \approx \rho_1' \in R_\Gamma \;\leftrightarrow\; (\ensuremath{\mathcal{D}}_\Delta :: \rho_1[\Uparrow] \approx \rho_1'[\Uparrow] \in R_\Delta \;\wedge\; \rho_1(0) \approx \rho_1'(0) \in R_H(\ensuremath{\mathcal{D}}_\Delta)). \end{aligned}

Instantiate \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} at \Gamma', \semweak[\Gamma']{\ensuremath{\textsf{id}}}{\Gamma'} (?), and \ensuremath{\mathcal{D}}: using \sigma[\ensuremath{\textsf{id}}] = \sigma and \ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)} = \rho we obtain \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma. By the biconditional of R_\Gamma, there exists \ensuremath{\mathcal{D}}_\Delta with

\begin{aligned} &\ensuremath{\mathcal{D}}_\Delta :: (\ensuremath{\llbracket \sigma \rrbracket(\rho)})[\Uparrow] \approx (\ensuremath{\llbracket \sigma' \rrbracket(\rho')})[\Uparrow] \in R_\Delta && \text{(tail)} \\ &(\ensuremath{\llbracket \sigma \rrbracket(\rho)})(0) \approx (\ensuremath{\llbracket \sigma' \rrbracket(\rho')})(0) \in R_H(\ensuremath{\mathcal{D}}_\Delta) && \text{(head)} \end{aligned}

Set R_T := R_H(\ensuremath{\mathcal{D}}_\Delta).

Type part. We must show \{\ensuremath{\llbracket \rrbracket(\rho)},\; \ensuremath{\llbracket S[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T. We obtain this by two instantiations of \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}, bridged through a shared inner value.

By ?, \Gamma \approx \Gamma \searrow R_\Gamma. By ?, \semweak[\Gamma]{\Uparrow}{\Delta}. By ? on \semweak[\Gamma]{\Uparrow}{\Delta} and \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}: \semtyeq[\Gamma']{\Uparrow \circ \sigma}{\Uparrow \circ \sigma'}{\Delta}.

First instantiation. Apply \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', \semtyeq[\Gamma']{\Uparrow \circ \sigma}{\Uparrow \circ \sigma'}{\Delta}, and \ensuremath{\mathcal{D}}: for some R_1,

\begin{aligned} &\{\ensuremath{\llbracket S[\Uparrow \circ \sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket S[\Uparrow \circ \sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_1. \end{aligned}

By ? (1), = S[\Uparrow \circ \sigma], so the outer values of the first instantiation match the goal’s outer values.

Second instantiation. By ? on \semweak[\Gamma]{\Uparrow}{\Delta}: \semtyeq[\Gamma]{\Uparrow}{\Uparrow}{\Delta}. From \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} at \Gamma', \ensuremath{\textsf{id}}, \ensuremath{\mathcal{D}}: \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma. Apply \semtyeq[\Delta]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma (using R_\Gamma), \semtyeq[\Gamma]{\Uparrow}{\Uparrow}{\Delta}, and \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma: for some R_2,

\begin{aligned} &\{\ensuremath{\llbracket S[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})})},\; \ensuremath{\llbracket S[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}\} \subseteq \mathcal{U}_i \searrow R_2. \end{aligned}

The outer values here are exactly the goal’s inner values.

Bridge. We have already established \ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho_0)} = \ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho_0)})} (from the proof of ?). Hence the inner-left values of both instantiations coincide:

\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho)})} = \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})})}.

Analogously for the primed side. By ?, R_1 \Leftrightarrow R_2; set R_T := R_1. By symmetry and transitivity of \mathcal{U}_i through the shared inner-left value, all four goal values are related in \mathcal{U}_i \searrow R_T.

Term part. Compute:

\begin{aligned} &\ensuremath{\llbracket x_0[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \sigma(x_0) \rrbracket(\rho)} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)})(0) && \text{(by definition of substitution and ev-var)} \\ &\ensuremath{\llbracket x_0 \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)})(0) && \text{(by ev-var)} \end{aligned}

The outer-left and inner-left values coincide as (\ensuremath{\llbracket \sigma \rrbracket(\rho)})(0); the primed pair coincides as (\ensuremath{\llbracket \sigma' \rrbracket(\rho')})(0). By the head clause, (\ensuremath{\llbracket \sigma \rrbracket(\rho)})(0) \approx (\ensuremath{\llbracket \sigma' \rrbracket(\rho')})(0) \in R_T, so all four term values are related in R_T.

Case

Mathpar.

y : S 1+y : S[] , x_0 : U

Here \Gamma = \Delta, x_0 : U, x = 1{+}y, and T = S[\Uparrow]. Inverting \ensuremath{\vDash \Delta, x_0 : U} gives \ensuremath{\vDash \Delta}, the packaged context PER \Gamma \approx \Gamma \searrow R_\Gamma, and \semtyeq[\Delta]{U}{U}{\ensuremath{\texttt{Ty}_{j}}}.

By ?, \semweak[\Gamma]{\Uparrow}{\Delta}. By ? on \semweak[\Gamma]{\Uparrow}{\Delta} and \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}: \semtyeq[\Gamma']{\Uparrow \circ \sigma}{\Uparrow \circ \sigma'}{\Delta}. By ? on \semweak[\Gamma]{\Uparrow}{\Delta}: \semtyeq[\Gamma]{\Uparrow}{\Uparrow}{\Delta}. From \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} at \Gamma', \ensuremath{\textsf{id}}, \ensuremath{\mathcal{D}}: \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma.

We apply the IH on y : S \in \Delta twice, paralleling the two instantiations used in the Base case.

First IH instantiation. Apply the IH to y : S \in \Delta at \Gamma', the semantic substitution \semtyeq[\Gamma']{\Uparrow \circ \sigma}{\Uparrow \circ \sigma'}{\Delta}, and \ensuremath{\mathcal{D}}: for some R_1,

\begin{aligned} &\{\ensuremath{\llbracket S[\Uparrow \circ \sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket S[\Uparrow \circ \sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_1, \\ &\{\ensuremath{\llbracket y[\Uparrow \circ \sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket y \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket y \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket y[\Uparrow \circ \sigma'] \rrbracket(\rho')}\} \subseteq R_1. \end{aligned}

Second IH instantiation. Apply the IH to y : S \in \Delta at \Gamma (using R_\Gamma), the semantic substitution \semtyeq[\Gamma]{\Uparrow}{\Uparrow}{\Delta}, and \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma: for some R_2,

\begin{aligned} &\{\ensuremath{\llbracket S[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})})},\; \ensuremath{\llbracket S[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}\} \subseteq \mathcal{U}_i \searrow R_2, \\ &\{\ensuremath{\llbracket y[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket y \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})})},\; \ensuremath{\llbracket y \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})})},\; \ensuremath{\llbracket y[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}\} \subseteq R_2. \end{aligned}

Match outer values to the goal. By ? (1): = S[\Uparrow \circ \sigma], so the first IH instantiation’s outer-type values are exactly the goal’s outer-type values. The second IH instantiation’s outer-type values \ensuremath{\llbracket S[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} are exactly the goal’s inner-type values.

For the term values:

\begin{aligned} &\ensuremath{\llbracket (1{+}y)[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \sigma(1{+}y) \rrbracket(\rho)} = \ensuremath{\llbracket (\Uparrow \circ \sigma)(y) \rrbracket(\rho)} = \ensuremath{\llbracket y[\Uparrow \circ \sigma] \rrbracket(\rho)} \\ &\ensuremath{\llbracket 1{+}y \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)})(1{+}y) = \ensuremath{\llbracket y[\Uparrow] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \end{aligned}

(using (\Uparrow \circ \sigma)(y) = \sigma(y+1) and \ensuremath{\llbracket y[\Uparrow] \rrbracket(\rho_0)} = \ensuremath{\llbracket \Uparrow(y) \rrbracket(\rho_0)} = \rho_0(y+1)). Hence the first IH’s outer-term values equal the goal’s outer-term values, and the second IH’s outer-term values equal the goal’s inner-term values.

Bridge via shared inner. By the identity established in the proof of ?, \ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho_0)} = (\ensuremath{\llbracket \sigma \rrbracket(\rho_0)})[\Uparrow] for any \rho_0. Also \ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)})[\Uparrow] by the pointwise definition of weakening evaluation. Hence the inner values of the two IH instantiations coincide:

\begin{aligned} &\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho)})} = \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})})}, \\ &\ensuremath{\llbracket y \rrbracket(\ensuremath{\llbracket \Uparrow \circ \sigma \rrbracket(\rho)})} = \ensuremath{\llbracket y \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})})}, \end{aligned}

and analogously for the primed side. By ?, R_1 \Leftrightarrow R_2; set R_T := R_1. By symmetry and transitivity through the shared inner value, all four goal type values are related in \mathcal{U}_i \searrow R_T, and all four goal term values are related in R_T.

Lemma

Lemma 6.56 (Fundamental — Var)

USRU

If \ensuremath{\vDash \Gamma} and x : T \in \Gamma, then \semtyeq[\Gamma]{x}{x}{T}.

Proof of Lemma 6.56

By ?, \Gamma \approx \Gamma \searrow R for some R, giving the first premise of the semantic term judgment. Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. By ? on \ensuremath{\vDash \Gamma}, x : T \in \Gamma at this instantiation, the four-value patterns hold for some R_T.

Lemma

Lemma 6.57 (Fundamental — Ze-I)

OAOQ

If \ensuremath{\vDash \Gamma}, then \semtyeq[\Gamma]{\textsf{zero}}{\textsf{zero}}{\ensuremath{\texttt{Nat}}}.

Proof of Lemma 6.57

By ?, \Gamma \approx \Gamma \searrow R for some R. Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. We must show

\{\ensuremath{\llbracket \ensuremath{\texttt{Nat}}[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \ensuremath{\texttt{Nat}}[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_0 \searrow R_T

for some R_T, and

\{\ensuremath{\llbracket \textsf{zero}[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \textsf{zero} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \textsf{zero} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket \textsf{zero}[\sigma'] \rrbracket(\rho')}\} \subseteq R_T.

Type part. Since \ensuremath{\texttt{Nat}} is closed, all four type values collapse to N:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Nat}}[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\rho)} = N && \text{(closed term, by evaluation)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = N && \text{(by evaluation)} \end{aligned}

and analogously for the primed pair.

\begin{aligned} &N \approx N \in \mathcal{U}_0 \searrow R_T \text{ with } R_T \Leftrightarrow \textsf{Nat} && \text{(by \textsc{U-Nat})} \end{aligned}

Term part. Since \textsf{zero} is closed, all four term values collapse to \texttt{ze}:

\begin{aligned} &\ensuremath{\llbracket \textsf{zero}[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \textsf{zero} \rrbracket(\rho)} = \texttt{ze} && \text{(closed term, by evaluation)} \\ &\ensuremath{\llbracket \textsf{zero} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = \texttt{ze} && \text{(by evaluation)} \end{aligned}

Since R_T \Leftrightarrow \textsf{Nat}, it suffices to show \texttt{ze} \approx \texttt{ze} \in \textsf{Nat}.

\begin{aligned} &\texttt{ze} \approx \texttt{ze} \in \textsf{Nat} && \text{(by \textsc{Nat-Ze})} \end{aligned}

Hence \texttt{ze} \approx \texttt{ze} \in R_T, and the four-value pattern follows.

Lemma

Lemma 6.58 (Fundamental — Su-I / Su-Cong)

GHMS

If \semtyeq[\Gamma]{t}{t'}{\ensuremath{\texttt{Nat}}}, then \semtyeq[\Gamma]{\textsf{succ}~t}{\textsf{succ}~t'}{\ensuremath{\texttt{Nat}}}.

Proof of Lemma 6.58

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given.

Type part. Identical to ?: \{\ensuremath{\llbracket \ensuremath{\texttt{Nat}}[\sigma] \rrbracket(\rho)}, \ldots\} \subseteq \mathcal{U}_0 \searrow R_T with R_T \Leftrightarrow \textsf{Nat} by U-Nat.

Term part. We compute the four term values, using that substitution and evaluation distribute over \textsf{su}:

\begin{aligned} &\ensuremath{\llbracket (\textsf{succ}~t)[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \textsf{succ}~t[\sigma] \rrbracket(\rho)} && \text{(by definition of substitution on $\textsf{su}$)} \\ &\quad = \texttt{su}(\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)}) && \text{(by evaluation of $\textsf{su}$)} \\[4pt] &\ensuremath{\llbracket \textsf{succ}~t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = \texttt{su}(\ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}) && \text{(by evaluation of $\textsf{su}$)} \end{aligned}

Analogous computations apply to the primed pair, giving \texttt{su}(\ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}) and \texttt{su}(\ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')}).

By the hypothesis \semtyeq[\Gamma]{t}{t'}{\ensuremath{\texttt{Nat}}} applied at \Gamma', \sigma \approx \sigma', and \rho \approx \rho' \in R', the term part gives

\begin{aligned} &\{\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')}\} \subseteq \textsf{Nat} && \text{(by hypothesis on $t, t'$)} \end{aligned}

Applying Nat-Su pointwise (using transitivity of \textsf{Nat}, ?, to chain the four values):

\begin{aligned} &\texttt{su}(\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)}) \approx \texttt{su}(\ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}) \in \textsf{Nat} && \text{(by \textsc{Nat-Su})} \\ &\texttt{su}(\ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}) \approx \texttt{su}(\ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}) \in \textsf{Nat} && \text{(by \textsc{Nat-Su})} \\ &\texttt{su}(\ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}) \approx \texttt{su}(\ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')}) \in \textsf{Nat} && \text{(by \textsc{Nat-Su})} \end{aligned}

By transitivity of \textsf{Nat}, all four are related in \textsf{Nat}, hence in R_T.

Lemma

Lemma 6.59 (Fundamental — \lambda-I / \lambda-Cong)

QVXP

If \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S]{t}{t'}{T}, then \semtyeq[\Gamma]{\lambda x.\,t}{\lambda x.\,t'}{\Pi(x:S).\,T}.

Proof of Lemma 6.59

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given.

Type part. By ? applied to the hypotheses \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} (the latter follows from \semtyeq[\Gamma, x:S]{t}{t}{T} via type extraction):

\{\ensuremath{\llbracket (\Pi(x:S).\,T)[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket \Pi(x:S).\,T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket \Pi(x:S).\,T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket (\Pi(x:S).\,T)[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R

where R is the function PER characterized by: f \approx f' \in R \;\leftrightarrow\; (\forall \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I.\; f \cdot a \approx f' \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I)).

Term part. We compute the four term values using the substitution behavior of \lambda:

\begin{aligned} &\ensuremath{\llbracket (\lambda x.\,t)[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket \lambda x.\,(t[q(\sigma)]) \rrbracket(\rho)} && \text{(by definition of substitution under $\lambda$)} \\ &\quad = \lambda(t[q(\sigma)],\, \rho) && \text{(by evaluation of $\lambda$, forming a closure)} \\[4pt] &\ensuremath{\llbracket \lambda x.\,t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = \lambda(t,\, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) && \text{(by evaluation of $\lambda$)} \end{aligned}

Analogously, \ensuremath{\llbracket \lambda x.\,t' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} = \lambda(t',\, \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) and \ensuremath{\llbracket (\lambda x.\,t')[\sigma'] \rrbracket(\rho')} = \lambda(t'[q(\sigma')],\, \rho').

By the biconditional characterization of R, it suffices to show that for every \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I (where R_I is the domain PER), the four closure applications are related in R_O(\ensuremath{\mathcal{D}}_I):

\{\lambda(t[q(\sigma)], \rho) \cdot a,\; \lambda(t, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) \cdot a,\; \lambda(t', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \cdot a',\; \lambda(t'[q(\sigma')], \rho') \cdot a'\} \subseteq R_O(\ensuremath{\mathcal{D}}_I).

We compute these closure applications:

\begin{aligned} &\lambda(t[q(\sigma)],\, \rho) \cdot a = \ensuremath{\llbracket t[q(\sigma)] \rrbracket((\rho, a/x))} && \text{(by closure application)} \\ &\lambda(t,\, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) \cdot a = \ensuremath{\llbracket t \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x))} && \text{(by closure application)} \end{aligned}

Analogous identities hold for the primed pair (using t').

By ? on \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}: \semtyeq[\Gamma', x:S[\sigma]]{q(\sigma)}{q(\sigma')}{\Gamma, x:S}. By the first premise of this judgment, (\Gamma', x:S[\sigma]) \approx (\Gamma', x:S[\sigma]) \searrow R_{\Gamma',x:S[\sigma]} and (\Gamma, x:S) \approx (\Gamma, x:S) \searrow R_{\Gamma,x:S}.

By ? on the same left type \ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} governing both R_I (from ?’s domain step) and the head PER R_H' of R_{\Gamma',x:S[\sigma]}, R_I \Leftrightarrow R_H'(\ensuremath{\mathcal{D}}') for \ensuremath{\mathcal{D}}' :: \rho \approx \rho' \in R'. Hence a \approx a' \in R_H'(\ensuremath{\mathcal{D}}'), so by the biconditional of R_{\Gamma',x:S[\sigma]}, (\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma',x:S[\sigma]}.

Apply the hypothesis \semtyeq[\Gamma, x:S]{t}{t'}{T} at \Gamma', x:S[\sigma], the lifted substitution \semtyeq[\Gamma', x:S[\sigma]]{q(\sigma)}{q(\sigma')}{\Gamma, x:S}, and (\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma',x:S[\sigma]}:

\begin{aligned} &\{\ensuremath{\llbracket t[q(\sigma)] \rrbracket((\rho, a/x))},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))})},\\ &\quad \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})},\; \ensuremath{\llbracket t'[q(\sigma')] \rrbracket((\rho', a'/x))}\} \subseteq R_O(\ensuremath{\mathcal{D}}_I) && \text{(by hypothesis on $t, t'$)} \end{aligned}

The outer two values are the closure applications \lambda(t[q(\sigma)], \rho) \cdot a and \lambda(t'[q(\sigma')], \rho') \cdot a'. The inner two values are \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))})} and \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})}, which we must relate to \ensuremath{\llbracket t \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x))} = \lambda(t, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) \cdot a and \ensuremath{\llbracket t' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} = \lambda(t', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \cdot a'.

We now show \ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x) \in R_{\Gamma, x:S}. Unfolding q(\sigma) = (\sigma[\Uparrow], x_0/x), the environment \ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))} has tail \ensuremath{\llbracket \sigma[\Uparrow] \rrbracket((\rho, a/x))} and head a (since \ensuremath{\llbracket x_0 \rrbracket((\rho, a/x))} = a). The environment (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x) has tail \ensuremath{\llbracket \sigma \rrbracket(\rho)} and head a. By the biconditional of R_{\Gamma, x:S} (from Ctx-Ext), it suffices to show:

    Tails: \ensuremath{\llbracket \sigma[\Uparrow] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket \sigma \rrbracket(\rho)} \in R_\Gamma. By ?, \semweak[\Gamma',x:S[\sigma]]{\Uparrow}{\Gamma'}. Apply \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} at \Gamma', x:S[\sigma], \Uparrow, and (\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma',x:S[\sigma]}: the four-value pattern includes \ensuremath{\llbracket \sigma[\Uparrow] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket((\rho, a/x))})} \in R_\Gamma. Since \ensuremath{\llbracket \Uparrow \rrbracket((\rho, a/x))} = \rho definitionally (the shift on environments drops the head), this gives the desired relatedness. Let \ensuremath{\mathcal{D}}_\Gamma denote this evidence in R_\Gamma. Heads: a \approx a \in R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma), where R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) is the head PER governed by \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma[\Uparrow] \rrbracket((\rho, a/x))})} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in \mathcal{U}_i \searrow R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma). By \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} instantiated at \Gamma', \semtyeq[\Gamma']{\sigma}{\sigma}{\Gamma} (reflexive, by ?, ?), and \rho \approx \rho \in R': the type part gives the commutation \ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in \mathcal{U}_i. By ?, R_I \Leftrightarrow R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma). From a \approx a \in R_I (reflexive of a \approx a' \in R_I), we conclude a \approx a \in R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma).

By Ctx-Ext’s biconditional, \ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x) \in R_{\Gamma, x:S}. By ? on the reflexive instance \semtyeq[\Gamma, x:S]{t}{t}{T} (from \semtyeq[\Gamma, x:S]{t}{t'}{T} by ?, ?) applied to this related pair:

\ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))})} \approx \ensuremath{\llbracket t \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, a/x))} \in R_O'(\ensuremath{\mathcal{D}}_I)

for some R_O'(\ensuremath{\mathcal{D}}_I). By ?, R_O'(\ensuremath{\mathcal{D}}_I) \Leftrightarrow R_O(\ensuremath{\mathcal{D}}_I) (governed by the same type \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a/x))})} which lies in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I) by the type part of the four-value pattern). Analogously on the primed side (using the reflexive instance \semtyeq[\Gamma, x:S]{t'}{t'}{T}): \ensuremath{\llbracket t' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})} \approx \ensuremath{\llbracket t' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \in R_O(\ensuremath{\mathcal{D}}_I).

Combining via symmetry and transitivity of R_O(\ensuremath{\mathcal{D}}_I), the four closure applications

\{\lambda(t[q(\sigma)], \rho) \cdot a,\; \lambda(t, \ensuremath{\llbracket \sigma \rrbracket(\rho)}) \cdot a,\; \lambda(t', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \cdot a',\; \lambda(t'[q(\sigma')], \rho') \cdot a'\} \subseteq R_O(\ensuremath{\mathcal{D}}_I).

Hence the biconditional is satisfied, and the four closures are related in R.

Lemma

Lemma 6.60 (Fundamental — \lambda-E / App-Cong)

6JXH

If \semtyeq[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma, x:S]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma]{r}{r'}{\Pi(x:S).\,T}, and \semtyeq[\Gamma]{s}{s'}{S}, then \semtyeq[\Gamma]{r\;s}{r'\;s'}{T[s/x]}.

Proof of Lemma 6.60

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given.

By \semtyeq[\Gamma]{s}{s'}{S} at \Gamma', \sigma \approx \sigma' : \Gamma, \rho \approx \rho' \in R':

\begin{aligned} &\{\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket S[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_I && \text{(by hypothesis on $S$)} \\ &\{\ensuremath{\llbracket s[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket s'[\sigma'] \rrbracket(\rho')}\} \subseteq R_I && \text{(by hypothesis on $s, s'$)} \end{aligned}

In particular, let \ensuremath{\mathcal{D}}_I :: \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket s'[\sigma'] \rrbracket(\rho')} \in R_I.

By \semtyeq[\Gamma]{r}{r'}{\Pi(x:S).\,T} at the same data, the four evaluations of r, r' are related in the function PER R for \Pi(\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)}, T[q(\sigma)], \rho):

\begin{aligned} &\{\ensuremath{\llbracket r[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket r \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket r' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket r'[\sigma'] \rrbracket(\rho')}\} \subseteq R && \text{(by hypothesis on $r, r'$)} \end{aligned}

Term part. We compute the four term values:

\begin{aligned} &\ensuremath{\llbracket (r\;s)[\sigma] \rrbracket(\rho)} = \ensuremath{\llbracket r[\sigma]\;s[\sigma] \rrbracket(\rho)} && \text{(by definition of substitution on app)} \\ &\quad = \ensuremath{\llbracket r[\sigma] \rrbracket(\rho)} \cdot \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)} && \text{(by evaluation of app)} \\[4pt] &\ensuremath{\llbracket r\;s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = \ensuremath{\llbracket r \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \cdot \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} && \text{(by evaluation of app)} \end{aligned}

Analogous computations for the primed pair (with r', s'), yielding \ensuremath{\llbracket r' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \cdot \ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} and \ensuremath{\llbracket r'[\sigma'] \rrbracket(\rho')} \cdot \ensuremath{\llbracket s'[\sigma'] \rrbracket(\rho')}.

Denote the four r/r'-values as f_1, f_2, f_3, f_4 (in order) and the four s/s'-values as a_1, a_2, a_3, a_4. By hypothesis, \{f_1, f_2, f_3, f_4\} \subseteq R and \{a_1, a_2, a_3, a_4\} \subseteq R_I. For each pair (i, j) with 1 \leq i < j \leq 4, we have f_i \approx f_j \in R and a_i \approx a_j \in R_I; let \ensuremath{\mathcal{D}}_I^{ij} :: a_i \approx a_j \in R_I. By the biconditional of R applied to f_i \approx f_j \in R and \ensuremath{\mathcal{D}}_I^{ij}: f_i \cdot a_i \approx f_j \cdot a_j \in R_O(\ensuremath{\mathcal{D}}_I^{ij}). By ? (right irrelevance), R_O(\ensuremath{\mathcal{D}}_I^{ij}) is independent of the witness, agreeing with R_O(\ensuremath{\mathcal{D}}_I) for any fixed \ensuremath{\mathcal{D}}_I :: a_1 \approx a_4 \in R_I. Hence

\begin{aligned} &\{\ensuremath{\llbracket r[\sigma] \rrbracket(\rho)} \cdot \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket r \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \cdot \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\\ &\quad \ensuremath{\llbracket r' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \cdot \ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket r'[\sigma'] \rrbracket(\rho')} \cdot \ensuremath{\llbracket s'[\sigma'] \rrbracket(\rho')}\} \subseteq R_O(\ensuremath{\mathcal{D}}_I). \end{aligned}

Type part. We instantiate \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at two semantic substitutions to obtain the goal’s outer and inner values, then bridge via ?.

Pattern A (outer instantiation): (\sigma, s[\sigma]/x) vs (\sigma', s'[\sigma']/x).

\begin{aligned} &\semtyeq[\Gamma']{(\sigma, s[\sigma]/x)}{(\sigma', s'[\sigma']/x)}{\Gamma, x:S} && \text{(by \Cref{lem:sem-ext-pre} on $\sigma \approx \sigma'$ and $s \approx s'$)} \end{aligned}

Apply \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', this semantic substitution, and \rho \approx \rho' \in R':

\begin{aligned} \{&\ensuremath{\llbracket T[\sigma, s[\sigma]/x] \rrbracket(\rho)},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)})}, \\ &\ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\sigma', s'[\sigma']/x) \rrbracket(\rho')})},\; \ensuremath{\llbracket T[\sigma', s'[\sigma']/x] \rrbracket(\rho')}\} &&\subseteq \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I). \end{aligned}

Identify the four values syntactically and definitionally:

\begin{aligned} &T[\sigma, s[\sigma]/x] = && \text{(by \Cref{lem:subst-ext-comm})} \\ &T[\sigma', s'[\sigma']/x] = && \text{(by \Cref{lem:subst-ext-comm})} \\ &\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)}/x) && \text{(by pointwise definition of substitution evaluation)} \end{aligned}

Hence the four-value pattern reads:

\begin{aligned} \{&\ensuremath{\llbracket \rrbracket(\rho)},\; \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)}/x))}, \\ &\ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \ensuremath{\llbracket s'[\sigma'] \rrbracket(\rho')}/x))},\; \ensuremath{\llbracket \rrbracket(\rho')}\} &&\subseteq \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I). \end{aligned}

The outer-left value matches the goal’s outer-left \ensuremath{\llbracket \rrbracket(\rho)}. The outer-right value \ensuremath{\llbracket \rrbracket(\rho')} governs the same PER as \ensuremath{\llbracket \rrbracket(\rho')} by ? once we establish

\ensuremath{\llbracket \rrbracket(\rho')} \approx \ensuremath{\llbracket \rrbracket(\rho')} \in \mathcal{U}_i,

which holds by another instantiation of \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at the related env-pair

(\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \ensuremath{\llbracket s[\sigma'] \rrbracket(\rho')}/x) \approx (\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \ensuremath{\llbracket s'[\sigma'] \rrbracket(\rho')}/x) \in R_{\Gamma, x:S}

(using the four-value relatedness of s, s').

Pattern B (inner instantiation): (\ensuremath{\textsf{id}}, s/x) vs (\ensuremath{\textsf{id}}, s'/x). By ? on \semtyeq[\Gamma]{\ensuremath{\textsf{id}}}{\ensuremath{\textsf{id}}}{\Gamma} and \semtyeq[\Gamma]{s}{s'}{S}: \semtyeq[\Gamma]{(\ensuremath{\textsf{id}}, s/x)}{(\ensuremath{\textsf{id}}, s'/x)}{\Gamma, x:S} (using s[\ensuremath{\textsf{id}}] = s and s'[\ensuremath{\textsf{id}}] = s'). From \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} at \ensuremath{\textsf{id}}, \ensuremath{\mathcal{D}}: \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma. Apply \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma (with R_\Gamma), this semantic substitution, and \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma:

\begin{aligned} \{&\ensuremath{\llbracket T[\ensuremath{\textsf{id}}, s/x] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\ensuremath{\textsf{id}}, s/x) \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})})}, \\ &\ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\ensuremath{\textsf{id}}, s'/x) \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})})},\; \ensuremath{\llbracket T[\ensuremath{\textsf{id}}, s'/x] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}\} &&\subseteq \mathcal{U}_i \searrow R_O^B. \end{aligned}

Identify T[\ensuremath{\textsf{id}}, s/x] = T[s/x], T[\ensuremath{\textsf{id}}, s'/x] = T[s'/x], and \ensuremath{\llbracket (\ensuremath{\textsf{id}}, s/x) \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}/x) (pointwise; \ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = \ensuremath{\llbracket \sigma \rrbracket(\rho)}). So the four-value pattern reads:

\begin{aligned} \{&\ensuremath{\llbracket T[s/x] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}/x))}, \\ &\ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}/x))},\; \ensuremath{\llbracket T[s'/x] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}\} &&\subseteq \mathcal{U}_i \searrow R_O^B. \end{aligned}

The outer values match the goal’s inner-left \ensuremath{\llbracket T[s/x] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} and inner-right \ensuremath{\llbracket T[s'/x] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} (modulo ? on T[s/x] vs T[s'/x] at \ensuremath{\llbracket \sigma' \rrbracket(\rho')}, established as in Pattern A).

Bridging Pattern A and Pattern B. Pattern A’s inner-left is

\ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)}/x))}

and Pattern B’s inner-left is

\ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}/x))}.

We bridge them via ?. We show

(\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)}/x) \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}/x) \in R_{\Gamma, x:S}

by Ctx-Ext’s biconditional:

\begin{aligned} &\ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma \rrbracket(\rho)} \in R_\Gamma && \text{(reflexive; let $\ensuremath{\mathcal{D}}_\Gamma$ be this witness)} \\ &\ensuremath{\llbracket s[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in R_I && \text{(outer-left vs inner-left of the four-value pattern of $s$)} \\ &\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in \mathcal{U}_i && \text{(outer-left vs inner-left of the type part of $s$)} \\ &R_I \Leftrightarrow R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) && \text{(by \Cref{lem:univ-functional}, both governed by $\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)}$)} \\ &\ensuremath{\llbracket s[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in R_H^\Gamma(\ensuremath{\mathcal{D}}_\Gamma) && \text{(transferring across the biconditional)} \end{aligned}

Apply ? on \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at this related pair:

\begin{gathered} \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)}/x))} \approx \\ \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}/x))} \in \mathcal{U}_i. \end{gathered}

Analogously on the primed side, bridging Pattern A’s inner-right and Pattern B’s inner-right:

\begin{gathered} \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \ensuremath{\llbracket s'[\sigma'] \rrbracket(\rho')}/x))} \approx \\ \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})}/x))} \in \mathcal{U}_i. \end{gathered}

Combining. By transitivity of \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I) through the bridges:

\begin{aligned} &\ensuremath{\llbracket \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)}/x))} && \text{(Pattern A: outer-left vs inner-left)} \\ &\ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)}/x))} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}/x))} && \text{(bridge above)} \\ &\ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})}/x))} \approx \ensuremath{\llbracket T[s/x] \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} && \text{(Pattern B, with $R_O^B \Leftrightarrow R_O(\ensuremath{\mathcal{D}}_I)$ by \Cref{lem:univ-functional})} \end{aligned}

Hence the goal’s outer-left \approx goal’s inner-left in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I). Analogously for outer-right \approx inner-right (using the primed bridge). Combined with Pattern A’s outer pair and Pattern B’s outer pair (which directly relate inner-left to inner-right in their respective four-value patterns), all four type values lie pairwise in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}_I).

Lemma

Lemma 6.61 (Semantic recursion, unsubstituted)

QN5H

Suppose:

    \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma]{z}{z'}{T[\textsf{zero}/x]}, \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s'}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]}, \Gamma \approx \Gamma \searrow R_\Gamma and \rho \approx \rho' \in R_\Gamma.

Then for every a \approx a' \in \textsf{Nat}, there exist domain values b, b' with

\begin{aligned} &\mathsf{rec}(a,\, T,\, z,\, s,\, \rho) \searrow b, \\ &\mathsf{rec}(a',\, T',\, z',\, s',\, \rho') \searrow b', \end{aligned}

and b \approx b' \in R_T, where R_T is determined by \ensuremath{\llbracket T \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T' \rrbracket((\rho', a'/x))} \in \mathcal{U}_i \searrow R_T.

Symmetric/reflexive instances also follow: by symmetry and transitivity of the hypotheses (?, ?), the lemma can be applied at T \approx T (using only T on both sides) when needed.

Furthermore, this \mathcal{U}_i-relatedness of types holds.

Proof of Lemma 6.61

We first establish the second claim.

\begin{aligned} &(\Gamma, x:\ensuremath{\texttt{Nat}}) \approx (\Gamma, x:\ensuremath{\texttt{Nat}}) \searrow R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:fund-ctx-ext} on $\semtyeq[\Gamma]{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{0}}}$)} \\ &\text{the head PER of $R_{\Gamma, x:\ensuremath{\texttt{Nat}}}$ is $\textsf{Nat}$} && \text{(by \textsc{U-Nat})} \\ &(\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext}'s biconditional)} \\ &\ensuremath{\llbracket T \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T' \rrbracket((\rho', a'/x))} \in \mathcal{U}_i \searrow R_T && \text{(by \Cref{lem:sem-ty-id} on $\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}}$)} \end{aligned}

for some R_T.

We prove the first claim by induction on a \approx a' \in \textsf{Nat}.

Case

Mathpar.

ze ze Nat

Here a = a' = \texttt{ze}.

\begin{aligned} &\ensuremath{\llbracket z \rrbracket(\rho)} \searrow b && \text{(some $b$, by termination via \Cref{lem:sem-ty-id})} \\ &\ensuremath{\llbracket z' \rrbracket(\rho')} \searrow b' && \text{(some $b'$)} \\ &\mathsf{rec}(\texttt{ze},\, T,\, z,\, s,\, \rho) \searrow b && \text{(by \textsc{rec-ze})} \\ &\mathsf{rec}(\texttt{ze},\, T',\, z',\, s',\, \rho') \searrow b' && \text{(by \textsc{rec-ze})} \end{aligned}

We must show b \approx b' \in R_T.

\begin{aligned} &\ensuremath{\llbracket z \rrbracket(\rho)} \approx \ensuremath{\llbracket z' \rrbracket(\rho')} \in R_z && \text{(by \Cref{lem:sem-ty-id})} \\ &\ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\rho)} \approx \ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_z && \text{(type part of \Cref{lem:sem-ty-id})} \end{aligned}

Hence b \approx b' \in R_z. We show R_z \Leftrightarrow R_T.

\begin{aligned} &\semtyeq[\Gamma]{(\ensuremath{\textsf{id}}, \textsf{zero}/x)}{(\ensuremath{\textsf{id}}, \textsf{zero}/x)}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:sem-ext-pre} on $\ensuremath{\textsf{id}}$ and \Cref{lem:fund-ze})} \\ &\ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket((\rho, \texttt{ze}/x))} \in \mathcal{U}_i && \text{(outer-vs-inner of $T$ at $(\ensuremath{\textsf{id}}, \textsf{zero}/x)$, $\rho \approx \rho'$,} \\ & && \text{using $T[\ensuremath{\textsf{id}}, \textsf{zero}/x] = T[\textsf{zero}/x]$ and ev-ze)} \\ &R_z \Leftrightarrow R_T && \text{(by \Cref{lem:univ-functional})} \end{aligned}

Hence b \approx b' \in R_T.

Case

Mathpar.

a_0 a_0’ Nat su(a_0) su(a_0’) Nat

with a = \texttt{su}(a_0), a' = \texttt{su}(a_0'). By IH on a_0 \approx a_0', there exist b_0, b_0' with

\begin{aligned} &\mathsf{rec}(a_0,\, T,\, z,\, s,\, \rho) \searrow b_0 && \text{(by IH)} \\ &\mathsf{rec}(a_0',\, T',\, z',\, s',\, \rho') \searrow b_0' && \text{(by IH)} \\ &b_0 \approx b_0' \in R_T^0 && \text{(by IH, with $R_T^0$ governed by $\ensuremath{\llbracket T \rrbracket((\rho, a_0/x))}$)} \end{aligned}

By rec-su:

\begin{aligned} &\ensuremath{\llbracket s \rrbracket((\rho, a_0/x, b_0/y))} \searrow b && \text{(some $b$)} \\ &\ensuremath{\llbracket s' \rrbracket((\rho', a_0'/x, b_0'/y))} \searrow b' && \text{(some $b'$)} \\ &\mathsf{rec}(\texttt{su}(a_0),\, T,\, z,\, s,\, \rho) \searrow b && \text{(by \textsc{rec-su})} \\ &\mathsf{rec}(\texttt{su}(a_0'),\, T',\, z',\, s',\, \rho') \searrow b' && \text{(by \textsc{rec-su})} \end{aligned}

We must show b \approx b' \in R_T. Build the env-pair in R_{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T}:

\begin{aligned} &(\rho, a_0/x) \approx (\rho', a_0'/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext}, head PER $\textsf{Nat}$)} \\ &(\rho, a_0/x, b_0/y) \approx (\rho', a_0'/x, b_0'/y) \\ & \quad \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T} && \text{(by \textsc{Ctx-Ext}, head PER $R_T^0$)} \end{aligned}

Apply ? on \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s'} {T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} at this env-pair:

\begin{aligned} &\ensuremath{\llbracket T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] \rrbracket((\rho, a_0/x, b_0/y))} \\ & \quad \approx \ensuremath{\llbracket T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] \rrbracket((\rho', a_0'/x, b_0'/y))} \\ & \quad \in \mathcal{U}_i \searrow R_s && \text{(type part of \Cref{lem:sem-ty-id})} \\ &\ensuremath{\llbracket s \rrbracket((\rho, a_0/x, b_0/y))} \approx \ensuremath{\llbracket s' \rrbracket((\rho', a_0'/x, b_0'/y))} \in R_s && \text{(term part of \Cref{lem:sem-ty-id})} \end{aligned}

where R_s is the PER governed by

\ensuremath{\llbracket T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] \rrbracket((\rho, a_0/x, b_0/y))}.

Hence b \approx b' \in R_s.

We show R_s \Leftrightarrow R_T by instantiating hypothesis on T at the substitution \tau := (\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x) over \Gamma, x:\ensuremath{\texttt{Nat}}, y:T (mapping into \Gamma, x:\ensuremath{\texttt{Nat}}). Semantic well-formedness of \tau:

\begin{aligned} &\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{\Uparrow \circ \Uparrow}{\Uparrow \circ \Uparrow}{\Gamma} && \text{(by \Cref{lem:sem-wk-shift} (twice), \Cref{lem:sem-wk-comp}, and \Cref{lem:sem-wk})} \\ &\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{x_1}{x_1}{\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:fund-var}, lookup $x_1 : \ensuremath{\texttt{Nat}}[\Uparrow] = \ensuremath{\texttt{Nat}}$)} \\ &\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{\textsf{succ}~x_1}{\textsf{succ}~x_1}{\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:fund-su})} \\ &\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{\tau}{\tau}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:sem-ext-pre})} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma, x:\ensuremath{\texttt{Nat}}, y:T, \tau \approx \tau, and the env-pair (\rho, a_0/x, b_0/y) \approx (\rho, a_0/x, b_0/y) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T} (reflexive):

\begin{aligned} &\ensuremath{\llbracket T[\tau] \rrbracket((\rho, a_0/x, b_0/y))} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \tau \rrbracket((\rho, a_0/x, b_0/y))})} \in \mathcal{U}_i \searrow R' && \text{(outer-left vs inner-left)} \\ &\ensuremath{\llbracket \tau \rrbracket((\rho, a_0/x, b_0/y))} = (\rho, \texttt{su}(a_0)/x) && \text{(by pointwise eval: $\Uparrow \circ \Uparrow$ projects to $\rho$,} \\ & && \text{$\textsf{succ}~x_1$ evaluates to $\texttt{su}(a_0)$ via ev-su, ev-var)} \end{aligned}

Hence:

\begin{aligned} &\ensuremath{\llbracket T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] \rrbracket((\rho, a_0/x, b_0/y))} \approx \ensuremath{\llbracket T \rrbracket((\rho, \texttt{su}(a_0)/x))} \in \mathcal{U}_i \searrow R' && \text{(by the above)} \end{aligned}

Combining with the second claim \ensuremath{\llbracket T \rrbracket((\rho, \texttt{su}(a_0)/x))} \approx \ensuremath{\llbracket T \rrbracket((\rho', \texttt{su}(a_0')/x))} \in \mathcal{U}_i \searrow R_T (applied at \texttt{su}(a_0) \approx \texttt{su}(a_0')):

\begin{aligned} &R_s \Leftrightarrow R' \Leftrightarrow R_T && \text{(by \Cref{lem:univ-functional} on shared values)} \end{aligned}

Hence b \approx b' \in R_T.

Case

Mathpar.

e e’ Ne ^N(e) ^N(e’) Nat

with a = {\uparrow}^N(e), a' = {\uparrow}^N(e'). Compute the eliminator outputs by rec-ne:

\begin{aligned} &\ensuremath{\llbracket T \rrbracket((\rho, {\uparrow}^N(e)/x))} \searrow A && \text{(by the second claim, governing $R_T$)} \\ &\ensuremath{\llbracket T \rrbracket((\rho', {\uparrow}^N(e')/x))} \searrow A' && \text{(analogously)} \\ &A \approx A' \in \mathcal{U}_i \searrow R_T && \text{(by the second claim at ${\uparrow}^N(e) \approx {\uparrow}^N(e')$)} \\ &\ensuremath{\llbracket z \rrbracket(\rho)} \searrow a_z,\;\; \ensuremath{\llbracket z' \rrbracket(\rho')} \searrow a_z',\;\; a_z \approx a_z' \in R_z && \text{(by \Cref{lem:sem-ty-id} on $\semtyeq[\Gamma]{z}{z'}{T[\textsf{zero}/x]}$)} \\ &b = {\uparrow}^A(\mathsf{rec}(T, a_z, s, \rho, e)) && \text{(by \textsc{rec-ne})} \\ &b' = {\uparrow}^{A'}(\mathsf{rec}(T, a_z', s', \rho', e')) && \text{(by \textsc{rec-ne})} \end{aligned}

We must show b \approx b' \in R_T. By ? on A \approx A' \in \mathcal{U}_i \searrow R_T, it suffices to show

\begin{aligned} &\mathsf{rec}(T, a_z, s, \rho, e) \approx \mathsf{rec}(T, a_z', s', \rho', e') \in \textsf{Ne}, \end{aligned}

i.e. for every depth n both sides read back via \textsf{R}^{\textsf{Ne}}_n to the same neutral normal form. By rule Re-rec:

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_n(\mathsf{rec}(T, a_z, s, \rho, e)) \searrow \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u} \end{aligned}

whenever

\begin{aligned} &\textsf{R}^{\textsf{Ty}}_{n+1}(A_x) \searrow W_T && \text{where $\ensuremath{\llbracket T \rrbracket((\rho, {\uparrow}^N(\ell_n)/x))} \searrow A_x$} \\ &\textsf{R}^{\textsf{Nf}}_n({\downarrow}^{A_z}(a_z)) \searrow w_z && \text{where $\ensuremath{\llbracket T \rrbracket((\rho, \texttt{ze}/x))} \searrow A_z$} \\ &\ensuremath{\llbracket s \rrbracket((\rho, {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_x}(\ell_{n+1})/y))} \searrow b_s \\ &\textsf{R}^{\textsf{Nf}}_{n+2}({\downarrow}^{A_x^{\textsf{succ}~}}(b_s)) \searrow w_s && \text{where $\ensuremath{\llbracket T \rrbracket((\rho, \texttt{su}({\uparrow}^N(\ell_n))/x))} \searrow A_x^{\textsf{succ}~}$} \\ &\textsf{R}^{\textsf{Ne}}_n(e) \searrow u \end{aligned}

(and analogously for the primed side, producing \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T')~w_z'~(x, y.\,w_s')~u'}). We show each component reads back to the same syntactic form.

Motive W_T = W_T'. Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at the env-pair extended with the fresh level \ell_n:

\begin{aligned} &{\uparrow}^N(\ell_n) \approx {\uparrow}^N(\ell_n) \in \textsf{Nat} && \text{(by \textsc{Nat-Ne}, $\ell_n \approx \ell_n \in \textsf{Ne}$)} \\ &(\rho, {\uparrow}^N(\ell_n)/x) \approx (\rho', {\uparrow}^N(\ell_n)/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext})} \\ &\ensuremath{\llbracket T \rrbracket((\rho, {\uparrow}^N(\ell_n)/x))} \approx \ensuremath{\llbracket T \rrbracket((\rho', {\uparrow}^N(\ell_n)/x))} \in \mathcal{U}_i \searrow R_T^\ell && \text{(by \Cref{lem:sem-ty-id})} \\ &W_T = W_T' && \text{(by \Cref{lem:type-readback})} \end{aligned}

Zero branch w_z = w_z'. Apply \semtyeq[\Gamma]{z}{z'}{T[\textsf{zero}/x]} at \Gamma, \ensuremath{\textsf{id}}, and \rho \approx \rho' \in R_\Gamma (term and type parts):

\begin{aligned} &\ensuremath{\llbracket \rrbracket(\rho)} \approx \ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_z && \text{(type part)} \\ &\ensuremath{\llbracket z[\ensuremath{\textsf{id}}] \rrbracket(\rho)} \approx \ensuremath{\llbracket z' \rrbracket(\rho')} \in R_z && \text{(term part)} \\ &a_z \approx a_z' \in R_z && \text{(using $z[\ensuremath{\textsf{id}}] = z$, $z'[\ensuremath{\textsf{id}}] = z'$)} \end{aligned}

Bridge R_z \Leftrightarrow R_T-at-\texttt{ze} via the same outer-vs-inner pattern as the Nat-Ze case (instantiate T at (\ensuremath{\textsf{id}}, \textsf{zero}/x)). By ? on a_z \approx a_z' \in R_T-at-\texttt{ze}:

\begin{aligned} &w_z = w_z' && \text{(by \Cref{lem:R-readback})} \end{aligned}

Step branch w_s = w_s'. Build the env-pair at fresh levels:

\begin{aligned} &(\rho, {\uparrow}^N(\ell_n)/x) \approx (\rho', {\uparrow}^N(\ell_n)/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(as above)} \\ &(\rho, {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_x}(\ell_{n+1})/y) \approx \\ &\quad (\rho', {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_x'}(\ell_{n+1})/y) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T} && \text{(by \textsc{Ctx-Ext}, head PER $R_T^\ell$;} \\ & && \text{${\uparrow}^{A_x}(\ell_{n+1}) \approx {\uparrow}^{A_x'}(\ell_{n+1}) \in R_T^\ell$} \\ & && \text{by \Cref{lem:ne-in-R})} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s'}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} at this env-pair (term and type parts, after bridging T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] to T at \texttt{su}({\uparrow}^N(\ell_n))/x as in the Nat-Su case):

\begin{aligned} &b_s \approx b_s' \in R_T \text{-at-} \texttt{su}({\uparrow}^N(\ell_n)) && \text{(by \Cref{lem:sem-ty-id} and bridging)} \end{aligned}

By ?:

\begin{aligned} &w_s = w_s' && \text{(by \Cref{lem:R-readback})} \end{aligned}

Underlying neutral u = u'. By hypothesis e \approx e' \in \textsf{Ne}:

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_n(e) \searrow u,\;\; \textsf{R}^{\textsf{Ne}}_n(e') \searrow u && \text{(by definition of $\textsf{Ne}$)} \end{aligned}

Combining:

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_n(\mathsf{rec}(T, a_z, s, \rho, e)) \searrow \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u} \\ &\textsf{R}^{\textsf{Ne}}_n(\mathsf{rec}(T, a_z', s', \rho', e')) \searrow \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u} && \text{(same syntactic form)} \\ &\mathsf{rec}(T, a_z, s, \rho, e) \approx \mathsf{rec}(T, a_z', s', \rho', e') \in \textsf{Ne} && \text{(by definition of $\textsf{Ne}$)} \end{aligned}

Hence b \approx b' \in R_T.

Lemma

Lemma 6.62 (Semantic recursion, one-sided substituted)

ASZ4

Suppose:

    \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma]{z}{z'}{T[\textsf{zero}/x]}, \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s'}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]}, \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \rho \approx \rho' \in R'.

Then for every a \approx a' \in \textsf{Nat}, there exist domain values b, b' with

\begin{aligned} &\mathsf{rec}(a,\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) \searrow b && \text{(substituted, left)} \\ &\mathsf{rec}(a',\, T',\, z',\, s',\, \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \searrow b' && \text{(unsubstituted, right)} \end{aligned}

and b \approx b' \in R_T, where R_T is determined by \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \in \mathcal{U}_i \searrow R_T.

Furthermore, this \mathcal{U}_i-relatedness of types holds.

Proof of Lemma 6.62

We first establish the lifted substitution and the second claim.

\begin{aligned} &\semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}]{q(\sigma)}{q(\sigma')}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:sem-q} on $\sigma \approx \sigma'$ and $\ensuremath{\texttt{Nat}}$, using $\ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}}$)} \\ &(\Gamma', x:\ensuremath{\texttt{Nat}}) \approx (\Gamma', x:\ensuremath{\texttt{Nat}}) \searrow R_{\Gamma', x:\ensuremath{\texttt{Nat}}} && \text{(carried by the lifted substitution)} \\ &(\Gamma, x:\ensuremath{\texttt{Nat}}) \approx (\Gamma, x:\ensuremath{\texttt{Nat}}) \searrow R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(carried by the lifted substitution)} \\ &\text{both head PERs are $\textsf{Nat}$} && \text{(by \textsc{U-Nat})} \\ &(\rho, a/x) \approx (\rho', a'/x) \in R_{\Gamma', x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext}'s biconditional)} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', x:\ensuremath{\texttt{Nat}}, the lifted substitution, and the env-pair above:

\begin{aligned} &\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})} \in \mathcal{U}_i \searrow R_T && \text{(outer-left vs inner-right of the four-value pattern)} \end{aligned}

Bridge \ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))} to (\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x):

\begin{aligned} &\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))} \approx (\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext}, tail via $\sigma'$ at $\Uparrow$, head $a' \approx a'$)} \\ &\ensuremath{\llbracket T' \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket((\rho', a'/x))})} \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \in \mathcal{U}_i && \text{(by \Cref{lem:sem-ty-id} on $T' \approx T'$, derived from} \\ & && \text{$T \approx T'$ via symmetry and transitivity)} \end{aligned}

By transitivity of \mathcal{U}_i and ?, \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a/x))} \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \in \mathcal{U}_i \searrow R_T, establishing the second claim.

We prove the first claim by induction on a \approx a' \in \textsf{Nat}.

Case

Mathpar.

ze ze Nat

Here a = a' = \texttt{ze}. Apply \semtyeq[\Gamma]{z}{z'}{T[\textsf{zero}/x]} at \Gamma', \sigma \approx \sigma', and \rho \approx \rho' \in R' (this gives the four-value pattern of z, z'):

\begin{aligned} &\ensuremath{\llbracket z[\sigma] \rrbracket(\rho)} \searrow b,\;\; \ensuremath{\llbracket z' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \searrow b' && \text{(termination, by hypothesis on $z, z'$)} \\ &b \approx b' \in R_z && \text{(outer-left vs inner-right of $z, z'$)} \\ &\ensuremath{\llbracket \rrbracket(\rho)} \approx \ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in \mathcal{U}_i \searrow R_z && \text{(corresponding type part)} \end{aligned}

Then by rec-ze applied to these evaluations:

\begin{aligned} &\mathsf{rec}(\texttt{ze},\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) \searrow b && \text{(by \textsc{rec-ze}, using $\ensuremath{\llbracket z[\sigma] \rrbracket(\rho)} \searrow b$)} \\ &\mathsf{rec}(\texttt{ze},\, T',\, z',\, s',\, \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \searrow b' && \text{(by \textsc{rec-ze}, using $\ensuremath{\llbracket z' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \searrow b'$)} \end{aligned}

We must show b \approx b' \in R_T. Currently b \approx b' \in R_z where R_z is governed by \ensuremath{\llbracket \rrbracket(\rho)}, while R_T is governed by \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{ze}/x))} (substituted left, second-claim instance at a = a' = \texttt{ze}). We bridge R_z \Leftrightarrow R_T via two type-hypothesis instantiations.

Left bridge. By ? on \semtyeq[\Gamma']{\sigma}{\sigma}{\Gamma} (reflexive instance via ?, ?) and \semtyeq[\Gamma']{\textsf{zero}[\sigma]}{\textsf{zero}[\sigma]}{\ensuremath{\texttt{Nat}}[\sigma]} (using \textsf{zero}[\sigma] = \textsf{zero}, \ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}}, and ?):

\begin{aligned} &\semtyeq[\Gamma']{(\sigma, \textsf{zero}/x)}{(\sigma, \textsf{zero}/x)}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:sem-ext-pre})} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', this substitution, and \rho \approx \rho \in R' (reflexive):

\begin{aligned} &\ensuremath{\llbracket T[(\sigma, \textsf{zero}/x)] \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\sigma, \textsf{zero}/x) \rrbracket(\rho)})} \in \mathcal{U}_i \searrow R_z' && \text{(outer-left vs inner-left)} \\ &T[(\sigma, \textsf{zero}/x)] = && \text{(by \Cref{lem:subst-ext-comm})} \\ &\ensuremath{\llbracket (\sigma, \textsf{zero}/x) \rrbracket(\rho)} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{ze}/x) && \text{(by pointwise eval, ev-ze)} \\ &R_z' \Leftrightarrow R_z && \text{(by \Cref{lem:univ-functional} on shared $\ensuremath{\llbracket \rrbracket(\rho)}$)} \end{aligned}

Hence \ensuremath{\llbracket \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{ze}/x))} \in \mathcal{U}_i \searrow R_z.

Right bridge. Symmetrically, instantiate T at (\ensuremath{\textsf{id}}, \textsf{zero}/x) over \Gamma at the env-pair \ensuremath{\llbracket \sigma \rrbracket(\rho)} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma (carried by the semantic-substitution hypothesis):

\begin{aligned} &\semtyeq[\Gamma]{(\ensuremath{\textsf{id}}, \textsf{zero}/x)}{(\ensuremath{\textsf{id}}, \textsf{zero}/x)}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:sem-ext-pre} and \Cref{lem:fund-ze})} \\ &\ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \texttt{ze}/x))} \in \mathcal{U}_i && \text{(outer-vs-inner of the four-value pattern of $T$)} \end{aligned}

Combining via the second claim. The second claim (proved above) gives:

\begin{aligned} &\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{ze}/x))} \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \texttt{ze}/x))} \in \mathcal{U}_i \searrow R_T \end{aligned}

Chaining via the bridges (using ?, ?, ?):

\begin{aligned} &\ensuremath{\llbracket \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{ze}/x))} \\ & \quad \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \texttt{ze}/x))} \\ & \quad \approx \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{ze}/x))} \in \mathcal{U}_i \\ &R_z \Leftrightarrow R_T && \text{(by \Cref{lem:univ-functional})} \end{aligned}

Hence b \approx b' \in R_T.

Case

Mathpar.

a_0 a_0’ Nat su(a_0) su(a_0’) Nat

with a = \texttt{su}(a_0), a' = \texttt{su}(a_0'). By IH on a_0 \approx a_0', there exist b_0, b_0' with

\begin{aligned} &\mathsf{rec}(a_0,\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) \searrow b_0 && \text{(by IH)} \\ &\mathsf{rec}(a_0',\, T',\, z',\, s',\, \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \searrow b_0' && \text{(by IH)} \\ &b_0 \approx b_0' \in R_T^0 && \text{(by IH, with $R_T^0$ governed by $\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, a_0/x))}$)} \end{aligned}

We derive the evaluations of s[q^2(\sigma)] and s' from the hypothesis on s, s'. First, lift \sigma, \sigma' over \ensuremath{\texttt{Nat}} and T:

\begin{aligned} &\semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}]{q(\sigma)}{q(\sigma')}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:sem-q} on $\sigma \approx \sigma'$ and $\ensuremath{\texttt{Nat}}$;} \\ & && \text{using $\ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}}$)} \\ &\semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]] {q^2(\sigma)}{q^2(\sigma')}{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T} && \text{(by \Cref{lem:sem-q} again on $T$)} \end{aligned}

Build the env-pair via two applications of Ctx-Ext:

\begin{aligned} &(\rho, a_0/x) \approx (\rho', a_0'/x) \in R_{\Gamma', x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext}, head PER $\textsf{Nat}$)} \\ &(\rho, a_0/x, b_0/y) \approx (\rho', a_0'/x, b_0'/y) \in R_{\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]} && \text{(by \textsc{Ctx-Ext}, head PER $R_T^0$)} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s'}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} at \Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)], the doubly-lifted substitution q^2(\sigma) \approx q^2(\sigma'), and this env-pair (this gives the four-value pattern of s, s'):

\begin{aligned} &\ensuremath{\llbracket s[q^2(\sigma)] \rrbracket((\rho, a_0/x, b_0/y))} \searrow b && \text{(termination, by hypothesis on $s$)} \\ &\ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket q^2(\sigma') \rrbracket((\rho', a_0'/x, b_0'/y))})} \searrow b'_0 && \text{(termination, by hypothesis on $s'$)} \\ &\ensuremath{\llbracket s' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a_0'/x, b_0'/y))} \searrow b' && \text{(termination, by reflexive instance $\semtyeq[\ldots]{s'}{s'}{\ldots}$)} \end{aligned}

By rec-su:

\begin{aligned} &\mathsf{rec}(\texttt{su}(a_0),\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) \searrow b && \text{(by \textsc{rec-su}, using $\ensuremath{\llbracket s[q^2(\sigma)] \rrbracket((\rho, a_0/x, b_0/y))} \searrow b$)} \\ &\mathsf{rec}(\texttt{su}(a_0'),\, T',\, z',\, s',\, \ensuremath{\llbracket \sigma' \rrbracket(\rho')}) \searrow b' && \text{(by \textsc{rec-su}, using $\ensuremath{\llbracket s' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a_0'/x, b_0'/y))} \searrow b'$)} \end{aligned}

We must show b \approx b' \in R_T. Outer-left vs inner-right of the four-value pattern of s, s':

\begin{aligned} &\ensuremath{\llbracket (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)] \rrbracket((\rho, a_0/x, b_0/y))} \approx \\ &\quad \ensuremath{\llbracket T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] \rrbracket(\ensuremath{\llbracket q^2(\sigma') \rrbracket((\rho', a_0'/x, b_0'/y))})} \in \mathcal{U}_i \searrow R_s && \text{(type part)} \\ &\ensuremath{\llbracket s[q^2(\sigma)] \rrbracket((\rho, a_0/x, b_0/y))} \approx \ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket q^2(\sigma') \rrbracket((\rho', a_0'/x, b_0'/y))})} \in R_s && \text{(term part, by hypothesis on $s, s'$)} \end{aligned}

where R_s is the PER governed by \ensuremath{\llbracket (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)] \rrbracket((\rho, a_0/x, b_0/y))}. Bridge \ensuremath{\llbracket q^2(\sigma') \rrbracket((\rho', a_0'/x, b_0'/y))} to (\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a_0'/x, b_0'/y) in R_{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T} analogously, then apply ? on \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s'}{s'}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} (the reflexive instance):

\begin{aligned} &\ensuremath{\llbracket s' \rrbracket(\ensuremath{\llbracket q^2(\sigma') \rrbracket((\rho', a_0'/x, b_0'/y))})} \approx \ensuremath{\llbracket s' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a_0'/x, b_0'/y))} \in R_s && \text{(by \Cref{lem:sem-ty-id})} \end{aligned}

By transitivity, b \approx b' \in R_s.

We bridge R_s \Leftrightarrow R_T, where R_s is governed by \ensuremath{\llbracket (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)] \rrbracket((\rho, a_0/x, b_0/y))} and R_T is governed by \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{su}(a_0)/x))} (the second-claim pattern instantiated at \texttt{su}(a_0) \approx \texttt{su}(a_0')):

\begin{aligned} &\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{su}(a_0)/x))} \\ &\quad \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, \texttt{su}(a_0')/x))} \in \mathcal{U}_i \searrow R_T && \text{(second claim)} \end{aligned}

All bridging uses syntactic substitution-composition lemmas (?, ?, ?) and instantiations of hypothesis on T.

Bridge B1: collapse (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)] into a single substitution.

\begin{aligned} (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)] &= T[(\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x) \circ q^2(\sigma)] \tag{by \Cref{lem:subst-assoc}} \\ &= T[(\Uparrow \circ \Uparrow) \circ q^2(\sigma),\; \textsf{succ}~x_1[q^2(\sigma)]/x] \tag{by \Cref{lem:ext-comp}} \\ &= T[\sigma \circ (\Uparrow \circ \Uparrow),\; \textsf{succ}~x_1/x] \tag{using $\textsf{succ}~x_1[q^2(\sigma)] = \textsf{succ}~x_1$ (since $q^2(\sigma)(1) = x_1$)} \\ & \tag{and $(\Uparrow \circ \Uparrow) \circ q^2(\sigma) = \sigma \circ (\Uparrow \circ \Uparrow)$ (\Cref{lem:wk-subst-comm})} \end{aligned}

Denote the collapsed substitution by \tau := (\sigma \circ (\Uparrow \circ \Uparrow),\, \textsf{succ}~x_1/x), with \judge[\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]]{\tau : \Gamma, x:\ensuremath{\texttt{Nat}}}.

Bridge B2: instantiate hypothesis on T via \tau. We show \tau is a semantic substitution from \Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)] to \Gamma, x:\ensuremath{\texttt{Nat}}. By ? (twice) and ?: \semweak[\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]]{\Uparrow \circ \Uparrow}{\Gamma'}. Apply ? to \semtyeq[\Gamma']{\sigma}{\sigma}{\Gamma} (reflexive, by ?, ?) and this semantic weakening:

\begin{aligned} &\semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]] {\sigma \circ (\Uparrow \circ \Uparrow)} {\sigma \circ (\Uparrow \circ \Uparrow)} {\Gamma} \end{aligned}

By ?, ?: \semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]] {\textsf{succ}~x_1}{\textsf{succ}~x_1}{\ensuremath{\texttt{Nat}}} (lookup x_1 : \ensuremath{\texttt{Nat}} at the second slot of \Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)], with \ensuremath{\texttt{Nat}}[\Uparrow] = \ensuremath{\texttt{Nat}}). By ?:

\begin{aligned} &\semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]]{\tau}{\tau}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(\Cref{lem:sem-ext-pre})} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)], \tau \approx \tau, and the reflexive env-pair (\rho, a_0/x, b_0/y) \approx (\rho, a_0/x, b_0/y) \in R_{\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]}. Outer-left vs inner-left:

\begin{aligned} &\ensuremath{\llbracket T[\tau] \rrbracket((\rho, a_0/x, b_0/y))} \\ &\quad \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \tau \rrbracket((\rho, a_0/x, b_0/y))})} \in \mathcal{U}_i \searrow R_{B2} \end{aligned}

By Bridge B1,

T[\tau] = (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)],

so the outer-left is exactly

\ensuremath{\llbracket (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)] \rrbracket((\rho, a_0/x, b_0/y))}

— the value governing R_s. Hence R_s \Leftrightarrow R_{B2}.

By pointwise definition of substitution evaluation:

\begin{aligned} &\ensuremath{\llbracket \tau \rrbracket((\rho, a_0/x, b_0/y))} = (\ensuremath{\llbracket \sigma \circ (\Uparrow \circ \Uparrow) \rrbracket((\rho, a_0/x, b_0/y))},\, \texttt{su}(a_0)/x) \\ & \text{(pointwise; head: $\ensuremath{\llbracket \textsf{succ}~x_1 \rrbracket((\rho, a_0/x, b_0/y))} = \texttt{su}(a_0)$ via ev-su, ev-var)} \end{aligned}

We do not equate the tail \ensuremath{\llbracket \sigma \circ (\Uparrow \circ \Uparrow) \rrbracket((\rho, a_0/x, b_0/y))} with \ensuremath{\llbracket \sigma \rrbracket(\rho)} definitionally — such an equality is a substitution–evaluation commutation that does not hold for operational substitutions. Instead, we relate them in R_\Gamma via the four-value pattern of \sigma \circ (\Uparrow \circ \Uparrow) := \sigma[\Uparrow \circ \Uparrow] established by ?, and the four-value pattern of \sigma itself:

\begin{aligned} &\ensuremath{\llbracket \sigma[\Uparrow \circ \Uparrow] \rrbracket((\rho, a_0/x, b_0/y))} \approx \ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \Uparrow \circ \Uparrow \rrbracket((\rho, a_0/x, b_0/y))})} \in R_\Gamma && \text{(four-value pattern of $\sigma[\Uparrow \circ \Uparrow]$,} \\ & && \text{outer-left vs inner-left)} \\ &\ensuremath{\llbracket \Uparrow \circ \Uparrow \rrbracket((\rho, a_0/x, b_0/y))} \approx \rho \in R_{\Gamma'} && \text{(four-value pattern of $\Uparrow \circ \Uparrow$,} \\ & && \text{by \Cref{lem:sem-shift,lem:sem-wk-comp})} \\ &\ensuremath{\llbracket \sigma \rrbracket(\ensuremath{\llbracket \Uparrow \circ \Uparrow \rrbracket((\rho, a_0/x, b_0/y))})} \approx \ensuremath{\llbracket \sigma \rrbracket(\rho)} \in R_\Gamma && \text{(by \Cref{lem:sem-ty-id} on the reflexive $\sigma$)} \end{aligned}

By transitivity of R_\Gamma:

\begin{aligned} &\ensuremath{\llbracket \sigma \circ (\Uparrow \circ \Uparrow) \rrbracket((\rho, a_0/x, b_0/y))} \approx \ensuremath{\llbracket \sigma \rrbracket(\rho)} \in R_\Gamma \\ &\ensuremath{\llbracket \tau \rrbracket((\rho, a_0/x, b_0/y))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)},\, \texttt{su}(a_0)/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext}, head $\texttt{su}(a_0) \approx \texttt{su}(a_0)$)} \end{aligned}

Bridge B3: instantiate hypothesis on T via q(\sigma). Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', x:\ensuremath{\texttt{Nat}}, the lifted q(\sigma) \approx q(\sigma), and reflexive (\rho, \texttt{su}(a_0)/x) \approx (\rho, \texttt{su}(a_0)/x) \in R_{\Gamma', x:\ensuremath{\texttt{Nat}}} (head \texttt{su}(a_0) \approx \texttt{su}(a_0) via ? reflexivity). Outer-left vs inner-left:

\begin{aligned} &\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{su}(a_0)/x))} \\ &\quad \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, \texttt{su}(a_0)/x))})} \in \mathcal{U}_i \searrow R_{B3} \\ &\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, \texttt{su}(a_0)/x))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{su}(a_0)/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \textsc{Ctx-Ext})} \end{aligned}

Combining B2 and B3. By B2’s bridging, \ensuremath{\llbracket \tau \rrbracket((\rho, a_0/x, b_0/y))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{su}(a_0)/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}}. By B3’s Ctx-Ext computation, \ensuremath{\llbracket q(\sigma) \rrbracket((\rho, \texttt{su}(a_0)/x))} \approx (\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{su}(a_0)/x) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}} (PER-related, via the lifted-substitution evidence). Apply ? on T to bridge the B3 inner-left:

\begin{aligned} &\ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, \texttt{su}(a_0)/x))})} \approx \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{su}(a_0)/x))} \in \mathcal{U}_i && \text{(\Cref{lem:sem-ty-id})} \end{aligned}

Both B2 and B3 inner-left values are now \mathcal{U}_i-related to the common value \ensuremath{\llbracket T \rrbracket((\ensuremath{\llbracket \sigma \rrbracket(\rho)}, \texttt{su}(a_0)/x))}, so by transitivity and ?, R_{B2} \Leftrightarrow R_{B3}.

Chaining: R_s \Leftrightarrow R_{B2} \Leftrightarrow R_{B3} \Leftrightarrow R_T. Hence b \approx b' \in R_T.

Case

Mathpar.

e e’ Ne ^N(e) ^N(e’) Nat

with a = {\uparrow}^N(e), a' = {\uparrow}^N(e'). Compute the eliminator outputs by rec-ne:

\begin{aligned} &\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, {\uparrow}^N(e)/x))} \searrow A && \text{(governing the left motive)} \\ &\ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, {\uparrow}^N(e')/x))} \searrow A' && \text{(governing the right motive)} \\ &A \approx A' \in \mathcal{U}_i \searrow R_T && \text{(by the second claim at ${\uparrow}^N(e) \approx {\uparrow}^N(e')$)} \\ &\ensuremath{\llbracket z[\sigma] \rrbracket(\rho)} \searrow a_z,\;\; \ensuremath{\llbracket z' \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \searrow a_z',\;\; a_z \approx a_z' \in R_z && \text{(by hypothesis on $z, z'$)} \\ &b = {\uparrow}^A(\mathsf{rec}(T[q(\sigma)], a_z, s[q^2(\sigma)], \rho, e)) && \text{(by \textsc{rec-ne})} \\ &b' = {\uparrow}^{A'}(\mathsf{rec}(T', a_z', s', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}, e')) && \text{(by \textsc{rec-ne})} \end{aligned}

We must show b \approx b' \in R_T. By ? on A \approx A' \in \mathcal{U}_i \searrow R_T, it suffices to show

\begin{aligned} &\mathsf{rec}(T[q(\sigma)], a_z, s[q^2(\sigma)], \rho, e) \approx \mathsf{rec}(T', a_z', s', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}, e') \in \textsf{Ne}, \end{aligned}

i.e. for every depth n both sides read back via \textsf{R}^{\textsf{Ne}}_n to the same neutral normal form. By rule Re-rec:

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_n(\mathsf{rec}(T[q(\sigma)], a_z, s[q^2(\sigma)], \rho, e)) \searrow \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u} \end{aligned}

whenever

\begin{aligned} &\textsf{R}^{\textsf{Ty}}_{n+1}(A_x) \searrow W_T && \text{where $\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, {\uparrow}^N(\ell_n)/x))} \searrow A_x$} \\ &\textsf{R}^{\textsf{Nf}}_n({\downarrow}^{A_z}(a_z)) \searrow w_z && \text{where $\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{ze}/x))} \searrow A_z$} \\ &\ensuremath{\llbracket s[q^2(\sigma)] \rrbracket((\rho, {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_x}(\ell_{n+1})/y))} \searrow b_s \\ &\textsf{R}^{\textsf{Nf}}_{n+2}({\downarrow}^{A_x^{\textsf{succ}~}}(b_s)) \searrow w_s && \text{where $\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{su}({\uparrow}^N(\ell_n))/x))} \searrow A_x^{\textsf{succ}~}$} \\ &\textsf{R}^{\textsf{Ne}}_n(e) \searrow u \end{aligned}

and analogously for the primed side, producing \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T')~w_z'~(x, y.\,w_s')~u'}. We show each component reads back to the same syntactic form.

Motive W_T = W_T'. Apply the second claim of this lemma at the fresh-level relation {\uparrow}^N(\ell_n) \approx {\uparrow}^N(\ell_n) \in \textsf{Nat} (by Nat-Ne, \ell_n \approx \ell_n \in \textsf{Ne}):

\begin{aligned} &\ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, {\uparrow}^N(\ell_n)/x))} \approx \ensuremath{\llbracket T' \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, {\uparrow}^N(\ell_n)/x))} \in \mathcal{U}_i \searrow R_T^\ell && \text{(second claim at $\ell_n$)} \\ &W_T = W_T' && \text{(by \Cref{lem:type-readback})} \end{aligned}

No separate env-pair construction is needed: the second claim is parametric in a \approx a' \in \textsf{Nat} and directly relates the two motive values at envs over the heterogeneous source–target contexts.

Zero branch w_z = w_z'. By the Nat-Ze sub-case proved above, a_z \approx a_z' \in R_T-at-\texttt{ze} (the PER governed by \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{ze}/x))}, which equals A_z). By ?:

\begin{aligned} &w_z = w_z' && \text{(by \Cref{lem:R-readback})} \end{aligned}

Step branch w_s = w_s'. We obtain b_s \approx b_s' at fresh levels by replaying the Nat-Su case with a_0 := {\uparrow}^N(\ell_n). First, lift \sigma, \sigma' to handle the binders of s:

\begin{aligned} &\semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}]{q(\sigma)}{q(\sigma')}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(by \Cref{lem:sem-q} on $\sigma \approx \sigma'$ and $\ensuremath{\texttt{Nat}}$)} \\ &\semtyeq[\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]] {q^2(\sigma)}{q^2(\sigma')}{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T} && \text{(by \Cref{lem:sem-q} again on $T$)} \end{aligned}

Build the env-pair via two applications of Ctx-Ext:

\begin{aligned} &{\uparrow}^N(\ell_n) \approx {\uparrow}^N(\ell_n) \in \textsf{Nat} && \text{(\textsc{Nat-Ne}, $\ell_n \approx \ell_n \in \textsf{Ne}$)} \\ &(\rho, {\uparrow}^N(\ell_n)/x) \approx (\rho', {\uparrow}^N(\ell_n)/x) \in R_{\Gamma', x:\ensuremath{\texttt{Nat}}} && \text{(\textsc{Ctx-Ext}, head $\textsf{Nat}$)} \\ &{\uparrow}^{A_x}(\ell_{n+1}) \approx {\uparrow}^{A_x'}(\ell_{n+1}) \in R_T^\ell && \text{(by \Cref{lem:ne-in-R} on $\ell_{n+1} \approx \ell_{n+1} \in \textsf{Ne}$)} \\ &(\rho, {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_x}(\ell_{n+1})/y) \\ &\quad \approx (\rho', {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_x'}(\ell_{n+1})/y) \in R_{\Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)]} && \text{(\textsc{Ctx-Ext}, head $R_T^\ell$)} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s'}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} at \Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)], the doubly-lifted substitution q^2(\sigma) \approx q^2(\sigma'), and this env-pair. The four-value pattern of s, s' gives:

\begin{aligned} &b_s \approx b_s' \in R_T^{step} && \text{(outer-left vs inner-right, parallel to the helper's} \\ & && \text{Nat-Su case)} \end{aligned}

where R_T^{step} is governed by \ensuremath{\llbracket (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[q^2(\sigma)] \rrbracket((\rho, {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_x}(\ell_{n+1})/y))}.

By the B1/B2/B3 bridging of the Nat-Su case (with a_0 replaced by {\uparrow}^N(\ell_n)):

\begin{aligned} &R_T^{step} \Leftrightarrow R_T^\ell\text{-at-}\texttt{su}({\uparrow}^N(\ell_n)) && \text{(B1/B2/B3 bridges, \Cref{lem:univ-functional})} \end{aligned}

i.e. the PER at \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \texttt{su}({\uparrow}^N(\ell_n))/x))}, which equals A_x^{\textsf{succ}~}. Hence b_s \approx b_s' \in R_T^\ell-at-\texttt{su}(\ell_n), and:

\begin{aligned} &w_s = w_s' && \text{(by \Cref{lem:R-readback})} \end{aligned}

Underlying neutral u = u'. By hypothesis e \approx e' \in \textsf{Ne}:

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_n(e) \searrow u,\;\; \textsf{R}^{\textsf{Ne}}_n(e') \searrow u && \text{(by definition of $\textsf{Ne}$)} \end{aligned}

Combining:

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_n(\mathsf{rec}(T[q(\sigma)], a_z, s[q^2(\sigma)], \rho, e)) \searrow \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u} \\ &\textsf{R}^{\textsf{Ne}}_n(\mathsf{rec}(T', a_z', s', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}, e')) \searrow \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u} && \text{(same syntactic form)} \\ &\mathsf{rec}(T[q(\sigma)], a_z, s[q^2(\sigma)], \rho, e) \approx \mathsf{rec}(T', a_z', s', \ensuremath{\llbracket \sigma' \rrbracket(\rho')}, e') \in \textsf{Ne} && \text{(definition of $\textsf{Ne}$)} \end{aligned}

Hence b \approx b' \in R_T.

Lemma

Lemma 6.63 (Fundamental — N-E / Rec-Cong)

TI5E

If \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma]{z}{z'}{T[\textsf{zero}/x]}, \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s'}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]}, and \semtyeq[\Gamma]{t}{t'}{\ensuremath{\texttt{Nat}}}, then \semtyeq[\Gamma]{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t}}{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z'~(x, y.\, s')~t'}}{T[t/x]}.

Proof of Lemma 6.63

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. Write \rho_\sigma := \ensuremath{\llbracket \sigma \rrbracket(\rho)} and \rho_{\sigma'} := \ensuremath{\llbracket \sigma' \rrbracket(\rho')}. From \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} at \ensuremath{\textsf{id}}, \ensuremath{\mathcal{D}}: \rho_\sigma \approx \rho_{\sigma'} \in R_\Gamma where \Gamma \approx \Gamma \searrow R_\Gamma.

By \semtyeq[\Gamma]{t}{t'}{\ensuremath{\texttt{Nat}}} applied at \Gamma', \sigma \approx \sigma', \rho \approx \rho' \in R':

\begin{aligned} &\{\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\rho_\sigma)},\; \ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})},\; \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')}\} \subseteq \textsf{Nat} && \text{(by hypothesis on $t, t'$)} \end{aligned}

Compute the four eliminator term values:

\begin{aligned} &\ensuremath{\llbracket (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t})[\sigma] \rrbracket(\rho)} && \text{(definition of substitution} \\ & \quad = \ensuremath{\llbracket \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\, s[q^2(\sigma)])~t[\sigma]} \rrbracket(\rho)} && \text{on $\textsf{elim}_{\ensuremath{\texttt{Nat}}}$)} \\ &\quad = \mathsf{rec}(\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) && \text{(by ev-rec)} \\[4pt] &\ensuremath{\llbracket \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t} \rrbracket(\rho_\sigma)} \\ & \quad = \mathsf{rec}(\ensuremath{\llbracket t \rrbracket(\rho_\sigma)},\, T,\, z,\, s,\, \rho_\sigma) && \text{(by ev-rec)} \end{aligned}

Analogous computations for the primed pair (using z', s', t'): \mathsf{rec}(\ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')},\, T[q(\sigma')],\, z'[\sigma'],\, s'[q^2(\sigma')],\, \rho') and \mathsf{rec}(\ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})},\, T,\, z',\, s',\, \rho_{\sigma'}).

Before applying the helpers, derive reflexive instances of all hypotheses (the helpers’ RHS are in primed form; we sometimes need unprimed-to-unprimed instances):

\begin{aligned} &\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(reflexive, by \Cref{lem:fund-sym,lem:fund-trans} on $T \approx T'$)} \\ &\semtyeq[\Gamma]{z}{z}{T[\textsf{zero}/x]} && \text{(reflexive)} \\ &\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} && \text{(reflexive)} \\ &\semtyeq[\Gamma]{t}{t}{\ensuremath{\texttt{Nat}}} && \text{(reflexive)} \\ &\semtyeq[\Gamma']{\sigma}{\sigma}{\Gamma} && \text{(reflexive)} \end{aligned}

(Primed analogues hold symmetrically.)

Inner pair via the unsubstituted helper. Apply ? at T \approx T (reflexive), z \approx z', s \approx s', R_\Gamma, env-pair \rho_\sigma \approx \rho_{\sigma'}, and witness \ensuremath{\llbracket t \rrbracket(\rho_\sigma)} \approx \ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})} \in \textsf{Nat} (inner-left vs inner-right of the four-value pattern of t, t'):

\begin{aligned} &\mathsf{rec}(\ensuremath{\llbracket t \rrbracket(\rho_\sigma)},\, T,\, z,\, s,\, \rho_\sigma) \searrow b_i \\ &\mathsf{rec}(\ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})},\, T,\, z',\, s',\, \rho_{\sigma'}) \searrow b_i' \\ &b_i \approx b_i' \in R_T && \text{(by \Cref{lem:sem-rec})} \end{aligned}

where R_T is governed by \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \ensuremath{\llbracket t \rrbracket(\rho_\sigma)}/x))} \approx \ensuremath{\llbracket T \rrbracket((\rho_{\sigma'}, \ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})}/x))} \in \mathcal{U}_i \searrow R_T. These match the goal’s inner-left and inner-right term values.

Outer-vs-inner via the one-sided helper. Apply ? at T \approx T, z \approx z, s \approx s (all reflexive), \Gamma' \approx \Gamma' \searrow R', \sigma \approx \sigma (reflexive), \rho \approx \rho \in R' (reflexive), and witness \ensuremath{\llbracket t[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket t \rrbracket(\rho_\sigma)} \in \textsf{Nat} (outer-left vs inner-left of the four-value pattern of t):

\begin{aligned} &\mathsf{rec}(\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) \searrow b_o \\ &\mathsf{rec}(\ensuremath{\llbracket t \rrbracket(\rho_\sigma)},\, T,\, z,\, s,\, \rho_\sigma) \searrow b_i \\ &b_o \approx b_i \in R_T^{oi} && \text{(by \Cref{lem:sem-rec-subst})} \end{aligned}

where R_T^{oi} is governed by \ensuremath{\llbracket T[q(\sigma)] \rrbracket((\rho, \ensuremath{\llbracket t[\sigma] \rrbracket(\rho)}/x))} \approx \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \ensuremath{\llbracket t \rrbracket(\rho_\sigma)}/x))} \in \mathcal{U}_i \searrow R_T^{oi}. By ?, R_T^{oi} \Leftrightarrow R_T. Hence b_o \approx b_i \in R_T.

Apply ? symmetrically at the primed reflexive instances (T' \approx T', z' \approx z', s' \approx s', \sigma' \approx \sigma', \rho' \approx \rho' \in R'), with witness \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})} \in \textsf{Nat}:

\begin{aligned} &b_o' \approx b_i' \in R_T && \text{(by \Cref{lem:sem-rec-subst} and \Cref{lem:univ-functional})} \end{aligned}

Combining. We assemble the four goal term values:

\begin{aligned} &b_i \approx b_i' \in R_T && \text{(inner pair, above)} \\ &b_o \approx b_i \in R_T && \text{(outer-vs-inner, left side, above)} \\ &b_o' \approx b_i' \in R_T && \text{(outer-vs-inner, right side, above)} \\ &b_o \approx b_o' \in R_T && \text{(by symmetry and transitivity of $R_T$)} \end{aligned}

Thus all four goal term values \{b_o, b_i, b_i', b_o'\} are pairwise related in R_T.

Type part. The goal type is T[t/x] on the LHS and T[t'/x] on the RHS (by the syntactic conclusion’s type, via the four-value pattern of the outer \semtyeq[\Gamma]{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(\ldots)~\ldots~(\ldots)~t}}{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(\ldots)~\ldots~(\ldots)~t'}}{T[t/x]} semantic judgment). We bridge the four goal type values via outer and inner instantiations of T \approx T'.

Outer instantiation. By ? on \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \semtyeq[\Gamma]{t}{t'}{\ensuremath{\texttt{Nat}}}:

\begin{aligned} &\semtyeq[\Gamma']{(\sigma, t[\sigma]/x)}{(\sigma', t'[\sigma']/x)}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(\Cref{lem:sem-ext-pre})} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma', this semantic substitution, and \rho \approx \rho' \in R':

\begin{aligned} &\{\ensuremath{\llbracket T[\sigma, t[\sigma]/x] \rrbracket(\rho)},\; \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \ensuremath{\llbracket t[\sigma] \rrbracket(\rho)}/x))}, \\ &\quad \ensuremath{\llbracket T' \rrbracket((\rho_{\sigma'}, \ensuremath{\llbracket t'[\sigma'] \rrbracket(\rho')}/x))},\; \ensuremath{\llbracket T'[\sigma', t'[\sigma']/x] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T^{out} && \text{(by hypothesis on $T \approx T'$)} \\ &T[\sigma, t[\sigma]/x] = && \text{(by \Cref{lem:subst-ext-comm})} \\ &T'[\sigma', t'[\sigma']/x] = (T'[t'/x])[\sigma'] && \text{(by \Cref{lem:subst-ext-comm})} \end{aligned}

Now the goal’s outer-RHS type is \ensuremath{\llbracket \rrbracket(\rho')}, but the outer instantiation gives \ensuremath{\llbracket (T'[t'/x])[\sigma'] \rrbracket(\rho')}. We show these coincide modulo \mathcal{U}_i:

\begin{aligned} &\ensuremath{\llbracket \rrbracket(\rho')} \approx \ensuremath{\llbracket (T'[t'/x])[\sigma'] \rrbracket(\rho')} \in \mathcal{U}_i && \text{(four-value pattern of $T \approx T'$ at } \\ & && \text{the outer-RHS instantiation, applied} \\ & && \text{at $(\sigma', t'[\sigma']/x)$ with $\rho' \approx \rho' \in R'$)} \end{aligned}

So the four values lie in \mathcal{U}_i \searrow R_T^{out} with the outer-LHS value exactly matching the goal’s \ensuremath{\llbracket \rrbracket(\rho)} and the outer-RHS value matching the goal’s \ensuremath{\llbracket \rrbracket(\rho')} (modulo \mathcal{U}_i, hence by ?).

Inner instantiation. By ? over \Gamma on \semtyeq[\Gamma]{\ensuremath{\textsf{id}}}{\ensuremath{\textsf{id}}}{\Gamma} and \semtyeq[\Gamma]{t}{t'}{\ensuremath{\texttt{Nat}}}:

\begin{aligned} &\semtyeq[\Gamma]{(\ensuremath{\textsf{id}}, t/x)}{(\ensuremath{\textsf{id}}, t'/x)}{\Gamma, x:\ensuremath{\texttt{Nat}}} && \text{(\Cref{lem:sem-ext-pre})} \end{aligned}

Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T'}{\ensuremath{\texttt{Ty}_{i}}} at \Gamma, this semantic substitution, and \rho_\sigma \approx \rho_{\sigma'} \in R_\Gamma:

\begin{aligned} &\{\ensuremath{\llbracket T[\ensuremath{\textsf{id}}, t/x] \rrbracket(\rho_\sigma)},\; \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \ensuremath{\llbracket t \rrbracket(\rho_\sigma)}/x))}, \\ &\quad \ensuremath{\llbracket T' \rrbracket((\rho_{\sigma'}, \ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})}/x))},\; \ensuremath{\llbracket T'[\ensuremath{\textsf{id}}, t'/x] \rrbracket(\rho_{\sigma'})}\} \subseteq \mathcal{U}_i \searrow R_T^{in} && \text{(by hypothesis on $T \approx T'$)} \\ &T[\ensuremath{\textsf{id}}, t/x] = T[t/x] && \text{(definition of single substitution)} \\ &T'[\ensuremath{\textsf{id}}, t'/x] = T'[t'/x] && \text{(definition of single substitution)} \end{aligned}

Bridging. The inner-pair values \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \ensuremath{\llbracket t \rrbracket(\rho_\sigma)}/x))} (shared between outer and inner instantiations) and \ensuremath{\llbracket T' \rrbracket((\rho_{\sigma'}, \ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})}/x))} (shared) bridge the PERs:

\begin{aligned} &R_T^{out} \Leftrightarrow R_T^{in} && \text{(by \Cref{lem:univ-functional} on shared inner values)} \\ &\ensuremath{\llbracket T \rrbracket((\rho_\sigma, \ensuremath{\llbracket t \rrbracket(\rho_\sigma)}/x))} \approx \ensuremath{\llbracket T \rrbracket((\rho_{\sigma'}, \ensuremath{\llbracket t' \rrbracket(\rho_{\sigma'})}/x))} \in \mathcal{U}_i \searrow R_T && \text{(unsubstituted helper's $R_T$ governance)} \\ &R_T^{in} \Leftrightarrow R_T && \text{(by \Cref{lem:univ-functional} on the shared} \\ & && \text{inner-LHS value with the helper's $R_T$)} \end{aligned}

Hence all four goal type values lie in \mathcal{U}_i \searrow R_T, with the term values \{b_o, b_i, b_i', b_o'\} in R_T as established.

Lemma

Lemma 6.64 (Fundamental — Subsump)

49UR

If \semtyeq[\Gamma]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma]{t}{t}{S} and \Gamma \vDash S \subseteq T, then \semtyeq[\Gamma]{t}{t}{T}.

Proof of Lemma 6.64

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given.

Type part. By \semtyeq[\Gamma]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at the given data:

\begin{aligned} &\{\ensuremath{\llbracket T[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T && \text{(by hypothesis on $T$)} \end{aligned}

Term part. By \semtyeq[\Gamma]{t}{t}{S} at the given data:

\begin{aligned} &\{\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket S[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_S && \text{(by hypothesis on $S$)} \\ &\{\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')}\} \subseteq R_S && \text{(by hypothesis on $t$)} \end{aligned}

By \Gamma \vDash S \subseteq T at the given data:

\begin{aligned} &\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in \mathcal{U}_i && \text{(by semantic subtyping, commutation)} \\ &\ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in \mathcal{U}_i && \text{(by semantic subtyping, commutation)} \\ &\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} && \text{(by semantic subtyping)} \end{aligned}

By ? applied to the subtyping \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} together with \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \approx \ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in \mathcal{U}_i \searrow R_S and \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in \mathcal{U}_i \searrow R_T:

\begin{aligned} &R_S \subseteq R_T && \text{(by \Cref{lem:subty-respects})} \end{aligned}

Hence the four term values, which lie in R_S, also lie in R_T:

\begin{aligned} &\{\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')}\} \subseteq R_T && \text{(by $R_S \subseteq R_T$)} \end{aligned}
Lemma

Lemma 6.65 (Fundamental — \Pi-\beta)

BRXR

If \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S]{t}{t}{T} and \semtyeq[\Gamma]{s}{s}{S}, then \semtyeq[\Gamma]{(\lambda x.\,t)\;s}{t[s/x]}{T[s/x]}.

Proof of Lemma 6.65

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given.

LHS computation at \sigma, \rho. By the syntactic action of substitution on \lambda and application, then ev-app/ev-lam/closure-application:

\begin{aligned} &((\lambda x.\,t)\;s)[\sigma] = (\lambda x.\,t[q(\sigma)])\;s[\sigma] && \text{(syntactic, definition of substitution)} \\ &\ensuremath{\llbracket (\lambda x.\,t[q(\sigma)])\;s[\sigma] \rrbracket(\rho)} \searrow b_L \text{ where} \\ &\quad \ensuremath{\llbracket \lambda x.\,t[q(\sigma)] \rrbracket(\rho)} \searrow \lambda(t[q(\sigma)], \rho) && \text{(ev-lam)} \\ &\quad \ensuremath{\llbracket s[\sigma] \rrbracket(\rho)} \searrow a_s && \text{(some $a_s$)} \\ &\quad \lambda(t[q(\sigma)], \rho) \cdot a_s \searrow b_L && \text{(closure application:} \\ & && \text{$\ensuremath{\llbracket t[q(\sigma)] \rrbracket((\rho, a_s/x))} \searrow b_L$)} \end{aligned}

RHS expression at \sigma, \rho. Using the sugar [s/x] = [\ensuremath{\textsf{id}}, s/x] and ?, ?:

\begin{aligned} & = t[q(\sigma)][s[\sigma]/x] = t[\sigma, s[\sigma]/x] && \text{(by \Cref{lem:subst-ext-comm,lem:q-ext})} \end{aligned}

Let b_R satisfy \ensuremath{\llbracket t[\sigma, s[\sigma]/x] \rrbracket(\rho)} \searrow b_R (existence via the four-value pattern below). We relate b_L and b_R in the term PER via the four-value pattern of t on the extended substitution.

Relatedness. By ? on \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \semtyeq[\Gamma]{s}{s}{S}:

\begin{aligned} &\semtyeq[\Gamma']{(\sigma, s[\sigma]/x)}{(\sigma', s[\sigma']/x)}{\Gamma, x:S} && \text{(\Cref{lem:sem-ext-pre})} \end{aligned}

Apply \semtyeq[\Gamma, x:S]{t}{t}{T} at \Gamma', this extended substitution, and \rho \approx \rho' \in R'. Let R_T be the PER governing the four-value pattern of t at this instantiation; concretely, R_T is determined by the type four-value pattern of T at the same env-pair (carried by semantic typing of t : T):

\begin{aligned} &\{\ensuremath{\llbracket T[\sigma, s[\sigma]/x] \rrbracket(\rho)},\; \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)})}, \\ &\quad \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\sigma', s[\sigma']/x) \rrbracket(\rho')})},\; \ensuremath{\llbracket T[\sigma', s[\sigma']/x] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T \end{aligned}

The term four-value pattern then gives:

\begin{aligned} &\{\ensuremath{\llbracket t[\sigma, s[\sigma]/x] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)})}, \\ &\quad \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket (\sigma', s[\sigma']/x) \rrbracket(\rho')})},\; \ensuremath{\llbracket t[\sigma', s[\sigma']/x] \rrbracket(\rho')}\} \subseteq R_T && \text{(by hypothesis on $t$)} \end{aligned}

By the syntactic identity above (and analogously at \sigma', \rho'), the outer values coincide with the goal’s RHS outer-values \{\ensuremath{\llbracket \rrbracket(\rho)}, \ensuremath{\llbracket \rrbracket(\rho')}\}.

LHS values via four-value pattern of t at q(\sigma). We bridge b_L = \ensuremath{\llbracket t[q(\sigma)] \rrbracket((\rho, a_s/x))} to the inner-left value \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)})} above. By ? on \semtyeq[\Gamma']{\sigma}{\sigma}{\Gamma} (reflexive, via ?, ?) and \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}}:

\begin{aligned} &\semtyeq[\Gamma', x:S[\sigma]]{q(\sigma)}{q(\sigma)}{\Gamma, x:S} && \text{(\Cref{lem:sem-q})} \end{aligned}

The reflexive env-pair (\rho, a_s/x) \approx (\rho, a_s/x) in R_{\Gamma', x:S[\sigma]} holds via Ctx-Ext (head a_s \approx a_s reflexively in the head PER, tail \rho \approx \rho \in R'). Apply \semtyeq[\Gamma, x:S]{t}{t}{T} at \Gamma', x:S[\sigma], q(\sigma) \approx q(\sigma), and this env-pair (four-value pattern of t, outer-left vs inner-left):

\begin{aligned} &\ensuremath{\llbracket t[q(\sigma)] \rrbracket((\rho, a_s/x))} \approx \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a_s/x))})} \in R_T && \text{(four-value pattern of $t$)} \end{aligned}

Bridge \ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a_s/x))} to \ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)} in R_{\Gamma, x:S} pointwise. Both envs have head a_s:

\begin{aligned} &\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a_s/x))} = (\ensuremath{\llbracket \sigma[\Uparrow] \rrbracket((\rho, a_s/x))},\, a_s/x) && \text{(by $q(\sigma) = (\sigma[\Uparrow], 0/x)$, pointwise eval)} \\ &\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)} = (\ensuremath{\llbracket \sigma \rrbracket(\rho)},\, a_s/x) && \text{(pointwise eval; $\ensuremath{\llbracket s[\sigma] \rrbracket(\rho)} = a_s$)} \\ &\ensuremath{\llbracket \sigma[\Uparrow] \rrbracket((\rho, a_s/x))} \approx \ensuremath{\llbracket \sigma \rrbracket(\rho)} \in R_\Gamma && \text{(four-value pattern of $\sigma \approx \sigma$ at} \\ & && \text{$\semweak[\Gamma', x:S[\sigma]]{\Uparrow}{\Gamma'}$, env} \\ & && \text{$(\rho, a_s/x) \approx (\rho, a_s/x) \in R_{\Gamma', x:S[\sigma]}$;} \\ & && \text{using $\ensuremath{\llbracket \Uparrow \rrbracket((\rho, a_s/x))} = \rho$ pointwise)} \\ &\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a_s/x))} \approx \ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)} \in R_{\Gamma, x:S} && \text{(by \textsc{Ctx-Ext}, head $a_s \approx a_s$ reflexively)} \end{aligned}

Apply ? on the reflexive instance \semtyeq[\Gamma, x:S]{t}{t}{T} at this env-pair:

\begin{aligned} &\ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket((\rho, a_s/x))})} \approx \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)})} \in R_T && \text{(\Cref{lem:sem-ty-id})} \end{aligned}

By transitivity, b_L \approx \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket (\sigma, s[\sigma]/x) \rrbracket(\rho)})} in R_T (the inner-left value of the relatedness pattern). Symmetrically for the primed side.

Combining: all eight values (four LHS, four RHS) lie in R_T, so the LHS-RHS pair at each of the four positions is in R_T.

Type part. Already established: the type four-value pattern displayed above (in \mathcal{U}_i \searrow R_T) is the goal’s T[s/x] pattern, since T[\sigma, s[\sigma]/x] = by the syntactic identity used for the term part.

Lemma

Lemma 6.66 (Fundamental — \Pi-\eta)

95FL

If \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma]{t}{t}{\Pi(x:S).\,T}, then \semtyeq[\Gamma]{t}{\lambda x.\,(t[\Uparrow]\;x)}{{\Pi(x:S).\,T}}.

Proof of Lemma 6.66

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given.

LHS values. By \semtyeq[\Gamma]{t}{t}{\Pi(x:S).\,T} at \Gamma', \sigma \approx \sigma', \rho \approx \rho' \in R', the four evaluations of t are related in the function PER R:

\begin{aligned} &\{\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})},\; \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})},\; \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')}\} \subseteq R && \text{(by hypothesis on $t$)} \end{aligned}

with biconditional characterization f \approx f' \in R \;\leftrightarrow\; (\forall \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I.\; f \cdot a \approx f' \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I)).

RHS values. The RHS evaluates on the \sigma', \rho'-side only:

\begin{aligned} &\ensuremath{\llbracket (\lambda x.\,(t[\Uparrow]\;x))[\sigma'] \rrbracket(\rho')} \searrow f_o && \text{(syntactic and ev-lam)} \\ &\ensuremath{\llbracket \lambda x.\,(t[\Uparrow]\;x) \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \searrow f_i && \text{(ev-lam)} \end{aligned}

where f_o := \lambda(t[\Uparrow][q(\sigma')]\;x,\, \rho') and f_i := \lambda(t[\Uparrow]\;x,\, \ensuremath{\llbracket \sigma' \rrbracket(\rho')}).

Step 1: \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \approx f_o in R. By the biconditional, suffices to show: for every \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I, \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \cdot a \approx f_o \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I).

Compute f_o \cdot a':

\begin{aligned} &f_o \cdot a' = \ensuremath{\llbracket t[\Uparrow][q(\sigma')]\;x \rrbracket((\rho', a'/x))} && \text{(closure app)} \\ &\quad = \ensuremath{\llbracket t[\Uparrow][q(\sigma')] \rrbracket((\rho', a'/x))} \cdot a' && \text{(ev-app)} \\ &\quad = \ensuremath{\llbracket t[\sigma'[\Uparrow]] \rrbracket((\rho', a'/x))} \cdot a' && \text{(\Cref{lem:subst-assoc} and \Cref{lem:shift-ext}:} \\ & && \text{$\Uparrow \circ q(\sigma') = \sigma'[\Uparrow]$)} \end{aligned}

Bridge \ensuremath{\llbracket t[\sigma'[\Uparrow]] \rrbracket((\rho', a'/x))} \approx \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \in R:

\begin{aligned} &\semweak[\Gamma', x:S[\sigma']]{\Uparrow}{\Gamma'} && \text{(\Cref{lem:sem-wk-shift})} \\ &\semtyeq[\Gamma', x:S[\sigma']]{\sigma'[\Uparrow]}{\sigma'[\Uparrow]}{\Gamma} && \text{(\Cref{lem:sem-wk-subst} on $\sigma' \approx \sigma'$ refl.)} \end{aligned}

Apply hypothesis on t at \Gamma', x:S[\sigma'], \sigma'[\Uparrow] \approx \sigma'[\Uparrow], env-pair (\rho', a'/x) \approx (\rho', a'/x) \in R_{\Gamma', x:S[\sigma']}:

\begin{aligned} &\ensuremath{\llbracket t[\sigma'[\Uparrow]] \rrbracket((\rho', a'/x))} \\ &\quad \approx \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma'[\Uparrow] \rrbracket((\rho', a'/x))})} \in R && \text{(outer-left vs inner-left of $t$)} \end{aligned}

Apply hypothesis on \sigma' at the same data (\Uparrow as the weakening, env-pair as above), giving \ensuremath{\llbracket \sigma'[\Uparrow] \rrbracket((\rho', a'/x))} \approx \ensuremath{\llbracket \sigma' \rrbracket(\rho')} \in R_\Gamma (using \ensuremath{\llbracket \Uparrow \rrbracket((\rho', a'/x))} = \rho' pointwise). By ? on t:

\begin{aligned} &\ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma'[\Uparrow] \rrbracket((\rho', a'/x))})} \approx \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in R && \text{(\Cref{lem:sem-ty-id})} \end{aligned}

Chained with \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \approx \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \in R (four-value pattern of t, inner-left vs outer-left):

\begin{aligned} &\ensuremath{\llbracket t[\sigma'[\Uparrow]] \rrbracket((\rho', a'/x))} \approx \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \in R && \text{(transitivity)} \end{aligned}

Apply the biconditional of R at \ensuremath{\mathcal{D}}_I: \ensuremath{\llbracket t[\sigma'[\Uparrow]] \rrbracket((\rho', a'/x))} \cdot a \approx \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I). Since f_o \cdot a' = \ensuremath{\llbracket t[\sigma'[\Uparrow]] \rrbracket((\rho', a'/x))} \cdot a', by symmetry of R_O on the reflexive instance of \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \in R at a \approx a': \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \cdot a \approx f_o \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I).

Step 2: \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \approx f_i in R. Suffices to show: for every \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I, \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \cdot a \approx f_i \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I).

Compute:

\begin{aligned} &f_i \cdot a' = \ensuremath{\llbracket t[\Uparrow]\;x \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} && \text{(closure app)} \\ &\quad = \ensuremath{\llbracket t[\Uparrow] \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \cdot a' && \text{(ev-app)} \end{aligned}

Bridge \ensuremath{\llbracket t[\Uparrow] \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))} \approx \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in R via the four-value pattern of t (reflexive) at the new context \Gamma, x:S, \semweak[\Gamma, x:S]{\Uparrow}{\Gamma}, env-pair (\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x) \approx (\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x) \in R_{\Gamma, x:S}: outer-left \ensuremath{\llbracket t[\Uparrow] \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))}, inner-left \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket((\ensuremath{\llbracket \sigma' \rrbracket(\rho')}, a'/x))})} = \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} (pointwise). Apply biconditional at \ensuremath{\mathcal{D}}_I and the reflexive \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \approx \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} at a \approx a': \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \cdot a \approx f_i \cdot a' \in R_O(\ensuremath{\mathcal{D}}_I).

Combining. By the four-value pattern of t, all four LHS values are pairwise related in R. By Steps 1 and 2, \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')} \approx f_o and \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \approx f_i in R. By symmetry and transitivity of R, every LHS-RHS pair (e.g. \ensuremath{\llbracket t[\sigma] \rrbracket(\rho)} \approx f_o, \ensuremath{\llbracket t \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \approx f_i, etc.) lies in R.

Type part. By ? on \semtyeq[\Gamma]{S}{S}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S]{T}{T}{\ensuremath{\texttt{Ty}_{i}}}, the four-value pattern of \Pi(x:S).\,T in \mathcal{U}_i is established. The goal’s type is \Pi(x:S).\,T on both sides, exactly this pattern.

Lemma

Lemma 6.67 (Fundamental — N-\beta-Ze)

0D9U

If \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma]{z}{z}{T[\textsf{zero}/x]} and \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]}, then \semtyeq[\Gamma]{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~\textsf{zero}}}{z}{T[\textsf{zero}/x]}.

Proof of Lemma 6.67

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. Write \rho_\sigma := \ensuremath{\llbracket \sigma \rrbracket(\rho)} and \rho_{\sigma'} := \ensuremath{\llbracket \sigma' \rrbracket(\rho')}.

LHS computation on the \sigma, \rho- and \rho_\sigma-side. The LHS is \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~\textsf{zero}}. Outer-LHS at \sigma, \rho:

\begin{aligned} &\ensuremath{\llbracket (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~\textsf{zero}})[\sigma] \rrbracket(\rho)} \\ &\quad = \ensuremath{\llbracket \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\, s[q^2(\sigma)])~\textsf{zero}} \rrbracket(\rho)} && \text{(definition of substitution on $\textsf{elim}_{\ensuremath{\texttt{Nat}}}$)} \\ &\quad \searrow b && \text{(by ev-rec, $\ensuremath{\llbracket \textsf{zero} \rrbracket(\rho)} = \texttt{ze}$;} \\ & && \text{$\mathsf{rec}(\texttt{ze}, T[q(\sigma)], z[\sigma], s[q^2(\sigma)], \rho) \searrow b$)} \\ &b = \ensuremath{\llbracket z[\sigma] \rrbracket(\rho)} && \text{(by \textsc{rec-ze})} \end{aligned}

Inner-LHS at \rho_\sigma:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~\textsf{zero}} \rrbracket(\rho_\sigma)} \searrow b' && \text{(by ev-rec;} \\ & && \text{$\mathsf{rec}(\texttt{ze}, T, z, s, \rho_\sigma) \searrow b'$)} \\ &b' = \ensuremath{\llbracket z \rrbracket(\rho_\sigma)} && \text{(by \textsc{rec-ze})} \end{aligned}

RHS values on the \sigma', \rho'- and \rho_{\sigma'}-side. The RHS is z, evaluated directly:

\begin{aligned} &\ensuremath{\llbracket z[\sigma'] \rrbracket(\rho')} && \text{(outer-RHS)} \\ &\ensuremath{\llbracket z \rrbracket(\rho_{\sigma'})} && \text{(inner-RHS)} \end{aligned}

Relatedness. By \semtyeq[\Gamma]{z}{z}{T[\textsf{zero}/x]} at \Gamma', \sigma \approx \sigma', \rho \approx \rho' \in R' (four-value pattern of z):

\begin{aligned} &\{\ensuremath{\llbracket z[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket z \rrbracket(\rho_\sigma)},\; \ensuremath{\llbracket z \rrbracket(\rho_{\sigma'})},\; \ensuremath{\llbracket z[\sigma'] \rrbracket(\rho')}\} \subseteq R_z && \text{(by hypothesis on $z$)} \end{aligned}

where R_z is the PER governed by the type four-value pattern of T[\textsf{zero}/x]. The LHS values b, b' coincide with \ensuremath{\llbracket z[\sigma] \rrbracket(\rho)} and \ensuremath{\llbracket z \rrbracket(\rho_\sigma)} (the unprimed-side outer-LHS and inner-LHS of the z pattern). The RHS values \ensuremath{\llbracket z[\sigma'] \rrbracket(\rho')} and \ensuremath{\llbracket z \rrbracket(\rho_{\sigma'})} are exactly the primed-side outer-RHS and inner-RHS of the same pattern. Hence all four LHS-RHS pairs lie in R_z.

Bridge R_z \Leftrightarrow R_T (where R_T is the goal’s type PER, governed by \ensuremath{\llbracket T[\textsf{zero}/x][\sigma] \rrbracket(\rho)}): the goal’s type is also T[\textsf{zero}/x], so R_z = R_T (functionality of \mathcal{U}_i, ?).

Lemma

Lemma 6.68 (Fundamental — N-\beta-Su)

5XCQ

If \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma]{z}{z}{T[\textsf{zero}/x]} and \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} and \semtyeq[\Gamma]{t}{t}{\ensuremath{\texttt{Nat}}}, then \semtyeq[\Gamma] {\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~(\textsf{succ}~t)}} {s[t/x,\, \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t}/y]} {T[\textsf{succ}~t/x]}.

Proof of Lemma 6.68

Let \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. Write \rho_\sigma := \ensuremath{\llbracket \sigma \rrbracket(\rho)} and \rho_{\sigma'} := \ensuremath{\llbracket \sigma' \rrbracket(\rho')}. Let a = \ensuremath{\llbracket t \rrbracket(\rho_\sigma)}, a' = \ensuremath{\llbracket t \rrbracket(\rho_{\sigma'})}, b_t = \ensuremath{\llbracket t[\sigma] \rrbracket(\rho)}, b_{t'} = \ensuremath{\llbracket t[\sigma'] \rrbracket(\rho')}.

Denote E := \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~t} (the inner eliminator with scrutinee t; this is the recursive call appearing in the \beta-su rule). Define c_t := \ensuremath{\llbracket E[\sigma] \rrbracket(\rho)}, c_{t'} := \ensuremath{\llbracket E[\sigma'] \rrbracket(\rho')}, c := \ensuremath{\llbracket E \rrbracket(\rho_\sigma)}, c' := \ensuremath{\llbracket E \rrbracket(\rho_{\sigma'})} (the four evaluations of E at the corresponding positions; existence by termination of evaluation).

LHS computation. By the syntactic action of substitution on \textsf{elim}_{\ensuremath{\texttt{Nat}}}, ev-rec, and rec-su:

\begin{aligned} &\ensuremath{\llbracket (\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~(\textsf{succ}~t)})[\sigma] \rrbracket(\rho)} \\ &\quad = \ensuremath{\llbracket \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\, s[q^2(\sigma)])~(\textsf{succ}~t[\sigma])} \rrbracket(\rho)} && \text{(definition of substitution on $\textsf{elim}_{\ensuremath{\texttt{Nat}}}$)} \\ &\quad \searrow b_L && \text{(by ev-rec, $\ensuremath{\llbracket \textsf{succ}~t[\sigma] \rrbracket(\rho)} = \texttt{su}(b_t)$)} \\ &\mathsf{rec}(\texttt{su}(b_t),\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) \searrow b_L && \text{(rec-su needs predecessor's rec value)} \\ &\mathsf{rec}(b_t,\, T[q(\sigma)],\, z[\sigma],\, s[q^2(\sigma)],\, \rho) \searrow c_t && \text{(by ev-rec on $E[\sigma]$ evaluated at $\rho$;} \\ & && \text{$\ensuremath{\llbracket t[\sigma] \rrbracket(\rho)} = b_t$)} \\ &\ensuremath{\llbracket s[q^2(\sigma)] \rrbracket((\rho,\, b_t/x,\, c_t/y))} \searrow b_L && \text{(by \textsc{rec-su})} \end{aligned}

At the inner position:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~(\textsf{succ}~t)} \rrbracket(\rho_\sigma)} \searrow b_I && \text{(by ev-rec)} \\ &\mathsf{rec}(\texttt{su}(a),\, T,\, z,\, s,\, \rho_\sigma) \searrow b_I && \text{(rec-su)} \\ &\mathsf{rec}(a,\, T,\, z,\, s,\, \rho_\sigma) \searrow c && \text{(by ev-rec on $E$ at $\rho_\sigma$; $\ensuremath{\llbracket t \rrbracket(\rho_\sigma)} = a$)} \\ &\ensuremath{\llbracket s \rrbracket((\rho_\sigma,\, a/x,\, c/y))} \searrow b_I && \text{(by \textsc{rec-su})} \end{aligned}

RHS expression on the \sigma', \rho'-side. The RHS appears on the right of \approx in the goal, so the four-value pattern’s RHS values are \ensuremath{\llbracket \rrbracket(\rho')} (outer-RHS) and \ensuremath{\llbracket s[t/x, E/y] \rrbracket(\rho_{\sigma'})} (inner-RHS). By ?, ?, ?:

\begin{aligned} & = s[\sigma',\, t[\sigma']/x,\, E[\sigma']/y] && \text{(syntactic, composition of substitutions)} \end{aligned}

Doubly-extended semantic substitution. We need the recursive call to be semantically valid: by ?, \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{x}{x}{\ensuremath{\texttt{Nat}}}. By ? on T \approx T, z \approx z, s \approx s (all reflexive hypotheses, using ?, ?) and x \approx x:

\begin{aligned} &\semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}] {\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~x}}{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\, s)~x}}{T} && \text{(by \Cref{lem:fund-rec}, scrutinee $x$;} \\ & && \text{conclusion type $T[x/x] = T$)} \end{aligned}

By ? on \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, \semtyeq[\Gamma]{t}{t}{\ensuremath{\texttt{Nat}}}, and the above (with the head substitution computing E[\sigma] on the LHS, E[\sigma'] on the RHS):

\begin{aligned} &\Gamma' \vDash (\sigma,\, t[\sigma]/x,\, E[\sigma]/y) \\ &\quad \approx (\sigma',\, t[\sigma']/x,\, E[\sigma']/y) : \Gamma, x:\ensuremath{\texttt{Nat}}, y:T. \end{aligned}

Four-value pattern of s at the doubly-extended substitution. Apply \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} at the above substitution and \rho \approx \rho' \in R':

\begin{aligned} &\{\ensuremath{\llbracket s[\sigma, t[\sigma]/x, E[\sigma]/y] \rrbracket(\rho)},\; \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket (\sigma, t[\sigma]/x, E[\sigma]/y) \rrbracket(\rho)})}, \\ &\quad \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket (\sigma', t[\sigma']/x, E[\sigma']/y) \rrbracket(\rho')})},\; \ensuremath{\llbracket s[\sigma', t[\sigma']/x, E[\sigma']/y] \rrbracket(\rho')}\} \subseteq R_O && \text{(by hypothesis on $s$)} \end{aligned}

By substitution-extension evaluation:

\begin{aligned} &\ensuremath{\llbracket (\sigma, t[\sigma]/x, E[\sigma]/y) \rrbracket(\rho)} = (\rho_\sigma, b_t/x, c_t/y) && \text{(pointwise; head eval, $\ensuremath{\llbracket E[\sigma] \rrbracket(\rho)} = c_t$)} \\ &\ensuremath{\llbracket (\sigma', t[\sigma']/x, E[\sigma']/y) \rrbracket(\rho')} = (\rho_{\sigma'}, b_{t'}/x, c_{t'}/y) && \text{(symmetrically; $\ensuremath{\llbracket E[\sigma'] \rrbracket(\rho')} = c_{t'}$)} \end{aligned}

where c_{t'} is the corresponding recursive-call value. Hence the four values of the pattern read:

\begin{aligned} &\{\ensuremath{\llbracket s[\sigma, t[\sigma]/x, E[\sigma]/y] \rrbracket(\rho)},\; \ensuremath{\llbracket s \rrbracket((\rho_\sigma, b_t/x, c_t/y))}, \\ &\quad \ensuremath{\llbracket s \rrbracket((\rho_{\sigma'}, b_{t'}/x, c_{t'}/y))},\; \ensuremath{\llbracket s[\sigma', t[\sigma']/x, E[\sigma']/y] \rrbracket(\rho')}\} \subseteq R_O \end{aligned}

Identifying R_O. R_O is the PER returned by the type four-value pattern of T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] at the same doubly-extended substitution. We bridge it to the PER at \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \texttt{su}(a)/x))} (which is the goal’s type T[\textsf{succ}~t/x] evaluated at the inner position) via two steps.

Step (a): collapse the iterated substitution. Denote \tau_* := (\sigma, t[\sigma]/x, E[\sigma]/y) (the doubly-extended substitution from \Gamma' to \Gamma, x:\ensuremath{\texttt{Nat}}, y:T). The value \ensuremath{\llbracket (T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[\tau_*] \rrbracket(\rho)} governs R_O. By ? and ?:

\begin{aligned} &(T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[\tau_*] = T[(\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x) \circ \tau_*] && \text{(by \Cref{lem:subst-assoc})} \\ &(\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x) \circ \tau_* = ((\Uparrow \circ \Uparrow) \circ \tau_*,\, (\textsf{succ}~x_1)[\tau_*]/x) && \text{(by \Cref{lem:ext-comp})} \\ &(\Uparrow \circ \Uparrow) \circ \tau_* = \sigma && \text{(by \Cref{lem:shift-ext} twice, dropping} \\ & && \text{$E[\sigma]/y$ and $t[\sigma]/x$)} \\ &(\textsf{succ}~x_1)[\tau_*] = \textsf{succ}~x_1[\tau_*] = \textsf{succ}~t[\sigma] && \text{(by syntactic substitution; $\tau_*(1) = t[\sigma]$)} \end{aligned}

Hence the collapsed substitution is (\sigma,\, \textsf{succ}~t[\sigma]/x):

\begin{aligned} &(T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x])[\tau_*] = T[\sigma,\, \textsf{succ}~t[\sigma]/x] && \text{(by combining the above)} \end{aligned}

Step (b): instantiate hypothesis on T at the collapsed substitution. By the IH on \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{T}{\ensuremath{\texttt{Ty}_{i}}}, applied at \Gamma', the semantic substitution \semtyeq[\Gamma']{(\sigma, \textsf{succ}~t[\sigma]/x)}{(\sigma', \textsf{succ}~t[\sigma']/x)}{\Gamma, x:\ensuremath{\texttt{Nat}}} (by ? on \sigma \approx \sigma' and \textsf{succ}~t[\sigma] \approx \textsf{succ}~t[\sigma'] \in \textsf{Nat} via Nat-Su on the t-pattern), and \rho \approx \rho' \in R':

\begin{aligned} &\ensuremath{\llbracket T[\sigma, \textsf{succ}~t[\sigma]/x] \rrbracket(\rho)} \\ & \quad \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket (\sigma, \textsf{succ}~t[\sigma]/x) \rrbracket(\rho)})} \in \mathcal{U}_i \searrow R_O && \text{(four-value of $T$, outer-LHS vs inner-LHS)} \\ &\ensuremath{\llbracket (\sigma, \textsf{succ}~t[\sigma]/x) \rrbracket(\rho)} = (\rho_\sigma, \texttt{su}(b_t)/x) && \text{(pointwise eval; $\ensuremath{\llbracket \textsf{succ}~t[\sigma] \rrbracket(\rho)} = \texttt{su}(b_t)$)} \end{aligned}

Bridge \texttt{su}(b_t) to \texttt{su}(a): from the four-value pattern of t,

b_t = \ensuremath{\llbracket t[\sigma] \rrbracket(\rho)} \approx a = \ensuremath{\llbracket t \rrbracket(\rho_\sigma)} \in \textsf{Nat}

(outer-LHS vs inner-LHS), so \texttt{su}(b_t) \approx \texttt{su}(a) \in \textsf{Nat} by Nat-Su. By ? on T:

\begin{aligned} &\ensuremath{\llbracket T \rrbracket((\rho_\sigma, \texttt{su}(b_t)/x))} \approx \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \texttt{su}(a)/x))} \in \mathcal{U}_i && \text{(\Cref{lem:sem-ty-id})} \end{aligned}

By transitivity and ?, R_O is the PER at \ensuremath{\llbracket T \rrbracket((\rho_\sigma, \texttt{su}(a)/x))} — the goal’s type T[\textsf{succ}~t/x] inner-LHS value (since T[\textsf{succ}~t/x] evaluated at \rho_\sigma equals T at the inner-extended env, modulo the same bridge).

LHS-RHS bridging. The RHS outer-RHS value is \ensuremath{\llbracket \rrbracket(\rho')} = \ensuremath{\llbracket s[\sigma', t[\sigma']/x, E[\sigma']/y] \rrbracket(\rho')}, which is the outer-RHS of the four-value pattern of s above. Similarly, the RHS inner-RHS value \ensuremath{\llbracket s[t/x, E/y] \rrbracket(\rho_{\sigma'})} relates to \ensuremath{\llbracket s \rrbracket((\rho_{\sigma'}, b_{t'}/x, c_{t'}/y))} via the four-value pattern of s on the primed side (analogous to the LHS-side bridging below).

For LHS values (the \sigma, \rho- and \rho_\sigma-sides of the goal): the LHS computation gives b_L = \ensuremath{\llbracket s[q^2(\sigma)] \rrbracket((\rho, b_t/x, c_t/y))} at \sigma, \rho, and b_I = \ensuremath{\llbracket s \rrbracket((\rho_\sigma, a/x, c/y))} at \rho_\sigma. We bridge b_L to \ensuremath{\llbracket s \rrbracket((\rho_\sigma, b_t/x, c_t/y))} (the inner-LHS of the four-value pattern) via the four-value pattern of s \approx s (reflexive) at \Gamma', x:\ensuremath{\texttt{Nat}}, y:T[q(\sigma)], doubly-lifted substitution q^2(\sigma) \approx q^2(\sigma), and reflexive env-pair (\rho, b_t/x, c_t/y) \approx (\rho, b_t/x, c_t/y):

\begin{aligned} &\ensuremath{\llbracket s[q^2(\sigma)] \rrbracket((\rho, b_t/x, c_t/y))} \approx \ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket q^2(\sigma) \rrbracket((\rho, b_t/x, c_t/y))})} \in R_O && \text{(four-value pattern of $s$)} \\ &\ensuremath{\llbracket q^2(\sigma) \rrbracket((\rho, b_t/x, c_t/y))} \approx (\rho_\sigma, b_t/x, c_t/y) \in R_{\Gamma, x:\ensuremath{\texttt{Nat}}, y:T} && \text{(by \textsc{Ctx-Ext} twice and the four-value} \\ & && \text{pattern of $\sigma$ at $\Uparrow$ for the tail)} \\ &\ensuremath{\llbracket s \rrbracket(\ensuremath{\llbracket q^2(\sigma) \rrbracket((\rho, b_t/x, c_t/y))})} \approx \ensuremath{\llbracket s \rrbracket((\rho_\sigma, b_t/x, c_t/y))} \in R_O && \text{(\Cref{lem:sem-ty-id} on $s$)} \end{aligned}

Hence by transitivity, b_L \approx \ensuremath{\llbracket s \rrbracket((\rho_\sigma, b_t/x, c_t/y))} \in R_O.

For b_I = \ensuremath{\llbracket s \rrbracket((\rho_\sigma, a/x, c/y))}: bridge to \ensuremath{\llbracket s \rrbracket((\rho_\sigma, b_t/x, c_t/y))} via ? on s at the env-pair related by:

\begin{aligned} &b_t \approx a \in \textsf{Nat} && \text{(four-value pattern of $t$, outer-LHS vs inner-LHS)} \\ &c_t \approx c \in R_T\text{-at-}a && \text{(four-value pattern of $E$ at $\sigma$, outer-LHS vs inner-LHS;} \\ & && \text{using $E$ semantic by \Cref{lem:fund-rec})} \end{aligned}

giving \ensuremath{\llbracket s \rrbracket((\rho_\sigma, b_t/x, c_t/y))} \approx \ensuremath{\llbracket s \rrbracket((\rho_\sigma, a/x, c/y))} = b_I \in R_O. Hence b_L \approx b_I in R_O, and both are PER-related to the four-value pattern’s inner-LHS.

Symmetrically for the primed side. Combining: all four LHS values (\{b_L, b_I, b_I', b_L'\}) are pairwise related to the four RHS values (the four-value pattern of s outer/inner) in R_O, by transitivity through the inner-LHS/inner-RHS bridge.

Type part. The type four-value pattern is included in the application of \semtyeq[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{s}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]} above; by the same syntactic identity used for the term part, the goal’s type T[\textsf{succ}~t/x] pattern coincides with this type four-value pattern modulo the substitution-composition lemmas.

Lemma

Lemma 6.69 (Fundamental — Sub-Univ)

4HNE

If \ensuremath{\vDash \Gamma} and i \le j, then \Gamma \vDash \ensuremath{\texttt{Ty}_{i}} \subseteq \ensuremath{\texttt{Ty}_{j}}.

Proof of Lemma 6.69

By ? on \ensuremath{\vDash \Gamma} we obtain \Gamma \approx \Gamma \searrow R_\Gamma. Let \Gamma' with \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. We verify the three clauses of \Gamma \vDash \ensuremath{\texttt{Ty}_{i}} \subseteq \ensuremath{\texttt{Ty}_{j}} at the level k := 1 + \max(i, j).

Since \ensuremath{\texttt{Ty}_{i}} and \ensuremath{\texttt{Ty}_{j}} are closed terms, for any substitution \tau and any environment \rho_0 we have \ensuremath{\texttt{Ty}_{i}}[\tau] = \ensuremath{\texttt{Ty}_{i}}, \ensuremath{\texttt{Ty}_{j}}[\tau] = \ensuremath{\texttt{Ty}_{j}}, and by evaluation of the universe constructor \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\rho_0)} = U_i, \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{j}} \rrbracket(\rho_0)} = U_j.

Part (1).

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}}[\sigma] \rrbracket(\rho)} = U_i && \text{(closed term + evaluation of $\ensuremath{\texttt{Ty}_{i}}$)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = U_i && \text{(evaluation of $\ensuremath{\texttt{Ty}_{i}}$)} \\ &U_i \approx U_i \in \mathcal{U}_k \searrow (\mathcal{U}_i) && \text{(by \textsc{U-Univ}, since $i < k$)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}}[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} \in \mathcal{U}_k && \text{(reflexivity of the previous line)} \end{aligned}

Part (2). Symmetrically:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{j}}[\sigma'] \rrbracket(\rho')} = U_j = \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{j}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} && \text{(closed term + evaluation of $\ensuremath{\texttt{Ty}_{j}}$)} \\ &U_j \approx U_j \in \mathcal{U}_k \searrow (\mathcal{U}_j) && \text{(by \textsc{U-Univ}, since $j < k$)} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{j}}[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{j}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} \in \mathcal{U}_k && \text{(reflexivity)} \end{aligned}

Part (3). By <:-Univ with i \le j and j < k:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\ensuremath{\llbracket \sigma \rrbracket(\rho)})} = U_i \mathrel{<:_k} U_j = \ensuremath{\llbracket \ensuremath{\texttt{Ty}_{j}} \rrbracket(\ensuremath{\llbracket \sigma' \rrbracket(\rho')})} && \text{(by \textsc{$<$:-Univ})} \end{aligned}
Lemma

Lemma 6.70 (Fundamental — Sub-Pi)

HSQ8

If \semtyeq[\Gamma]{S_1}{S_1}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma]{S_2}{S_2}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma]{S_1}{S_2}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma, x:S_1]{T_1}{T_1}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma, x:S_2]{T_2}{T_2}{\ensuremath{\texttt{Ty}_{i}}}, and \Gamma, x:S_1 \vDash T_1 \subseteq T_2, then \Gamma \vDash \Pi(x:S_1).\,T_1 \subseteq \Pi(x:S_2).\,T_2.

Proof of Lemma 6.70

Let \Gamma' with \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. Write \rho_\sigma := \ensuremath{\llbracket \sigma \rrbracket(\rho)} and \rho_{\sigma'} := \ensuremath{\llbracket \sigma' \rrbracket(\rho')}.

We must verify the three clauses of \Gamma \vDash \Pi(x:S_1).\,T_1 \subseteq \Pi(x:S_2).\,T_2. Computing the four type values via substitution and evaluation of \Pi:

\begin{aligned} &\ensuremath{\llbracket (\Pi(x:S_1).\,T_1)[\sigma] \rrbracket(\rho)} = \Pi(\ensuremath{\llbracket S_1[\sigma] \rrbracket(\rho)},\; T_1[q(\sigma)],\; \rho) && \text{(by definition of substitution and evaluation on $\Pi$)} \\ &\ensuremath{\llbracket \Pi(x:S_1).\,T_1 \rrbracket(\rho_\sigma)} = \Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)},\; T_1,\; \rho_\sigma) && \text{(by evaluation on $\Pi$)} \\ &\ensuremath{\llbracket \Pi(x:S_2).\,T_2 \rrbracket(\rho_{\sigma'})} = \Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})},\; T_2,\; \rho_{\sigma'}) && \text{(by evaluation on $\Pi$)} \\ &\ensuremath{\llbracket (\Pi(x:S_2).\,T_2)[\sigma'] \rrbracket(\rho')} = \Pi(\ensuremath{\llbracket S_2[\sigma'] \rrbracket(\rho')},\; T_2[q(\sigma')],\; \rho') && \text{(by definition of substitution and evaluation on $\Pi$)} \end{aligned}

Part (1). By ? applied to \semtyeq[\Gamma]{S_1}{S_1}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S_1]{T_1}{T_1}{\ensuremath{\texttt{Ty}_{i}}}, we obtain \semtyeq[\Gamma]{\Pi(x:S_1).\,T_1}{\Pi(x:S_1).\,T_1}{\ensuremath{\texttt{Ty}_{i}}}. Instantiating its type-side four-value relation at \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \ensuremath{\mathcal{D}}, the outer-LHS-vs-inner-LHS leg yields:

\begin{aligned} &\Pi(\ensuremath{\llbracket S_1[\sigma] \rrbracket(\rho)},\, T_1[q(\sigma)],\, \rho) \approx \Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)},\, T_1,\, \rho_\sigma) \in \mathcal{U}_i && \text{(part (1))} \end{aligned}

Part (2). Symmetrically, by ? on S_2 and T_2 and the outer-RHS-vs-inner-RHS leg of its type-side four-value relation at the same data:

\begin{aligned} &\Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})},\, T_2,\, \rho_{\sigma'}) \approx \Pi(\ensuremath{\llbracket S_2[\sigma'] \rrbracket(\rho')},\, T_2[q(\sigma')],\, \rho') \in \mathcal{U}_i && \text{(part (2), via symmetry of $\mathcal{U}_i$)} \end{aligned}

Part (3). We must show \Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)}, T_1, \rho_\sigma) \mathrel{<:_i} \Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})}, T_2, \rho_{\sigma'}). We apply <:-Pi, which requires:

    \ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)} \approx \ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})} \in \mathcal{U}_i \searrow R_I for some R_I; for every \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I, \ensuremath{\llbracket T_1 \rrbracket(\rho_\sigma, a/x)} \mathrel{<:_i} \ensuremath{\llbracket T_2 \rrbracket(\rho_{\sigma'}, a'/x)}; \Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)}, T_1, \rho_\sigma) \approx \Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)}, T_1, \rho_\sigma) \in \mathcal{U}_i and \Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})}, T_2, \rho_{\sigma'}) \approx \Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})}, T_2, \rho_{\sigma'}) \in \mathcal{U}_i.

(a) Domain. Instantiate the type-side four-value relation of \semtyeq[\Gamma]{S_1}{S_2}{\ensuremath{\texttt{Ty}_{i}}} at \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \ensuremath{\mathcal{D}}:

\begin{aligned} &\{\ensuremath{\llbracket S_1[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)},\; \ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})},\; \ensuremath{\llbracket S_2[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_I && \text{(by hypothesis on $S_1, S_2$)} \end{aligned}

The inner-LHS-vs-inner-RHS pair gives \ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)} \approx \ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})} \in \mathcal{U}_i \searrow R_I.

(b) Codomain. By ? on \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \semtyeq[\Gamma]{S_1}{S_1}{\ensuremath{\texttt{Ty}_{i}}}:

\semtyeq[\Gamma', x:S_1[\sigma]]{q(\sigma)}{q(\sigma')}{\Gamma, x:S_1}.

By the first premise of the semantic substitution judgment, this carries (\Gamma', x:S_1[\sigma]) \approx (\Gamma', x:S_1[\sigma]) \searrow R'_{x:S_1[\sigma]} and (\Gamma, x:S_1) \approx (\Gamma, x:S_1) \searrow R_{\Gamma,x:S_1}.

Let \ensuremath{\mathcal{D}}_I :: a \approx a' \in R_I be given. By the biconditional of R'_{x:S_1[\sigma]} from Ctx-Ext, (\rho, a/x) \approx (\rho', a'/x) \in R'_{x:S_1[\sigma]} requires \rho \approx \rho' \in R' (which we have via \ensuremath{\mathcal{D}}) and a \approx a' \in R_H'(\ensuremath{\mathcal{D}}) where R_H' is the head family for R'_{x:S_1[\sigma]}, governed by \ensuremath{\llbracket S_1[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S_1[\sigma] \rrbracket(\rho')} \in \mathcal{U}_i \searrow R_H'(\ensuremath{\mathcal{D}}). By ? on the same left type \ensuremath{\llbracket S_1[\sigma] \rrbracket(\rho)} that governs both R_I (from (a)) and R_H'(\ensuremath{\mathcal{D}}), R_I \Leftrightarrow R_H'(\ensuremath{\mathcal{D}}). Hence a \approx a' \in R_H'(\ensuremath{\mathcal{D}}), and (\rho, a/x) \approx (\rho', a'/x) \in R'_{x:S_1[\sigma]}.

Apply \Gamma, x:S_1 \vDash T_1 \subseteq T_2 at \Gamma', x:S_1[\sigma] (with R'_{x:S_1[\sigma]}), the lifted substitution \semtyeq[\Gamma', x:S_1[\sigma]]{q(\sigma)}{q(\sigma')}{\Gamma, x:S_1}, and (\rho, a/x) \approx (\rho', a'/x) \in R'_{x:S_1[\sigma]}:

\begin{aligned} &\ensuremath{\llbracket T_1[q(\sigma)] \rrbracket(\rho, a/x)} \approx \ensuremath{\llbracket T_1 \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket(\rho, a/x)})} \in \mathcal{U}_i && \text{(part (1) of $T_1 \subseteq T_2$)} \\ &\ensuremath{\llbracket T_2[q(\sigma')] \rrbracket(\rho', a'/x)} \approx \ensuremath{\llbracket T_2 \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket(\rho', a'/x)})} \in \mathcal{U}_i && \text{(part (2))} \\ &\ensuremath{\llbracket T_1 \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket(\rho, a/x)})} \mathrel{<:_i} \ensuremath{\llbracket T_2 \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket(\rho', a'/x)})} && \text{(part (3))} \end{aligned}

We now bridge the inner-evaluations of q(\sigma) and q(\sigma') to the desired environments. Using the lifted-substitution four-value pattern (instantiated at the identity weakening on \Gamma', x:S_1[\sigma] with (\rho, a/x) \approx (\rho', a'/x)):

\begin{aligned} &\ensuremath{\llbracket q(\sigma) \rrbracket(\rho, a/x)} \approx (\rho_\sigma, a/x) \in R_{\Gamma, x:S_1} && \text{(outer-LHS vs inner-LHS in the four-value pattern)} \\ &\ensuremath{\llbracket q(\sigma') \rrbracket(\rho', a'/x)} \approx (\rho_{\sigma'}, a'/x) \in R_{\Gamma, x:S_1} && \text{(outer-RHS vs inner-RHS, symmetrically)} \end{aligned}

By ? on \semtyeq[\Gamma, x:S_1]{T_1}{T_1}{\ensuremath{\texttt{Ty}_{i}}} applied to the first relation, and on \semtyeq[\Gamma, x:S_2]{T_2}{T_2}{\ensuremath{\texttt{Ty}_{i}}} applied (after substituting S_1 for S_2 via the well-formedness premises) to the second:

\begin{aligned} &\ensuremath{\llbracket T_1 \rrbracket(\ensuremath{\llbracket q(\sigma) \rrbracket(\rho, a/x)})} \approx \ensuremath{\llbracket T_1 \rrbracket(\rho_\sigma, a/x)} \in \mathcal{U}_i && \text{(by \Cref{lem:sem-ty-id} on $T_1$)} \\ &\ensuremath{\llbracket T_2 \rrbracket(\ensuremath{\llbracket q(\sigma') \rrbracket(\rho', a'/x)})} \approx \ensuremath{\llbracket T_2 \rrbracket(\rho_{\sigma'}, a'/x)} \in \mathcal{U}_i && \text{(by \Cref{lem:sem-ty-id} on $T_2$)} \end{aligned}

By ? applied to the codomain subtyping above and these two \mathcal{U}_i-equivalences:

\begin{aligned} &\ensuremath{\llbracket T_1 \rrbracket(\rho_\sigma, a/x)} \mathrel{<:_i} \ensuremath{\llbracket T_2 \rrbracket(\rho_{\sigma'}, a'/x)} && \text{(by \Cref{lem:subty-respects})} \end{aligned}

(c) Self-relatedness. By ? on \semtyeq[\Gamma]{S_1}{S_1}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma, x:S_1]{T_1}{T_1}{\ensuremath{\texttt{Ty}_{i}}} instantiated at the same data, the inner-LHS-vs-inner-LHS leg of the resulting type-side four-value relation gives \Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)}, T_1, \rho_\sigma) \approx \Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)}, T_1, \rho_\sigma) \in \mathcal{U}_i. Symmetrically for S_2, T_2: \Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})}, T_2, \rho_{\sigma'}) \approx \Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})}, T_2, \rho_{\sigma'}) \in \mathcal{U}_i.

Conclusion. By <:-Pi with the four ingredients (a)–(c):

\begin{aligned} &\Pi(\ensuremath{\llbracket S_1 \rrbracket(\rho_\sigma)}, T_1, \rho_\sigma) \mathrel{<:_i} \Pi(\ensuremath{\llbracket S_2 \rrbracket(\rho_{\sigma'})}, T_2, \rho_{\sigma'}) && \text{(part (3))} \end{aligned}
Lemma

Lemma 6.71 (Fundamental — Sub-Trans)

LZ2S

If \Gamma \vDash S \subseteq T' and \Gamma \vDash T' \subseteq T, then \Gamma \vDash S \subseteq T.

Proof of Lemma 6.71

Let \Gamma' with \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. Write \rho_\sigma := \ensuremath{\llbracket \sigma \rrbracket(\rho)} and \rho_{\sigma'} := \ensuremath{\llbracket \sigma' \rrbracket(\rho')}. We must establish each clause of \Gamma \vDash S \subseteq T.

Part (1). Instantiate the first hypothesis \Gamma \vDash S \subseteq T' at this data; its clause (1) gives the goal:

\begin{aligned} &\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\rho_\sigma)} \in \mathcal{U}_i && \text{(by clause (1) of $\Gamma \vDash S \subseteq T'$)} \end{aligned}

Part (2). Instantiate the second hypothesis \Gamma \vDash T' \subseteq T at the same data; its clause (2) gives the goal:

\begin{aligned} &\ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})} \in \mathcal{U}_i && \text{(by clause (2) of $\Gamma \vDash T' \subseteq T$)} \end{aligned}

Part (3). From the two hypotheses at the same data:

\begin{aligned} &\ensuremath{\llbracket S \rrbracket(\rho_\sigma)} \mathrel{<:_i} \ensuremath{\llbracket T' \rrbracket(\rho_{\sigma'})} && \text{(by clause (3) of $\Gamma \vDash S \subseteq T'$)} \\ &\ensuremath{\llbracket T' \rrbracket(\rho_{\sigma'})} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})} && \text{(by clause (3) of $\Gamma \vDash T' \subseteq T$)} \\ &\ensuremath{\llbracket S \rrbracket(\rho_\sigma)} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})} && \text{(by transitivity of $<:_i$, \Cref{lem:subty-trans})} \end{aligned}

All three clauses of \Gamma \vDash S \subseteq T are now established.

Lemma

Lemma 6.72 (Fundamental — Sub-Eq)

GCSA

If \semtyeq[\Gamma]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} and \semtyeq[\Gamma]{S}{T}{\ensuremath{\texttt{Ty}_{i}}}, then \Gamma \vDash S \subseteq T.

Proof of Lemma 6.72

Let \Gamma' with \Gamma' \approx \Gamma' \searrow R', \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, and \ensuremath{\mathcal{D}} :: \rho \approx \rho' \in R' be given. Write \rho_\sigma := \ensuremath{\llbracket \sigma \rrbracket(\rho)} and \rho_{\sigma'} := \ensuremath{\llbracket \sigma' \rrbracket(\rho')}. We establish each clause of \Gamma \vDash S \subseteq T.

Part (1). Instantiate the type-side four-value relation of \semtyeq[\Gamma]{S}{T}{\ensuremath{\texttt{Ty}_{i}}} at \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma} and \ensuremath{\mathcal{D}}:

\begin{aligned} &\{\ensuremath{\llbracket S[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket S \rrbracket(\rho_\sigma)},\; \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})},\; \ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T && \text{(by hypothesis on $S, T$)} \end{aligned}

The outer-LHS-vs-inner-LHS leg gives \ensuremath{\llbracket S[\sigma] \rrbracket(\rho)} \approx \ensuremath{\llbracket S \rrbracket(\rho_\sigma)} \in \mathcal{U}_i, which is clause (1).

Part (2). Instantiate the type-side four-value relation of \semtyeq[\Gamma]{T}{T}{\ensuremath{\texttt{Ty}_{i}}} at the same data:

\begin{aligned} &\{\ensuremath{\llbracket T[\sigma] \rrbracket(\rho)},\; \ensuremath{\llbracket T \rrbracket(\rho_\sigma)},\; \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})},\; \ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')}\} \subseteq \mathcal{U}_i \searrow R_T' && \text{(by hypothesis on $T, T$)} \end{aligned}

The outer-RHS-vs-inner-RHS leg gives \ensuremath{\llbracket T[\sigma'] \rrbracket(\rho')} \approx \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})} \in \mathcal{U}_i, which is clause (2).

Part (3). From the four-value relation in part (1), the inner-LHS-vs-inner-RHS leg gives:

\begin{aligned} &\ensuremath{\llbracket S \rrbracket(\rho_\sigma)} \approx \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})} \in \mathcal{U}_i \searrow R_T && \text{(inner-LHS vs inner-RHS in the four-value pattern)} \end{aligned}

By ?:

\begin{aligned} &\ensuremath{\llbracket S \rrbracket(\rho_\sigma)} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\rho_{\sigma'})} && \text{(by \Cref{lem:univ-implies-subty})} \end{aligned}

This is clause (3).

Theorem

Theorem 6.73 (Fundamental Theorem)

4I78

The following statements hold:

    If \vdash \Gamma, then \vDash \Gamma. If \typing[\Gamma]{t}{T}, then \semtyeq[\Gamma]{t}{t}{T}. If \tyequiv[\Gamma]{t}{t'}{T}, then \semtyeq[\Gamma]{t}{t'}{T}. If \subty[\Gamma]{S}{T}, then \Gamma \vDash S \subseteq T.

Proof of Theorem 6.73

By mutual induction on the syntactic derivations. Each rule’s case follows by applying the corresponding semantic rule lemma (?, ?, ?, ?, ?, ?) to the IHs on the rule’s premises.

Theorem

Theorem 6.74 (Completeness of NbE)

H697

If \tyequiv[\Gamma]{s}{t}{T}, then \textsf{nbe}_\Gamma^T(s) = \textsf{nbe}_\Gamma^T(t). That is, judgmentally equal terms have the same normal form.

Proof of Theorem 6.74

By the fundamental theorem (?, statement (3)): \semtyeq[\Gamma]{s}{t}{T}. Unfolding, this means: for all \Gamma' \approx \Gamma' \searrow R', all \semtyeq[\Gamma']{\sigma}{\sigma'}{\Gamma}, all \rho \approx \rho' \in R', the evaluations of s and t are related in the appropriate PER.

We instantiate at:

    \Gamma' := \Gamma (by statement (1), \Gamma \approx \Gamma \searrow R for some R), \sigma := \sigma' := \ensuremath{\textsf{id}} (the identity substitution is semantic by ?), \rho := \rho' := {\uparrow}^\Gamma (the initial environment is in R by ?).

Since s[\ensuremath{\textsf{id}}] = s and t[\ensuremath{\textsf{id}}] = t, and \ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)} = \rho, we obtain:

\begin{aligned} &\ensuremath{\llbracket T \rrbracket({\uparrow}^\Gamma)} \approx \ensuremath{\llbracket T \rrbracket({\uparrow}^\Gamma)} \in \mathcal{U}_i \searrow R_T && \text{(type part, with LHS = RHS since $\sigma = \sigma'$ and $\rho = \rho'$)} \\ &\ensuremath{\llbracket s \rrbracket({\uparrow}^\Gamma)} \approx \ensuremath{\llbracket t \rrbracket({\uparrow}^\Gamma)} \in R_T && \text{(term part)} \end{aligned}

Let A = \ensuremath{\llbracket T \rrbracket({\uparrow}^\Gamma)}, a = \ensuremath{\llbracket s \rrbracket({\uparrow}^\Gamma)}, and b = \ensuremath{\llbracket t \rrbracket({\uparrow}^\Gamma)}. Then A \approx A \in \mathcal{U}_i \searrow R_T and a \approx b \in R_T.

By realizability (?): {\downarrow}^A(a) \approx {\downarrow}^A(b) \in \textsf{Nf}. Unfolding the definition of \textsf{Nf}: for all n, there exists w such that \textsf{R}^{\textsf{Nf}}_n({\downarrow}^A(a)) \searrow w and \textsf{R}^{\textsf{Nf}}_n({\downarrow}^A(b)) \searrow w.

Taking n = |\Gamma| (the length of \Gamma, which provides enough fresh names):

\begin{aligned} &\textsf{nbe}_\Gamma^T(s) = \textsf{R}^{\textsf{Nf}}_{|\Gamma|}({\downarrow}^{\ensuremath{\llbracket T \rrbracket({\uparrow}^\Gamma)}}(\ensuremath{\llbracket s \rrbracket({\uparrow}^\Gamma)})) = \textsf{R}^{\textsf{Nf}}_{|\Gamma|}({\downarrow}^A(a)) \searrow w \\ &\textsf{nbe}_\Gamma^T(t) = \textsf{R}^{\textsf{Nf}}_{|\Gamma|}({\downarrow}^{\ensuremath{\llbracket T \rrbracket({\uparrow}^\Gamma)}}(\ensuremath{\llbracket t \rrbracket({\uparrow}^\Gamma)})) = \textsf{R}^{\textsf{Nf}}_{|\Gamma|}({\downarrow}^A(b)) \searrow w \end{aligned}

Hence \textsf{nbe}_\Gamma^T(s) = w = \textsf{nbe}_\Gamma^T(t).

Definition

Definition 7.1 (Kripke weakening)

MJGG

The judgment \kweak[\Gamma]{\phi}{\Delta} states that \phi is a Kripke weakening from \Delta to \Gamma (i.e. \phi extends \Delta to \Gamma by appending entries on the left). It is defined inductively:

Mathpar.

id

STy_i

Equivalently, every Kripke weakening is a finite composition \Uparrow \circ \cdots \circ \Uparrow of \Uparrow’s (with \ensuremath{\textsf{id}} as the empty composition); no q(\phi) lifting is permitted.

Uses Definition 2.11 · Used by Proof, Proof, Proof
Lemma

Lemma 7.2 (Kripke weakenings are weakenings)

JUIC

If \kweak[\Gamma]{\phi}{\Delta}, then \weakening[\Gamma]{\phi}{\Delta}.

Proof of Lemma 7.2

By induction on \kweak[\Gamma]{\phi}{\Delta}.

\begin{aligned} &\textsc{KW-Id}: \weakening[\Gamma]{\ensuremath{\textsf{id}}}{\Gamma} && \text{(by \Cref{lem:wk-id-wt})} \\ &\textsc{KW-Shift}: \weakening[\Gamma]{\phi}{\Delta} \text{ (IH)} && \\ &\quad \weakening[\Gamma, x:S]{\Uparrow}{\Gamma} && \text{(by \Cref{lem:wk-shift-wt})} \\ &\quad \weakening[\Gamma, x:S]{\phi \circ \Uparrow}{\Delta} && \text{(by \Cref{lem:wk-comp-wt})} \end{aligned}
Lemma

Lemma 7.3 (Composition of Kripke weakenings)

R57T

If \kweak[\Gamma]{\psi}{\Delta} and \kweak[\Delta']{\phi}{\Gamma}, then \kweak[\Delta']{\psi \circ \phi}{\Delta}.

Proof of Lemma 7.3

By induction on \kweak[\Delta']{\phi}{\Gamma}.

\begin{aligned} &\textsc{KW-Id} \text{ (}\phi = \ensuremath{\textsf{id}}\text{): } \psi \circ \ensuremath{\textsf{id}} = \psi && \text{(by left-id of $\circ$)} \\ &\quad \kweak[\Delta']{\psi}{\Delta} && \text{(by hypothesis)} \\[2pt] &\textsc{KW-Shift} \text{ (}\phi = \phi_0 \circ \Uparrow\text{, } \Delta' = \Delta_0, x:S\text{)}: \\ &\quad \kweak[\Delta_0]{\psi \circ \phi_0}{\Delta} && \text{(by IH on $\phi_0$)} \\ &\quad \kweak[\Delta_0, x:S]{(\psi \circ \phi_0) \circ \Uparrow}{\Delta} && \text{(by \textsc{KW-Shift})} \\ &\quad \psi \circ (\phi_0 \circ \Uparrow) = (\psi \circ \phi_0) \circ \Uparrow && \text{(by associativity of $\circ$)} \\ &\quad \kweak[\Delta']{\psi \circ \phi}{\Delta} && \text{(by the above)} \end{aligned}
Definition

Definition 7.4 (Type Gluing Model \Uc_i^\ast)

W77K

The relation a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} is defined inductively by:

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

P Nat_i
El Nat_i N U_i^P El

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^P El

a U_i^P_I El_I
a a U_i R_I

  D :: b b R_I, c. T (, b/x) c c U_i^P_O(D) El_O(D)

(a, T, ) (a, T, ) U_i R

P _i(R_I, P_I, El_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a, T, ) U_i^P El

Definition

Definition 7.5 (Neutral Type Predicate \textsf{Neu}_i^e)

UVBY

The judgment \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e holds when:

    \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}, and for all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}, there exists u with \textsf{R}^{\textsf{Ne}}_{|\Delta|}(e) \searrow u and \tyequiv[\Delta]{S[\phi]}{u}{\ensuremath{\texttt{Ty}_{i}}}.

Definition

Definition 7.6 (Neutral Term Predicate \textsf{Neu}_i^e)

OEFB

The judgment \typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \textsf{Neu}_i^e holds when:

    \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e, \typing[\Gamma]{t}{S}, w \approx w \in \textsf{Ne}, and for all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}, there exists u with \textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow u and \tyequiv[\Delta]{t[\phi]}{u}{S[\phi]}.

Definition

Definition 7.7 (Natural Number Type Predicate \textsf{Nat}_i)

QWAM

\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i holds when \tyequiv[\Gamma]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}}.

Definition

Definition 7.8 (Natural Number Term Predicate \textsf{Nat}_i)

0DN2

The judgment \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nat}_i holds when \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i and \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nat}, where the latter is defined by:

Mathpar.

tzeroS tS ze Nat

t’S b’ Nat
tsucc t’S tS su(b’) Nat

tS ^N(w) Neu_i^e tS ^N(w) Nat

Definition

Definition 7.9 (Pi Type Predicate \Pi_i(R_I, P_I, \El_I, P_O))

B683

\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) holds when:

    There exist S_1, S_2 with \tyequiv[\Gamma]{S}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}}. For all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}: \typing[\Delta]{S_1[\phi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I. For all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}, and all s, b with \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I, and all \ensuremath{\mathcal{D}} :: b \approx b \in R_I: \typing[\Delta]{S_2[\iota(\phi), s/x]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_O(\ensuremath{\mathcal{D}}).

Definition

Definition 7.10 (Pi Term Predicate \Pi_i^{\El})

WEC9

\typing[\Gamma]{t}{S} \;\circledR\; f \in \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) holds when:

    \typing[\Gamma]{t}{S}. f \approx f \in R. \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O). For all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}, and all s, b with \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I, and all \ensuremath{\mathcal{D}} :: b \approx b \in R_I: there exists c with f \cdot b \searrow c and \typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}).

Definition

Definition 7.11 (Universe Type Predicate \textsf{Univ}_{i,j})

3YR1

\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j} holds when \tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}.

Definition

Definition 7.12 (Universe Term Predicate \textsf{Univ}_{i,j}^{\El})

VC4X

\typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}} holds when:

    \typing[\Gamma]{t}{S}, \tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}, and there exist P_b, \textbf{El}_b with b \in \mathcal{U}_j^\ast \searrow P_b \searrow \textbf{El}_b and \typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b (the term t, viewed as a type at \ensuremath{\texttt{Ty}_{j}} via Russell, glues to P_b).

Definition

Definition 7.13 (Normal Form Predicate \Nf_i^a)

ACYL

\typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nf}_i^a holds when:

    \typing[\Gamma]{t}{S}, {\downarrow}^a(b) \approx {\downarrow}^a(b) \in \textsf{Nf}, and for all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}, there exists w with \textsf{R}^{\textsf{Nf}}_{|\Delta|}({\downarrow}^a(b)) \searrow w and \tyequiv[\Delta]{t[\phi]}{w}{S[\phi]}.

Definition

Definition 7.14 (Neutral Predicate \Ne_i^a)

2M6S

\typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Ne}_i^a holds when:

    \typing[\Gamma]{t}{S}, w \approx w \in \textsf{Ne}, and for all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}, there exists u with \textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow u and \tyequiv[\Delta]{t[\phi]}{u}{S[\phi]}.

Definition

Definition 7.15 (Wrapped predicates \Botp_i^a and \Topp_i^a)

VNNM

The wrappers package gluing-side data with a uniform interface, parameterized by a domain value a \in \mathcal{U}_i^\ast. The judgment form distinguishes type-level from term-level use.

    (Term-bottom) \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Bot}_i^a holds when there exist P, \textbf{El} with a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} and:

      \typing[\Gamma]{t}{S}, \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P, and \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Ne}_i^a.

    (Type-top) \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Top}_i^a holds when:

      \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}, a \approx a \in \mathcal{U}_i \searrow R for some R, and for all \Delta, \phi with \kweak[\Delta]{\phi}{\Gamma}, there exists W with \textsf{R}^{\textsf{Ty}}_{|\Delta|}(a) \searrow W and \tyequiv[\Delta]{S[\phi]}{W}{\ensuremath{\texttt{Ty}_{i}}}.

    (Term-top) \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Top}_i^a holds when there exist P, \textbf{El} with a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} and:

      \typing[\Gamma]{t}{S}, \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P, and \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nf}_i^a.

Definition

Definition 7.16 (Context Gluing)

MUAY

Given a well-formed context \Gamma, the judgment \Gamma \searrow \textsf{Sb} defines a predicate \textsf{Sb} on substitution–environment pairs \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb}, inductively on \Gamma:

Mathpar.

Sb (: ) Sb

Sb_T
STy_i

’, _T, _T. _T : _T Sb_T
a, P, El. S (_T) a a U_i^P El S[_T]Ty_i P

Sb Cons_i(, S, Sb_T) (, x : S) Sb

Here \textsf{Cons}_i(\Gamma, S, \textsf{Sb}_T) holds at any \judge[\Delta]{\sigma : \Gamma, x:S} \;\circledR\; \rho when there exist i, a, P, \textbf{El} with:

    Substitution typing: \judge[\Delta]{\sigma : \Gamma, x:S}, Tail: \judge[\Delta]{\Uparrow \circ \sigma : \Gamma} \;\circledR\; \rho[\Uparrow] \in \textsf{Sb}_T, Type: \ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])} \searrow a, a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}, and \typing[\Delta]{S[\Uparrow \circ \sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P, and Head: \typing[\Delta]{x_0[\sigma]}{S[\Uparrow \circ \sigma]} \;\circledR\; \rho(x_0) \in \textbf{El}.

Here \Uparrow \circ \sigma drops the head, mapping index n to \sigma(n+1); the corresponding drop operation \rho[\Uparrow] on environments is from ?.

Definition

Definition 7.17 (Semantic context well-formedness)

62S6

We write \Vdash \Gamma to mean that the context-gluing predicate exists for \Gamma:

\Vdash \Gamma \quad \iff \quad \exists \textsf{Sb}.\; \Gamma \searrow \textsf{Sb}.

Syntactic well-formedness \vdash \Gamma is derivable as a consequence of \Vdash \Gamma (proved next).

Lemma

Lemma 7.18 (\Vdash \Gamma implies \vdash \Gamma)

3QL8

If \Vdash \Gamma, then \vdash \Gamma.

Proof of Lemma 7.18

By induction on the derivation of \Gamma \searrow \textsf{Sb}.

Case

Mathpar.

Sb (: ) Sb

\vdash \cdot holds by Ctx-Emp.

Case

Mathpar.

_0 Sb_T
STy_i

’, _T, _T. _T : _0 _T Sb_T
a, P, El. S (_T) a a U_i^P El S[_T]Ty_i P

Sb Cons_i(_0, S, Sb_T) (_0, x : S) Sb

\begin{aligned} &\vdash \Gamma_0 && \text{(by IH on $\Gamma_0 \searrow \textsf{Sb}_T$)} \\ &\typing[\Gamma_0]{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \textsc{G-Ctx-Ext} premise)} \\ &\vdash \Gamma_0, x:S && \text{(by \textsc{Ctx-Ext})} \end{aligned}
Theorem

Theorem 7.19 (Monotonicity)

82NZ

Suppose a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} and \kweak[\Delta']{\psi}{\Delta}.

    If \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P, then \typing[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P. If \typing[\Delta]{t}{S} \;\circledR\; b \in \textbf{El}, then \typing[\Delta']{t[\psi]}{S[\psi]} \;\circledR\; b \in \textbf{El}.

Proof of Theorem 7.19

By induction on the derivation a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}.

Case

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

Type predicate (1). Assume \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e. By ?:

\begin{aligned} &\typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:neu-type-pred} clause 1)} \\ &\forall \Delta'', \kweak[\Delta'']{\phi'}{\Delta}.\; \exists u.\; \textsf{R}^{\textsf{Ne}}_{|\Delta''|}(e) \searrow u \wedge \tyequiv[\Delta'']{S[\phi']}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:neu-type-pred} clause 2)} \end{aligned}

We must show \typing[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e.

\begin{aligned} &\typing[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:kweak-is-wk} on $\psi$ and \Cref{lem:wk-typing})} \end{aligned}

For the Kripke condition: take any \Delta'' with \kweak[\Delta'']{\phi'}{\Delta'}.

\begin{aligned} &\kweak[\Delta'']{\psi \circ \phi'}{\Delta} && \text{(by \Cref{lem:kweak-comp} on $\psi$ and $\phi'$)} \\ &\exists u.\; \textsf{R}^{\textsf{Ne}}_{|\Delta''|}(e) \searrow u \wedge \tyequiv[\Delta'']{S[\psi \circ \phi']}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by hypothesis on $S$ at the composed weakening)} \\ &S[\psi \circ \phi'] = S[\psi][\phi'] && \text{(by \Cref{sec:syn}'s substitution-composition law)} \\ &\tyequiv[\Delta'']{S[\psi][\phi']}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(rewriting)} \end{aligned}

This establishes the Kripke condition for S[\psi] at \textsf{Neu}_i^e.

Term predicate (2). Assume \typing[\Delta]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \textsf{Neu}_i^e. By ?:

\begin{aligned} &\typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e,\; \typing[\Delta]{t}{S},\; w \approx w \in \textsf{Ne} && \text{(\Cref{def:neu-term-pred} clauses 1--3)} \\ &\forall \Delta'', \kweak[\Delta'']{\phi'}{\Delta}.\; \exists u.\; \textsf{R}^{\textsf{Ne}}_{|\Delta''|}(w) \searrow u \wedge \tyequiv[\Delta'']{t[\phi']}{u}{S[\phi']} && \text{(\Cref{def:neu-term-pred} clause 4)} \end{aligned}

By type-predicate monotonicity (just proved): \typing[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e. \typing[\Delta']{t[\psi]}{S[\psi]} by ?. w \approx w \in \textsf{Ne} unchanged. Kripke condition: for \kweak[\Delta'']{\phi'}{\Delta'}, by ? \kweak[\Delta'']{\psi \circ \phi'}{\Delta}, hypothesis gives \textsf{R}^{\textsf{Ne}}_{|\Delta''|}(w) \searrow u and \tyequiv[\Delta'']{t[\psi \circ \phi']}{u}{S[\psi \circ \phi']}. By substitution composition: t[\psi \circ \phi'] = t[\psi][\phi'] and S[\psi \circ \phi'] = S[\psi][\phi'].

Case

Mathpar.

P Nat_i
El Nat_i N U_i^P El

Type predicate (1). Assume \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i, i.e. \tyequiv[\Delta]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}}.

\begin{aligned} &\tyequiv[\Delta']{S[\psi]}{\ensuremath{\texttt{Nat}}[\psi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:wk-typing})} \\ &\ensuremath{\texttt{Nat}}[\psi] = \ensuremath{\texttt{Nat}} && \text{(syntactic, $\ensuremath{\texttt{Nat}}$ closed)} \\ &\tyequiv[\Delta']{S[\psi]}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(rewriting)} \\ &\typing[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i && \text{(by \Cref{def:nat-type-pred})} \end{aligned}

Term predicate (2). Assume \typing[\Delta]{t}{S} \;\circledR\; b \in \textsf{Nat}_i. By inner induction on the derivation b \in \textsf{Nat}.

Sub-case

Mathpar.

tzeroS tS ze Nat

\begin{aligned} &\tyequiv[\Delta']{t[\psi]}{\textsf{zero}[\psi]}{S[\psi]} && \text{(by \Cref{lem:wk-typing})} \\ &\textsf{zero}[\psi] = \textsf{zero} && \text{(syntactic, $\textsf{zero}$ closed)} \\ &\tyequiv[\Delta']{t[\psi]}{\textsf{zero}}{S[\psi]} && \text{(rewriting)} \\ &\typing[\Delta']{t[\psi]}{S[\psi]} \;\circledR\; \texttt{ze} \in \textsf{Nat} && \text{(by \textsc{GN-Ze})} \end{aligned}

Sub-case

Mathpar.

t’S b’ Nat
tsucc t’S tS su(b’) Nat

\begin{aligned} &\typing[\Delta']{t'[\psi]}{S[\psi]} \;\circledR\; b' \in \textsf{Nat} && \text{(by inner IH on $b'$)} \\ &\tyequiv[\Delta']{t[\psi]}{(\textsf{succ}~t')[\psi]}{S[\psi]} && \text{(by \Cref{lem:wk-typing})} \\ &(\textsf{succ}~t')[\psi] = \textsf{succ}~(t'[\psi]) && \text{(syntactic substitution on $\textsf{succ}~$)} \\ &\tyequiv[\Delta']{t[\psi]}{\textsf{succ}~(t'[\psi])}{S[\psi]} && \text{(rewriting)} \\ &\typing[\Delta']{t[\psi]}{S[\psi]} \;\circledR\; \texttt{su}(b') \in \textsf{Nat} && \text{(by \textsc{GN-Su} on the IH)} \end{aligned}

Sub-case

Mathpar.

tS ^N(w) Neu_i^e tS ^N(w) Nat

\begin{aligned} &\typing[\Delta']{t[\psi]}{S[\psi]} \;\circledR\; {\uparrow}^N(w) \in \textsf{Neu}_i^e && \text{(by the \textsc{G-Ne} case above, applied to $\textsf{Neu}_i^e$)} \\ &\typing[\Delta']{t[\psi]}{S[\psi]} \;\circledR\; {\uparrow}^N(w) \in \textsf{Nat} && \text{(by \textsc{GN-Ne})} \end{aligned}

Case

Mathpar.

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^P El

Type predicate (1). Assume \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j}, i.e. \tyequiv[\Delta]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}.

\begin{aligned} &\tyequiv[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{j}}[\psi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:wk-typing})} \\ &\ensuremath{\texttt{Ty}_{j}}[\psi] = \ensuremath{\texttt{Ty}_{j}} && \text{(syntactic; $\ensuremath{\texttt{Ty}_{j}}$ closed)} \\ &\tyequiv[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(rewriting)} \\ &\typing[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j} && \text{(by \Cref{def:univ-type-pred})} \end{aligned}

Term predicate (2). Assume \typing[\Delta]{t}{S} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}}. By ?, b \in \mathcal{U}_j^\ast \searrow P_b \searrow \textbf{El}_b for some P_b, \textbf{El}_b, with \typing[\Delta]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b at level j and \tyequiv[\Delta]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}.

\begin{aligned} &\typing[\Delta']{t[\psi]}{\ensuremath{\texttt{Ty}_{j}}[\psi]} \;\circledR\; P_b && \text{(by IH at level $j$ on $b \in \mathcal{U}_j^\ast$, type predicate)} \\ &\ensuremath{\texttt{Ty}_{j}}[\psi] = \ensuremath{\texttt{Ty}_{j}} && \text{(syntactic; $\ensuremath{\texttt{Ty}_{j}}$ closed)} \\ &\typing[\Delta']{t[\psi]}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b && \text{(rewriting)} \\ &\tyequiv[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by type-predicate monotonicity (1) above)} \\ &\typing[\Delta']{t[\psi]}{S[\psi]} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}} && \text{(by \Cref{def:univ-term-pred} with the previous lines)} \end{aligned}

Case

Mathpar.

a U_i^P_I El_I
a a U_i R_I

  D :: b b R_I, c. T (, b/x) c c U_i^P_O(D) El_O(D)

(a, T, ) (a, T, ) U_i R

P _i(R_I, P_I, El_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a, T, ) U_i^P El

Type predicate (1). Assume \typing[\Delta]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O). By ?, this gives S_1, S_2 with \tyequiv[\Delta]{S}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} and the three clauses (well-formedness of S, domain-predicate, codomain-predicate). We must show \typing[\Delta']{S[\psi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O).

Clause 1: \Pi-shape equality.

\begin{aligned} &\tyequiv[\Delta]{S}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:pi-type-pred} clause 1)} \\ &\tyequiv[\Delta']{S[\psi]}{(\Pi(x:S_1).\,S_2)[\psi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:wk-typing})} \\ &(\Pi(x:S_1).\,S_2)[\psi] = \Pi(x:S_1[\psi]).\,(S_2[q(\psi)]) && \text{(by syntactic substitution on $\Pi$)} \\ &\tyequiv[\Delta']{S[\psi]}{\Pi(x:S_1[\psi]).\,(S_2[q(\psi)])}{\ensuremath{\texttt{Ty}_{i}}} && \text{(rewriting)} \end{aligned}

Clause 2: domain-predicate at every Kripke extension of \Delta'. Let \kweak[\Delta'']{\phi'}{\Delta'} be arbitrary.

\begin{aligned} &\kweak[\Delta'']{\psi \circ \phi'}{\Delta} && \text{(by \Cref{lem:kweak-comp})} \\ &\typing[\Delta'']{S_1[\psi \circ \phi']}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by hypothesis clause 2 at $\psi \circ \phi'$)} \\ &S_1[\psi \circ \phi'] = (S_1[\psi])[\phi'] && \text{(by \Cref{lem:subst-assoc})} \\ &\typing[\Delta'']{(S_1[\psi])[\phi']}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(rewriting)} \end{aligned}

Clause 3: codomain-predicate at every Kripke extension of \Delta' and every El-related b. Let \kweak[\Delta'']{\phi'}{\Delta'}, s, b, \ensuremath{\mathcal{D}} :: b \approx b \in R_I with \typing[\Delta'']{s}{(S_1[\psi])[\phi']} \;\circledR\; b \in \textbf{El}_I.

\begin{aligned} &\kweak[\Delta'']{\psi \circ \phi'}{\Delta} && \text{(by \Cref{lem:kweak-comp})} \\ &\typing[\Delta'']{s}{S_1[\psi \circ \phi']} \;\circledR\; b \in \textbf{El}_I && \text{(by \Cref{lem:subst-assoc} on the type)} \\ &\typing[\Delta'']{S_2[\iota(\psi \circ \phi'), s/x]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_O(\ensuremath{\mathcal{D}}) && \text{(by hypothesis clause 3 at $\psi \circ \phi', s, b, \ensuremath{\mathcal{D}}$)} \end{aligned}

This is the required predicate at the Kripke weakening \psi \circ \phi' for \Pi_i at S[\psi] over \Delta'.

Term predicate (2). Assume \typing[\Delta]{t}{S} \;\circledR\; f \in \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O). We verify the four clauses of ? at \typing[\Delta']{t[\psi]}{S[\psi]} and value f.

Clause 1: self-relatedness f \approx f \in R. Unchanged by Kripke weakening (PER fact, independent of \Delta).

Clause 2: R_I-coherence of f. Unchanged for the same reason.

Clause 3: type-readback of f at \Pi-shape. By type-predicate monotonicity (1) above, the \Pi_i-type predicate transfers to S[\psi] over \Delta', supplying the type-readback witnesses required by clause 3.

Clause 4: application. Let \kweak[\Delta'']{\phi'}{\Delta'}, s, b, \ensuremath{\mathcal{D}} :: b \approx b \in R_I with \typing[\Delta'']{s}{(S_1[\psi])[\phi']} \;\circledR\; b \in \textbf{El}_I.

\begin{aligned} &\kweak[\Delta'']{\psi \circ \phi'}{\Delta} && \text{(by \Cref{lem:kweak-comp})} \\ &\typing[\Delta'']{s}{S_1[\psi \circ \phi']} \;\circledR\; b \in \textbf{El}_I && \text{(by \Cref{lem:subst-assoc})} \\ &f \cdot b \searrow c && \text{(by hypothesis clause 4 at $\psi \circ \phi', s, b, \ensuremath{\mathcal{D}}$)} \\ &\typing[\Delta'']{(t[\psi \circ \phi'])\;s}{S_2[\iota(\psi \circ \phi'), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by hypothesis clause 4)} \\ &t[\psi \circ \phi'] = t[\psi][\phi'] && \text{(by \Cref{lem:subst-assoc})} \\ &\typing[\Delta'']{t[\psi][\phi']\;s}{S_2[\iota(\psi \circ \phi'), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(rewriting)} \end{aligned}

This is the required form for \Pi_i^{\textbf{El}} clause 4 at t[\psi] over \Delta' at the Kripke weakening \psi \circ \phi'.

Clause 5: R_I-coherence under application. Inherited from the original predicate’s clause 5 by composition with \psi as in clause 4.

Corollary

Corollary 7.20 (Context Gluing Monotonicity)

IQWD

If \Gamma \searrow \textsf{Sb}, \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb}, and \kweak[\Delta']{\psi}{\Delta}, then \judge[\Delta']{\sigma[\psi] : \Gamma} \;\circledR\; \rho \in \textsf{Sb}.

Proof of Corollary 7.20

By induction on the context-gluing derivation \Gamma \searrow \textsf{Sb}.

Case

Mathpar.

Sb (: ) Sb

\begin{aligned} &\judge[\Delta]{\sigma : \cdot} && \text{(by hypothesis on $\sigma$)} \\ &\judge[\Delta']{\sigma[\psi] : \cdot} && \text{(by substitution composition, \Cref{sec:syn})} \\ &\judge[\Delta']{\sigma[\psi] : \cdot} \;\circledR\; \rho \in \textsf{Sb} && \text{(by $\textsf{Sb}$'s definition for $\cdot$)} \end{aligned}

Case

Mathpar.

_0 Sb_T
STy_i

”, _T, _T. _T : _0 _T Sb_T
a, P, El. S (_T) a a U_i^P El S[_T]Ty_i P

Sb Cons_i(_0, S, Sb_T) (_0, x : S) Sb

Unfolding \textsf{Cons}_i at \sigma, \rho provides existential a, P, \textbf{El} specific to this pair:

\begin{aligned} &\judge[\Delta]{\Uparrow \circ \sigma : \Gamma_0} \;\circledR\; \rho[\Uparrow] \in \textsf{Sb}_T && \text{(tail of $\textsf{Cons}_i$)} \\ &\ensuremath{\llbracket S \rrbracket(\rho[\Uparrow])} \searrow a,\; a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} && \text{(type clause of $\textsf{Cons}_i$)} \\ &\typing[\Delta]{S[\Uparrow \circ \sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P && \text{(type clause of $\textsf{Cons}_i$)} \\ &\typing[\Delta]{x_0[\sigma]}{S[\Uparrow \circ \sigma]} \;\circledR\; \rho(x_0) \in \textbf{El} && \text{(head of $\textsf{Cons}_i$)} \\ &\judge[\Delta']{(\Uparrow \circ \sigma)[\psi] : \Gamma_0} \;\circledR\; \rho[\Uparrow] \in \textsf{Sb}_T && \text{(by IH on the smaller derivation $\Gamma_0 \searrow \textsf{Sb}_T$)} \\ &(\Uparrow \circ \sigma)[\psi] = \Uparrow \circ (\sigma[\psi]) && \text{(by associativity of $\circ$, \Cref{lem:subst-cat})} \\ &\typing[\Delta']{S[\Uparrow \circ \sigma][\psi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P && \text{(by \Cref{thm:monotonicity} on the type predicate)} \\ &S[\Uparrow \circ \sigma][\psi] = S[\Uparrow \circ \sigma[\psi]] && \text{(by \Cref{lem:subst-assoc} and the previous identity)} \\ &\typing[\Delta']{x_0[\sigma][\psi]}{S[\Uparrow \circ \sigma][\psi]} \;\circledR\; \rho(x_0) \in \textbf{El} && \text{(by \Cref{thm:monotonicity} on the head)} \\ &x_0[\sigma][\psi] = x_0[\sigma[\psi]] && \text{(by \Cref{lem:subst-assoc})} \\ &\typing[\Delta']{x_0[\sigma[\psi]]}{S[\Uparrow \circ \sigma[\psi]]} \;\circledR\; \rho(x_0) \in \textbf{El} && \text{(rewriting via the previous identities)} \\ &\judge[\Delta']{\sigma[\psi] : \Gamma_0, x:S} \;\circledR\; \rho \in \textsf{Sb} && \text{(by $\textsf{Cons}_i$ assembly with the same $a, P, \textbf{El}$)} \end{aligned}
Lemma

Lemma 7.21 (Gluing implies PER)

18JS

If a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}, then there exists R such that a \approx a \in \mathcal{U}_i \searrow R.

Proof of Lemma 7.21

By induction on the derivation a \in \mathcal{U}_i^\ast.

Case

Mathpar.

^A(e) D ^A(e) U_i^

By U-Ne of ?: {\uparrow}^A(e) \approx {\uparrow}^A(e) \in \mathcal{U}_i \searrow R with R \Leftrightarrow \textsf{Neu}, using e \approx e \in \textsf{Ne} from \mathcal{U}_i^\ast’s implicit assumption.

Case

Mathpar.

N U_i^

By U-Nat: N \approx N \in \mathcal{U}_i \searrow R with R \Leftrightarrow \textsf{Nat}.

Case

Mathpar.

j < i U_j U_i^

By U-Univ: U_j \approx U_j \in \mathcal{U}_i \searrow R with R \Leftrightarrow \mathcal{U}_j.

Case

Mathpar.

a U_i^P_I El_I
a a U_i R_I

  D :: b b R_I, c. T (, b/x) c c U_i^P_O(D) El_O(D)

(a, T, ) (a, T, ) U_i R

P _i(R_I, P_I, El_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a, T, ) U_i^P El

The PER witness R for \Pi(a, T, \rho) \approx \Pi(a, T, \rho) \in \mathcal{U}_i is packaged directly as a premise of G-Pi, hence is available immediately.

Lemma

Lemma 7.22 (Type-predicate syntactic escape)

2MLY

If a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} and \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P, then \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}.

Proof of Lemma 7.22

By case analysis on a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}.

Case

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

\begin{aligned} &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e && \text{(by hypothesis with $P \Leftrightarrow \textsf{Neu}_i^e$)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:neu-type-pred} clause 1)} \end{aligned}

Case

Mathpar.

P Nat_i
El Nat_i N U_i^P El

\begin{aligned} &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i && \text{(by hypothesis)} \\ &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:nat-type-pred})} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by presupposition of judgmental equality)} \end{aligned}

Case

Mathpar.

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^P El

\begin{aligned} &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j} && \text{(by hypothesis)} \\ &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:univ-type-pred})} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by presupposition of judgmental equality)} \end{aligned}

Case

Mathpar.

P _i(R_I, P_I, El_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a_I, T, ) U_i^P El

\begin{aligned} &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) && \text{(by hypothesis)} \\ &\exists S_1, S_2.\; \tyequiv[\Gamma]{S}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:pi-type-pred} clause 1)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by presupposition of judgmental equality)} \end{aligned}
Lemma

Lemma 7.23 (Term-predicate syntactic escape)

O676

If a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} and \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El}, then \typing[\Gamma]{t}{S} and \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P.

Proof of Lemma 7.23

By case analysis on a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}.

Case

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

\begin{aligned} &\typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Neu}_i^e && \text{(by hypothesis)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e && \text{(by \Cref{def:neu-term-pred} clause 1)} \\ &\typing[\Gamma]{t}{S} && \text{(by \Cref{def:neu-term-pred} clause 2)} \end{aligned}

Case

Mathpar.

P Nat_i
El Nat_i N U_i^P El

\begin{aligned} &\typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nat}_i && \text{(by hypothesis)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i && \text{(by \Cref{def:nat-term-pred})} \end{aligned}

By inner induction on the \textsf{Nat}-derivation at b:

    Mathpar.

    tzeroS tS ze Nat

    \typing[\Gamma]{t}{S} by presupposition of \tyequiv[\Gamma]{t}{\textsf{zero}}{S}.

    Mathpar.

    t’S b’ Nat
    tsucc t’S tS su(b’) Nat

    \typing[\Gamma]{t}{S} by presupposition of \tyequiv[\Gamma]{t}{\textsf{succ}~t'}{S}.

    Mathpar.

    tS ^N(w) Neu_i^e tS ^N(w) Nat

    \typing[\Gamma]{t}{S} by G-Ne case (just proved) on the neutral premise.

Case

Mathpar.

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^P El

\begin{aligned} &\typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}} && \text{(by hypothesis)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j} && \text{(by \Cref{def:univ-term-pred} clause 1)} \\ &\typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b && \text{(by \Cref{def:univ-term-pred} clause 2)} \\ &\typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} && \text{(by \Cref{lem:gluing-typ-escape} on the previous line at level $j$)} \\ &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:univ-type-pred})} \\ &\subty[\Gamma]{\ensuremath{\texttt{Ty}_{j}}}{S} && \text{(by \textsc{Sub-Eq} from the symmetric equality)} \\ &\typing[\Gamma]{t}{S} && \text{(by \textsc{Subsump})} \end{aligned}

Case

Mathpar.

P _i(R_I, P_I, El_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a_I, T, ) U_i^P El

\begin{aligned} &\typing[\Gamma]{t}{S} \;\circledR\; b \in \Pi_i^{\textbf{El}} && \text{(by hypothesis)} \\ &\typing[\Gamma]{t}{S} && \text{(by \Cref{def:pi-term-pred} clause 2)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i && \text{(by \Cref{def:pi-term-pred} clause 3)} \end{aligned}
Lemma

Lemma 7.24 (Functionality of \Uc_i^\ast)

GN7E

If a \in \mathcal{U}_i^\ast \searrow P_1 \searrow \textbf{El}_1 and a \in \mathcal{U}_i^\ast \searrow P_2 \searrow \textbf{El}_2, then P_1 \Leftrightarrow P_2 and \textbf{El}_1 \Leftrightarrow \textbf{El}_2.

Proof of Lemma 7.24

By induction on the first derivation a \in \mathcal{U}_i^\ast, with case analysis on the second (which must end with the same rule, since each rule’s conclusion form determines a syntactically).

Case

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

\begin{aligned} &P_1 \Leftrightarrow \textsf{Neu}_i^e && \text{(by \textsc{G-Ne} on the first derivation)} \\ &P_2 \Leftrightarrow \textsf{Neu}_i^e && \text{(by \textsc{G-Ne} on the second derivation)} \\ &P_1 \Leftrightarrow P_2 && \text{(transitivity)} \\ &\textbf{El}_1 \Leftrightarrow \textsf{Neu}_i^e \Leftrightarrow \textbf{El}_2 && \text{(symmetrically)} \end{aligned}

Case

Mathpar.

P Nat_i
El Nat_i N U_i^P El

\begin{aligned} &P_1 \Leftrightarrow \textsf{Nat}_i \Leftrightarrow P_2,\; \textbf{El}_1 \Leftrightarrow \textsf{Nat}_i \Leftrightarrow \textbf{El}_2 && \text{(by \textsc{G-Nat} on both derivations)} \end{aligned}

Case

Mathpar.

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^P El

Both derivations fix the same j < i, so P_1 \Leftrightarrow \textsf{Univ}_{i,j} \Leftrightarrow P_2 and \textbf{El}_1 \Leftrightarrow \textsf{Univ}_{i,j}^{\textbf{El}} \Leftrightarrow \textbf{El}_2.

Case

Mathpar.

a U_i^P_I El_I
a a U_i R_I

  D :: b b R_I, c. T (, b/x) c c U_i^P_O(D) El_O(D)

(a, T, ) (a, T, ) U_i R

P _i(R_I, P_I, El_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a, T, ) U_i^P El

Let the two derivations have inner data (P_I^{(1)}, \textbf{El}_I^{(1)}, R_I^{(1)}, P_O^{(1)}, \textbf{El}_O^{(1)}, R^{(1)}) and (P_I^{(2)}, \ldots) respectively.

\begin{aligned} &P_I^{(1)} \Leftrightarrow P_I^{(2)},\; \textbf{El}_I^{(1)} \Leftrightarrow \textbf{El}_I^{(2)} && \text{(by IH on the inner $a \in \mathcal{U}_i^\ast$)} \\ &R_I^{(1)} \Leftrightarrow R_I^{(2)},\; R^{(1)} \Leftrightarrow R^{(2)} && \text{(by \Cref{lem:univ-functional} on the inner $\mathcal{U}_i$ judgments)} \\ &\forall \ensuremath{\mathcal{D}}.\; P_O^{(1)}(\ensuremath{\mathcal{D}}) \Leftrightarrow P_O^{(2)}(\ensuremath{\mathcal{D}}),\; \textbf{El}_O^{(1)}(\ensuremath{\mathcal{D}}) \Leftrightarrow \textbf{El}_O^{(2)}(\ensuremath{\mathcal{D}}) && \text{(by IH on the codomain fibers, pointwise in $\ensuremath{\mathcal{D}}$)} \\ &P_1 \Leftrightarrow \Pi_i(R_I^{(1)}, P_I^{(1)}, \textbf{El}_I^{(1)}, P_O^{(1)}) \Leftrightarrow \Pi_i(R_I^{(2)}, P_I^{(2)}, \textbf{El}_I^{(2)}, P_O^{(2)}) \\ & \quad \Leftrightarrow P_2 && \text{(by congruence of $\Pi_i$)} \\ &\textbf{El}_1 \Leftrightarrow \Pi_i^{\textbf{El}}(\ldots) \Leftrightarrow \textbf{El}_2 && \text{(symmetrically)} \end{aligned}
Lemma

Lemma 7.25 (Cumulativity of \Uc_i^\ast (subrelation)

46PH

Suppose i \le j, a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}, and a \in \mathcal{U}_j^\ast \searrow P' \searrow \textbf{El}'. Then:

    Type-predicate raising: If \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P, then \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P'. Term-predicate raising: If \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El}, then \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El}'. Term-predicate lowering (under type-predicate at level i): If \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P and \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El}', then \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El}.

Existence of P', \textbf{El}' at level j follows from re-applying the gluing rules at level j to the same data.

Proof of Lemma 7.25

Since the gluing rules at level i and level j agree on the syntactic shape of a, the second derivation a \in \mathcal{U}_j^\ast \searrow P' \searrow \textbf{El}' must end with the same rule (G-Ne, G-Nat, G-Univ, or G-Pi) as the first. We proceed by induction on a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}, with sub-case-analysis on the rule shared by the two derivations.

Case

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

Then P' \Leftrightarrow \textsf{Neu}_j^e and \textbf{El}' \Leftrightarrow \textsf{Neu}_j^e. But \textsf{Neu}_*^e does not depend on the index (?, ?), so P \Leftrightarrow P' and \textbf{El} \Leftrightarrow \textbf{El}'. All three claims (1)–(3) hold trivially.

Case

Mathpar.

P Nat_i
El Nat_i N U_i^P El

Then P' \Leftrightarrow \textsf{Nat}_j and \textbf{El}' \Leftrightarrow \textsf{Nat}_j.

Type-predicate raising (1): given \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i:

\begin{aligned} &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:nat-type-pred})} \\ &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{j}}} && \text{(by cumulativity of universes, $i \le j$, \Cref{sec:rules})} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; \textsf{Nat}_j && \text{(by \Cref{def:nat-type-pred} at level $j$)} \end{aligned}

Term-predicate raising (2): given \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nat}_i, by inner induction on the \textsf{Nat}-derivation at b. Each sub-case (GN-Ze, GN-Su, GN-Ne) constructs the same derivation at level j, since the constructors \ensuremath{\texttt{Nat}}, \textsf{zero}, \textsf{succ}~ and the neutral predicate \textsf{Neu}_*^e are level-independent. The type-predicate part upgrades via (1).

Term-predicate lowering (3): given \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i and \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nat}_j. By inner induction on the \textsf{Nat}-derivation at b (level-j); each sub-case re-uses the level-independent constructors and re-derives the \textsf{Nat}-predicate at level i, with the type-predicate part already provided by hypothesis.

Case

Mathpar.

k < i
P Univ_i,k
El Univ_i,k^El U_k U_i^P El

Then k < j (from k < i \le j), P' \Leftrightarrow \textsf{Univ}_{j,k}, \textbf{El}' \Leftrightarrow \textsf{Univ}_{j,k}^{\textbf{El}}.

Type-predicate raising (1):

\begin{aligned} &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{k}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:univ-type-pred} on $\textsf{Univ}_{i,k}$)} \\ &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{k}}}{\ensuremath{\texttt{Ty}_{j}}} && \text{(by cumulativity of universes, $i \le j$, \Cref{sec:rules})} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; \textsf{Univ}_{j,k} && \text{(by \Cref{def:univ-type-pred} at level $j$)} \end{aligned}

Term-predicate raising (2): the conditions b \in \mathcal{U}_k^\ast \searrow P_b \searrow \textbf{El}_b and \typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{k}}} \;\circledR\; P_b at level k are unchanged; the type-predicate part upgrades via (1).

Term-predicate lowering (3): given \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,k} and \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Univ}_{j,k}^{\textbf{El}}. The conditions at level k (b \in \mathcal{U}_k^\ast \searrow P_b \searrow \textbf{El}_b and \typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{k}}} \;\circledR\; P_b) are level-k data, unchanged; the type-predicate at level i is provided by hypothesis. Hence \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Univ}_{i,k}^{\textbf{El}} via ?.

Case

Mathpar.

a U_i^P_I El_I
a a U_i R_I

  D :: b b R_I, c. T (, b/x) c c U_i^P_O(D) El_O(D)

(a, T, ) (a, T, ) U_i R

P _i(R_I, P_I, El_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a, T, ) U_i^P El

By inversion on the level-j derivation (which must end with G-Pi by the syntactic shape of \Pi(a, T, \rho)):

\begin{aligned} &a \in \mathcal{U}_j^\ast \searrow P_I' \searrow \textbf{El}_I' && \text{(level-$j$ inner data)} \\ &a \approx a \in \mathcal{U}_j \searrow R_I && \text{(by \Cref{lem:cumul}; same $R_I$ as level $i$)} \\ &\forall\, \ensuremath{\mathcal{D}}, c.\; \ensuremath{\llbracket T \rrbracket(\rho, b/x)} \searrow c \implies c \in \mathcal{U}_j^\ast \searrow P_O'(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O'(\ensuremath{\mathcal{D}}) && \text{(level-$j$ codomain fibers)} \\ &\Pi(a, T, \rho) \approx \Pi(a, T, \rho) \in \mathcal{U}_j \searrow R && \text{(by \Cref{lem:cumul}; same $R$)} \\ &P' \Leftrightarrow \Pi_j(R_I, P_I', \textbf{El}_I', P_O') \\ &\textbf{El}' \Leftrightarrow \Pi_j^{\textbf{El}}(R, R_I, P_I', \textbf{El}_I', \textbf{El}_O') \end{aligned}

The PER witnesses R_I, R are unchanged (level-independent in \mathcal{U} via ?). The IH applies to the inner a and to each codomain fiber c (smaller derivations).

Type-predicate raising (1). Suppose \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) with witnesses S_1, S_2. We verify the three clauses of \Pi_j(R_I, P_I', \textbf{El}_I', P_O') at S.

Clause 1.

\begin{aligned} &\tyequiv[\Gamma]{S}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:pi-type-pred} clause 1 on the hypothesis)} \\ &\tyequiv[\Gamma]{S}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{j}}} && \text{(by cumulativity of universes, $i \le j$, \Cref{sec:rules})} \end{aligned}

Clause 2. Let \kweak[\Delta]{\phi}{\Gamma}.

\begin{aligned} &\typing[\Delta]{S_1[\phi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by \Cref{def:pi-type-pred} clause 2 on the hypothesis)} \\ &\typing[\Delta]{S_1[\phi]}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_I' && \text{(by IH (1) on $a$, raising)} \end{aligned}

Clause 3. Let \kweak[\Delta]{\phi}{\Gamma}, s, b, \ensuremath{\mathcal{D}} :: b \approx b \in R_I with \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I'.

\begin{aligned} &\typing[\Delta]{S_1[\phi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by clause 2 above, the level-$i$ part)} \\ &\typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I && \text{(by IH (3) on $a$, lowering, using the previous line as the level-$i$ type-predicate)} \\ &\typing[\Delta]{S_2[\iota(\phi), s/x]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{def:pi-type-pred} clause 3 on the hypothesis)} \\ &\typing[\Delta]{S_2[\iota(\phi), s/x]}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_O'(\ensuremath{\mathcal{D}}) && \text{(by IH (1) on the codomain fiber} \\ & && \text{$c$ at $\ensuremath{\mathcal{D}}$, raising)} \end{aligned}

Term-predicate raising (2). Suppose \typing[\Gamma]{t}{S} \;\circledR\; f \in \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O). We verify the four clauses of \Pi_j^{\textbf{El}}(R, R_I, P_I', \textbf{El}_I', \textbf{El}_O') at t, f.

Clauses 1–2.

\begin{aligned} &f \approx f \in R && \text{(unchanged from hypothesis)} \\ &\typing[\Gamma]{t}{S} && \text{(unchanged from hypothesis)} \end{aligned}

Clause 3.

\begin{aligned} &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) && \text{(by \Cref{def:pi-term-pred} clause 3 on the hypothesis)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; \Pi_j(R_I, P_I', \textbf{El}_I', P_O') && \text{(by part (1) of this case, applied just above)} \end{aligned}

Clause 4 (application). Let \kweak[\Delta]{\phi}{\Gamma}, s, b, \ensuremath{\mathcal{D}} :: b \approx b \in R_I with \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I'.

\begin{aligned} &\typing[\Delta]{S_1[\phi]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by hypothesis clause 3 at level $i$, clause 2 of $\Pi_i$)} \\ &\typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I && \text{(by IH (3) on $a$, lowering)} \\ &f \cdot b \searrow c,\; \typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by hypothesis clause 4 at level $i$)} \\ &\typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O'(\ensuremath{\mathcal{D}}) && \text{(by IH (2) on the codomain fiber $c$, raising)} \end{aligned}

Clause 5 (R_I-coherence). Unchanged, since the R_I-classes and the function value f are level-independent.

Term-predicate lowering (3). Suppose \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) and \typing[\Gamma]{t}{S} \;\circledR\; f \in \Pi_j^{\textbf{El}}(R, R_I, P_I', \textbf{El}_I', \textbf{El}_O'). We verify the four clauses of \Pi_i^{\textbf{El}} at t, f.

Clauses 1–3.

\begin{aligned} &f \approx f \in R && \text{(by \Cref{def:pi-term-pred} clause 1 on hypothesis at level $j$)} \\ &\typing[\Gamma]{t}{S} && \text{(by \Cref{def:pi-term-pred} clause 2 on hypothesis at level $j$)} \\ &\typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) && \text{(by lemma's lowering hypothesis on $S$)} \end{aligned}

Clause 4 (application). Let \kweak[\Delta]{\phi}{\Gamma}, s, b, \ensuremath{\mathcal{D}} :: b \approx b \in R_I with \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I.

\begin{aligned} &\typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I' && \text{(by IH (2) on $a$, raising)} \\ &f \cdot b \searrow c && \text{(by hypothesis clause 4 at level $j$)} \\ &\typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O'(\ensuremath{\mathcal{D}}) && \text{(by hypothesis clause 4 at level $j$)} \\ &\typing[\Delta]{S_2[\iota(\phi), s/x]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{def:pi-type-pred} clause 3 on the} \\ & && \text{level-$i$ type-predicate hypothesis)} \\ &\typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by IH (3) on the codomain fiber $c$, lowering)} \end{aligned}
Lemma

Lemma 7.26 (Gluing respects judgmental equality)

WHJ0

Suppose a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}.

    If \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P and \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}, then \typing[\Gamma]{S'}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P. If \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El} and \tyequiv[\Gamma]{t}{t'}{S}, then \typing[\Gamma]{t'}{S} \;\circledR\; b \in \textbf{El}. If \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El} and \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}, then \typing[\Gamma]{t}{S'} \;\circledR\; b \in \textbf{El}.

Proof of Lemma 7.26

By induction on a \in \mathcal{U}_i^\ast.

Case

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

Type predicate (1). Given \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e and \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}} with \typing[\Gamma]{S'}{\ensuremath{\texttt{Ty}_{i}}}. For arbitrary \kweak[\Delta]{\phi}{\Gamma}:

\begin{aligned} &\exists u.\; \textsf{R}^{\textsf{Ne}}_{|\Delta|}(e) \searrow u \wedge \tyequiv[\Delta]{S[\phi]}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by hypothesis on $S$)} \\ &\tyequiv[\Delta]{S[\phi]}{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:wk-typing})} \\ &\tyequiv[\Delta]{S'[\phi]}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by symmetry and transitivity of judgmental equality)} \\ &\typing[\Gamma]{S'}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e && \text{(by \Cref{def:neu-type-pred})} \end{aligned}

Term predicate (2). Given \typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \textsf{Neu}_i^e and \tyequiv[\Gamma]{t}{t'}{S} with \typing[\Gamma]{t'}{S}. For \kweak[\Delta]{\phi}{\Gamma}:

\begin{aligned} &\exists u.\; \textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow u \wedge \tyequiv[\Delta]{t[\phi]}{u}{S[\phi]} && \text{(by hypothesis on $t$)} \\ &\tyequiv[\Delta]{t[\phi]}{t'[\phi]}{S[\phi]} && \text{(by \Cref{lem:wk-typing})} \\ &\tyequiv[\Delta]{t'[\phi]}{u}{S[\phi]} && \text{(by symmetry and transitivity)} \\ &\typing[\Gamma]{t'}{S} \;\circledR\; {\uparrow}^A(w) \in \textsf{Neu}_i^e && \text{(by \Cref{def:neu-term-pred})} \end{aligned}

Type-side rewriting (3). Given \typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \textsf{Neu}_i^e and \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}} with \typing[\Gamma]{t}{S'}. For \kweak[\Delta]{\phi}{\Gamma}:

\begin{aligned} &\exists u.\; \textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow u \wedge \tyequiv[\Delta]{t[\phi]}{u}{S[\phi]} && \text{(by hypothesis on $t$)} \\ &\tyequiv[\Delta]{S[\phi]}{S'[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:wk-typing})} \\ &\tyequiv[\Delta]{t[\phi]}{u}{S'[\phi]} && \text{(by \textsc{Tm-Subsump} with the previous line)} \\ &\typing[\Gamma]{t}{S'} \;\circledR\; {\uparrow}^A(w) \in \textsf{Neu}_i^e && \text{(by \Cref{def:neu-term-pred}, using the type predicate at $S'$ from (1))} \end{aligned}

Case

Mathpar.

P Nat_i
El Nat_i N U_i^P El

Type predicate (1).

\begin{aligned} &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:nat-type-pred} on hypothesis)} \\ &\tyequiv[\Gamma]{S'}{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by symmetry of $\tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}$)} \\ &\tyequiv[\Gamma]{S'}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by transitivity of judgmental equality)} \\ &\typing[\Gamma]{S'}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i && \text{(by \Cref{def:nat-type-pred})} \end{aligned}

Term predicate (2). Given \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nat}_i and \tyequiv[\Gamma]{t}{t'}{S}. By inner induction on the derivation b \in \textsf{Nat}_i at t:

    Mathpar.

    tzeroS tS ze Nat

    \begin{aligned} &\tyequiv[\Gamma]{t'}{t}{S} && \text{(by symmetry of $\tyequiv[\Gamma]{t}{t'}{S}$)} \\ &\tyequiv[\Gamma]{t'}{\textsf{zero}}{S} && \text{(by transitivity)} \\ &\typing[\Gamma]{t'}{S} \;\circledR\; \texttt{ze} \in \textsf{Nat} && \text{(by \textsc{GN-Ze})} \end{aligned}
    Mathpar.

    t_0S b’ Nat
    tsucc t_0S tS su(b’) Nat

    \begin{aligned} &\tyequiv[\Gamma]{t'}{\textsf{succ}~t_0}{S} && \text{(by symmetry/transitivity, as above)} \\ &\typing[\Gamma]{t_0}{S} \;\circledR\; b' \in \textsf{Nat} && \text{(unchanged, hypothesis on $t_0$)} \\ &\typing[\Gamma]{t'}{S} \;\circledR\; \texttt{su}(b') \in \textsf{Nat} && \text{(by \textsc{GN-Su})} \end{aligned}
    Mathpar.

    tS w Ne_i^N tS ^N(w) Nat

    \begin{aligned} &\typing[\Gamma]{t'}{S} \;\circledR\; w \in \textsf{Ne}_i^N && \text{(by the \textsc{G-Ne} case (2) above on the neutral predicate)} \\ &\typing[\Gamma]{t'}{S} \;\circledR\; {\uparrow}^N(w) \in \textsf{Nat} && \text{(by \textsc{GN-Ne})} \end{aligned}

Type-side rewriting (3). Given \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}. Then \tyequiv[\Gamma]{S'}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} by symmetry/transitivity with \tyequiv[\Gamma]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}}. The \textsf{Nat}-derivation transfers to \typing[\Gamma]{t}{S'} since each sub-case’s hypotheses involve S only through \tyequiv[\Gamma]{t}{w}{S} for some w, which becomes \tyequiv[\Gamma]{t}{w}{S'} via Tm-Subsump.

Case

Mathpar.

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^P El

Type predicate (1).

\begin{aligned} &\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:univ-type-pred})} \\ &\tyequiv[\Gamma]{S'}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by symmetry/transitivity with the assumed equality)} \\ &\typing[\Gamma]{S'}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j} && \text{(by \Cref{def:univ-type-pred})} \end{aligned}

Term predicate (2). Given \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}} and \tyequiv[\Gamma]{t}{t'}{S}. By ?, b \in \mathcal{U}_j^\ast \searrow P_b \searrow \textbf{El}_b with \typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b and \tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}.

\begin{aligned} &\tyequiv[\Gamma]{t}{t'}{\ensuremath{\texttt{Ty}_{j}}} && \text{(by judgmental-equality conversion under $\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}$)} \\ &\typing[\Gamma]{t'}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b && \text{(by IH on $P_b$ at level $j$, type-predicate part)} \\ &\typing[\Gamma]{t'}{S} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}} && \text{(by \Cref{def:univ-term-pred} with $\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}$)} \end{aligned}

Type-side rewriting (3). Given \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}. Then \tyequiv[\Gamma]{S'}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} by transitivity, and the universe term predicate at S' holds with the same data b, P_b, \textbf{El}_b.

Case

Mathpar.

a U_i^P_I El_I
a a U_i R_I

  D :: b b R_I, c. T (, b/x) c c U_i^P_O(D) El_O(D)

(a, T, ) (a, T, ) U_i R

P _i(…)
El _i^El(…) (a, T, ) U_i^P El

Type predicate (1). Given \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) and \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}. By ? clause 1, \tyequiv[\Gamma]{S}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} for some S_1, S_2.

\begin{aligned} &\tyequiv[\Gamma]{S'}{S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by symmetry of $\tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}}$)} \\ &\tyequiv[\Gamma]{S'}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by transitivity with the previous line)} \end{aligned}

Clauses 2–3 of \Pi_i for S' at any \kweak[\Delta]{\phi}{\Gamma} require the same data on S_1[\phi] and S_2[\iota(\phi), s/x] as the original predicate; these are exactly the data already satisfied by hypothesis on S, since the data depend on S_1, S_2 rather than on the outer type S.

Term predicate (2). Given \typing[\Gamma]{t}{S} \;\circledR\; f \in \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) and \tyequiv[\Gamma]{t}{t'}{S} with \typing[\Gamma]{t'}{S}. We verify the four clauses of ? at t' and value f.

    Self-relatedness f \approx f \in R does not depend on t. R_I-coherence: a property of f, not of t. Type-readback: clause 3 of \Pi_i^{\textbf{El}} matches clause 3 of \Pi_i on S at t, and is preserved by part (1) above on S' unchanged. Application: let \kweak[\Delta]{\phi}{\Gamma}, s, b, \ensuremath{\mathcal{D}} :: b \approx b \in R_I with \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I.

    \begin{aligned} &f \cdot b \searrow c && \text{(by hypothesis clause 4 on $f$)} \\ &\typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by hypothesis clause 4)} \\ &\tyequiv[\Delta]{t[\phi]}{t'[\phi]}{S[\phi]} && \text{(by \Cref{lem:wk-typing})} \\ &\tyequiv[\Delta]{(t[\phi])\;s}{(t'[\phi])\;s}{S_2[\iota(\phi), s/x]} && \text{(by \textsc{App-Cong} on the previous line,} \\ & && \text{after observing that $S[\phi]$ on the function side} \\ & && \text{reduces to $\Pi(x:S_1[\phi]).\,(S_2[q(\phi)])$)} \\ &\typing[\Delta]{(t'[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by IH (2) on $\textbf{El}_O(\ensuremath{\mathcal{D}})$ applied} \\ & && \text{to the equality above)} \end{aligned}

    R_I-coherence under application: a property of f via clauses 4 parametrically; transfers from t to t' alongside clause 4.

Type-side rewriting (3). Given \tyequiv[\Gamma]{S}{S'}{\ensuremath{\texttt{Ty}_{i}}} with \typing[\Gamma]{t}{S'}. Clauses 1, 4 of \Pi_i^{\textbf{El}} depend on S only through S_2[\iota(\phi), s/x] (the codomain instantiation), which is invariant under the equation S \approx S'. Clause 3’s \Pi-shape readback transfers via part (1) applied to the universe-equation. Hence \typing[\Gamma]{t}{S'} \;\circledR\; f \in \Pi_i^{\textbf{El}}.

Lemma

Lemma 7.27 (\Uc_i^\ast closed under \Uc_i-equivalence)

RTRL

If a \approx a' \in \mathcal{U}_i \searrow R and a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}, then a' \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}.

Proof of Lemma 7.27

By induction on a \approx a' \in \mathcal{U}_i.

Case

Mathpar.

b b’ Ne
R Neu ^A(b) ^A’(b’) U_i R

a = {\uparrow}^A(b), a' = {\uparrow}^{A'}(b'). a \in \mathcal{U}_i^\ast via G-Ne with P \Leftrightarrow \textbf{El} \Leftrightarrow \textsf{Neu}_i^b. By definition of \textsf{Ne} (b \approx b' \in \textsf{Ne}), readbacks of b and b' coincide, so \textsf{Neu}_i^b \Leftrightarrow \textsf{Neu}_i^{b'}. Hence a' \in \mathcal{U}_i^\ast via G-Ne with the same predicates.

Case

Mathpar.

j < i
R U_j U_j U_j U_i R

a = a' = U_j; the conclusion is immediate.

Case

Mathpar.

R Nat N N U_i R

a = a' = N; immediate.

Case

Mathpar.

a_I a_I’ U_i R_I
R_I is a PER

  D :: b b’ R_I. T (, b/x) T’ (’, b’/x) U_i R_O(D)

  f, f’. f f’ R (  D :: b b’ R_I. f b f’ b’ R_O(D)) (a_I, T, ) (a_I’, T’, ’) U_i R

a = \Pi(a_I, T, \rho), a' = \Pi(a_I', T', \rho'). a \in \mathcal{U}_i^\ast via G-Pi provides inner data a_I \in \mathcal{U}_i^\ast \searrow P_I \searrow \textbf{El}_I and a codomain clause: for any \ensuremath{\mathcal{D}} :: b \approx b \in R_I and c with \ensuremath{\llbracket T \rrbracket(\rho, b/x)} \searrow c, c \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}).

\begin{aligned} &a_I \approx a_I' \in \mathcal{U}_i \searrow R_I && \text{(from the \textsc{U-Pi} premise)} \\ &a_I' \in \mathcal{U}_i^\ast \searrow P_I \searrow \textbf{El}_I && \text{(by IH on $a_I \approx a_I' \in \mathcal{U}_i$ and $a_I \in \mathcal{U}_i^\ast$)} \\ &\forall \ensuremath{\mathcal{D}}' :: b' \approx b' \in R_I, c'.\; \ensuremath{\llbracket T' \rrbracket(\rho', b'/x)} \searrow c' \\ & \quad \implies c' \approx c' \in \mathcal{U}_i && \text{(by symmetry/transitivity from the \textsc{U-Pi} premise)} \\ &\forall \ensuremath{\mathcal{D}}' :: b' \approx b' \in R_I, c'.\; \ensuremath{\llbracket T' \rrbracket(\rho', b'/x)} \searrow c' \\ & \quad \implies c' \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}') \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}') && \text{(by IH on the codomain fibers,} \\ & && \text{transporting from $c \approx c'$)} \\ &\Pi(a_I', T', \rho') \approx \Pi(a_I', T', \rho') \in \mathcal{U}_i \searrow R && \text{(by \Cref{lem:univ-sym,lem:univ-trans})} \\ &\Pi(a_I', T', \rho') \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} && \text{(by \textsc{G-Pi} at the previous data, with the same $P, \textbf{El}$)} \end{aligned}
Lemma

Lemma 7.28 (PER membership yields gluing-model membership)

QMZX

If a \approx a \in \mathcal{U}_i \searrow R, then there exist P, \textbf{El} with a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}.

Proof of Lemma 7.28

By induction on a \approx a \in \mathcal{U}_i.

Case

Mathpar.

b b Ne
R Neu ^A(b) ^A(b) U_i R

\begin{aligned} &{\uparrow}^A(b) \in \mathcal{U}_i^\ast \searrow \textsf{Neu}_i^b \searrow \textsf{Neu}_i^b && \text{(by \textsc{G-Ne} on $b$)} \end{aligned}

Case

Mathpar.

j < i
R U_j U_j U_j U_i R

\begin{aligned} &U_j \in \mathcal{U}_i^\ast \searrow \textsf{Univ}_{i,j} \searrow \textsf{Univ}_{i,j}^{\textbf{El}} && \text{(by \textsc{G-Univ} at $j < i$)} \end{aligned}

Case

Mathpar.

R Nat N N U_i R

\begin{aligned} &N \in \mathcal{U}_i^\ast \searrow \textsf{Nat}_i \searrow \textsf{Nat}_i && \text{(by \textsc{G-Nat})} \end{aligned}

Case

Mathpar.

a_I a_I U_i R_I
R_I is a PER

  D :: b b R_I. T (, b/x) T (, b/x) U_i R_O(D)

  f, f’. f f’ R (  D :: b b’ R_I. f b f’ b’ R_O(D)) (a_I, T, ) (a_I, T, ) U_i R

\begin{aligned} &a_I \in \mathcal{U}_i^\ast \searrow P_I \searrow \textbf{El}_I && \\ &\forall\, \ensuremath{\mathcal{D}} :: b \approx b \in R_I,\; c.\; \ensuremath{\llbracket T \rrbracket(\rho, b/x)} \searrow c \\ & \quad \implies c \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}) && \\ &\Pi(a_I, T, \rho) \in \mathcal{U}_i^\ast \searrow \Pi_i(R_I, P_I, \textbf{El}_I, P_O) \searrow \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) && \text{(by \textsc{G-Pi})} \end{aligned}
Lemma

Lemma 7.29 (Term predicate closed under PER-equivalence)

UISE

Suppose a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} and a \approx a \in \mathcal{U}_i \searrow R. If \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El} and b \approx b' \in R, then \typing[\Gamma]{t}{S} \;\circledR\; b' \in \textbf{El}.

Proof of Lemma 7.29

By induction on a \in \mathcal{U}_i^\ast.

Case

Mathpar.

^A(e) D
P Neu_i^e
El Neu_i^e ^A(e) U_i^P El

R \Leftrightarrow \textsf{Neu}. From \textbf{El} \Leftrightarrow \textsf{Neu}_i^e, b = {\uparrow}^{A_0}(w) with w \approx w \in \textsf{Ne}. b \approx b' \in R \Leftrightarrow \textsf{Neu} gives b' = {\uparrow}^{A_0'}(w') with w \approx w' \in \textsf{Ne}.

\begin{aligned} &\forall \kweak[\Delta]{\phi}{\Gamma}.\; \exists u.\; \textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow u \wedge \tyequiv[\Delta]{t[\phi]}{u}{S[\phi]} && \text{(hypothesis on $b = {\uparrow}^{A_0}(w)$)} \\ &\textsf{R}^{\textsf{Ne}}_{|\Delta|}(w') \searrow u && \text{(by definition of $\textsf{Ne}$, $w \approx w'$ read back to the same $u$)} \\ &\typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^{A_0'}(w') \in \textsf{Neu}_i^e && \text{(by \Cref{def:neu-term-pred})} \end{aligned}

Case

Mathpar.

P Nat_i
El Nat_i N U_i^P El

R \Leftrightarrow \textsf{Nat}, and b \approx b' \in \textsf{Nat}. By inner induction on the \textsf{Nat} derivation (?).

Sub-case

Mathpar.

ze ze Nat

b = b' = \texttt{ze}; the predicate is unchanged.

Sub-case

Mathpar.

b_0 b_0’ Nat su(b_0) su(b_0’) Nat

b = \texttt{su}(b_0), b' = \texttt{su}(b_0'). The \textsf{Nat}-predicate derivation for b uses GN-Su from a derivation for some t_0 at b_0:

\begin{aligned} &\typing[\Gamma]{t_0}{S} \;\circledR\; b_0 \in \textsf{Nat} && \text{(from the \textsc{GN-Su} premise)} \\ &\tyequiv[\Gamma]{t}{\textsf{succ}~t_0}{S} && \text{(from the \textsc{GN-Su} premise)} \\ &\typing[\Gamma]{t_0}{S} \;\circledR\; b_0' \in \textsf{Nat} && \text{(by inner IH)} \\ &\typing[\Gamma]{t}{S} \;\circledR\; \texttt{su}(b_0') \in \textsf{Nat} && \text{(by \textsc{GN-Su} repackaging)} \end{aligned}

Sub-case

Mathpar.

e e’ Ne ^N(e) ^N(e’) Nat

b = {\uparrow}^N(e), b' = {\uparrow}^N(e'). The \textsf{Nat}-predicate derivation for b uses GN-Ne from a neutral predicate at e:

\begin{aligned} &\typing[\Gamma]{t}{S} \;\circledR\; e \in \textsf{Ne}_i^N && \text{(from the \textsc{GN-Ne} premise)} \\ &\typing[\Gamma]{t}{S} \;\circledR\; e' \in \textsf{Ne}_i^N && \text{(by readback equality: $e \approx e' \in \textsf{Ne}$ implies $\textsf{R}^{\textsf{Ne}}(e) = \textsf{R}^{\textsf{Ne}}(e')$ at every depth)} \\ &\typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^N(e') \in \textsf{Nat} && \text{(by \textsc{GN-Ne})} \end{aligned}

Case

Mathpar.

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^P El

R \Leftrightarrow \mathcal{U}_j. By ?, b \in \mathcal{U}_j^\ast \searrow P_b \searrow \textbf{El}_b with \typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b, and b \approx b' \in \mathcal{U}_j.

\begin{aligned} &b' \in \mathcal{U}_j^\ast \searrow P_b \searrow \textbf{El}_b && \text{(by \Cref{lem:gluing-univ-equiv} at level $j$ on $b \approx b'$)} \\ &\typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b && \text{(unchanged from hypothesis)} \\ &\typing[\Gamma]{t}{S} \;\circledR\; b' \in \textsf{Univ}_{i,j}^{\textbf{El}} && \text{(by \Cref{def:univ-term-pred} with the previous lines} \\ & && \text{and $\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}$)} \end{aligned}

Case

Mathpar.

a U_i^P_I El_I
a a U_i R_I

  D :: b_0 b_0 R_I, c. T (, b_0/x) c c U_i^P_O(D) El_O(D)

(a, T, ) (a, T, ) U_i R

P _i(…)
El _i^El(…) (a, T, ) U_i^P El

Hypothesis: \typing[\Gamma]{t}{S} \;\circledR\; f \in \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) and f \approx f' \in R. We verify the four clauses of ? at f'.

    Self-relatedness f' \approx f' \in R: by PER symmetry and transitivity on f \approx f' \in R (?, ?). R_I-coherence of f': clause (2) is a property of R-classes; since f, f' are in the same R-class, the coherence transfers. Type-readback of f': clause (3) depends only on S and the \Pi-shape, not on the function value, so it transfers verbatim. Application: let \kweak[\Delta]{\phi}{\Gamma}, s, b_0, \ensuremath{\mathcal{D}} :: b_0 \approx b_0 \in R_I with \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b_0 \in \textbf{El}_I.

    \begin{aligned} &f \cdot b_0 \searrow c && \text{(by hypothesis on $f$, clause (4))} \\ &\typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by hypothesis on $f$, clause (4))} \\ &f \cdot b_0 \approx f' \cdot b_0 \in R_O(\ensuremath{\mathcal{D}}) && \text{(by the application clause of $R$ for $f \approx f' \in R$ at $b_0 \approx b_0 \in R_I$)} \\ &\exists c'.\; f' \cdot b_0 \searrow c',\; c \approx c' \in R_O(\ensuremath{\mathcal{D}}) && \text{(by determinism of evaluation and the previous line)} \\ &\typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \;\circledR\; c' \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by IH on the codomain fiber $\textbf{El}_O(\ensuremath{\mathcal{D}})$, applied to $c \approx c'$)} \end{aligned}

    R_I-coherence under application: a property of the R-class on the codomain; transfers as in clauses (1)–(2).

Lemma

Lemma 7.30 (Subtyping type-escape)

TJSL

Suppose a_1 \in \mathcal{U}_i^\ast \searrow P_1 \searrow \textbf{El}_1, a_2 \in \mathcal{U}_i^\ast \searrow P_2 \searrow \textbf{El}_2, and a_1 \mathrel{<:_i} a_2 (semantic subtyping from ?). If \typing[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_1 and \typing[\Gamma]{S_2}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_2, then \subty[\Gamma]{S_1}{S_2}.

Proof of Lemma 7.30

By induction on a_1 \mathrel{<:_i} a_2.

Case

Mathpar.

b b’ Ne ^A(b) <:_i ^A’(b’)

P_1 \Leftrightarrow \textsf{Neu}_i^b, P_2 \Leftrightarrow \textsf{Neu}_i^{b'}. The hypothesis b \approx b' \in \textsf{Ne} implies \textsf{R}^{\textsf{Ne}}_n(b) and \textsf{R}^{\textsf{Ne}}_n(b') produce the same syntactic neutral at every depth.

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_{|\Gamma|}(b) \searrow u,\; \tyequiv[\Gamma]{S_1}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:neu-type-pred} on $S_1$ at $\phi = \ensuremath{\textsf{id}}$)} \\ &\textsf{R}^{\textsf{Ne}}_{|\Gamma|}(b') \searrow u && \text{(by $b \approx b' \in \textsf{Ne}$, same readback)} \\ &\tyequiv[\Gamma]{S_2}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:neu-type-pred} on $S_2$ at $\phi = \ensuremath{\textsf{id}}$)} \\ &\tyequiv[\Gamma]{S_1}{S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by symmetry/transitivity of judgmental equality)} \\ &\subty[\Gamma]{S_1}{S_2} && \text{(by \textsc{Sub-Eq} on the previous line)} \end{aligned}

Case

Mathpar.

j k
k < i U_j <:_i U_k

P_1 \Leftrightarrow \textsf{Univ}_{i,j}, P_2 \Leftrightarrow \textsf{Univ}_{i,k}.

\begin{aligned} &\tyequiv[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:univ-type-pred} on $\textsf{Univ}_{i,j}$)} \\ &\tyequiv[\Gamma]{S_2}{\ensuremath{\texttt{Ty}_{k}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:univ-type-pred} on $\textsf{Univ}_{i,k}$)} \\ &\subty[\Gamma]{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{k}}} && \text{(by \textsc{Sub-Univ} from $j \le k$)} \\ &\subty[\Gamma]{S_1}{S_2} && \text{(by \textsc{Sub-Trans} via the equalities and the previous line)} \end{aligned}

Case

Mathpar.

N <:_i N

P_1 \Leftrightarrow P_2 \Leftrightarrow \textsf{Nat}_i.

\begin{aligned} &\tyequiv[\Gamma]{S_1}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:nat-type-pred} on $S_1$)} \\ &\tyequiv[\Gamma]{S_2}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:nat-type-pred} on $S_2$)} \\ &\tyequiv[\Gamma]{S_1}{S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by symmetry/transitivity through $\ensuremath{\texttt{Nat}}$)} \\ &\subty[\Gamma]{S_1}{S_2} && \text{(by \textsc{Sub-Eq})} \end{aligned}

Case

Mathpar.

A A’ U_i R_I
  D :: a a’ R_I. T (, a/x) <:_i T’ (’, a’/x)

(A, T, ) (A, T, ) U_i
(A’, T’, ’) (A’, T’, ’) U_i (A, T, ) <:_i (A’, T’, ’)

P_1 \Leftrightarrow \Pi_i(R_I, P_I, \textbf{El}_I, P_O), P_2 \Leftrightarrow \Pi_i(R_I', P_I', \textbf{El}_I', P_O'). The domain PERs are related by equality (A \approx A' \in \mathcal{U}_i \searrow R_I, so R_I = R_I' via ?; correspondingly P_I \Leftrightarrow P_I', \textbf{El}_I \Leftrightarrow \textbf{El}_I' via ?).

Given \typing[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(\ldots) at shape \Pi(x:S_{1,1}).\,S_{1,2} and similarly S_2 at \Pi(x:S_{2,1}).\,S_{2,2} (both by ? clause 1).

\begin{aligned} &\typing[\Gamma]{S_{1,1}}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by \Cref{def:pi-type-pred} clause 2 on $S_1$ at $\phi = \ensuremath{\textsf{id}}$)} \\ &\typing[\Gamma]{S_{2,1}}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(symmetrically on $S_2$, using $P_I' \Leftrightarrow P_I$)} \\ &\tyequiv[\Gamma]{S_{1,1}}{S_{2,1}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:gluing-functional} on the two predicates at $a = A$)} \\ &\subty[\Gamma, x:S_{1,1}]{S_{1,2}}{S_{2,2}} && \text{(by IH on the codomain subtyping at fresh variable $x$ at $A$)} \\ &\subty[\Gamma]{\Pi(x:S_{1,1}).\,S_{1,2}}{\Pi(x:S_{2,1}).\,S_{2,2}} && \text{(by \textsc{Sub-Pi})} \\ &\subty[\Gamma]{S_1}{S_2} && \text{(by \textsc{Sub-Eq} with the $\Pi$-shape equalities)} \end{aligned}
Lemma

Lemma 7.31 (Subtyping term-transfer)

YTOZ

Suppose a_1 \in \mathcal{U}_i^\ast \searrow P_1 \searrow \textbf{El}_1, a_2 \in \mathcal{U}_i^\ast \searrow P_2 \searrow \textbf{El}_2, and a_1 \mathrel{<:_i} a_2. If \typing[\Gamma]{S_2}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_2 and \typing[\Gamma]{t}{S_1} \;\circledR\; b \in \textbf{El}_1, then \typing[\Gamma]{t}{S_2} \;\circledR\; b \in \textbf{El}_2.

Proof of Lemma 7.31

By induction on a_1 \mathrel{<:_i} a_2. Each case extracts the type predicate at S_1 from the term predicate (via the relevant \textbf{El}-definition) and then applies ? to obtain \subty[\Gamma]{S_1}{S_2}.

Case

Mathpar.

b b’ Ne ^A(b) <:_i ^A’(b’)

P_1 \Leftrightarrow \textbf{El}_1 \Leftrightarrow \textsf{Neu}_i^b, P_2 \Leftrightarrow \textbf{El}_2 \Leftrightarrow \textsf{Neu}_i^{b'}. Given \typing[\Gamma]{t}{S_1} \;\circledR\; w \in \textsf{Neu}_i^b.

\begin{aligned} &\typing[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^b && \text{(by \Cref{def:neu-term-pred} on the hypothesis)} \\ &\subty[\Gamma]{S_1}{S_2} && \text{(by \Cref{lem:gluing-subty-typ} on $S_1, S_2, P_1, P_2$)} \end{aligned}

For each \kweak[\Delta]{\phi}{\Gamma}, by ?:

\begin{aligned} &\exists v.\; \textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow v \wedge \tyequiv[\Delta]{t[\phi]}{v}{S_1[\phi]} && \text{(Kripke condition at $w$)} \\ &\subty[\Delta]{S_1[\phi]}{S_2[\phi]} && \text{(by \Cref{lem:wk-typing} on the previous-block subtyping)} \\ &\tyequiv[\Delta]{t[\phi]}{v}{S_2[\phi]} && \text{(by \textsc{Tm-Subsump} on the previous two lines)} \end{aligned}

Combining with b \approx b' \in \textsf{Ne} (same readback at every depth) and the type predicate at S_2 (hypothesis), ? gives \typing[\Gamma]{t}{S_2} \;\circledR\; w \in \textsf{Neu}_i^{b'}.

Case

Mathpar.

j k
k < i U_j <:_i U_k

\textbf{El}_1 \Leftrightarrow \textsf{Univ}_{i,j}^{\textbf{El}}, \textbf{El}_2 \Leftrightarrow \textsf{Univ}_{i,k}^{\textbf{El}}. Given \typing[\Gamma]{t}{S_1} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}}, so by ?: b \in \mathcal{U}_j^\ast \searrow P_b \searrow \textbf{El}_b and \typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b.

\begin{aligned} &\exists P_b', \textbf{El}_b'.\; b \in \mathcal{U}_k^\ast \searrow P_b' \searrow \textbf{El}_b' && \text{(by \Cref{lem:gluing-cumul} existence at $k$, since $j \le k$)} \\ &\typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{k}}} \;\circledR\; P_b' && \text{(by \Cref{lem:gluing-cumul} (1) raising on $b$ from $j$ to $k$)} \\ &\typing[\Gamma]{S_2}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,k} && \text{(by hypothesis $P_2 = \textsf{Univ}_{i,k}$)} \\ &\typing[\Gamma]{t}{S_2} \;\circledR\; b \in \textsf{Univ}_{i,k}^{\textbf{El}} && \text{(by \Cref{def:univ-term-pred} with the previous lines)} \end{aligned}

Case

Mathpar.

N <:_i N

P_1 \Leftrightarrow \textbf{El}_1 \Leftrightarrow P_2 \Leftrightarrow \textbf{El}_2 \Leftrightarrow \textsf{Nat}_i. Given \typing[\Gamma]{t}{S_1} \;\circledR\; b \in \textsf{Nat}_i.

\begin{aligned} &\typing[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i && \text{(by \Cref{def:nat-term-pred} on the hypothesis)} \\ &\subty[\Gamma]{S_1}{S_2} && \text{(by \Cref{lem:gluing-subty-typ})} \\ &\tyequiv[\Gamma]{S_1}{S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:nat-type-pred} on $S_1$ and $S_2$, both equal $\ensuremath{\texttt{Nat}}$)} \\ &\typing[\Gamma]{t}{S_2} \;\circledR\; b \in \textsf{Nat}_i && \text{(by \Cref{lem:gluing-respects-eq} (3) on $a = N$)} \end{aligned}

Case

Mathpar.

A A’ U_i R_I
  D :: a a’ R_I. T (, a/x) <:_i T’ (’, a’/x)

(A, T, ) (A, T, ) U_i
(A’, T’, ’) (A’, T’, ’) U_i (A, T, ) <:_i (A’, T’, ’)

P_1 \Leftrightarrow \Pi_i(R_I, P_I, \textbf{El}_I, P_O), \textbf{El}_1 \Leftrightarrow \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O), P_2 \Leftrightarrow \Pi_i(R_I, P_I, \textbf{El}_I, P_O'), \textbf{El}_2 \Leftrightarrow \Pi_i^{\textbf{El}}(R', R_I, P_I, \textbf{El}_I, \textbf{El}_O') (R_I, P_I, \textbf{El}_I shared via ?, as the domains are PER-equal). The hypothesis P_2 has shape \Pi(x:S_{2,1}).\,S_{2,2}; similarly S_1 has shape \Pi(x:S_{1,1}).\,S_{1,2} from the term-predicate hypothesis on \textbf{El}_1 via ? clause 3.

Setup: subtyping at the syntactic Pi-shapes.

\begin{aligned} &\typing[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) && \text{(by \Cref{def:pi-term-pred} clause 3 on $f \in \textbf{El}_1$)} \\ &\subty[\Gamma]{S_1}{S_2} && \text{(by \Cref{lem:gluing-subty-typ})} \end{aligned}

Given \typing[\Gamma]{t}{S_1} \;\circledR\; f \in \Pi_i^{\textbf{El}} at \textbf{El}_1. We verify the four clauses of \textbf{El}_2 \Leftrightarrow \Pi_i^{\textbf{El}}(R', R_I, P_I, \textbf{El}_I, \textbf{El}_O') at S_2, t, f.

Clause 1.

\begin{aligned} &f \approx f \in R && \text{(by hypothesis clause 1 on $f \in \textbf{El}_1$)} \\ &f \approx f \in R' && \text{(by \textsc{U-Pi}'s biconditional: domains equal,} \\ & && \text{codomains $R_O \mathrel{<:_i} R_O'$ from the inner subtyping)} \end{aligned}

Clause 2.

\begin{aligned} &\typing[\Gamma]{t}{S_1} && \text{(by hypothesis clause 2 on $f \in \textbf{El}_1$)} \\ &\typing[\Gamma]{t}{S_2} && \text{(by \textsc{Subsump} with $\subty[\Gamma]{S_1}{S_2}$)} \end{aligned}

Clause 3. \typing[\Gamma]{S_2}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O') holds directly by the lemma’s hypothesis on S_2, P_2.

Clause 4 (application). Let \kweak[\Delta]{\phi}{\Gamma}, s, b_0, \ensuremath{\mathcal{D}} :: b_0 \approx b_0 \in R_I with \typing[\Delta]{s}{S_{2,1}[\phi]} \;\circledR\; b_0 \in \textbf{El}_I.

\begin{aligned} &\typing[\Gamma]{S_{1,1}}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I,\; \typing[\Gamma]{S_{2,1}}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by clause 2 of $\Pi_i$ on $S_1, S_2$ at $\phi = \ensuremath{\textsf{id}}$)} \\ &\tyequiv[\Gamma]{S_{1,1}}{S_{2,1}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:gluing-functional} on the two predicates)} \\ &\tyequiv[\Delta]{S_{1,1}[\phi]}{S_{2,1}[\phi]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:wk-typing})} \\ &\typing[\Delta]{s}{S_{1,1}[\phi]} \;\circledR\; b_0 \in \textbf{El}_I && \text{(by \Cref{lem:gluing-respects-eq} (3) on the equality above)} \\ &f \cdot b_0 \searrow c,\; \typing[\Delta]{(t[\phi])\;s}{S_{1,2}[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by hypothesis clause 4 on $f \in \textbf{El}_1$)} \\ &\ensuremath{\llbracket T \rrbracket(\rho, b_0/x)} \mathrel{<:_i} \ensuremath{\llbracket T' \rrbracket(\rho', b_0/x)} && \text{(by codomain subtyping at $\ensuremath{\mathcal{D}} :: b_0 \approx b_0 \in R_I$)} \\ &\typing[\Delta]{S_{2,2}[\iota(\phi), s/x]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_O'(\ensuremath{\mathcal{D}}) && \text{(by clause 3 of $\Pi_i$ on $S_2$ at $\phi, s, b_0, \ensuremath{\mathcal{D}}$)} \\ &\typing[\Delta]{(t[\phi])\;s}{S_{2,2}[\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O'(\ensuremath{\mathcal{D}}) && \text{(by IH (term-transfer) on the codomain subtyping at $\ensuremath{\mathcal{D}}$,} \\ & && \text{using the previous-line type-predicate at level $i$)} \end{aligned}

Clause 5 (R_I-coherence under application). Inherited from clause 5 on f \in \textbf{El}_1, alongside the codomain subtyping: an R_I-class of arguments produces an R_O'-class of results in the codomain via clause 4.

Theorem

Theorem 7.32 (Realizability of the gluing model)

VEYB

Suppose a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}.

    (\textsf{Bot} enters \textbf{El}.) If \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Bot}_i^a, then \typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^a(w) \in \textbf{El}. (\textbf{El} enters \textsf{Top}.) If \typing[\Gamma]{t}{S} \;\circledR\; b \in \textbf{El} and b \approx b \in R (where a \approx a \in \mathcal{U}_i \searrow R), then \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Top}_i^a. (P enters \textsf{Top}.) If \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P, then \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Top}_i^a.

Proof of Theorem 7.32

By simultaneous induction on the lexicographic pair (i,\; a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}): the outer induction on the level i provides the IH at strictly smaller levels, used in the G-Univ case; the inner induction on the gluing derivation provides the IH at structurally smaller derivations at the same level i.

Case

Mathpar.

a = ^A(e)
P Neu_i^e
El Neu_i^e ^A(e) U_i^

    \textsf{Bot} enters \textbf{El}. Suppose \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Bot}_i^a. Unpacking ? clauses (a)–(c) yields \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e (the P-side component) and \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Ne}_i^a. These are exactly the four clauses of ? for the term {\uparrow}^A(w), hence \typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \textbf{El} \Leftrightarrow \textsf{Neu}_i^e. \textbf{El} enters \textsf{Top}. Suppose \typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \textsf{Neu}_i^e and {\uparrow}^A(w) \approx {\uparrow}^A(w) \in R. We assemble the three clauses of ?(c). The type-side gluing \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P \Leftrightarrow \textsf{Neu}_i^e is the inner component of \textsf{Neu}_i^e at term level. For \textsf{Nf}_i^a: for each \kweak[\Delta]{\phi}{\Gamma}, by Rf-ne:

    \begin{aligned} &\textsf{R}^{\textsf{Nf}}_{|\Delta|}({\downarrow}^{{\uparrow}^A(e)}({\uparrow}^A(w))) \searrow v && \text{(via $\textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow v$, by \textsc{Rf-ne})} \\ &\tyequiv[\Delta]{t[\phi]}{v}{S[\phi]} && \text{(by \Cref{def:neu-term-pred})} \end{aligned}

    This satisfies \textsf{Nf}_i^a, and packaged with \typing[\Gamma]{t}{S} and the type gluing yields \typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \textsf{Top}_i^a. P enters \textsf{Top}. Hypothesis: \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Neu}_i^e. We assemble the three clauses of ?(b). The first clause \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} is part of \textsf{Neu}_i^e. For a \approx a \in \mathcal{U}_i \searrow R: by ?, the binary relation R exists. For each \kweak[\Delta]{\phi}{\Gamma}:

    \begin{aligned} &\textsf{R}^{\textsf{Ne}}_{|\Delta|}(e) \searrow u && \text{(by \Cref{def:neu-type-pred} applied to $\textsf{Neu}_i^e$)} \\ &\textsf{R}^{\textsf{Ty}}_{|\Delta|}({\uparrow}^A(e)) \searrow u && \text{(by \textsc{Rty-ne})} \\ &\tyequiv[\Delta]{S[\phi]}{u}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:neu-type-pred})} \end{aligned}

Case

Mathpar.

P Nat_i
El Nat_i N U_i^

    \textsf{Bot} enters \textbf{El}. Suppose \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Bot}_i^N. Unpacking ?(a) yields \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i (which by ? gives \tyequiv[\Gamma]{S}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}}) and \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Ne}_i^N. The premises of GN-Ne are exactly these, hence {\uparrow}^N(w) \in \textsf{Nat}_i at t. \textbf{El} enters \textsf{Top}. Given \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Nat}_i and b \approx b \in R (where R is the Nat-PER closure), we establish the three clauses of ?(c). The type-side \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i is part of ?; for \textsf{Nf}_i^N, by inner induction on the derivation of b \in \textsf{Nat}_i.

      Mathpar.

      tzeroS tS ze Nat

      For each \kweak[\Delta]{\phi}{\Gamma}:

      \begin{aligned} &\textsf{R}^{\textsf{Nf}}_{|\Delta|}({\downarrow}^N(\texttt{ze})) \searrow \textsf{zero} && \text{(by \textsc{Rf-ze})} \\ &\tyequiv[\Delta]{t[\phi]}{\textsf{zero}}{S[\phi]} && \text{(by \Cref{lem:wk-typing} on the hypothesis)} \end{aligned}
      Mathpar.

      t’S b’ Nat
      tsucc t’S tS su(b’) Nat

      For each \kweak[\Delta]{\phi}{\Gamma}:

      \begin{aligned} &\textsf{R}^{\textsf{Nf}}_{|\Delta|}({\downarrow}^N(b')) \searrow w' && \text{(by inner IH on $b'$)} \\ &\tyequiv[\Delta]{t'[\phi]}{w'}{S[\phi]} && \text{(by inner IH on $b'$)} \\ &\textsf{R}^{\textsf{Nf}}_{|\Delta|}({\downarrow}^N(\texttt{su}(b'))) \searrow \textsf{succ}~w' && \text{(by \textsc{Rf-su})} \\ &\tyequiv[\Delta]{\textsf{succ}~t'[\phi]}{\textsf{succ}~w'}{S[\phi]} && \text{(by \textsc{Su-Cong} on the previous line)} \\ &\tyequiv[\Delta]{t[\phi]}{\textsf{succ}~w'}{S[\phi]} && \text{(by transitivity with the \textsc{GN-Su} hypothesis)} \end{aligned}
      Mathpar.

      tS ^N(w) Neu_i^e tS ^N(w) Nat

      For each \kweak[\Delta]{\phi}{\Gamma}:

      \begin{aligned} &\textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow v && \text{(by hypothesis on $w \in \textsf{Ne}_i^a$)} \\ &\textsf{R}^{\textsf{Nf}}_{|\Delta|}({\downarrow}^N({\uparrow}^N(w))) \searrow v && \text{(by \textsc{Rf-ne})} \\ &\tyequiv[\Delta]{t[\phi]}{v}{S[\phi]} && \text{(by hypothesis on $w$)} \end{aligned}

    P enters \textsf{Top}. Hypothesis: \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i. We assemble the three clauses of ?(b). The first clause \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} is part of ? via presupposition. For N \approx N \in \mathcal{U}_i \searrow R_N: immediate by the PER definition. For each \kweak[\Delta]{\phi}{\Gamma}:

    \begin{aligned} &\textsf{R}^{\textsf{Ty}}_{|\Delta|}(N) \searrow \ensuremath{\texttt{Nat}} && \text{(by \textsc{Rty-N})} \\ &\tyequiv[\Delta]{S[\phi]}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:nat-type-pred})} \end{aligned}

Case

Mathpar.

a = (a_I, T, )
a_I U_i^P_I El_I

 D :: b b R_I, c. T (, b/x) c c U_i^P_O(D) El_O(D)

P _i(R_I, P_I, P_O)
El _i^El(R, R_I, P_I, El_I, El_O) (a_I, T, ) U_i^

By inner IH-(1) on a_I, neutral inhabitants enter \textbf{El}_I; by inner IH-(2) on a_I, \textbf{El}_I-elements read back; analogously for \textbf{El}_O(\ensuremath{\mathcal{D}}) at each \ensuremath{\mathcal{D}}.

    \textsf{Bot} enters \textbf{El}. Suppose

    \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Bot}_i^a.

    Unpacking ?(a) yields

    \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O)

    together with \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Ne}_i^a. We verify the four clauses of ? for {\uparrow}^a(w).

      Self-relatedness {\uparrow}^a(w) \approx {\uparrow}^a(w) \in R holds by U-Ne of the PER closure. Coherence under R_I: trivial because the function value does not depend on a representative of R_I on the left of the predicate. For each \kweak[\Delta]{\phi}{\Gamma}, \textsf{R}^{\textsf{Ne}}_{|\Delta|}(w) \searrow v by hypothesis on w \in \textsf{Ne}, so the type readback obligation holds via ?. Application: given \kweak[\Delta]{\phi}{\Gamma} and \typing[\Delta]{s}{S_1[\phi]} \;\circledR\; b \in \textbf{El}_I with \ensuremath{\mathcal{D}} :: b \approx b \in R_I (by inner IH-(1) bridging through ?, applied to b):

      \begin{aligned} &\ensuremath{\llbracket T \rrbracket(\rho, b/x)} \searrow c_b && \text{(evaluation of $T$ at $\rho, b/x$; well-defined since $\Pi(a_I, T, \rho) \approx \Pi(a_I, T, \rho) \in \mathcal{U}_i$)} \\ &c_b \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by the \textsc{G-Pi} codomain clause applied to $\ensuremath{\mathcal{D}}$ and $c_b$)} \\ &b \in \textsf{Nf}_i^{a_I} && \text{(by inner IH-(2) on $a_I$ applied to $b \in \textbf{El}_I$)} \\ &\textsf{R}^{\textsf{Nf}}_{|\Delta|}({\downarrow}^{a_I}(b)) \searrow u_b && \text{(by the previous line)} \\ &{\uparrow}^a(w) \cdot b \searrow {\uparrow}^{c_b}(w \;\$\; {\downarrow}^{a_I}(b)) && \text{(by neutral application)} \\ &w \;\$\; {\downarrow}^{a_I}(b) \in \textsf{Ne}_i^{c_b} && \text{(by \textsc{Rne-app}, using $\textsf{R}^{\textsf{Ne}}_{|\Delta|}(w)$ and $u_b$)} \\ &\typing[\Delta]{(t[\phi])\;s}{S_2[\iota(\phi), s/x]} \\ & \quad \;\circledR\; {\uparrow}^{c_b}(w \;\$\; {\downarrow}^{a_I}(b)) \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by inner IH-(1) on $c_b$)} \end{aligned}

    \textbf{El} enters \textsf{Top}. Suppose \typing[\Gamma]{t}{S} \;\circledR\; f \in \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) and f \approx f \in R. We assemble the three clauses of ?(c). The type-side \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) is part of ?; the term-typing \typing[\Gamma]{t}{S} likewise. For \textsf{Nf}_i^a, for each \kweak[\Delta]{\phi}{\Gamma}, set n := |\Delta| and form \Delta' := \Delta, x' : S_1[\phi] together with the lifted Kripke weakening \phi \circ \Uparrow (by KW-Shift; ?).

    \begin{aligned} &\typing[\Delta']{x'}{S_1[\phi \circ \Uparrow]} \;\circledR\; {\uparrow}^{a_I}(\ell_n) \in \textbf{El}_I && \text{(by inner IH-(1) on $a_I$ applied to $\ell_n$)} \\ &f \cdot {\uparrow}^{a_I}(\ell_n) \searrow c && \text{(by clause (4) of $\Pi_i^{\textbf{El}}$ on $f$)} \\ &\typing[\Delta']{(t[\phi \circ \Uparrow])\;x'} {S_2[\iota(\phi \circ \Uparrow), x'/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}') && \text{(by clause (4) on $f$, with $\ensuremath{\mathcal{D}}'$ the witness from line 1)} \\ &c \in \textsf{Nf}_i^{c_{\ell_n}} && \text{(by inner IH-(2) on $c_{\ell_n} \in \mathcal{U}_i^\ast$)} \\ &\textsf{R}^{\textsf{Nf}}_{n+1}({\downarrow}^{c_{\ell_n}}(c)) \searrow v && \text{(by the previous line)} \\ &\tyequiv[\Delta']{(t[\phi \circ \Uparrow])\;x'}{v} {S_2[\iota(\phi \circ \Uparrow), x'/x]} && \text{(by inner IH-(2) on $c_{\ell_n}$)} \\ &\textsf{R}^{\textsf{Nf}}_n({\downarrow}^a(f)) \searrow \lambda x.\,v && \text{(by \textsc{Rf-Pi}, using the previous line)} \\ &\tyequiv[\Delta]{t[\phi]}{\lambda x.\,(t[\phi \circ \Uparrow])\;x'} {S[\phi]} && \text{(by \textsc{$\Pi$-$\eta$})} \\ &\tyequiv[\Delta]{t[\phi]}{\lambda x.\,v}{S[\phi]} && \text{(by congruence with the $\textsf{R}^{\textsf{Nf}}$ equality)} \end{aligned}

    P enters \textsf{Top}. Hypothesis: \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O). We assemble the three clauses of ?(b). The first clause \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} is part of ?. For a \approx a \in \mathcal{U}_i \searrow R: by ? on the components a_I and c at each \ensuremath{\mathcal{D}}, the binary closure exists. For each \kweak[\Delta]{\phi}{\Gamma}, set n := |\Delta|:

    \begin{aligned} &\textsf{R}^{\textsf{Ty}}_n(a_I) \searrow W_S,\; \tyequiv[\Delta]{S_1[\phi]}{W_S}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by inner IH-(3) on $a_I$)} \\ &\ensuremath{\llbracket T \rrbracket(\rho, {\uparrow}^{a_I}(\ell_n)/x)} \searrow c_{\ell_n} && \text{(by \Cref{def:pi-type-pred})} \\ &\textsf{R}^{\textsf{Ty}}_{n+1}(c_{\ell_n}) \searrow W_T && \text{(by inner IH-(3) on $c_{\ell_n}$)} \\ &\tyequiv[\Delta, x' : S_1[\phi]]{S_2[\iota(\phi \circ \Uparrow), x'/x]} {W_T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by inner IH-(3) on $c_{\ell_n}$)} \\ &\textsf{R}^{\textsf{Ty}}_n(\Pi(a_I, T, \rho)) \searrow \Pi(x:W_S).\,W_T && \text{(by \textsc{Rty-Pi})} \\ &\tyequiv[\Delta]{S[\phi]}{\Pi(x:W_S).\,W_T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:pi-type-pred} clauses 1--3 and \textsc{$\Pi$-Cong})} \end{aligned}

Case

Mathpar.

j < i
P Univ_i,j
El Univ_i,j^El U_j U_i^

Since j < i, the outer-IH applies at level j to every value b \in \mathcal{U}_j^\ast.

    \textsf{Bot} enters \textbf{El}. Suppose \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Bot}_i^{U_j}. Unpacking ?(a) yields \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j} and \typing[\Gamma]{t}{S} \;\circledR\; w \in \textsf{Ne}_i^{U_j}. Apply G-Ne at level j:

    \begin{aligned} &{\uparrow}^A(w) \in \mathcal{U}_j^\ast \searrow \textsf{Neu}_j^e \searrow \textsf{Neu}_j^e && \text{(by \textsc{G-Ne} at level $j$)} \\ &\typing[\Gamma]{t}{S} \;\circledR\; {\uparrow}^A(w) \in \mathcal{U}_j^\ast && \text{(by \Cref{def:univ-term-pred} clause (1) with the previous line)} \\ &\typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; \textsf{Neu}_j^e && \text{(by \Cref{def:univ-term-pred} clause (2);} \\ & && \text{the type predicate attached to ${\uparrow}^A(w)$ is} \\ & && \text{$\textsf{Neu}_j^e$, which by hypothesis on $w$ inhabits} \\ & && \text{the type-predicate condition; the equality} \\ & && \text{$\tyequiv[\Gamma]{S}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}$ comes from \Cref{def:univ-type-pred})} \end{aligned}

    \textbf{El} enters \textsf{Top}. Suppose \typing[\Gamma]{t}{S} \;\circledR\; b \in \textsf{Univ}_{i,j}^{\textbf{El}} and b \approx b \in R. By ?, b \in \mathcal{U}_j^\ast \searrow P_b \searrow \textbf{El}_b for some P_b, \textbf{El}_b, with \typing[\Gamma]{t}{\ensuremath{\texttt{Ty}_{j}}} \;\circledR\; P_b at the type level. We assemble ?(c). The P-side \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j} comes from ?; for \textsf{Nf}_i^{U_j}, for each \kweak[\Delta]{\phi}{\Gamma}, n := |\Delta|:

    \begin{aligned} &\textsf{R}^{\textsf{Ty}}_n(b) \searrow W && \text{(by outer-IH-(3) on $b \in \mathcal{U}_j^\ast$)} \\ &\tyequiv[\Delta]{t[\phi]}{W}{\ensuremath{\texttt{Ty}_{j}}} && \text{(by outer-IH-(3) on $b$)} \\ &\textsf{R}^{\textsf{Nf}}_n({\downarrow}^{U_j}(b)) \searrow W && \text{(by \textsc{Rf-Univ})} \\ &\tyequiv[\Delta]{t[\phi]}{W}{S[\phi]} && \text{(by \Cref{def:univ-type-pred}: $\tyequiv[\Delta]{S[\phi]}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}$,} \\ & && \text{and \textsc{Subsump} from the $\ensuremath{\texttt{Ty}_{j}}$-equality)} \end{aligned}

    P enters \textsf{Top}. Hypothesis: \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Univ}_{i,j}. We assemble ?(b). The first clause is from ?; for U_j \approx U_j \in \mathcal{U}_i \searrow R, immediate from U-Univ of the PER. For each \kweak[\Delta]{\phi}{\Gamma}:

    \begin{aligned} &\textsf{R}^{\textsf{Ty}}_{|\Delta|}(U_j) \searrow \ensuremath{\texttt{Ty}_{j}} && \text{(by \textsc{Rty-Univ})} \\ &\tyequiv[\Delta]{S[\phi]}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{def:univ-type-pred})} \end{aligned}
Lemma

Lemma 7.33 (Initial Environment Validity)

6BBE

If \Gamma \searrow \textsf{Sb}, then \judge[\Gamma]{\ensuremath{\textsf{id}} : \Gamma} \;\circledR\; {\uparrow}^\Gamma \in \textsf{Sb}.

Proof of Lemma 7.33

By induction on \Gamma \searrow \textsf{Sb}.

Case

Mathpar.

Sb (: ) Sb

\judge[\cdot]{\ensuremath{\textsf{id}} : \cdot} holds trivially, hence \judge[\cdot]{\ensuremath{\textsf{id}} : \cdot} \;\circledR\; {\uparrow}^\cdot \in \textsf{Sb}.

Case

Mathpar.

’ Sb’
S_kTy_i

_0, _T, _T. _T : ’ _T Sb’
a, P, El. S_k (_T) a a U_i^P El S_k[_T]Ty_i P

Sb Cons_i(’, S_k, Sb’) (’, x_k : S_k) Sb

Set \Gamma := \Gamma', x_k : S_k with |\Gamma| = k+1.

\begin{aligned} &\judge[\Gamma']{\ensuremath{\textsf{id}} : \Gamma'} \;\circledR\; {\uparrow}^{\Gamma'} \in \textsf{Sb}' && \text{(by IH on $\Gamma' \searrow \textsf{Sb}'$)} \\ &\ensuremath{\llbracket S_k \rrbracket({\uparrow}^{\Gamma'})} \searrow A_k,\; A_k \in \mathcal{U}_i^\ast \searrow P_k \searrow \textbf{El}_k && \text{(by the universal type-clause of \textsc{G-Ctx-Ext}} \\ & && \text{instantiated at $\ensuremath{\textsf{id}}, {\uparrow}^{\Gamma'}$)} \\ &\typing[\Gamma']{S_k[\ensuremath{\textsf{id}}]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_k && \text{(type clause at the same instantiation)} \\ &\typing[\Gamma']{S_k}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_k && \text{(using $S_k[\ensuremath{\textsf{id}}] = S_k$)} \end{aligned}

We supply the head witness for \textsf{Cons}_i:

\begin{aligned} &{\uparrow}^\Gamma = ({\uparrow}^{\Gamma'},\, {\uparrow}^{A_k}(\ell_k)/x_k) && \text{(by \Cref{def:init-env})} \\ &\typing[\Gamma]{x_k}{S_k[\Uparrow]} && \text{(by \textsc{Var-Hd})} \\ &\textsf{R}^{\textsf{Ne}}_{|\Delta'|}(\ell_k) \searrow x_{|\Delta'| - k - 1} \text{ for each $\kweak[\Delta']{\phi}{\Gamma}$} && \text{(by \textsc{Rne-var}, the level-reading rule for $\ell_k$)} \\ &\tyequiv[\Delta']{x_k[\phi]}{x_{|\Delta'| - k - 1}}{S_k[\Uparrow][\phi]} && \text{(by the syntactic action of $\phi$ on the variable $x_k$)} \\ &\typing[\Gamma]{x_k}{S_k[\Uparrow]} \;\circledR\; \ell_k \in \textsf{Ne}_i^{A_k} && \text{(by \Cref{def:neu-term-pred}, using the previous two lines)} \\ &\typing[\Gamma]{x_k}{S_k[\Uparrow]} \;\circledR\; {\uparrow}^{A_k}(\ell_k) \in \textbf{El}_k && \text{(by \Cref{thm:gluing-realizability} part (1) on $A_k$)} \\ &\judge[\Gamma]{\ensuremath{\textsf{id}} : \Gamma} \;\circledR\; {\uparrow}^\Gamma \in \textsf{Sb} && \text{(by $\textsf{Cons}_i$ assembly: tail (IH) and head witness above)} \end{aligned}
Lemma

Lemma 7.34 (Semantic — Ctx-Emp)

24RG

\Vdash \cdot.

Proof of Lemma 7.34

By G-Ctx-\cdot: \cdot \searrow \textsf{Sb} where \textsf{Sb} \Leftrightarrow (\judge[\Delta]{\sigma : \cdot}). Hence \Vdash \cdot by ?.

Lemma

Lemma 7.35 (Semantic — Ctx-Ext)

BG26

If \Vdash \Gamma and \Semtyp[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}, then \Vdash \Gamma, x:S.

Proof of Lemma 7.35

By \Vdash \Gamma, fix \Gamma \searrow \textsf{Sb}_T for some \textsf{Sb}_T. We supply each premise of G-Ctx-Ext.

Syntactic typing of S. By ? on \Gamma \searrow \textsf{Sb}_T, the initial pair \judge[\Gamma]{\ensuremath{\textsf{id}} : \Gamma} \;\circledR\; {\uparrow}^\Gamma \in \textsf{Sb}_T is in \textsf{Sb}_T. By \Semtyp[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} at this pair, \typing[\Gamma]{S[\ensuremath{\textsf{id}}]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P for some P, hence \typing[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} by ? (using S[\ensuremath{\textsf{id}}] = S).

Universal type-clause. Let \judge[\Delta']{\sigma_T : \Gamma} \;\circledR\; \rho_T \in \textsf{Sb}_T be arbitrary. By \Semtyp[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}} at \sigma_T, \rho_T:

\begin{aligned} &\ensuremath{\llbracket S \rrbracket(\rho_T)} \searrow a,\; a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} && \text{(by $\Semtyp[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}$ at $\sigma_T, \rho_T$)} \\ &\typing[\Delta']{S[\sigma_T]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P && \text{(by $\Semtyp[\Gamma]{S}{\ensuremath{\texttt{Ty}_{i}}}$, type part)} \end{aligned}

This supplies the universal-clause witness for the given \sigma_T, \rho_T.

By G-Ctx-Ext: (\Gamma, x:S) \searrow \textsf{Sb} where \textsf{Sb} \Leftrightarrow \textsf{Cons}_i(\Gamma, S, \textsf{Sb}_T). Hence \Vdash \Gamma, x:S by ?.

Lemma

Lemma 7.36 (Semantic — Var)

7CMN

If \Vdash \Gamma and x : S \in \Gamma, then \Semtyp[\Gamma]{x}{S}.

Proof of Lemma 7.36

By \Vdash \Gamma, fix \Gamma \searrow \textsf{Sb} and let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given. We proceed by induction on the lookup derivation x : S \in \Gamma.

Case

Mathpar.

x_0 : T[] _0, x_0 : T

Here \Gamma = \Gamma_0, x_0:T and S = T[\Uparrow]. We must show \Semtyp[\Gamma]{x_0}{T[\Uparrow]}: for the given \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb}, evaluating T[\Uparrow] at \rho yields a value a^\ast with a^\ast \in \mathcal{U}_i^\ast \searrow P^\ast \searrow \textbf{El}^\ast, and:

    \typing[\Delta]{T[\Uparrow \circ \sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P^\ast, and \typing[\Delta]{x_0[\sigma]}{T[\Uparrow \circ \sigma]} \;\circledR\; \ensuremath{\llbracket x_0 \rrbracket(\rho)} \in \textbf{El}^\ast.

Since \Gamma = \Gamma_0, x_0:T, the gluing \Gamma \searrow \textsf{Sb} is by G-Ctx-Ext on \Gamma_0 \searrow \textsf{Sb}_{T_0} with \typing[\Gamma_0]{T}{\ensuremath{\texttt{Ty}_{i}}}, and \textsf{Sb} \Leftrightarrow \textsf{Cons}_i(\Gamma_0, T, \textsf{Sb}_{T_0}). Unfolding \textsf{Cons}_i at our \sigma, \rho (which provides existential a, P, \textbf{El} specific to this \sigma, \rho):

\begin{aligned} &\judge[\Delta]{\Uparrow \circ \sigma : \Gamma_0} \;\circledR\; \rho[\Uparrow] \in \textsf{Sb}_{T_0} && \text{(tail of $\textsf{Cons}_i$)} \\ &\ensuremath{\llbracket T \rrbracket(\rho[\Uparrow])} \searrow a,\; a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} && \text{(type clause of $\textsf{Cons}_i$)} \\ &\typing[\Delta]{T[\Uparrow \circ \sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P && \text{(type clause of $\textsf{Cons}_i$)} \\ &\typing[\Delta]{x_0[\sigma]}{T[\Uparrow \circ \sigma]} \;\circledR\; \rho(x_0) \in \textbf{El} && \text{(head of $\textsf{Cons}_i$)} \\ &\ensuremath{\llbracket x_0 \rrbracket(\rho)} = \rho(x_0) && \text{(by \textsc{ev-var})} \end{aligned}

Establishing the goal \ensuremath{\llbracket T[\Uparrow] \rrbracket(\rho)} \searrow a^\ast at the same (P, \textbf{El}). The \textsf{Cons}_i type clause gives \ensuremath{\llbracket T \rrbracket(\rho[\Uparrow])} \searrow a, but the goal needs \ensuremath{\llbracket T[\Uparrow] \rrbracket(\rho)} \searrow a^\ast. By ? of ? on \typing[\Gamma_0]{T}{\ensuremath{\texttt{Ty}_{i}}}, \semtyeq[\Gamma_0]{T}{T}{\ensuremath{\texttt{Ty}_{i}}}. Instantiate this at \Uparrow and \rho (self-related in R_\Gamma):

\begin{aligned} &\semweak[\Gamma]{\Uparrow}{\Gamma_0} && \text{(by \textsc{KW-Shift})} \\ &\semtyeq[\Gamma]{\Uparrow}{\Uparrow}{\Gamma_0} && \text{(by \Cref{lem:sem-wk})} \\ &\ensuremath{\llbracket T[\Uparrow] \rrbracket(\rho)} \approx \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \Uparrow \rrbracket(\rho)})} \in \mathcal{U}_i \searrow R && \text{(four-value pattern of $\semtyeq[\Gamma_0]{T}{T}{\ensuremath{\texttt{Ty}_{i}}}$ at $\Uparrow, \rho$)} \\ &\ensuremath{\llbracket \Uparrow \rrbracket(\rho)} = \rho[\Uparrow] && \text{(by definition of weakening evaluation, \Cref{sec:sem})} \\ &a^\ast \approx a \in \mathcal{U}_i \searrow R && \text{(rewriting $\ensuremath{\llbracket T[\Uparrow] \rrbracket(\rho)} = a^\ast$ and $\ensuremath{\llbracket T \rrbracket(\rho[\Uparrow])} = a$)} \\ &a^\ast \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} && \text{(by \Cref{lem:gluing-univ-equiv} from $a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}$)} \end{aligned}

This supplies the goal evaluation \ensuremath{\llbracket T[\Uparrow] \rrbracket(\rho)} \searrow a^\ast with a^\ast \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}, where (P, \textbf{El}) are the same predicates packaged by \textsf{Cons}_i. Clauses (1) and (2) of \Semtyp[\Gamma]{x_0}{T[\Uparrow]} are exactly the \textsf{Cons}_i type clause \typing[\Delta]{T[\Uparrow \circ \sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P and the head’s \textbf{El}-witness \rho(x_0) = \ensuremath{\llbracket x_0 \rrbracket(\rho)} above.

Case

Mathpar.

y : S’ _0 1+y : S’[] _0, z:T

Here \Gamma = \Gamma_0, z:T, x = 1{+}y for some y with y : S' \in \Gamma_0, and S = S'[\Uparrow]. We must show \Semtyp[\Gamma]{1{+}y}{S'[\Uparrow]}: evaluating S'[\Uparrow] at \rho yields a value a^\ast in \mathcal{U}_i^\ast \searrow P^\ast \searrow \textbf{El}^\ast, with the type and term predicates at \sigma, \rho. \textsf{Sb} unfolds to \textsf{Cons}_i at \sigma, \rho, giving the tail \Uparrow \circ \sigma, \rho[\Uparrow] \in \textsf{Sb}_T.

Apply IH on the tail.

\begin{aligned} &\judge[\Delta]{\Uparrow \circ \sigma : \Gamma_0} \;\circledR\; \rho[\Uparrow] \in \textsf{Sb}_T && \text{(tail of $\textsf{Cons}_i$)} \\ &y : S' \in \Gamma_0 && \text{(premise)} \\ &\Semtyp[\Gamma_0]{y}{S'} && \text{(by IH on the shorter lookup derivation,} \\ & && \text{with $\Vdash \Gamma_0$ from $\Vdash \Gamma$ via the tail)} \\ &\ensuremath{\llbracket S' \rrbracket(\rho[\Uparrow])} \searrow b,\; b \in \mathcal{U}_i^\ast \searrow P' \searrow \textbf{El}' && \text{(by IH on $S'$ at $\Uparrow \circ \sigma, \rho[\Uparrow]$)} \\ &\typing[\Delta]{S'[\Uparrow \circ \sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P' && \text{(by IH on $S'$, type part)} \\ &\typing[\Delta]{y[\Uparrow \circ \sigma]}{S'[\Uparrow \circ \sigma]} \;\circledR\; \ensuremath{\llbracket y \rrbracket(\rho[\Uparrow])} \in \textbf{El}' && \text{(by IH on $y$, term part)} \end{aligned}

Bridging the goal evaluation \ensuremath{\llbracket S'[\Uparrow] \rrbracket(\rho)} to b. By ? of ? on \typing[\Gamma_0]{S'}{\ensuremath{\texttt{Ty}_{i}}} (extracted from the IH via ?): \semtyeq[\Gamma_0]{S'}{S'}{\ensuremath{\texttt{Ty}_{i}}}. Instantiating at \Uparrow and \rho (self-related in R_\Gamma):

\begin{aligned} &\ensuremath{\llbracket \Uparrow \rrbracket(\rho)} = \rho[\Uparrow] && \text{(by definition of weakening evaluation, \Cref{sec:sem})} \\ &\ensuremath{\llbracket S'[\Uparrow] \rrbracket(\rho)} \approx \ensuremath{\llbracket S' \rrbracket(\rho[\Uparrow])} \in \mathcal{U}_i \searrow R' && \text{(four-value pattern of $\semtyeq[\Gamma_0]{S'}{S'}{\ensuremath{\texttt{Ty}_{i}}}$ at $\Uparrow, \rho$)} \\ &a^\ast \approx b \in \mathcal{U}_i \searrow R' && \text{(rewriting $\ensuremath{\llbracket S'[\Uparrow] \rrbracket(\rho)} = a^\ast$ and $\ensuremath{\llbracket S' \rrbracket(\rho[\Uparrow])} = b$)} \\ &a^\ast \in \mathcal{U}_i^\ast \searrow P' \searrow \textbf{El}' && \text{(by \Cref{lem:gluing-univ-equiv} from $b \in \mathcal{U}_i^\ast \searrow P' \searrow \textbf{El}'$)} \end{aligned}

The term-side equality \ensuremath{\llbracket 1{+}y \rrbracket(\rho)} = \ensuremath{\llbracket y \rrbracket(\rho[\Uparrow])} holds directly: \ensuremath{\llbracket 1{+}y \rrbracket(\rho)} = \rho(1{+}y) = \rho[\Uparrow](y) = \ensuremath{\llbracket y \rrbracket(\rho[\Uparrow])} (variable lookup), so no bridging is needed for the term side.

Assembling the goal.

\begin{aligned} &(1{+}y)[\sigma] = y[\Uparrow \circ \sigma] && \text{(by syntactic action and \Cref{lem:subst-assoc})} \\ &S'[\Uparrow][\sigma] = S'[\Uparrow \circ \sigma] && \text{(by \Cref{lem:subst-assoc})} \\ &\typing[\Delta]{(1{+}y)[\sigma]}{S'[\Uparrow][\sigma]} \;\circledR\; \ensuremath{\llbracket 1{+}y \rrbracket(\rho)} \in \textbf{El}' && \text{(rewriting the IH instance via the previous identities)} \end{aligned}

This supplies the goal at a^\ast \in \mathcal{U}_i^\ast \searrow P' \searrow \textbf{El}'.

Lemma

Lemma 7.37 (Semantic — U-Wf)

C4N3

If \Vdash \Gamma and j < i, then \Semtyp[\Gamma]{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}}.

Proof of Lemma 7.37

By \Vdash \Gamma, fix \Gamma \searrow \textsf{Sb} and let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given. Type is \ensuremath{\texttt{Ty}_{i}}, sitting at universe-level 1+i. We establish the four clauses of \Semtyp[\Gamma]{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} at a = U_i, P = \textsf{Univ}_{1+i, i}, \textbf{El} = \textsf{Univ}_{1+i, i}^{\textbf{El}}.

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\rho)} \searrow U_i && \text{(by \textsc{ev-U})} \\ &U_i \in \mathcal{U}_{1+i}^\ast \searrow \textsf{Univ}_{1+i, i} \searrow \textsf{Univ}_{1+i, i}^{\textbf{El}} && \text{(by \textsc{G-Univ})} \\ &\ensuremath{\texttt{Ty}_{i}}[\sigma] = \ensuremath{\texttt{Ty}_{i}} && \text{(syntactic; closed)} \\ &\tyequiv[\Delta]{\ensuremath{\texttt{Ty}_{i}}[\sigma]}{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{1+i}}} && \text{(by reflexivity)} \\ &\typing[\Delta]{\ensuremath{\texttt{Ty}_{i}}[\sigma]}{\ensuremath{\texttt{Ty}_{1+i}}} \;\circledR\; \textsf{Univ}_{1+i, i} && \text{(by \Cref{def:univ-type-pred})} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{j}} \rrbracket(\rho)} \searrow U_j && \text{(by \textsc{ev-U})} \\ &U_j \in \mathcal{U}_{1+j}^\ast \searrow \textsf{Univ}_{1+j, j} \searrow \textsf{Univ}_{1+j, j}^{\textbf{El}} && \text{(by \textsc{G-Univ} at level $1+j$)} \\ &U_j \in \mathcal{U}_i^\ast \searrow \textsf{Univ}_{i, j} \searrow \textsf{Univ}_{i, j}^{\textbf{El}} && \text{(by \Cref{lem:gluing-cumul} from $1+j \le i$, since $j < i$)} \\ &\tyequiv[\Delta]{\ensuremath{\texttt{Ty}_{j}}[\sigma]}{\ensuremath{\texttt{Ty}_{j}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by reflexivity, $j < i$)} \\ &\typing[\Delta]{\ensuremath{\texttt{Ty}_{j}}[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; U_j \in \textsf{Univ}_{1+i, i}^{\textbf{El}} && \text{(by \Cref{def:univ-term-pred} on $U_j \in \mathcal{U}_i^\ast \searrow \textsf{Univ}_{i,j} \searrow \textsf{Univ}_{i,j}^{\textbf{El}}$)} \end{aligned}
Lemma

Lemma 7.38 (Semantic — N-Wf)

ZP8P

If \Vdash \Gamma, then \Semtyp[\Gamma]{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} for every i.

Proof of Lemma 7.38

By \Vdash \Gamma, fix \Gamma \searrow \textsf{Sb} and let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given. We establish the four clauses of \Semtyp[\Gamma]{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} at a = U_i, P = \textsf{Univ}_{1+i, i}, \textbf{El} = \textsf{Univ}_{1+i, i}^{\textbf{El}}.

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\rho)} \searrow U_i && \text{(by \textsc{ev-U})} \\ &U_i \in \mathcal{U}_{1+i}^\ast \searrow \textsf{Univ}_{1+i, i} \searrow \textsf{Univ}_{1+i, i}^{\textbf{El}} && \text{(by \textsc{G-Univ})} \\ &\ensuremath{\texttt{Ty}_{i}}[\sigma] = \ensuremath{\texttt{Ty}_{i}} && \text{(syntactic; closed)} \\ &\tyequiv[\Delta]{\ensuremath{\texttt{Ty}_{i}}[\sigma]}{\ensuremath{\texttt{Ty}_{i}}}{\ensuremath{\texttt{Ty}_{1+i}}} && \text{(by reflexivity)} \\ &\typing[\Delta]{\ensuremath{\texttt{Ty}_{i}}[\sigma]}{\ensuremath{\texttt{Ty}_{1+i}}} \;\circledR\; \textsf{Univ}_{1+i, i} && \text{(by \Cref{def:univ-type-pred})} \\ &\ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\rho)} \searrow N && \text{(by \textsc{ev-N})} \\ &N \in \mathcal{U}_i^\ast \searrow \textsf{Nat}_i \searrow \textsf{Nat}_i && \text{(by \textsc{G-Nat})} \\ &\ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}} && \text{(syntactic; closed)} \\ &\tyequiv[\Delta]{\ensuremath{\texttt{Nat}}[\sigma]}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by reflexivity)} \\ &\typing[\Delta]{\ensuremath{\texttt{Nat}}[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; N \in \textsf{Univ}_{1+i, i}^{\textbf{El}} && \text{(by \Cref{def:univ-term-pred} on $N \in \mathcal{U}_i^\ast$)} \end{aligned}
Lemma

Lemma 7.39 (Semantic — \Pi-Wf)

UN9K

If \Semtyp[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} and \Semtyp[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}}, then \Semtyp[\Gamma]{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}}.

Proof of Lemma 7.39

Fix \Gamma \searrow \textsf{Sb} from \Semtyp[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} and \Gamma, x:S_1 \searrow \textsf{Sb}' from \Semtyp[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}}. By inversion on G-Ctx-Ext for the latter, \textsf{Sb}' \Leftrightarrow \textsf{Cons}_i(\Gamma, S_1, \textsf{Sb}) (using \textsf{Sb} uniqueness up to biimplication via ?).

Let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given. By hypothesis on S_1 at \sigma, \rho:

\begin{aligned} &\ensuremath{\llbracket S_1 \rrbracket(\rho)} \searrow a_I,\; a_I \in \mathcal{U}_i^\ast \searrow P_I \searrow \textbf{El}_I && \text{(by hypothesis on $S_1$)} \\ &\typing[\Delta]{S_1[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by hypothesis on $S_1$, type part at level $1+i$)} \\ &a_I \approx a_I \in \mathcal{U}_i \searrow R_I && \text{(by \Cref{lem:gluing-implies-per})} \\ &\ensuremath{\llbracket \Pi(x:S_1).\,S_2 \rrbracket(\rho)} \searrow \Pi(a_I,\, S_2,\, \rho) && \text{(by \textsc{ev-Pi})} \end{aligned}

By syntactic substitution:

\begin{aligned} &(\Pi(x:S_1).\,S_2)[\sigma] = \Pi(x:S_1[\sigma]).\,(S_2[q(\sigma)]) && \text{(definition of substitution on $\Pi$)} \end{aligned}

We construct \Pi(a_I, S_2, \rho) \in \mathcal{U}_i^\ast by G-Pi, deriving each premise. We first establish the PER-side membership of the \Pi, which introduces the codomain PER family R_O used below.

PER-side: \Pi(a_I, S_2, \rho) \approx \Pi(a_I, S_2, \rho) \in \mathcal{U}_i \searrow R.

\begin{aligned} &\typing[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:gluing-typ-escape} on hypothesis $S_1$)} \\ &\typing[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:gluing-typ-escape} on hypothesis $S_2$)} \\ &\typing[\Gamma]{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \textsc{$\Pi$-Wf})} \\ &\semtyeq[\Gamma]{\Pi(x:S_1).\,S_2}{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{thm:fundamental} of \Cref{sec:comp})} \\ &\Pi(a_I, S_2, \rho) \approx \Pi(a_I, S_2, \rho) \in \mathcal{U}_i \searrow R && \text{(by instantiating at $\sigma, \rho$ self-related in $R_\Gamma$)} \end{aligned}

Inverting the resulting U-Pi witness yields the codomain PER family: for every \ensuremath{\mathcal{D}} :: b \approx b \in R_I, \ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} \approx \ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}).

Codomain gluing. Let \ensuremath{\mathcal{D}} :: b \approx b \in R_I and c with \ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} \searrow c be given.

\begin{aligned} &c \approx c \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}) && \text{(by the codomain PER family established above)} \\ &c \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:per-implies-gluing})} \end{aligned}

This defines P_O(\ensuremath{\mathcal{D}}), \textbf{El}_O(\ensuremath{\mathcal{D}}); functionality in \ensuremath{\mathcal{D}} follows from ?, since glu-univ-elem predicates at a fixed domain value are unique up to logical equivalence.

Combining all premises:

\begin{aligned} &\Pi(a_I, S_2, \rho) \in \mathcal{U}_i^\ast \searrow \Pi_i(R_I, P_I, \textbf{El}_I, P_O) \searrow \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) && \text{(by \textsc{G-Pi})} \end{aligned}

Type-predicate \Pi_i at (\Pi(x:S_1).\,S_2)[\sigma]. We verify the three clauses of ?.

Clause 1.

\begin{aligned} &(\Pi(x:S_1).\,S_2)[\sigma] = \Pi(x:S_1[\sigma]).\,(S_2[q(\sigma)]) && \text{(syntactic substitution on $\Pi$)} \\ &\tyequiv[\Delta]{(\Pi(x:S_1).\,S_2)[\sigma]} {\Pi(x:S_1[\sigma]).\,(S_2[q(\sigma)])}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by reflexivity)} \end{aligned}

Clause 2 (domain Kripke). For each \kweak[\Delta'']{\phi'}{\Delta}:

\begin{aligned} &\judge[\Delta'']{\sigma[\phi'] : \Gamma} \;\circledR\; \rho \in \textsf{Sb} && \text{(by \Cref{cor:ctx-mono})} \\ &\typing[\Delta'']{S_1[\sigma[\phi']]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by hypothesis on $S_1$, type part at $\sigma[\phi'], \rho$)} \\ &S_1[\sigma][\phi'] = S_1[\sigma[\phi']] && \text{(by \Cref{lem:subst-assoc})} \\ &\typing[\Delta'']{S_1[\sigma][\phi']}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(rewriting)} \end{aligned}

Clause 3 (codomain Kripke). For each \kweak[\Delta'']{\phi'}{\Delta}, s', b', \ensuremath{\mathcal{D}} :: b' \approx b' \in R_I with \typing[\Delta'']{s'}{S_1[\sigma][\phi']} \;\circledR\; b' \in \textbf{El}_I, set \sigma_*' := (\sigma[\phi'],\, s'/x). We first transport the substitution into \textsf{Sb}', then unpack \Semtyp[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}} at the resulting pair.

\begin{aligned} &\judge[\Delta'']{\sigma[\phi'] : \Gamma} \;\circledR\; \rho \in \textsf{Sb} && \text{(by \Cref{cor:ctx-mono} on the substitution-environment pair)} \\ &\judge[\Delta'']{\sigma_*' : \Gamma, x:S_1} \;\circledR\; (\rho, b'/x) \in \textsf{Sb}' && \text{(by \textsc{G-Ctx-Ext}'s $\textsf{Cons}_i$, head: $b' \in \textbf{El}_I$)} \end{aligned}

Instantiating \Semtyp[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}} at \sigma_*', (\rho, b'/x) yields the four clauses of ?’s semantic typing judgment at a = U_i, P = \textsf{Univ}_{1+i,i}, \textbf{El} = \textsf{Univ}_{1+i,i}^{\textbf{El}}. The fourth clause states \typing[\Delta'']{S_2[\sigma_*']}{\ensuremath{\texttt{Ty}_{i}}[\sigma_*']} \;\circledR\; \ensuremath{\llbracket S_2 \rrbracket((\rho, b'/x))} \in \textsf{Univ}_{1+i,i}^{\textbf{El}}. Unpacking ?:

\begin{aligned} &\ensuremath{\llbracket S_2 \rrbracket((\rho, b'/x))} \searrow c_{b'} && \text{(evaluation; deterministic)} \\ &c_{b'} \in \mathcal{U}_i^\ast \searrow P_{b'} \searrow \textbf{El}_{b'} && \text{(by \Cref{def:univ-term-pred} clause (3))} \\ &\typing[\Delta'']{S_2[\sigma_*']}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_{b'} && \text{(by \Cref{def:univ-term-pred} clause (3), Russell type-side gluing)} \end{aligned}

By ? (the gluing-model membership c_{b'} \in \mathcal{U}_i^\ast uniquely determines its predicates up to extensional equivalence), P_{b'} \Leftrightarrow P_O(\ensuremath{\mathcal{D}}) and \textbf{El}_{b'} \Leftrightarrow \textbf{El}_O(\ensuremath{\mathcal{D}}), where P_O, \textbf{El}_O are the codomain predicates established in the Codomain-gluing block. Rewriting:

\begin{aligned} &c_{b'} \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:gluing-functional})} \\ &S_2[\sigma_*'] = S_2[(\sigma[\phi'], s'/x)] = S_2[q(\sigma)][\phi', s'/x] && \text{(by \Cref{lem:q-ext-gen})} \\ &\typing[\Delta'']{S_2[q(\sigma)][\phi', s'/x]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_O(\ensuremath{\mathcal{D}}) && \text{(rewriting the previous type-gluing line)} \end{aligned}

Combining the three clauses of \Pi_i:

\begin{aligned} &\typing[\Delta]{\Pi(x:S_1[\sigma]).\,(S_2[q(\sigma)])}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) && \text{(by \Cref{def:pi-type-pred} clauses 1--3)} \\ &\typing[\Delta]{(\Pi(x:S_1).\,S_2)[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) && \text{(by clause 1's equality on the LHS)} \end{aligned}

For the term predicate at \ensuremath{\texttt{Ty}_{1+i}}, \Pi(a_I, S_2, \rho) \in \mathcal{U}_i^\ast by the previous derivation, the four clauses of \Semtyp[\Gamma]{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}} at a = U_i, P = \textsf{Univ}_{1+i, i}, \textbf{El} = \textsf{Univ}_{1+i, i}^{\textbf{El}}:

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Ty}_{i}} \rrbracket(\rho)} \searrow U_i && \text{(by \textsc{ev-U})} \\ &U_i \in \mathcal{U}_{1+i}^\ast \searrow \textsf{Univ}_{1+i, i} \searrow \textsf{Univ}_{1+i, i}^{\textbf{El}} && \text{(by \textsc{G-Univ})} \\ &\typing[\Delta]{\ensuremath{\texttt{Ty}_{i}}[\sigma]}{\ensuremath{\texttt{Ty}_{1+i}}} \;\circledR\; \textsf{Univ}_{1+i, i} && \text{(by \Cref{def:univ-type-pred} with $\ensuremath{\texttt{Ty}_{i}}[\sigma] = \ensuremath{\texttt{Ty}_{i}}$)} \\ &\typing[\Delta]{(\Pi(x:S_1).\,S_2)[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi(a_I, S_2, \rho) \in \textsf{Univ}_{1+i, i}^{\textbf{El}} && \text{(by \Cref{def:univ-term-pred} on the $\Pi$-gluing above)} \end{aligned}
Lemma

Lemma 7.40 (Semantic — Ze-I)

ELLU

If \Vdash \Gamma, then \Semtyp[\Gamma]{\textsf{zero}}{\ensuremath{\texttt{Nat}}}.

Proof of Lemma 7.40

By \Vdash \Gamma, fix \Gamma \searrow \textsf{Sb} and let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given. We establish the four clauses of \Semtyp[\Gamma]{\textsf{zero}}{\ensuremath{\texttt{Nat}}} at a = N, P = \textsf{Nat}_i, \textbf{El} = \textsf{Nat}_i.

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\rho)} \searrow N && \text{(by \textsc{ev-N})} \\ &N \in \mathcal{U}_i^\ast \searrow \textsf{Nat}_i \searrow \textsf{Nat}_i && \text{(by \textsc{G-Nat})} \\ &\ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}} && \text{(syntactic; closed)} \\ &\tyequiv[\Delta]{\ensuremath{\texttt{Nat}}[\sigma]}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by reflexivity)} \\ &\typing[\Delta]{\ensuremath{\texttt{Nat}}[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i && \text{(by \Cref{def:nat-type-pred})} \\ &\ensuremath{\llbracket \textsf{zero} \rrbracket(\rho)} \searrow \texttt{ze} && \text{(by \textsc{ev-ze})} \\ &\textsf{zero}[\sigma] = \textsf{zero} && \text{(syntactic; closed)} \\ &\tyequiv[\Delta]{\textsf{zero}[\sigma]}{\textsf{zero}}{\ensuremath{\texttt{Nat}}[\sigma]} && \text{(by reflexivity)} \\ &\typing[\Delta]{\textsf{zero}[\sigma]}{\ensuremath{\texttt{Nat}}[\sigma]} \;\circledR\; \texttt{ze} \in \textsf{Nat}_i && \text{(by \textsc{GN-Ze} combined with the type predicate}\\ & && \text{above, \Cref{def:nat-term-pred})} \end{aligned}
Lemma

Lemma 7.41 (Semantic — Su-I)

QKR5

If \Semtyp[\Gamma]{t}{\ensuremath{\texttt{Nat}}}, then \Semtyp[\Gamma]{\textsf{succ}~t}{\ensuremath{\texttt{Nat}}}.

Proof of Lemma 7.41

\Vdash \Gamma is presupposed by the hypothesis \Semtyp[\Gamma]{t}{\ensuremath{\texttt{Nat}}}. Fix \Gamma \searrow \textsf{Sb} and let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given. We establish the four clauses of \Semtyp[\Gamma]{\textsf{succ}~t}{\ensuremath{\texttt{Nat}}} at a = N, P = \textsf{Nat}_i, \textbf{El} = \textsf{Nat}_i.

\begin{aligned} &\ensuremath{\llbracket \ensuremath{\texttt{Nat}} \rrbracket(\rho)} \searrow N && \text{(by \textsc{ev-N})} \\ &N \in \mathcal{U}_i^\ast \searrow \textsf{Nat}_i \searrow \textsf{Nat}_i && \text{(by \textsc{G-Nat})} \\ &\typing[\Delta]{\ensuremath{\texttt{Nat}}[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \textsf{Nat}_i && \text{(by \Cref{def:nat-type-pred} with $\ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}}$)} \\ &\ensuremath{\llbracket t \rrbracket(\rho)} \searrow b && \text{(by hypothesis on $t$)} \\ &\typing[\Delta]{t[\sigma]}{\ensuremath{\texttt{Nat}}[\sigma]} \;\circledR\; b \in \textsf{Nat}_i && \text{(by hypothesis on $t$, term part)} \\ &\ensuremath{\llbracket \textsf{succ}~t \rrbracket(\rho)} \searrow \texttt{su}(b) && \text{(by \textsc{ev-su})} \\ &(\textsf{succ}~t)[\sigma] = \textsf{succ}~t[\sigma] && \text{(syntactic substitution on $\textsf{succ}~$)} \\ &\typing[\Delta]{(\textsf{succ}~t)[\sigma]}{\ensuremath{\texttt{Nat}}[\sigma]} \;\circledR\; \texttt{su}(b) \in \textsf{Nat}_i && \text{(by \textsc{GN-Su} combined with the type predicate above,}\\ & && \text{\Cref{def:nat-term-pred})} \end{aligned}
Lemma

Lemma 7.42 (Semantic — \lambda-I)

KWKI

If \Semtyp[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}}, \Semtyp[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}}, and \Semtyp[\Gamma, x:S_1]{t}{S_2}, then \Semtyp[\Gamma]{\lambda x.\,t}{\Pi(x:S_1).\,S_2}.

Proof of Lemma 7.42

\Vdash \Gamma is presupposed; fix \Gamma \searrow \textsf{Sb}_\Gamma and \Gamma, x:S_1 \searrow \textsf{Sb}_{\Gamma,x:S_1} where, by inversion on G-Ctx-Ext, \textsf{Sb}_{\Gamma,x:S_1} \Leftrightarrow \textsf{Cons}_i(\Gamma, S_1, \textsf{Sb}_\Gamma). By ? on the hypotheses:

\begin{aligned} &\typing[\Gamma]{S_1}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:gluing-typ-escape} on the $S_1$ hypothesis)} \\ &\typing[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{lem:gluing-typ-escape} on the $S_2$ hypothesis)} \\ &\typing[\Gamma, x:S_1]{t}{S_2} && \text{(by \Cref{lem:gluing-trm-escape} on the $t$ hypothesis)} \\ &\typing[\Gamma]{\lambda x.\,t}{\Pi(x:S_1).\,S_2} && \text{(by \textsc{$\lambda$-I})} \end{aligned}

By ? on the S_1, S_2 hypotheses, \Semtyp[\Gamma]{\Pi(x:S_1).\,S_2}{\ensuremath{\texttt{Ty}_{i}}}.

Let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb}_\Gamma be given.

\begin{aligned} &\ensuremath{\llbracket S_1 \rrbracket(\rho)} \searrow a_I,\; a_I \in \mathcal{U}_i^\ast \searrow P_I \searrow \textbf{El}_I && \text{(by hypothesis on $S_1$, evaluation and gluing clauses)} \\ &a_I \approx a_I \in \mathcal{U}_i \searrow R_I && \text{(by \Cref{lem:gluing-implies-per})} \\ &\typing[\Delta]{S_1[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by hypothesis on $S_1$, type clause)} \\ &\ensuremath{\llbracket \Pi(x:S_1).\,S_2 \rrbracket(\rho)} \searrow \Pi(a_I,\, S_2,\, \rho) && \text{(by \textsc{ev-Pi})} \\ &\ensuremath{\llbracket \lambda x.\,t \rrbracket(\rho)} \searrow \lambda(t, \rho) && \text{(by \textsc{ev-lam})} \\ &\Pi(a_I, S_2, \rho) \in \mathcal{U}_i^\ast \\ & \quad \searrow \Pi_i(R_I, P_I, \textbf{El}_I, P_O) \searrow \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) && \text{(by \Cref{lem:fund-sound-pi-wf}, gluing clause)} \\ &\typing[\Delta]{(\Pi(x:S_1).\,S_2)[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O) && \text{(by \Cref{lem:fund-sound-pi-wf}, type clause)} \end{aligned}

We assemble the four clauses of \Semtyp[\Gamma]{\lambda x.\,t} {\Pi(x:S_1).\,S_2} at a := \Pi(a_I, S_2, \rho), P := \Pi_i(R_I, P_I, \textbf{El}_I, P_O), \textbf{El} := \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O):

\begin{aligned} &\ensuremath{\llbracket \Pi(x:S_1).\,S_2 \rrbracket(\rho)} \searrow \Pi(a_I, S_2, \rho) && \\ &\Pi(a_I, S_2, \rho) \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} && \\ &\typing[\Delta]{(\Pi(x:S_1).\,S_2)[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P && \end{aligned}

All three are restated from the per-substitution data block. For clause (4), we must show \typing[\Delta]{(\lambda x.\,t)[\sigma]}{(\Pi(x:S_1).\,S_2)[\sigma]} \;\circledR\; \lambda(t, \rho) \in \textbf{El}. We verify the four sub-clauses of ?.

Sub-clause (1): \typing[\Delta]{(\lambda x.\,t)[\sigma]} {(\Pi(x:S_1).\,S_2)[\sigma]}. By syntactic substitution applied to \typing[\Gamma]{\lambda x.\,t}{\Pi(x:S_1).\,S_2} along \judge[\Delta]{\sigma : \Gamma}.

Sub-clause (2): \lambda(t, \rho) \approx \lambda(t, \rho) \in R. By ? of ? on \typing[\Gamma]{\lambda x.\,t}{\Pi(x:S_1).\,S_2}, instantiated at \rho \approx \rho \in \ensuremath{\llbracket \Gamma \rrbracket} (self-related via ?): \lambda(t, \rho) \approx \lambda(t, \rho) \in R.

Sub-clause (3): \typing[\Delta]{(\Pi(x:S_1).\,S_2)[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; \Pi_i(R_I, P_I, \textbf{El}_I, P_O). Established above from ?.

Sub-clause (4): application. Given \kweak[\Delta']{\phi}{\Delta} and s, b with \typing[\Delta']{s}{S_1[\sigma][\phi]} \;\circledR\; b \in \textbf{El}_I, and \ensuremath{\mathcal{D}} :: b \approx b \in R_I (by ? on b \in \textbf{El}_I). Set \sigma_*' := (\sigma[\phi],\, s/x).

\begin{aligned} &\judge[\Delta']{\sigma[\phi] : \Gamma} \;\circledR\; \rho \in \textsf{Sb}_\Gamma && \text{(by \Cref{cor:ctx-mono} on $\sigma, \rho$ along $\phi$)} \\ &\typing[\Delta']{S_1[\sigma[\phi]]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_I && \text{(by hypothesis on $S_1$ at $\sigma[\phi], \rho$, type clause)} \\ &S_1[\sigma][\phi] = S_1[\sigma[\phi]] && \text{(by \Cref{lem:subst-assoc})} \\ &\typing[\Delta']{s}{S_1[\sigma[\phi]]} \;\circledR\; b \in \textbf{El}_I && \text{(rewriting via the previous line)} \\ &\judge[\Delta']{\sigma_*' : \Gamma, x:S_1} \;\circledR\; (\rho, b/x) \in \textsf{Sb}_{\Gamma,x:S_1} && \text{(by $\textsf{Cons}_i$ on the type-side $P_I$ and the term-side $b \in \textbf{El}_I$,} \\ & && \text{realized by $s$ at $S_1[\sigma[\phi]]$)} \end{aligned}

Instantiate the t-hypothesis at \sigma_*', (\rho, b/x):

\begin{aligned} &\ensuremath{\llbracket t \rrbracket((\rho, b/x))} \searrow c && \text{(by hypothesis on $t$, evaluation clause)} \\ &\ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} \searrow a' && \text{(by hypothesis on $t$, type-eval clause)} \\ &a' \in \mathcal{U}_i^\ast \searrow P' \searrow \textbf{El}' && \text{(by hypothesis on $t$, gluing clause)} \\ &\typing[\Delta']{t[\sigma_*']}{S_2[\sigma_*']} \;\circledR\; c \in \textbf{El}' && \text{(by hypothesis on $t$, term clause)} \\ &P' \Leftrightarrow P_O(\ensuremath{\mathcal{D}}),\;\; \textbf{El}' \Leftrightarrow \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:gluing-functional}: same $a'$ as in} \\ & && \text{\Cref{lem:fund-sound-pi-wf}; gluing-model predicates at} \\ & && \text{a fixed value are unique up to logical equivalence)} \\ &\typing[\Delta']{t[\sigma_*']}{S_2[\sigma_*']} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(rewriting via the previous line)} \\ &\lambda(t, \rho) \cdot b \searrow c && \text{(by \textsc{ev-app-clos})} \end{aligned}

Compute syntactic identities for the resulting term and type:

\begin{aligned} &(\lambda x.\,t)[\sigma] = \lambda x.\,(t[q(\sigma)]) && \text{(by syntactic substitution on $\lambda$)} \\ &(\lambda x.\,(t[q(\sigma)]))[\phi] = \lambda x.\,(t[q(\sigma)][q(\phi)]) && \text{(by syntactic substitution on $\lambda$ along $\phi$)} \\ &t[q(\sigma)][q(\phi)] = t[q(\sigma) \circ q(\phi)] = t[q(\sigma[\phi])] && \text{(by \Cref{lem:subst-assoc} and \Cref{lem:subst-q-comp})} \\ &(\lambda x.\,t)[\sigma][\phi] = \lambda x.\,(t[q(\sigma[\phi])]) && \text{(combining)} \\ &t[q(\sigma[\phi])][s/x] = t[\sigma_*'] && \text{(by \Cref{lem:q-ext})} \\ &S_2[q(\sigma[\phi])][s/x] = S_2[\sigma_*'] && \text{(by \Cref{lem:q-ext})} \end{aligned}

Apply the \beta-rule with premises \typing[\Delta']{S_1[\sigma[\phi]]}{\ensuremath{\texttt{Ty}_{i}}} (escaped above); \typing[\Delta', x:S_1[\sigma[\phi]]]{S_2[q(\sigma[\phi])]}{\ensuremath{\texttt{Ty}_{i}}} (by substitution typing on the S_2 escape along q(\sigma[\phi])); \typing[\Delta', x:S_1[\sigma[\phi]]]{t[q(\sigma[\phi])]} {S_2[q(\sigma[\phi])]} (by substitution typing on the t escape); and \typing[\Delta']{s}{S_1[\sigma[\phi]]} (escape on s):

\begin{aligned} &\tyequiv[\Delta']{(\lambda x.\,(t[q(\sigma[\phi])]))\;s} {t[q(\sigma[\phi])][s/x]} {S_2[q(\sigma[\phi])][s/x]} && \text{(by $\beta$)} \\ &\tyequiv[\Delta']{(\lambda x.\,t)[\sigma][\phi]\;s} {t[\sigma_*']} {S_2[\sigma_*']} && \text{(rewriting)} \\ &\typing[\Delta']{(\lambda x.\,t)[\sigma][\phi]\;s}{S_2[\sigma_*']} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:gluing-respects-eq})} \\ &S_2[\sigma_*'] = S_2[q(\sigma)][\iota(\phi), s/x] && \text{(by \Cref{lem:q-ext-gen})} \\ &\typing[\Delta']{(\lambda x.\,t)[\sigma][\phi]\;s} {S_2[q(\sigma)][\iota(\phi), s/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(rewriting; matches} \\ & && \text{\Cref{def:pi-term-pred} clause~(4))} \end{aligned}
Lemma

Lemma 7.43 (Semantic — \lambda-E)

NDGO

If \Semtyp[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}}, \Semtyp[\Gamma]{r}{\Pi(x:S_1).\,S_2}, and \Semtyp[\Gamma]{s}{S_1}, then \Semtyp[\Gamma]{r\;s}{S_2[s/x]}.

Proof of Lemma 7.43

\Vdash \Gamma and \Vdash \Gamma, x:S_1 are presupposed. Fix \Gamma \searrow \textsf{Sb}_\Gamma and (\Gamma, x:S_1) \searrow \textsf{Sb}_{\Gamma,x:S_1} where \textsf{Sb}_{\Gamma,x:S_1} \Leftrightarrow \textsf{Cons}_i(\Gamma, S_1, \textsf{Sb}_\Gamma) by G-Ctx-Ext. Let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb}_\Gamma be given.

Unpacking the hypotheses.

\begin{aligned} &\ensuremath{\llbracket r \rrbracket(\rho)} \searrow f && \text{(by hypothesis on $r$, evaluation clause)} \\ &\typing[\Delta]{r[\sigma]}{(\Pi(x:S_1).\,S_2)[\sigma]} \;\circledR\; f \in \Pi_i^{\textbf{El}}(R, R_I, P_I, \textbf{El}_I, \textbf{El}_O) && \text{(by hypothesis on $r$, term clause)} \\ &\ensuremath{\llbracket s \rrbracket(\rho)} \searrow b && \text{(by hypothesis on $s$, evaluation clause)} \\ &\typing[\Delta]{s[\sigma]}{S_1[\sigma]} \;\circledR\; b \in \textbf{El}_I && \text{(by hypothesis on $s$, term clause)} \\ &b \approx b \in R_I && \text{(by \Cref{lem:gluing-implies-per})} \end{aligned}

Let \ensuremath{\mathcal{D}} :: b \approx b \in R_I. Here P_O, \textbf{El}_O are functions of \ensuremath{\mathcal{D}}, supplied by the \Pi-gluing of f.

Building the substitution-environment pair for S_2. Set \sigma_* := (\sigma,\, s[\sigma]/x).

\begin{aligned} &\judge[\Delta]{\sigma_* : \Gamma, x:S_1} \;\circledR\; (\rho, b/x) \in \textsf{Sb}_{\Gamma,x:S_1} && \text{(by $\textsf{Cons}_i$ on $\sigma, \rho \in \textsf{Sb}_\Gamma$ and the term} \\ & && \text{gluing of $s[\sigma]$, taking the trailing weakening as $\ensuremath{\textsf{id}}$)} \end{aligned}

Instantiating the codomain semantic typing. Apply \Semtyp[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}} at \sigma_*, (\rho, b/x):

\begin{aligned} &\ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} \searrow a_2 && \text{(by hypothesis on $S_2$, evaluation clause)} \\ &a_2 \in \mathcal{U}_i^\ast \searrow P_2 \searrow \textbf{El}_2 && \text{(by hypothesis on $S_2$, gluing clause)} \\ &\typing[\Delta]{S_2[\sigma_*]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_2 && \text{(by hypothesis on $S_2$, type clause)} \end{aligned}

Reconciling (P_2, \textbf{El}_2) with (P_O(\ensuremath{\mathcal{D}}), \textbf{El}_O(\ensuremath{\mathcal{D}})). The \Pi-gluing of f, by G-Pi, requires \ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} \searrow c implies c \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}). By determinism, c = a_2, so a_2 \in \mathcal{U}_i^\ast \searrow P_O(\ensuremath{\mathcal{D}}) \searrow \textbf{El}_O(\ensuremath{\mathcal{D}}). By ?, gluing-model predicates at a fixed domain value are unique up to logical equivalence:

\begin{aligned} &P_2 \Leftrightarrow P_O(\ensuremath{\mathcal{D}}),\quad \textbf{El}_2 \Leftrightarrow \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by \Cref{lem:gluing-functional})} \end{aligned}

Application via the \Pi-gluing of f. Instantiate the application clause (? clause (4)) on f at the identity Kripke weakening \ensuremath{\textsf{id}}, term s[\sigma], value b, witness \ensuremath{\mathcal{D}}:

\begin{aligned} &f \cdot b \searrow c && \text{(by clause (4) on $f$)} \\ &\typing[\Delta]{(r[\sigma][\ensuremath{\textsf{id}}])\;s[\sigma]} {S_2[\iota(\ensuremath{\textsf{id}}) \circ q(\sigma),\, s[\sigma]/x]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(by clause (4) on $f$)} \\ &r[\sigma][\ensuremath{\textsf{id}}] = r[\sigma] && \text{(by \Cref{lem:subst-id})} \\ &\iota(\ensuremath{\textsf{id}}) = \ensuremath{\textsf{id}} && \text{(by definition of $\iota$ on the identity weakening)} \\ &S_2[\iota(\ensuremath{\textsf{id}}) \circ q(\sigma),\, s[\sigma]/x] = S_2[\sigma_*] && \text{(via \Cref{lem:q-ext} and identity absorption)} \\ &\typing[\Delta]{(r[\sigma])\;s[\sigma]}{S_2[\sigma_*]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(rewriting the previous gluing line)} \end{aligned}

Type rewriting from S_2[\sigma_*] to S_2[s/x][\sigma].

\begin{aligned} &S_2[\sigma_*] = S_2[(\sigma, s[\sigma]/x)] = S_2[q(\sigma)][s[\sigma]/x] && \text{(by \Cref{lem:q-ext})} \\ &S_2[s/x][\sigma] = S_2[\sigma, s[\sigma]/x] = S_2[\sigma_*] && \text{(by \Cref{lem:subst-ext-comm})} \end{aligned}

Bridging \ensuremath{\llbracket S_2[s/x] \rrbracket(\rho)} to a_2. With operational substitutions, \ensuremath{\llbracket S_2[s/x] \rrbracket(\rho)} does not directly evaluate to a_2. By ? of ? on \typing[\Gamma, x:S_1]{S_2}{\ensuremath{\texttt{Ty}_{i}}} (escaped from the S_2 hypothesis), we obtain \semtyeq[\Gamma, x:S_1]{S_2}{S_2}{\ensuremath{\texttt{Ty}_{i}}}. By ? on the substitution typing \judge[\Gamma]{(\ensuremath{\textsf{id}}, s/x) : \Gamma, x:S_1} (derivable from \typing[\Gamma]{s}{S_1} via the substitution-extension rule), we obtain \semtyeq[\Gamma]{(\ensuremath{\textsf{id}}, s/x)}{(\ensuremath{\textsf{id}}, s/x)}{\Gamma, x:S_1}. Instantiate \semtyeq[\Gamma, x:S_1]{S_2}{S_2}{\ensuremath{\texttt{Ty}_{i}}} at outer context \Gamma, this semantic substitution, and \rho \approx \rho \in \ensuremath{\llbracket \Gamma \rrbracket} (the latter from \rho \in \textsf{Sb}_\Gamma via ?). The four-value pattern of ? yields:

\begin{aligned} &\ensuremath{\llbracket (\ensuremath{\textsf{id}}, s/x) \rrbracket(\rho)} \searrow (\rho, b/x) && \text{(by \textsc{ev-ext} on $\ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)} \searrow \rho$ and $\ensuremath{\llbracket s \rrbracket(\rho)} \searrow b$)} \\ &\ensuremath{\llbracket S_2[(\ensuremath{\textsf{id}}, s/x)] \rrbracket(\rho)} \searrow a_2' && \text{(by the four-value pattern, outer left value)} \\ &S_2[s/x] = S_2[(\ensuremath{\textsf{id}}, s/x)] && \text{(by definition: single-substitution sugar)} \\ &\ensuremath{\llbracket S_2[s/x] \rrbracket(\rho)} \searrow a_2' && \text{(rewriting)} \\ &a_2' \approx \ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}) && \text{(by the four-value pattern, outer-inner relatedness)} \\ &a_2' \approx a_2 \in \mathcal{U}_i \searrow R_O(\ensuremath{\mathcal{D}}) && \text{(by determinism: $\ensuremath{\llbracket S_2 \rrbracket((\rho, b/x))} = a_2$)} \\ &a_2' \in \mathcal{U}_i^\ast \searrow P_2 \searrow \textbf{El}_2 && \text{(by \Cref{lem:gluing-univ-equiv} symmetric form on $a_2 \in \mathcal{U}_i^\ast$)} \end{aligned}

Assembling the four clauses of \Semtyp[\Gamma]{r\;s}{S_2[s/x]}. At a := a_2', P := P_2, \textbf{El} := \textbf{El}_2:

\begin{aligned} &\ensuremath{\llbracket S_2[s/x] \rrbracket(\rho)} \searrow a_2' && \\ &a_2' \in \mathcal{U}_i^\ast \searrow P_2 \searrow \textbf{El}_2 && \\ &\typing[\Delta]{S_2[s/x][\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_2 && \text{(rewriting $S_2[\sigma_*] = S_2[s/x][\sigma]$ on the type-clause line)} \\ &\ensuremath{\llbracket r\;s \rrbracket(\rho)} \searrow c && \text{(by \textsc{ev-app} on $\ensuremath{\llbracket r \rrbracket(\rho)} \searrow f$, $\ensuremath{\llbracket s \rrbracket(\rho)} \searrow b$, $f \cdot b \searrow c$)} \\ &(r\;s)[\sigma] = r[\sigma]\;s[\sigma] && \text{(by syntactic substitution on application)} \\ &\typing[\Delta]{r\;s[\sigma]}{S_2[\sigma_*]} \;\circledR\; c \in \textbf{El}_O(\ensuremath{\mathcal{D}}) && \text{(established above)} \\ &\typing[\Delta]{(r\;s)[\sigma]}{S_2[s/x][\sigma]} \;\circledR\; c \in \textbf{El}_2 && \text{(rewriting via $S_2[\sigma_*] = S_2[s/x][\sigma]$ and $\textbf{El}_O(\ensuremath{\mathcal{D}}) \Leftrightarrow \textbf{El}_2$)} \end{aligned}
Lemma

Lemma 7.44 (N-E helper)

440K

Suppose \Semtyp[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}, \Semtyp[\Gamma]{z}{T[\textsf{zero}/x]}, and \Semtyp[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]}. Let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given, with \textsf{Sb} from \Vdash \Gamma. For any t_* and b with \typing[\Delta]{t_*}{\ensuremath{\texttt{Nat}}} \;\circledR\; b \in \textsf{Nat}_i, and any a, P, \textbf{El} with \ensuremath{\llbracket T \rrbracket((\rho, b/x))} \searrow a and a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El}, there exists r with \mathsf{rec}(b, T, z, s, \rho) \searrow r and \typing[\Delta]{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\,s[q(q(\sigma))])~t_*}} {T[\sigma, t_*/x]} \;\circledR\; r \in \textbf{El}.

Proof of Lemma 7.44

Write E := \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\,s[q(q(\sigma))])~t_*} for the syntactic recursor under \sigma. By inner induction on b \in \textsf{Nat} (?).

Case

Mathpar.

t_*zeroNat t_*Nat ze Nat

Here b = \texttt{ze}, so the helper’s hypothesis specializes to \ensuremath{\llbracket T \rrbracket((\rho, \texttt{ze}/x))} \searrow a.

\begin{aligned} &\ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\rho)} \searrow a^{ze} && \text{(by hypothesis on $z$, type-evaluation clause)} \\ &a^{ze} \in \mathcal{U}_i^\ast \searrow P^{ze} \searrow \textbf{El}^{ze} && \text{(by hypothesis on $z$, gluing clause)} \\ &\ensuremath{\llbracket z \rrbracket(\rho)} \searrow r_z && \text{(by hypothesis on $z$, evaluation clause)} \\ &\typing[\Delta]{z[\sigma]}{T[\textsf{zero}/x][\sigma]} \;\circledR\; r_z \in \textbf{El}^{ze} && \text{(by hypothesis on $z$, term clause)} \\ &\mathsf{rec}(\texttt{ze}, T, z, s, \rho) \searrow r_z && \text{(by \textsc{rec-ze})} \\ &a^{ze} \approx a \in \mathcal{U}_i && \text{(by completeness on $\typing[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}$ instantiated at} \\ & && \text{$(\ensuremath{\textsf{id}}, \textsf{zero}/x)$; both evaluations produce the same value modulo $\mathcal{U}_i$)} \\ &\textbf{El}^{ze} \Leftrightarrow \textbf{El} && \text{(by \Cref{lem:gluing-functional}: gluing-model predicates at} \\ & && \text{the same value are unique up to logical equivalence)} \\ &T[\textsf{zero}/x][\sigma] = T[\sigma, \textsf{zero}/x] && \text{(by \Cref{lem:subst-ext-comm})} \\ &\tyequiv[\Delta]{T[\sigma, \textsf{zero}/x]}{T[\sigma, t_*/x]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{cor:subst-head-eq} on $\typing[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}$ from \Cref{lem:gluing-typ-escape},} \\ & && \text{the substitution $\sigma$, and the head equality $\tyequiv[\Delta]{\textsf{zero}}{t_*}{\ensuremath{\texttt{Nat}}}$} \\ & && \text{from $\tyequiv[\Delta]{t_*}{\textsf{zero}}{\ensuremath{\texttt{Nat}}}$ by symmetry)} \\ &\tyequiv[\Delta]{E}{z[\sigma]}{T[\sigma, t_*/x]} && \text{(by the $\beta$-zero rule combined with $\tyequiv[\Delta]{t_*}{\textsf{zero}}{\ensuremath{\texttt{Nat}}}$)} \\ &\typing[\Delta]{E}{T[\sigma, t_*/x]} \;\circledR\; r_z \in \textbf{El} && \text{(by \Cref{lem:gluing-respects-eq} on the previous lines)} \end{aligned}

Take r := r_z.

Case

Mathpar.

t_*’Nat b’ Nat
t_*succ t_*’Nat t_*Nat su(b’) Nat

Here b = \texttt{su}(b').

Predecessor via inner IH. We need to apply the helper inductively at t_*', b'. By ? of ? on \typing[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}} instantiated at the related environments (\rho, b'/x) \approx (\rho, b'/x) \in \ensuremath{\llbracket \Gamma, x:\ensuremath{\texttt{Nat}} \rrbracket} (using b' \in R_\ensuremath{\texttt{Nat}} via ? on the inner predecessor):

\begin{aligned} &\ensuremath{\llbracket T \rrbracket((\rho, b'/x))} \searrow a' && \text{(by completeness on $T$)} \\ &a' \in \mathcal{U}_i^\ast \searrow P' \searrow \textbf{El}' && \text{(by \Cref{lem:per-implies-gluing} on $a' \approx a' \in \mathcal{U}_i$)} \\ &\mathsf{rec}(b', T, z, s, \rho) \searrow r',\; \typing[\Delta]{E'}{T[\sigma, t_*'/x]} \;\circledR\; r' \in \textbf{El}' && \text{(by inner IH on $b', t_*', a', P', \textbf{El}'$;} \\ & && \text{$E' := \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\,s[q(q(\sigma))])~t_*'}$)} \end{aligned}

Step instantiation. Set \sigma_{\text{step}} := (\sigma, t_*'/x, E'/y) and \rho_{\text{step}} := (\rho, b'/x, r'/y).

\begin{aligned} &\judge[\Delta]{(\sigma, t_*'/x) : \Gamma, x:\ensuremath{\texttt{Nat}}} \;\circledR\; (\rho, b'/x) \in \textsf{Sb}_{x:\ensuremath{\texttt{Nat}}} && \text{(by $\textsf{Cons}_0$ on $\typing[\Delta]{t_*'}{\ensuremath{\texttt{Nat}}[\sigma]} \;\circledR\; b' \in \textsf{Nat}_i$,} \\ & && \text{after rewriting $\ensuremath{\texttt{Nat}}[\sigma] = \ensuremath{\texttt{Nat}}$)} \\ &\judge[\Delta]{\sigma_{\text{step}} : \Gamma, x:\ensuremath{\texttt{Nat}}, y:T} \;\circledR\; \rho_{\text{step}} \in \textsf{Sb}_{x:\ensuremath{\texttt{Nat}},y:T} && \text{(by $\textsf{Cons}_i$ on the previous line, head $r' \in \textbf{El}'$,} \\ & && \text{type bridged via \Cref{lem:gluing-respects-eq})} \\ &\ensuremath{\llbracket T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x] \rrbracket(\rho_{\text{step}})} \searrow a^{su} && \text{(by hypothesis on $s$, type-evaluation clause)} \\ &a^{su} \in \mathcal{U}_i^\ast \searrow P^{su} \searrow \textbf{El}^{su} && \text{(by hypothesis on $s$, gluing clause)} \\ &\ensuremath{\llbracket s \rrbracket(\rho_{\text{step}})} \searrow r_s && \text{(by hypothesis on $s$, evaluation clause)} \\ &\typing[\Delta] {s[\sigma_{\text{step}}]} {T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x][\sigma_{\text{step}}]} \;\circledR\; r_s \in \textbf{El}^{su} && \text{(by hypothesis on $s$, term clause)} \\ &\mathsf{rec}(\texttt{su}(b'), T, z, s, \rho) \searrow r_s && \text{(by \textsc{rec-su} on $\mathsf{rec}(b', \ldots) \searrow r'$ and $\ensuremath{\llbracket s \rrbracket(\rho_{\text{step}})} \searrow r_s$)} \end{aligned}

Type rewriting for the step branch. We compute the substituted motive type:

\begin{aligned} &T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x][\sigma_{\text{step}}] = T[(\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x) \circ \sigma_{\text{step}}] && \text{(by \Cref{lem:subst-assoc})} \\ &(\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x) \circ \sigma_{\text{step}} = (\Uparrow \circ \Uparrow \circ \sigma_{\text{step}},\, \textsf{succ}~x_1[\sigma_{\text{step}}]/x) && \text{(by \Cref{lem:ext-comp})} \\ &\Uparrow \circ \sigma_{\text{step}} = (\sigma, t_*'/x),\; \Uparrow \circ (\sigma, t_*'/x) = \sigma && \text{(by \Cref{lem:shift-ext})} \\ &\Uparrow \circ \Uparrow \circ \sigma_{\text{step}} = \sigma && \text{(combining)} \\ &x_1[\sigma_{\text{step}}] = t_*' && \text{(de Bruijn lookup at index 1 in $\sigma_{\text{step}}$)} \\ &\textsf{succ}~x_1[\sigma_{\text{step}}] = \textsf{succ}~x_1[\sigma_{\text{step}}] = \textsf{succ}~t_*' && \text{(by syntactic substitution on $\textsf{succ}~$)} \\ &T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x][\sigma_{\text{step}}] = T[\sigma, \textsf{succ}~t_*'/x] && \text{(combining the previous lines)} \\ &\tyequiv[\Delta]{T[\sigma, \textsf{succ}~t_*'/x]}{T[\sigma, t_*/x]}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{cor:subst-head-eq} on $\typing[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}$, the} \\ & && \text{substitution $\sigma$, and the head equality $\tyequiv[\Delta]{\textsf{succ}~t_*'}{t_*}{\ensuremath{\texttt{Nat}}}$} \\ & && \text{from $\tyequiv[\Delta]{t_*}{\textsf{succ}~t_*'}{\ensuremath{\texttt{Nat}}}$ by symmetry)} \end{aligned}

Functionality. By the type rewriting, T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x][\sigma_{\text{step}}] = T[\sigma, \textsf{succ}~t_*'/x], whose evaluation is \ensuremath{\llbracket T \rrbracket((\rho, \texttt{su}(b')/x))} \searrow a (the helper’s hypothesis on a at b = \texttt{su}(b')). Hence a^{su} \approx a \in \mathcal{U}_i by completeness on \typing[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}, and \textbf{El}^{su} \Leftrightarrow \textbf{El} by ?.

Conclusion.

\begin{aligned} &\tyequiv[\Delta]{E}{s[\sigma_{\text{step}}]}{T[\sigma, t_*/x]} && \text{(by the $\beta$-su rule combined with $\tyequiv[\Delta]{t_*}{\textsf{succ}~t_*'}{\ensuremath{\texttt{Nat}}}$ and the type rewriting)} \\ &\typing[\Delta]{E}{T[\sigma, t_*/x]} \;\circledR\; r_s \in \textbf{El} && \text{(by \Cref{lem:gluing-respects-eq})} \end{aligned}

Take r := r_s.

Case

Mathpar.

t_*Nat ^N(e) Neu_i^e t_*Nat ^N(e) Nat

Here b = {\uparrow}^N(e), with the type-side neutral predicate giving \textsf{R}^{\textsf{Ne}}_n(e) \searrow u_e and \tyequiv[\Delta'']{t_*[\phi]}{u_e}{\ensuremath{\texttt{Nat}}} for every \kweak[\Delta'']{\phi}{\Delta}, n := |\Delta''|.

Reduction step. The helper’s hypothesis specializes to \ensuremath{\llbracket T \rrbracket((\rho, {\uparrow}^N(e)/x))} \searrow a.

\begin{aligned} &\mathsf{rec}({\uparrow}^N(e), T, z, s, \rho) \searrow {\uparrow}^a(\mathsf{rec}(T, a_z, s, \rho, e)) && \text{(by \textsc{rec-ne}, where $\ensuremath{\llbracket z \rrbracket(\rho)} \searrow a_z$)} \\ &{\uparrow}^N(e) \approx {\uparrow}^N(e) \in R_\ensuremath{\texttt{Nat}} && \text{(by \textsc{U-Ne})} \end{aligned}

Recursor as a neutral. We verify \mathsf{rec}(T, a_z, s, \rho, e) \in \textsf{Ne}_i^a at the term E. For each \kweak[\Delta'']{\phi}{\Delta}, set n := |\Delta''| and assemble the four readback components:

\begin{aligned} &\textsf{R}^{\textsf{Ne}}_n(e) \searrow u_e,\; \tyequiv[\Delta'']{t_*[\phi]}{u_e}{\ensuremath{\texttt{Nat}}} && \text{(by hypothesis on $e$, neutral readback)} \\ &\textsf{R}^{\textsf{Ty}}_{n+1}(a) \searrow W_T,\; \tyequiv[\Delta'', x':\ensuremath{\texttt{Nat}}] {T[q(\sigma)][\iota(\phi), x'/x]}{W_T}{\ensuremath{\texttt{Ty}_{i}}} && \text{(by \Cref{thm:gluing-realizability} part (3) on} \\ & && \text{$a \in \mathcal{U}_i^\ast$, at the Kripke weakening to $\Delta'', x':\ensuremath{\texttt{Nat}}$)} \\ &\ensuremath{\llbracket T[\textsf{zero}/x] \rrbracket(\rho)} \searrow A_z',\; A_z' \in \mathcal{U}_i^\ast \searrow P_z' \searrow \textbf{El}_z' && \text{(by hypothesis on $z$ via $\Semtyp[\Gamma]{z}{T[\textsf{zero}/x]}$,} \\ & && \text{type-evaluation and gluing clauses)} \\ &\typing[\Delta]{z[\sigma]}{T[\textsf{zero}/x][\sigma]} \;\circledR\; a_z \in \textbf{El}_z' && \text{(by hypothesis on $z$, term clause; with $a_z := \ensuremath{\llbracket z \rrbracket(\rho)}$)} \\ &\ensuremath{\llbracket T \rrbracket((\rho, \texttt{ze}/x))} \searrow A_z && \text{(type evaluation; the form required by \textsc{Re-rec})} \\ &A_z' \approx A_z \in \mathcal{U}_i && \text{(by completeness on $\typing[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}$ instantiated} \\ & && \text{at the substitution $(\ensuremath{\textsf{id}}, \textsf{zero}/x)$)} \\ &A_z \in \mathcal{U}_i^\ast \searrow P_z \searrow \textbf{El}_z,\; \textbf{El}_z' \Leftrightarrow \textbf{El}_z && \text{(by \Cref{lem:gluing-univ-equiv} and \Cref{lem:gluing-functional})} \\ &\textsf{R}^{\textsf{Nf}}_n({\downarrow}^{A_z}(a_z)) \searrow w_z && \text{(by \Cref{thm:gluing-realizability} part (2) on $a_z \in \textbf{El}_z$)} \\ &\tyequiv[\Delta''] {z[\sigma][\phi]}{w_z}{T[\textsf{zero}/x][\sigma][\phi]} && \text{(after term-side type-bridging via \Cref{lem:gluing-respects-eq})} \\ &\ensuremath{\llbracket T \rrbracket((\rho, \texttt{su}({\uparrow}^N(\ell_n))/x))} \searrow A_s && \text{(type evaluation at the fresh-step head $\texttt{su}(\ell_n)$)} \\ &\ensuremath{\llbracket s \rrbracket(\rho, {\uparrow}^N(\ell_n)/x, {\uparrow}^{A_p}(\ell_{n+1})/y)} \searrow b_s && \text{(step branch evaluated at the fresh-neutral pair,} \\ & && \text{where $A_p := \ensuremath{\llbracket T \rrbracket((\rho, {\uparrow}^N(\ell_n)/x))}$)} \\ &\textsf{R}^{\textsf{Nf}}_{n+2}({\downarrow}^{A_s}(b_s)) \searrow w_s && \text{(by \Cref{thm:gluing-realizability} part (2) on the step value)} \\ &\Delta_s \vdash s[q(q(\sigma))][\iota(\iota(\phi))] \approx w_s \\ & \qquad : T[q(\sigma)][\iota(\phi), \textsf{succ}~x'/x] && \text{(at the corresponding type, where} \\ & && \text{$\Delta_s := \Delta'', x':\ensuremath{\texttt{Nat}}, y':T[q(\sigma)][\iota(\phi), x'/x]$)} \\ &\textsf{R}^{\textsf{Ne}}_n(\mathsf{rec}(T, a_z, s, \rho, e)) \\ & \quad \searrow \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u_e} && \text{(by \textsc{Rne-rec})} \\ &\Delta'' \vdash E[\phi] \approx \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,W_T)~w_z~(x, y.\,w_s)~u_e} \\ & \qquad : T[\sigma,\, t_*/x][\phi] && \text{(by \textsc{N-E-Cong} on the four readback equalities)} \end{aligned}

Type-side gluing. The helper’s hypothesis already gives the type-side gluing of T[\sigma, t_*/x] at P (via the outer \Semtyp[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}} instantiation that produced a, P, \textbf{El}).

Conclusion.

\begin{aligned} &\typing[\Delta]{E}{T[\sigma, t_*/x]} \;\circledR\; \mathsf{rec}(T, a_z, s, \rho, e) \in \textsf{Ne}_i^a && \text{(by \Cref{def:neu-term-pred} from the previous block)} \\ &\typing[\Delta]{E}{T[\sigma, t_*/x]} \;\circledR\; {\uparrow}^a(\mathsf{rec}(T, a_z, s, \rho, e)) \in \textbf{El} && \text{(by \Cref{thm:gluing-realizability} part (1) on $a \in \mathcal{U}_i^\ast$)} \end{aligned}

Take r := {\uparrow}^a(\mathsf{rec}(T, a_z, s, \rho, e)).

Lemma

Lemma 7.45 (Semantic — N-E)

VZP5

If \Semtyp[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}, \Semtyp[\Gamma]{z}{T[\textsf{zero}/x]}, \Semtyp[\Gamma, x:\ensuremath{\texttt{Nat}}, y:T]{s}{T[\Uparrow \circ \Uparrow, \textsf{succ}~x_1/x]}, and \Semtyp[\Gamma]{t}{\ensuremath{\texttt{Nat}}}, then \Semtyp[\Gamma]{\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\,s)~t}}{T[t/x]}.

Proof of Lemma 7.45

\Vdash \Gamma is presupposed by the hypotheses. Fix \Gamma \searrow \textsf{Sb} and let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given.

\begin{aligned} &\ensuremath{\llbracket t \rrbracket(\rho)} \searrow a && \text{(by hypothesis on $t$, evaluation clause)} \\ &\typing[\Delta]{t[\sigma]}{\ensuremath{\texttt{Nat}}[\sigma]} \;\circledR\; a \in \textsf{Nat}_i && \text{(by hypothesis on $t$, term clause)} \\ &\tyequiv[\Delta]{\ensuremath{\texttt{Nat}}[\sigma]}{\ensuremath{\texttt{Nat}}}{\ensuremath{\texttt{Ty}_{0}}} && \text{(syntactic; closed)} \\ &\typing[\Delta]{t[\sigma]}{\ensuremath{\texttt{Nat}}} \;\circledR\; a \in \textsf{Nat}_i && \text{(by \Cref{lem:gluing-respects-eq})} \end{aligned}

Build the substitution pair for T:

\begin{aligned} &\sigma_T := (\sigma, t[\sigma]/x) && \text{(definition)} \\ &\judge[\Delta]{\sigma_T : \Gamma, x:\ensuremath{\texttt{Nat}}} \;\circledR\; (\rho, a/x) \in \textsf{Sb}_{x:\ensuremath{\texttt{Nat}}} && \text{(by $\textsf{Cons}_0$ on $\textsf{Sb}$, head $a \in \textsf{Nat}_i$ realized by $t[\sigma]$)} \\ &\ensuremath{\llbracket T \rrbracket((\rho, a/x))} \searrow a_T && \text{(by hypothesis on $T$ at $\sigma_T, (\rho, a/x)$)} \\ &a_T \in \mathcal{U}_i^\ast \searrow P_T \searrow \textbf{El}_T && \text{(by hypothesis on $T$, gluing clause)} \\ &\typing[\Delta]{T[\sigma_T]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_T && \text{(by hypothesis on $T$, type clause)} \end{aligned}

By ? on t_* := t[\sigma], b := a, with the data above:

\begin{aligned} &\mathsf{rec}(a, T, z, s, \rho) \searrow r && \text{(by helper)} \\ &\typing[\Delta] {\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\,s[q(q(\sigma))])~t[\sigma]}} {T[\sigma, t[\sigma]/x]} \;\circledR\; r \in \textbf{El}_T && \text{(by helper)} \\ &\ensuremath{\llbracket \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\,s)~t} \rrbracket(\rho)} \searrow r && \text{(by \textsc{ev-rec})} \\ &(\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\,s)~t})[\sigma] && \text{(by syntactic} \\ & \quad = \ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T[q(\sigma)])~z[\sigma]~(x, y.\,s[q(q(\sigma))])~t[\sigma]} && \text{substitution on $\textsf{elim}_{\ensuremath{\texttt{Nat}}}$)} \\ &T[\sigma_T] = T[\sigma, t[\sigma]/x] = T[t/x][\sigma] && \text{(by \Cref{lem:subst-ext-comm})} \end{aligned}

We assemble the four clauses of \Semjudge[]f : o r the conclusion at a := a_T, P := P_T, \textbf{El} := \textbf{El}_T:

\begin{aligned} &\ensuremath{\llbracket T[t/x] \rrbracket(\rho)} \searrow a_T && \text{(via the equality $\ensuremath{\llbracket T[t/x] \rrbracket(\rho)} = \ensuremath{\llbracket T \rrbracket((\rho, a/x))}$ established by} \\ & && \text{\Cref{thm:fundamental} of \Cref{sec:comp} on $\typing[\Gamma, x:\ensuremath{\texttt{Nat}}]{T}{\ensuremath{\texttt{Ty}_{i}}}$)} \\ &a_T \in \mathcal{U}_i^\ast \searrow P_T \searrow \textbf{El}_T && \text{(established above)} \\ &\typing[\Delta]{T[t/x][\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_T && \text{(by rewriting the $T[\sigma_T]$ identity)} \\ &\typing[\Delta]{(\ensuremath{\textsf{elim}_{\ensuremath{\texttt{Nat}}}~(x.\,T)~z~(x, y.\,s)~t})[\sigma]}{T[t/x][\sigma]} \\ & \quad \;\circledR\; r \in \textbf{El}_T && \text{(by rewriting via the syntactic identity above)} \end{aligned}
Lemma

Lemma 7.46 (Semantic — Subsump)

JW7J

If \Semtyp[\Gamma]{t}{S}, \Semtyp[\Gamma]{T}{\ensuremath{\texttt{Ty}_{i}}}, and \subty[\Gamma]{S}{T}, then \Semtyp[\Gamma]{t}{T}.

Proof of Lemma 7.46

\Vdash \Gamma is presupposed by the hypotheses. Fix \Gamma \searrow \textsf{Sb} and let \judge[\Delta]{\sigma : \Gamma} \;\circledR\; \rho \in \textsf{Sb} be given. By ? of ? on \subty[\Gamma]{S}{T}, we obtain the semantic subtyping judgment \Gamma \vDash S \subseteq T (?).

\begin{aligned} &\ensuremath{\llbracket S \rrbracket(\rho)} \searrow a_S,\; a_S \in \mathcal{U}_i^\ast \searrow P_S \searrow \textbf{El}_S && \text{(by hypothesis on $t$, evaluation and gluing clauses)} \\ &\ensuremath{\llbracket T \rrbracket(\rho)} \searrow a_T,\; a_T \in \mathcal{U}_i^\ast \searrow P_T \searrow \textbf{El}_T && \text{(by hypothesis on $T$, evaluation and gluing clauses)} \\ &\typing[\Delta]{t[\sigma]}{S[\sigma]} \;\circledR\; \ensuremath{\llbracket t \rrbracket(\rho)} \in \textbf{El}_S && \text{(by hypothesis on $t$, term clause)} \\ &\rho \approx \rho \in R_\Gamma && \text{(by \Cref{lem:gluing-implies-per} on $\rho \in \textsf{Sb}$)} \\ &\semtyeq[\Gamma]{\ensuremath{\textsf{id}}}{\ensuremath{\textsf{id}}}{\Gamma} && \text{(by \Cref{lem:sem-id})} \\ &a_S \mathrel{<:_i} a_T && \text{(by $\Gamma \vDash S \subseteq T$ instantiated at} \\ & && \text{the identity semantic substitution and $\rho \approx \rho$:} \\ & && \text{the inner-pair relation gives $\ensuremath{\llbracket S \rrbracket(\ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)})} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\ensuremath{\llbracket \ensuremath{\textsf{id}} \rrbracket(\rho)})}$,} \\ & && \text{which is $\ensuremath{\llbracket S \rrbracket(\rho)} \mathrel{<:_i} \ensuremath{\llbracket T \rrbracket(\rho)}$)} \\ &\typing[\Delta]{T[\sigma]}{\ensuremath{\texttt{Ty}_{i}}} \;\circledR\; P_T && \text{(by hypothesis on $T$, type clause)} \\ &\typing[\Delta]{t[\sigma]}{T[\sigma]} \;\circledR\; \ensuremath{\llbracket t \rrbracket(\rho)} \in \textbf{El}_T && \text{(by \Cref{lem:gluing-subty} on $a_S \mathrel{<:_i} a_T$, $a_S \in \textbf{El}_S$,} \\ & && \text{and $T[\sigma] \;\circledR\; P_T$)} \end{aligned}
Theorem

Theorem 7.47 (Fundamental Theorem (Soundness)

KBIP

    If \vdash \Gamma, then \Vdash \Gamma. If \typing[\Gamma]{t}{T}, then \Vdash \Gamma and \Semtyp[\Gamma]{t}{T}.

Proof of Theorem 7.47

By simultaneous induction on the well-formedness derivation \vdash \Gamma and the typing derivation \typing[\Gamma]{t}{T}. The presupposition \vdash \Gamma inherent in \typing[\Gamma]{t}{T} produces \Vdash \Gamma through part (1) at each step; semantic rules in ? consume \Vdash \Gamma wherever needed. Each case applies the corresponding semantic-rule lemma:

    Context cases: ?, ?. Term cases: ?, ?, ?, ?, ?, ?, ?, ?, ?, ?.

Each lemma’s \Vdash-hypotheses are supplied by part (1) on the corresponding \vdash-premise of its syntactic rule; its \Semjudge[]- : h ypotheses are the IHs from the typing premises.

Theorem

Theorem 7.48 (Soundness of NbE)

GQCW

If \typing[\Gamma]{t}{T}, then \textsf{nbe}^T_\Gamma(t) = v for some v with \tyequiv[\Gamma]{t}{v}{T}.

Proof of Theorem 7.48
\begin{aligned} &\Vdash \Gamma,\; \Semtyp[\Gamma]{t}{T} && \text{(by \Cref{thm:fundamental-sound} part (2))} \\ &\Gamma \searrow \textsf{Sb} && \text{(by \Cref{def:sound-semctx} on $\Vdash \Gamma$)} \\ &\judge[\Gamma]{\ensuremath{\textsf{id}} : \Gamma} \;\circledR\; {\uparrow}^\Gamma \in \textsf{Sb} && \text{(by \Cref{lem:init-env-valid} on $\Gamma \searrow \textsf{Sb}$)} \\ &\ensuremath{\llbracket T \rrbracket({\uparrow}^\Gamma)} \searrow a,\; a \in \mathcal{U}_i^\ast \searrow P \searrow \textbf{El} && \text{(unfolding $\Vdash$ at $\ensuremath{\textsf{id}}, {\uparrow}^\Gamma$)} \\ &\typing[\Gamma]{t[\ensuremath{\textsf{id}}]}{T[\ensuremath{\textsf{id}}]} \;\circledR\; \ensuremath{\llbracket t \rrbracket({\uparrow}^\Gamma)} \in \textbf{El} && \text{(unfolding $\Vdash$ at $\ensuremath{\textsf{id}}, {\uparrow}^\Gamma$)} \\ &T[\ensuremath{\textsf{id}}] = T,\; t[\ensuremath{\textsf{id}}] = t && \text{(by left-id of substitution)} \\ &\typing[\Gamma]{t}{T} \;\circledR\; b \in \textsf{Nf}_i^a \text{ where } b = \ensuremath{\llbracket t \rrbracket({\uparrow}^\Gamma)} && \text{(by \Cref{thm:gluing-realizability} part (2))} \\ &\textsf{R}^{\textsf{Nf}}_{|\Gamma|}({\downarrow}^a(b)) \searrow v,\; \tyequiv[\Gamma]{t[\ensuremath{\textsf{id}}]}{v}{T[\ensuremath{\textsf{id}}]} && \text{(Kripke condition at $\phi = \ensuremath{\textsf{id}}$)} \\ &\tyequiv[\Gamma]{t}{v}{T} && \text{(using $t[\ensuremath{\textsf{id}}] = t, T[\ensuremath{\textsf{id}}] = T$)} \\ &\textsf{nbe}^T_\Gamma(t) = v && \text{(by \Cref{def:nbe}: evaluation followed by readback)} \end{aligned}
Corollary

Corollary 7.49 (Decidability of Judgmental Equality)

E6VD

Given \typing[\Gamma]{s}{T} and \typing[\Gamma]{t}{T}, the judgment \tyequiv[\Gamma]{s}{t}{T} is decidable.

Proof of Corollary 7.49

By soundness, \tyequiv[\Gamma]{s}{\textsf{nbe}_\Gamma^T(s)}{T} and \tyequiv[\Gamma]{t}{\textsf{nbe}_\Gamma^T(t)}{T}. By completeness, \tyequiv[\Gamma]{s}{t}{T} iff \textsf{nbe}_\Gamma^T(s) = \textsf{nbe}_\Gamma^T(t). Comparing normal forms is decidable.

Source and licence

The text on this page is from arXiv:2610.21131v1 by Jason Z. S. Hu, under the licence CC BY 4.0. The corpus made these changes: it read the items out of the LaTeX source, it expanded the macros of the paper, it put each proof after its statement, and it converted the text to HTML. The formulas are the TeX of the paper, and KaTeX renders them. A formula or a reference can look different from the PDF. The page is published under CC BY 4.0.

The record of each item is in analysis/objects/2610/2610.21131.jsonl.