proof.tex 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. The correctness of the algorithm relies on the fact that we only compute with
  2. well-typed terms. This guarantees the existence of normal forms, and hence,
  3. ensures the termination of the type checking algorithm.
  4. The proof will be done in two stages: first we prove soundness in the absence
  5. of constraint solving, and then we prove that constraint solving is sound.
  6. \subsection{Soundness without constraint solving}
  7. There are a number of things we need to prove: that type checking preserves
  8. well-formed signatures, that it produces well-typed terms, that conversion
  9. checking is sound, and that new signatures respect the old signatures.
  10. Unfortunately these properties are all interdependent, so we cannot prove them
  11. separately.
  12. \begin{definition}[Signature extension] \label{defSigExt}
  13. We say that $\Sigma'$ {\em extends} $\Sigma$ if for any {\Core}
  14. judgement $J$, $\vdash_\Sigma J$ implies $\vdash_{\Sigma'} J$.
  15. \end{definition}
  16. Note that this definition admits both simple extensions--adding a new
  17. constant--and refinement, where we give a definition to a constant.
  18. \if \DetailedProofs 1
  19. This is expressed by the following two lemmas.
  20. \begin{lemma}[Signature weakening] \label{lemWeakenSig}
  21. If $\Sigma' = \Ext \Sigma {c:A}$ and $\IsSigCS {\Sigma'}$ then $\Extends
  22. {\Sigma'} \Sigma$.
  23. \end{lemma}
  24. \begin{lemma}[Signature refinement] \label{lemRefineSig}
  25. Giving a definition to a constant in a signature is an extension of the
  26. signature.
  27. \if \DetailedProofs 1
  28. More precisely, if
  29. \begin{itemize}
  30. \item $\HasTypeCS {\Sigma_1} {} M A$
  31. \item $\Sigma ~ = ~ \Ext {\Sigma_1} \Ext {\MetaDecl c A} \Sigma_2$
  32. \item $\Sigma' ~ = ~ \Ext {\Sigma_1} \Ext {\IMetaDecl c A M} \Sigma_2$
  33. \end{itemize}
  34. then $\Extends {\Sigma'} \Sigma$.
  35. \fi
  36. \end{lemma}
  37. \fi
  38. \if \DetailedProofs 1
  39. \begin{proof}[Proofs]
  40. In both lemmas any derivation using $\Sigma$ is immediately valid also with $\Sigma'$.
  41. \end{proof}
  42. \fi
  43. \if \DetailedProofs 1
  44. To express the soundness of conversion checking we need to define when a
  45. constraint is well-formed. Note that this is not the same as being true. For
  46. instance, $\TypeConstr {\mathit{Nat}} {\mathit{Bool}}$ is a well-formed
  47. constraint given $\mathit{Nat} : \SET$ and $\mathit{Bool} : \SET$ in the
  48. signature.
  49. \begin{definition}[Well-formed constraint]
  50. A constraint if well-formed if the terms (or types) under consideration are
  51. well-typed.
  52. \if \DetailedProofs 1
  53. \[
  54. \infer{ \ValidConstr \Sigma {\TypeConstr A B}}
  55. {\begin{array}{l}
  56. \IsTypeCS \Sigma \Gamma A \\
  57. \IsTypeCS \Sigma \Gamma B
  58. \end{array}}
  59. \qquad
  60. \infer{ \ValidConstr \Sigma {\TermConstr M N A}}
  61. {\begin{array}{l}
  62. \HasTypeCS \Sigma \Gamma M A \\
  63. \HasTypeCS \Sigma \Gamma N A \\
  64. \end{array}}
  65. \]
  66. \else
  67. For instace, $\TermConstr M N A$ is well-formed if $\HasTypeC
  68. \Gamma M A$ and $\HasTypeC \Gamma N A$.
  69. \fi
  70. \end{definition}
  71. \fi
  72. Now we are ready to state the soundness of the type checking algorithm in the
  73. absence of constraint solving.
  74. \begin{theorem}[Soundness of type checking] \label{thmSoundNoCs}
  75. Type checking produces well-typed terms, conversion checking produces
  76. well-formed constraints and if no constraints are produced, the conversion
  77. is valid in {\Core}. Also, all rules produce well-formed extensions of the
  78. signature.
  79. \if \DetailedProofs 1
  80. \begin{itemize}
  81. % is type
  82. \item
  83. $\begin{array}[t]{l}
  84. \ExplicitJudgement \Sigma {\IsType e A} {\Sigma'}
  85. ~ \wedge ~ \IsCtxCS \Sigma \Gamma \\
  86. {} \implies \Extends {\Sigma'} {\Sigma}
  87. ~ \wedge ~ \IsTypeCS {\Sigma'} \Gamma A
  88. \end{array}$
  89. % check type
  90. \item
  91. $\begin{array}[t]{l}
  92. \ExplicitJudgement \Sigma {\CheckType e A M} {\Sigma'}
  93. ~ \wedge ~ \IsTypeCS \Sigma \Gamma A \\
  94. {} \implies \Extends {\Sigma'} {\Sigma}
  95. ~ \wedge ~ \HasTypeCS {\Sigma'} \Gamma M A
  96. \end{array}$
  97. % infer type
  98. \item
  99. $\begin{array}[t]{l}
  100. \ExplicitJudgement \Sigma {\InferType e A M} {\Sigma'}
  101. ~ \wedge ~ \IsCtxCS \Sigma \Gamma \\
  102. {} \implies \Extends {\Sigma'} {\Sigma}
  103. ~ \wedge ~ \HasTypeCS {\Sigma'} \Gamma M A
  104. \end{array}$
  105. % equal types
  106. \item
  107. $\begin{array}[t]{l}
  108. \ExplicitJudgement \Sigma {\EqualType A B \Cs} {\Sigma'}
  109. ~ \wedge ~ \IsTypeCS \Sigma \Gamma A
  110. ~ \wedge ~ \IsTypeCS \Sigma \Gamma B
  111. \\
  112. {} \implies \Extends {\Sigma'} {\Sigma}
  113. ~ \wedge ~ \ValidConstr {\Sigma'} \Cs
  114. ~ \wedge ~ (\Cs = \emptyset \implies \EqualTypeCS {\Sigma'} \Gamma A B)
  115. \end{array}$
  116. % equal terms
  117. \item
  118. $\begin{array}[t]{l}
  119. \ExplicitJudgement \Sigma {\Equal M N A \Cs} {\Sigma'}
  120. ~ \wedge ~ \HasTypeCS \Sigma \Gamma M A
  121. ~ \wedge ~ \HasTypeCS \Sigma \Gamma N A
  122. \\
  123. {} \implies \Extends {\Sigma'} {\Sigma}
  124. ~ \wedge ~ \ValidConstr {\Sigma'} \Cs
  125. ~ \wedge ~ (\Cs = \emptyset \implies \EqualCS {\Sigma'} \Gamma M N A)
  126. \end{array}$
  127. \end{itemize}
  128. The statements for weak head normal form conversion ($\EqualWhnf M N A
  129. \Cs$) and term sequence conversion ($\Equal {\bar M} {\bar N} \Delta \Cs$)
  130. are equivalent to that of term conversion.
  131. \fi
  132. \end{theorem}
  133. \begin{proof}
  134. By induction on the derivation.
  135. \if \DetailedProofs 1
  136. Some interesting cases:
  137. \begin{itemize}
  138. \item {\em (TODO: Not so interesting)} In the type conversion case for
  139. function spaces where the domains produce constraints, we have to use
  140. Lemma~\ref{lemCoreSubstType}.
  141. \item In the term conversion case where the terms are weak head
  142. normalised we need subject reduction for weak head normalisation
  143. (Lemma~\ref{lemCoreSubjectReduction}).
  144. \item When checking conversion of terms with the same head we need an
  145. inversion principle for application (Lemma~\ref{lemCoreAppInv}).
  146. \item The most interesting case is the meta-variable instantiation
  147. case, so let us spell that out in more detail.
  148. The instantiation rule does not produce any constraints, so the only
  149. thing we have to prove is that it constructs a valid extension of the
  150. signature. This follows from the signature refinement lemma
  151. (Lemma~\ref{lemRefineSig}) which can be applied if we prove that if
  152. $\Sigma = \Ext {\Sigma_1} \Ext {\MetaDecl \alpha {B'}} \Sigma_2$ then
  153. $\LAM {\bar x} M : {B'}$.
  154. We have $\HasTypeCS \Sigma \Gamma {\alpha \, \bar x} A$ so $B'$ must
  155. have the form $\PI {\bar x} \Delta B$. By Lemma~\ref{lemCoreAppInv} we
  156. conclude that $\HasTypeCS \Sigma \Gamma {\bar x} \Delta$ and thus
  157. $\HasTypeCS \Sigma \Gamma {\alpha \, \bar x} B$. Then by
  158. Lemma~\ref{lemCoreEqType} $\EqualTypeCS \Sigma \Gamma A B$.
  159. From $\HasTypeCS \Sigma \Gamma M A$ we get $\HasTypeCS \Sigma \Gamma M
  160. B$ and using Lemma~\ref{lemCoreShadow} $\HasTypeCS \Sigma \Gamma {\LAM
  161. {\bar x} M} {\Delta \to B}$. We know that $\Delta \to B$ is a closed
  162. type, and since $\FV{M} \subseteq \bar x$, $\LAM {\bar x} M$ is also
  163. closed. Thus by strenghtening (Lemma~\ref{lemCoreStrengthen})
  164. $\HasTypeCS \Sigma {} {\LAM {\bar x} M} {\Delta \to B}$. We have
  165. $\IsTypeCS {\Sigma_1} {} {\Delta \to B}$ and $\InScope \alpha M$ so
  166. $\HasTypeCS {\Sigma_1} {} {\LAM {\bar x} M} {\Delta \to B}$ which is
  167. what we set out to prove.
  168. \end{itemize}
  169. \else
  170. The most interesting case is the meta-variable instantiation case where we
  171. have to prove that the instantiation constructs a valid extension of the
  172. signature. This is proven by showing that the instantiation is well-typed.
  173. % This follows from Lemma~\ref{lemRefineSig} once we show that
  174. % the instantiation is well-typed.
  175. \fi
  176. \end{proof}
  177. Since well-typed terms in {\Core} have normal forms we get the existence of
  178. normal forms for type checked terms and hence the type checking algorithm is
  179. terminating.
  180. \begin{corollary}
  181. The type checking algorithm is terminating.
  182. \end{corollary}
  183. Note that type checking terminates with one of three answers: {\em yes it is
  184. type correct}, {\em no it is not correct}, or {\em it might be correct if the
  185. meta-variables are instantiated properly}. The algorithm is not complete, since
  186. finding correct instantiations to the meta-variables is undecidable in the
  187. general case.
  188. \subsection{Soundness of constraint solving}
  189. In the previous section we proved type checking sound and decidable in the
  190. absence of constraint solving. We also mostly ignored the constraints, only
  191. requiring them to be well-formed. In this section we prove that the terms
  192. produced by the type checker stay well-typed under constraint solving. This is
  193. done by showing that constraint solving is a signature extension operator in
  194. the sense of Definition~\ref{defSigExt}.
  195. Previously we only ensured that the {\Core} restriction of the signature was
  196. well-formed. Now, since we are going to update and remove the constraints of
  197. guarded constants we have to strengthen the requirements and demand {\em
  198. consistent} signatures. A signature is consistent if the solution of a guard is
  199. a sufficient condition for the well-typedness of the definition it is guarding.
  200. \if \DetailedProofs 1
  201. \begin{definition}[Ensures] \label{defEnsures}
  202. A set of constraints $\Cs$ {\em ensures} a {\Core} judgement $J$ in a signature
  203. $\Sigma$ if, for any $\Sigma_1$ such that
  204. $\Extends {\Sigma_1} \Sigma$ and
  205. $\ExplicitJudgement {\Sigma_1} {\CheckConstr \Cs \emptyset} {\Sigma_2}$
  206. it is the case that $\vdash_{\CoreSig{\Sigma_2}} J$.
  207. \end{definition}
  208. \begin{remark} \label{lemExtendEnsures}
  209. If $\Cs$ ensures $J$ in $\Sigma$ and $\Extends {\Sigma'} \Sigma$ then $\Cs$
  210. ensures $J$ in $\Sigma'$.
  211. \end{remark}
  212. \begin{definition}[Consistent signature] \label{defConsistentSig}
  213. A signature $\Sigma$ is said to be {\em consistent} if $\Sigma = \Ext
  214. {\Sigma_1} \Ext {\ConstDecl p A M \Cs} \Sigma_2$ implies that $\Cs$ ensures
  215. $\HasTypeC {} M A$ in $\Sigma_1$.
  216. \end{definition}
  217. \fi
  218. In order to prove that type checking preserves consistency, we first need to
  219. know that the constraints we produce are sound.
  220. \begin{lemma}[Soundness of generated constraints] \label{lemSoundConstraints}
  221. The constraints generated during conversion checking ensures that the
  222. checked terms are convertible. For instance, if $\EqualType A B \Cs$, then
  223. solving $\Cs$ guarantees that $\EqualTypeC \Gamma A B$ in {\Core}.
  224. \if \DetailedProofs 1
  225. More precisely,
  226. \begin{itemize}
  227. \item \( \begin{array}[t]{l}
  228. \IsTypeCS \Sigma \Gamma A
  229. ~ \wedge ~ \IsTypeCS \Sigma \Gamma B
  230. ~ \wedge ~ \ExplicitJudgement \Sigma {\EqualType A B \Cs} {\Sigma'}
  231. \\ {} \implies \mbox{$\Cs$ ensures $\EqualTypeC \Gamma A B$ in $\Sigma'$}
  232. \end{array} \)
  233. \item \( \begin{array}[t]{l}
  234. \HasTypeCS \Sigma \Gamma M A
  235. ~ \wedge ~ \HasTypeCS \Sigma \Gamma N A
  236. ~ \wedge ~ \ExplicitJudgement \Sigma {\Equal M N A \Cs} {\Sigma'}
  237. \\ {} \implies \mbox{$\Cs$ ensures $\EqualC \Gamma M N A$ in $\Sigma'$}
  238. \end{array} \)
  239. \end{itemize}
  240. \fi
  241. \end{lemma}
  242. \if \DetailedProofs 1
  243. \begin{proof}
  244. Again we highlight some interesting cases.
  245. \begin{itemize}
  246. \item
  247. The only difficult case is the case of conversion for function types
  248. where a new constant $p$ is introduced. There we need to prove
  249. $\EqualTypeCS {\Sigma_2} {\Ext \Gamma x : A_1} {B_1} {B_2}$ from
  250. $\EqualTypeCS {\Sigma_2} {\Ext \Gamma x : A_1} {B_1} {\SubstD {B_2} {p
  251. \, \Gamma \, x}}$
  252. If $\Sigma_2$ has an empty guard for $p$ then $p \, \Gamma \, x$
  253. reduces to $x$ and we are done. If the guard is non-empty we can apply
  254. Lemma~\ref{lemCoreEqualDummySubst}, since $p \, \Gamma \, x$ is on weak
  255. head normal form, and $p$ is a fresh constant which does not appear in
  256. $B_1$.
  257. \item In the case where $\Cs$ is known (for instance, in the rule for
  258. blocked terms), we can apply soundness of conversion checking
  259. (Theorem~\ref{thmSoundNoCs}) to get $\TrueConstr {\Sigma_2} \Cs$.
  260. \end{itemize}
  261. \end{proof}
  262. \fi
  263. \if \DetailedProofs 1
  264. \begin{lemma} \label{lemRefineConsistent}
  265. Refinement preserves consistent signatures.
  266. More precisely, if
  267. \begin{itemize}
  268. \item $\HasTypeCS {\Sigma_1} {} M A$
  269. \item $\Sigma ~ = ~ \Ext {\Sigma_1} \Ext {\MetaDecl c A} \Sigma_2$
  270. \item $\Sigma' ~ = ~ \Ext {\Sigma_1} \Ext {\IMetaDecl c A M} \Sigma_2$
  271. \item $\Sigma$ is consistent
  272. \end{itemize}
  273. then $\Sigma'$ is consistent.
  274. \end{lemma}
  275. \begin{proof}
  276. There are two cases to consider: refinement to the left and to the right of
  277. a guard. In the latter case the proof is trivial, and in the former case
  278. consistency follows from the fact that refinement extends a signature
  279. (Lemma~\ref{lemRefineSig}).
  280. \end{proof}
  281. \fi
  282. \begin{lemma}[Type checking preserves consistency] \label{lemTypeCheckConsistent}
  283. Type checking and conversion checking preserves consistent signatures.
  284. \if \DetailedProofs 1
  285. More precisely,
  286. \begin{itemize}
  287. % is type
  288. \item
  289. $\begin{array}[t]{l}
  290. \ExplicitJudgement \Sigma {\IsType e A} {\Sigma'}
  291. ~ \wedge ~ \IsCtxCS \Sigma \Gamma
  292. ~ \wedge ~ \mbox{$\Sigma$ is consistent}
  293. \\ {} \implies \mbox{$\Sigma'$ is consistent}
  294. \end{array}$
  295. % check type
  296. \item
  297. $\begin{array}[t]{l}
  298. \ExplicitJudgement \Sigma {\CheckType e A M} {\Sigma'}
  299. ~ \wedge ~ \IsTypeCS \Sigma \Gamma A
  300. ~ \wedge ~ \mbox{$\Sigma$ is consistent}
  301. \\ {} \implies \mbox{$\Sigma'$ is consistent}
  302. \end{array}$
  303. % infer type
  304. \item
  305. $\begin{array}[t]{l}
  306. \ExplicitJudgement \Sigma {\InferType e A M} {\Sigma'}
  307. ~ \wedge ~ \IsCtxCS \Sigma \Gamma
  308. ~ \wedge ~ \mbox{$\Sigma$ is consistent}
  309. \\ {} \implies \mbox{$\Sigma'$ is consistent}
  310. \end{array}$
  311. % equal types
  312. \item
  313. $\begin{array}[t]{l}
  314. \ExplicitJudgement \Sigma {\EqualType A B \Cs} {\Sigma'}
  315. ~ \wedge ~ \IsTypeCS \Sigma \Gamma A
  316. ~ \wedge ~ \IsTypeCS \Sigma \Gamma B \\
  317. ~ \wedge ~ \mbox{$\Sigma$ is consistent}
  318. \\ {} \implies \mbox{$\Sigma'$ is consistent}
  319. \end{array}$
  320. % equal terms
  321. \item
  322. $\begin{array}[t]{l}
  323. \ExplicitJudgement \Sigma {\Equal M N A \Cs} {\Sigma'}
  324. ~ \wedge ~ \HasTypeCS \Sigma \Gamma M A
  325. ~ \wedge ~ \HasTypeCS \Sigma \Gamma N A \\
  326. ~ \wedge ~ \mbox{$\Sigma$ is consistent}
  327. \\ {} \implies \mbox{$\Sigma'$ is consistent}
  328. \end{array}$
  329. \end{itemize}
  330. The statements for weak head normal form conversion ($\EqualWhnf M N A
  331. \Cs$) and term sequence conversion ($\Equal {\bar M} {\bar N} \Delta \Cs$)
  332. are equivalent to that of term conversion.
  333. \fi
  334. \end{lemma}
  335. \begin{proof}
  336. \if \DetailedProofs 1
  337. By induction on the derivation. We only need to consider the cases where
  338. the signature changes. Adding a (non-guarded) constant trivially preserves
  339. consistency, instantiating a meta-variable preserves consistency by
  340. Lemma~\ref{lemRefineConsistent}. What remains is to check that new guarded
  341. constants are consistent. There are two cases: the conversion rule and
  342. conversion checking of function types. In both cases consistency follows
  343. from soundness of conversion checking (Lemma~\ref{lemSoundConstraints}).
  344. \else
  345. We have to prove that when we introduce a guarded constant the guard
  346. ensures the well-typedness of the value. This follows from
  347. Lemma~\ref{lemSoundConstraints}.
  348. \fi
  349. \end{proof}
  350. \begin{lemma}[Constraint solving is sound] \label{lemSolveConsistent}
  351. If $\Sigma$ is consistent and the solving the constraints yields a
  352. signature $\Sigma'$, then $\Sigma'$ is consistent and $\Extends {\Sigma'}
  353. \Sigma$.
  354. \end{lemma}
  355. \begin{proof}
  356. Follows from Theorem~\ref{thmSoundNoCs}, Lemma~\ref{lemSoundConstraints},
  357. and Lemma~\ref{lemTypeCheckConsistent}.
  358. \end{proof}
  359. From this follows that we can mix type checking and constraint solving freely,
  360. so we can add a constraint solving rule to the type checking algorithm. In
  361. order to obtain optimal approximations we have to solve constraints eagerly,
  362. i.e as soon as a meta-variable has been instantiated.
  363. \subsection{Relating user expressions and checked terms}
  364. An important property of the type checking algorithm is that the type correct terms
  365. produced correspond to the expressions being type checked. The correspondance
  366. is expressed by stating that the only operations the type checker is allowed
  367. when constructing a term is replacing a $?$ by a term ({\em refinement}) and
  368. replacing a term by a guarded constant ({\em approximation}).
  369. \if \DetailedProofs 1
  370. \begin{definition}[Approximation]
  371. A term $M$ {\em approximates} $M'$ if $M$ can be obtained by replacing
  372. subterms of $M'$ by guarded constants $p \, \bar x$.
  373. \end{definition}
  374. \begin{definition}[Refinement]
  375. A term $M$ is a {\em refinment} of a user expression $e$ if $M$ can be
  376. obtained by replacing the $?$ in $e$ by concrete terms.
  377. \end{definition}
  378. \fi
  379. \begin{lemma} \label{lemApproxRefine}
  380. If $\CheckType e A M$ then $M$ approximates a refinement of $e$. This
  381. property is preserved when unfolding instantiated meta-variables and
  382. guarded constants in $M$.
  383. \end{lemma}
  384. \begin{lemma}
  385. If $\CheckType e A M$ then $M$ is an {\em optimal approximation} of a
  386. refinement $M'$ of $e$.
  387. \end{lemma}
  388. \begin{proof}
  389. The proof relies on the fact that we only introduce guarded constants when
  390. absolutely necessary and solve the constraints eagerly. This is proven by
  391. showing that the constraints produced by conversion checking are not only
  392. sufficient but also necessary for the validity of the judgement.
  393. \end{proof}
  394. \subsection{Main result}
  395. We now prove the main soundness theorem stating that if all meta-variables are
  396. instantiated and all guards solved, then the term produced by the type checker
  397. (extended with constraint solving) is valid in the original signature after
  398. unfolding the definitions of the meta-variables and guarded constants
  399. introduced during type checking.
  400. \begin{theorem}[Soundness of type checking] \label{thmMain}
  401. If $\Sigma$ is a well-formed {\Core} signature and $\ExplicitJudgement
  402. \Sigma {\CheckType e A M} {\Sigma'}$, then if all meta-variables have been
  403. instantiated and all guards are empty in $\Sigma'$, then $\HasTypeCS \Sigma
  404. \Gamma {M\sigma} A$ where $\sigma$ is the substitution inlining the meta
  405. variables and constants in $\Sigma'$. Moreover, $M\sigma$ is a refinement
  406. of $e$.
  407. \end{theorem}
  408. \if \DetailedProofs 1
  409. \begin{proof}
  410. From Theorem~\ref{thmSoundNoCs} follows that $\HasTypeCS {\Sigma'} \Gamma M
  411. A$ and Lemma~\ref{lemTypeCheckConsistent} and
  412. Lemma~\ref{lemSolveConsistent} give that $\Sigma'$ is a consistent
  413. extension of $\Sigma$. Thus $\sigma$ is well-typed and we have $\HasTypeCS
  414. {\Sigma'} \Gamma {M\sigma} A$.
  415. Since $M\sigma$ only uses constants from $\Sigma$ we can strengthen the
  416. signature to obtain $\HasTypeCS \Sigma \Gamma {M\sigma} A$.
  417. By Lemma~\ref{lemApproxRefine} we have that $M\sigma$ approximates a
  418. refinement of $e$. Since $M\sigma$ does not contain any guarded constants
  419. it is a refinement of $e$.
  420. \end{proof}
  421. \fi