model.tex 21.2 KB
 Ralf Jung committed Jan 31, 2016 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 \section{Model and semantics} The semantics closely follows the ideas laid out in~\cite{catlogic}. We just repeat some of the most important definitions here. An \emph{ordered family of equivalence relations} (o.f.e.\@) is a pair $(X,(\nequiv{n})_{n\in\mathbb{N}})$, with $X$ a set, and each $\nequiv{n}$ an equivalence relation over $X$ satisfying \begin{itemize} \item $\All x,x'. x \nequiv{0} x',$ \item $\All x,x',n. x \nequiv{n+1} x' \implies x \nequiv{n} x',$ \item $\All x,x'. (\All n. x\nequiv{n} x') \implies x = x'.$ \end{itemize} Let $(X,(\nequivset{n}{X})_{n\in\mathbb{N}})$ and $(Y,(\nequivset{n}{Y})_{n\in\mathbb{N}})$ be o.f.e.'s. A function $f: X\to Y$ is \emph{non-expansive} if, for all $x$, $x'$ and $n$, $x \nequivset{n}{X} x' \implies fx \nequivset{n}{Y} f x'.$ Let $(X,(\nequiv{n})_{n\in\mathbb{N}})$ be an o.f.e. A sequence $(x_i)_{i\in\mathbb{N}}$ of elements in $X$ is a \emph{chain} (aka \emph{Cauchy sequence}) if $\All k. \Exists n. \All i,j\geq n. x_i \nequiv{k} x_j.$ A \emph{limit} of a chain $(x_i)_{i\in\mathbb{N}}$ is an element $x\in X$ such that $\All n. \Exists k. \All i\geq k. x_i \nequiv{n} x.$ An o.f.e.\ $(X,(\nequiv{n})_{n\in\mathbb{N}})$ is \emph{complete} if all chains have a limit. A complete o.f.e.\ is called a c.o.f.e.\ (pronounced coffee''). When the family of equivalence relations is clear from context we simply write $X$ for a c.o.f.e.\ $(X,(\nequiv{n})_{n\in\mathbb{N}})$. Let $\cal U$ be the category of c.o.f.e.'s and nonexpansive maps. Products and function spaces are defined as follows. For c.o.f.e.'s $(X,(\nequivset{n}{X})_{n\in\mathbb{N}})$ and $(Y,(\nequivset{n}{Y})_{n\in\mathbb{N}})$, their product is $(X\times Y, (\nequiv{n})_{n\in\mathbb{N}}),$ where $(x,y) \nequiv{n} (x',y') \iff x \nequiv{n} x' \land y \nequiv{n} y'.$ The function space is $(\{\, f : X\to Y \mid f \text{ is non-expansive}\,\}, (\nequiv{n})_{n\in\mathbb{N}}),$ where $f \nequiv{n} g \iff \All x. f(x) \nequiv{n} g(x).$ For a c.o.f.e.\ $(X,(\nequiv{n}_{n\in\mathbb{N}}))$, $\latert (X,(\nequiv{n}_{n\in\mathbb{N}}))$ is the c.o.f.e.\@ $(X,(\nequivB{n}_{n\in\mathbb{N}}))$, where $x \nequivB{n} x' \iff \begin{cases} \top &\IF n=0 \\ x \nequiv{n-1} x' &\IF n>0 \end{cases}$ (Sidenote: $\latert$ extends to a functor on $\cal U$ by the identity action on morphisms). \subsection{Semantic structures: propositions} \ralf{This needs to be synced with the Coq development again.} $\begin{array}[t]{rcl} % \protStatus &::=& \enabled \ALT \disabled \\[0.4em] \textdom{Res} &\eqdef&  Ralf Jung committed Jan 31, 2016 85 \{\, \rs = (\pres, \ghostRes) \mid  Ralf Jung committed Jan 31, 2016 86 87 88 89 90 91 92 93 94 \pres \in \textdom{State} \uplus \{\munit\} \land \ghostRes \in \mcarp{\monoid} \,\} \\[0.5em] (\pres, \ghostRes) \rsplit (\pres', \ghostRes') &\eqdef& \begin{cases} (\pres, \ghostRes \mtimes \ghostRes') & \mbox{if \pres' = \munit and \ghostRes \mtimes \ghostRes' \neq \mzero} \\ (\pres', \ghostRes \mtimes \ghostRes') & \mbox{if \pres = \munit and \ghostRes \mtimes \ghostRes' \neq \mzero} \end{cases} \\[0.5em] %  Ralf Jung committed Jan 31, 2016 95 96 \rs \leq \rs' & \eqdef & \Exists \rs''. \rs' = \rs \rsplit \rs''\\[1em]  Ralf Jung committed Jan 31, 2016 97 98 99 % \UPred(\textdom{Res}) &\eqdef& \{\, p \subseteq \mathbb{N} \times \textdom{Res} \mid  Ralf Jung committed Jan 31, 2016 100 \All (k,\rs) \in p.  Ralf Jung committed Jan 31, 2016 101 \All j\leq k.  Ralf Jung committed Jan 31, 2016 102 103 \All \rs' \geq \rs. (j,\rs')\in p \,\}\\[0.5em]  Ralf Jung committed Jan 31, 2016 104 \restr{p}{k} &\eqdef&  Ralf Jung committed Jan 31, 2016 105 \{\, (j, \rs) \in p \mid j < k \,\}\\[0.5em]  Ralf Jung committed Jan 31, 2016 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 p \nequiv{n} q & \eqdef & \restr{p}{n} = \restr{q}{n}\\[1em] % \textdom{PreProp} & \cong & \latert\big( \textdom{World} \monra \UPred(\textdom{Res}) \big)\\[0.5em] % \textdom{World} & \eqdef & \mathbb{N} \fpfn \textdom{PreProp}\\[0.5em] % w \nequiv{n} w' & \eqdef & n = 0 \lor \bigl(\dom(w) = \dom(w') \land \All i\in\dom(w). w(i) \nequiv{n} w'(i)\bigr) \\[0.5em] % w \leq w' & \eqdef & \dom(w) \subseteq \dom(w') \land \All i \in \dom(w). w(i) = w'(i) \\[0.5em] % \textdom{Prop} & \eqdef & \textdom{World} \monra \UPred(\textdom{Res}) \end{array}$ For $p,q\in\UPred(\textdom{Res})$ with $p \nequiv{n} q$ defined as above, $\UPred(\textdom{Res})$ is a c.o.f.e. $\textdom{Prop}$ is a c.o.f.e., which exists by America and Rutten's theorem~\cite{America-Rutten:JCSS89}. We do not need to consider how the object is constructed. We only need the isomorphism, given by maps \begin{align*} \wIso &: \latert \bigl(World \monra \UPred(\textdom{Res})\bigr) \to \textdom{PreProp} \\ \wIso^{-1} &: \textdom{PreProp} \to \latert \bigl(World \monra \UPred(\textdom{Res})\bigr) \end{align*} which are inverses to each other. Note: this is an isomorphism in $\cal U$, i.e., $\wIso$ and $\wIso^{-1}$ are both non-expansive. $\textdom{World}$ is a c.o.f.e.\ with the family of equivalence relations defined as shown above. \subsection{Semantic structures: types and environments} For a set $X$, write $\Delta X$ for the discrete c.o.f.e.\ with $x \nequiv{n} x'$ iff $n = 0$ or $x = x'$ $\begin{array}[t]{@{}l@{\ }c@{\ }l@{}} \semSort{\unit} &\eqdef& \Delta \{ \star \} \\ \semSort{\textsort{InvName}} &\eqdef& \Delta \mathbb{N} \\ \semSort{\textsort{InvMask}} &\eqdef& \Delta \pset{\mathbb{N}} \\ \semSort{\textsort{Monoid}} &\eqdef& \Delta |\monoid| \end{array} \qquad\qquad \begin{array}[t]{@{}l@{\ }c@{\ }l@{}} \semSort{\textsort{Val}} &\eqdef& \Delta \textdom{Val} \\ \semSort{\textsort{Exp}} &\eqdef& \Delta \textdom{Exp} \\ \semSort{\textsort{Ectx}} &\eqdef& \Delta \textdom{Ectx} \\ \semSort{\textsort{State}} &\eqdef& \Delta \textdom{State} \\ \end{array} \qquad\qquad \begin{array}[t]{@{}l@{\ }c@{\ }l@{}} \semSort{\sort \times \sort'} &\eqdef& \semSort{\sort} \times \semSort{\sort} \\ \semSort{\sort \to \sort'} &\eqdef& \semSort{\sort} \to \semSort{\sort} \\ \semSort{\Prop} &\eqdef& \textdom{Prop} \\ \end{array}$ The balance of our signature $\SigNat$ is interpreted as follows. For each base type $\type$ not covered by the preceding table, we pick an object $X_\type$ in $\cal U$ and define $\semSort{\type} \eqdef X_\type$ For each function symbol $\sigfn : \type_1, \dots, \type_n \to \type_{n+1} \in \SigFn$, we pick an arrow $\Sem{\sigfn} : \semSort{\type_1} \times \dots \times \semSort{\type_n} \to \semSort{\type_{n+1}}$ in $\cal U$. An environment $\vctx$ is interpreted as the set of maps $\rho$, with $\dom(\rho) = \dom(\vctx)$ and $\rho(x)\in\semSort{\vctx(x)}$, and $\rho\nequiv{n} \rho' \iff n=0 \lor \bigl(\dom(\rho)=\dom(\rho') \land \All x\in\dom(\rho). \rho(x) \nequiv{n} \rho'(x)\bigr)$. \ralf{Re-check all the following definitions with the Coq development.} %\typedsection{Validity}{valid : \pset{\textdom{Prop}} \in Sets} % %\begin{align*}  Ralf Jung committed Jan 31, 2016 190 %valid(p) &\iff \All n \in \mathbb{N}. \All \rs \in \textdom{Res}. \All W \in \textdom{World}. (n, \rs) \in p(W)  Ralf Jung committed Jan 31, 2016 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 %\end{align*} \typedsection{Later modality}{\later : \textdom{Prop} \to \textdom{Prop} \in {\cal U}} \begin{align*} \later p &\eqdef \Lam W. \{\, (n + 1, r) \mid (n, r) \in p(W) \,\} \cup \{\, (0, r) \mid r \in \textdom{Res} \,\} \end{align*} \begin{lem} $\later{}$ is well-defined: $\later {p}$ is a valid proposition (this amounts to showing non-expansiveness), and $\later{}$ itself is a \emph{contractive} map. \end{lem} \typedsection{Always modality}{\always{} : \textdom{Prop} \to \textdom{Prop} \in {\cal U}} \begin{align*} \always{p} \eqdef \Lam W. \{\, (n, r) \mid (n, \munit) \in p(W) \,\} \end{align*} \begin{lem} $\always{}$ is well-defined: $\always{p}$ is a valid proposition (this amounts to showing non-expansiveness), and $\always{}$ itself is a non-expansive map. \end{lem} % PDS: p \Rightarrow q not defined. %\begin{lem}\label{lem:always-impl-valid} %\begin{align*} %&\forall p, q \in \textdom{Prop}.~\\ %&\qquad  Ralf Jung committed Jan 31, 2016 216 % (\forall n \in \mathbb{N}.~\forall \rs \in \textdom{Res}.~\forall W \in \textdom{World}.~(n, \rs) \in p(W) \Rightarrow (n, \rs) \in q(W)) \Leftrightarrow~valid(\always{(p \Rightarrow q)})  Ralf Jung committed Jan 31, 2016 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 %\end{align*} %\end{lem} \typedsection{Invariant definition}{inv : \Delta(\mathbb{N}) \times \textdom{Prop} \to \textdom{Prop} \in {\cal U}} \begin{align*} \mathit{inv}(\iota, p) &\eqdef \Lam W. \{\, (n, r) \mid \iota\in\dom(W) \land W(\iota) \nequiv{n+1}_{\textdom{PreProp}} \wIso(p) \,\} \end{align*} \begin{lem} $\mathit{inv}$ is well-defined: $\mathit{inv}(\iota, p)$ is a valid proposition (this amounts to showing non-expansiveness), and $\mathit{inv}$ itself is a non-expansive map. \end{lem} \typedsection{World satisfaction}{\fullSat{-}{-}{-}{-} : \textdom{State} \times \pset{\mathbb{N}} \times \textdom{Res} \times \textdom{World} \to \psetdown{\mathbb{N}} \in {\cal U}} \ralf{Make this Dave-compatible: Explicitly compose all the things in $s$} \begin{align*}  Ralf Jung committed Jan 31, 2016 235  \fullSat{\state}{\mask}{\rs}{W} &=  Ralf Jung committed Jan 31, 2016 236  \begin{aligned}[t]  Ralf Jung committed Jan 31, 2016 237 238 239  \{\, n + 1 \in \mathbb{N} \mid &\Exists \rsB:\mathbb{N} \fpfn \textdom{Res}. (\rs \rsplit \rsB).\pres = \state \land{}\\ &\quad \All \iota \in \dom(W). \iota \in \dom(W) \leftrightarrow \iota \in \dom(\rsB) \land {}\\ &\quad\quad \iota \in \mask \ra (n, \rsB(\iota)) \in \wIso^{-1}(W(\iota))(W) \,\} \cup \{ 0 \}  Ralf Jung committed Jan 31, 2016 240 241 242 243 244 245 246 247 248 249 250  \end{aligned} \end{align*} \begin{lem}\label{lem:fullsat-nonexpansive} $\fullSat{-}{-}{-}{-}$ is well-defined: It maps into $\psetdown{\mathbb{N}}$. (There is no need for it to be a non-expansive map, it doesn't itself live in $\cal U$.) \end{lem} \begin{lem}\label{lem:fullsat-weaken-mask} \begin{align*} \MoveEqLeft \All \state \in \Delta(\textdom{State}). \All \mask_1, \mask_2 \in \Delta(\pset{\mathbb{N}}).  Ralf Jung committed Jan 31, 2016 251  \All \rs, \rsB \in \Delta(\textdom{Res}).  Ralf Jung committed Jan 31, 2016 252  \All W \in \textdom{World}. \\&  Ralf Jung committed Jan 31, 2016 253  \mask_1 \subseteq \mask_2 \implies (\fullSat{\state}{\mask_2}{\rs}{W}) \subseteq (\fullSat{\state}{\mask_1}{\rs}{W})  Ralf Jung committed Jan 31, 2016 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295  \end{align*} \end{lem} \begin{lem}\label{lem:nequal_ext_world} \begin{align*} & \All n \in \mathbb{N}. \All W_1, W_1', W_2 \in \textdom{World}. W_1 \nequiv{n} W_2 \land W_1 \leq W_1' \implies \Exists W_2' \in \textdom{World}. W_1' \nequiv{n} W_2' \land W_2 \leq W_2' \end{align*} \end{lem} \typedsection{Timeless}{\textit{timeless} : \textdom{Prop} \to \textdom{Prop}} \begin{align*} \textit{timeless}(p) \eqdef \begin{aligned}[t] \Lam W. \{\, (n, r) &\mid \All W' \geq W. \All k \leq n. \All r' \in \textdom{Res}. \\ &\qquad k > 0 \land (k - 1, r') \in p(W') \implies (k, r') \in p(W') \,\} \end{aligned} \end{align*} \begin{lem} \textit{timeless} is well-defined: \textit{timeless}(p) is a valid proposition, and \textit{timeless} itself is a non-expansive map. \end{lem} % PDS: \Ra undefined. %\begin{lem} %\begin{align*} %& % \All p \in \textdom{Prop}. % \All \mask \in \pset{\mathbb{N}}. %valid(\textit{timeless}(p) \Ra (\later p \vs[\mask][\mask] p)) %\end{align*} %\end{lem} \typedsection{View-shift}{\mathit{vs} : \Delta(\pset{\mathbb{N}}) \times \Delta(\pset{\mathbb{N}}) \times \textdom{Prop} \to \textdom{Prop} \in {\cal U}} \begin{align*} \mathit{vs}_{\mask_1}^{\mask_2}(q) &= \Lam W. \begin{aligned}[t]  Ralf Jung committed Jan 31, 2016 296  \{\, (n, \rs) &\mid \All W_F \geq W. \All \rs_F, \mask_F, \state. \All k \leq n.\\  Ralf Jung committed Jan 31, 2016 297  &\qquad  Ralf Jung committed Jan 31, 2016 298  k \in (\fullSat{\state}{\mask_1 \cup \mask_F}{\rs \rsplit \rs_F}{W_F}) \land k > 0 \land \mask_F \sep (\mask_1 \cup \mask_2) \implies{} \\  Ralf Jung committed Jan 31, 2016 299  &\qquad  Ralf Jung committed Jan 31, 2016 300  \Exists W' \geq W_F. \Exists \rs'. k \in (\fullSat{\state}{\mask_2 \cup \mask_F}{\rs' \rsplit \rs_F}{W'}) \land (k, \rs') \in q(W')  Ralf Jung committed Jan 31, 2016 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340  \,\} \end{aligned} \end{align*} \begin{lem} $\mathit{vs}$ is well-defined: $\mathit{vs}_{\mask_1}^{\mask_2}(q)$ is a valid proposition, and $\mathit{vs}$ is a non-expansive map. \end{lem} %\begin{lem}\label{lem:prim_view_shift_trans} %\begin{align*} %\MoveEqLeft % \All \mask_1, \mask_2, \mask_3 \in \Delta(\pset{\mathbb{N}}). % \All p, q \in \textdom{Prop}. \All W \in \textdom{World}. % \All n \in \mathbb{N}.\\ %& % \mask_2 \subseteq \mask_1 \cup \mask_3 \land % \bigl(\All W' \geq W. \All r \in \textdom{Res}. \All k \leq n. (k, r) \in p(W') \implies (k, r) \in vs_{\mask_2}^{\mask_3}(q)(W')\bigr) \\ %&\qquad % {}\implies \All r \in \textdom{Res}. (n, r) \in vs_{\mask_1}^{\mask_2}(p)(W) \implies (n, r) \in vs_{\mask_1}^{\mask_3}(q)(W) %\end{align*} %\end{lem} % PDS: E_1 ==>> E_2 undefined. %\begin{lem} %\begin{align*} %& % \forall \mask_1, \mask_2, \mask_3 \in \Delta(\pset{\mathbb{N}}).~ % \forall p_1, p_2, p_3 \in \textdom{Prop}.~\\ %&\qquad % \mask_2 \subseteq \mask_1 \cup \mask_3 \Rightarrow % valid(((p_1 \vs[\mask_1][\mask_2] p_2) \land (p_2 \vs[\mask_2][\mask_3] p_3)) \Rightarrow (p_1 \vs[\mask_1][\mask_3] p_3)) %\end{align*} %\end{lem} %\begin{lem} %\begin{align*} %\MoveEqLeft % \All \iota \in \mathbb{N}. % \All p \in \textdom{Prop}. % \All W \in \textdom{World}.  Ralf Jung committed Jan 31, 2016 341 % \All \rs \in \textdom{Res}.  Ralf Jung committed Jan 31, 2016 342 343 % \All n \in \mathbb{N}. \\ %&  Ralf Jung committed Jan 31, 2016 344 % (n, \rs) \in inv(\iota, p)(W) \implies (n, \rs) \in vs_{\{ \iota \}}^{\emptyset}(\later p)(W)  Ralf Jung committed Jan 31, 2016 345 346 347 348 349 350 351 352 353 354 %\end{align*} %\end{lem} % PDS: * undefined. %\begin{lem} %\begin{align*} %& % \forall \iota \in \mathbb{N}.~ % \forall p \in \textdom{Prop}.~ % \forall W \in \textdom{World}.~  Ralf Jung committed Jan 31, 2016 355 % \forall \rs \in \textdom{Res}.~  Ralf Jung committed Jan 31, 2016 356 357 % \forall n \in \mathbb{N}.~\\ %&\qquad  Ralf Jung committed Jan 31, 2016 358 % (n, \rs) \in (inv(\iota, p) * \later p)(W) \Rightarrow (n, \rs) \in vs^{\{ \iota \}}_{\emptyset}(\top)(W)  Ralf Jung committed Jan 31, 2016 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 %\end{align*} %\end{lem} % \begin{lem} % \begin{align*} % & % \forall \mask_1, \mask_2 \in \Delta(\pset{\mathbb{N}}).~ % valid(\bot \vs[\mask_1][\mask_2] \bot) % \end{align*} % \end{lem} % PDS: E_1 ==>> E_2 undefined. %\begin{lem} %\begin{align*} %& % \forall p, q \in \textdom{Prop}.~ % \forall \mask \in \pset{\mathbb{N}}.~ %valid(\always{(p \Rightarrow q)} \Rightarrow (p \vs[\mask][\mask] q)) %\end{align*} %\end{lem} % PDS: E # E' and E_1 ==>> E_2 undefined. %\begin{lem} %\begin{align*} %& % \forall p_1, p_2, p_3 \in \textdom{Prop}.~ % \forall \mask_1, \mask_2, \mask \in \pset{\mathbb{N}}.~ %valid(\mask \sep \mask_1 \Ra \mask \sep \mask_2 \Ra (p_1 \vs[\mask_1][\mask_2] p_2) \Rightarrow (p_1 * p_3 \vs[\mask_1 \cup \mask][\mask_2 \cup \mask] p_2 * p_3)) %\end{align*} %\end{lem} \typedsection{Weakest precondition}{\mathit{wp} : \Delta(\pset{\mathbb{N}}) \times \Delta(\textdom{Exp}) \times (\Delta(\textdom{Val}) \to \textdom{Prop}) \to \textdom{Prop} \in {\cal U}} \begin{align*} \mathit{wp}_\mask(\expr, q) &\eqdef \Lam W. \begin{aligned}[t]  Ralf Jung committed Jan 31, 2016 395  \{\, (n, \rs) &\mid \All W_F \geq W; k \leq n; \rs_F; \state; \mask_F \sep \mask. k > 0 \land k \in (\fullSat{\state}{\mask \cup \mask_F}{\rs \rsplit \rs_F}{W_F}) \implies{}\\  Ralf Jung committed Jan 31, 2016 396  &\qquad  Ralf Jung committed Jan 31, 2016 397  (\expr \in \textdom{Val} \implies \Exists W' \geq W_F. \Exists \rs'. \\  Ralf Jung committed Jan 31, 2016 398  &\qquad\qquad  Ralf Jung committed Jan 31, 2016 399  k \in (\fullSat{\state}{\mask \cup \mask_F}{\rs' \rsplit \rs_F}{W'}) \land (k, \rs') \in q(\expr)(W'))~\land \\  Ralf Jung committed Jan 31, 2016 400  &\qquad  Ralf Jung committed Jan 31, 2016 401  (\All\ectx,\expr_0,\expr'_0,\state'. \expr = \ectx[\expr_0] \land \cfg{\state}{\expr_0} \step \cfg{\state'}{\expr'_0} \implies \Exists W' \geq W_F. \Exists \rs'. \\  Ralf Jung committed Jan 31, 2016 402  &\qquad\qquad  Ralf Jung committed Jan 31, 2016 403  k - 1 \in (\fullSat{\state'}{\mask \cup \mask_F}{\rs' \rsplit \rs_F}{W'}) \land (k-1, \rs') \in wp_\mask(\ectx[\expr_0'], q)(W'))~\land \\  Ralf Jung committed Jan 31, 2016 404  &\qquad  Ralf Jung committed Jan 31, 2016 405  (\All\ectx,\expr'. \expr = \ectx[\fork{\expr'}] \implies \Exists W' \geq W_F. \Exists \rs', \rs_1', \rs_2'. \\  Ralf Jung committed Jan 31, 2016 406  &\qquad\qquad  Ralf Jung committed Jan 31, 2016 407  k - 1 \in (\fullSat{\state}{\mask \cup \mask_F}{\rs' \rsplit \rs_F}{W'}) \land \rs' = \rs_1' \rsplit \rs_2'~\land \\  Ralf Jung committed Jan 31, 2016 408  &\qquad\qquad  Ralf Jung committed Jan 31, 2016 409 410  (k-1, \rs_1') \in \mathit{wp}_\mask(\ectx[\textsf{fRet}], q)(W') \land (k-1, \rs_2') \in \mathit{wp}_\top(\expr', \Lam\any. \top)(W'))  Ralf Jung committed Jan 31, 2016 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493  \,\} \end{aligned} \end{align*} \begin{lem} $\mathit{wp}$ is well-defined: $\mathit{wp}_{\mask}(\expr, q)$ is a valid proposition, and $\mathit{wp}$ is a non-expansive map. Besides, the dependency on the recursive occurrence is contractive, so $\mathit{wp}$ has a fixed-point. \end{lem} \begin{lem} $\mathit{wp}$ on values and non-mask-changing $\mathit{vs}$ agree: $\mathit{wp}_\mask(\val, q) = \mathit{vs}_{\mask}^{\mask}(q \: \val)$ \end{lem} \typedsection{Interpretation of terms}{\Sem{\vctx \proves \term : \sort} : \Sem{\vctx} \to \semSort{\sort} \in {\cal U}} %A term $\vctx \proves \term : \sort$ is interpreted as a non-expansive map from $\Sem{\vctx}$ to $\semSort{\sort}$. \begin{align*} \semTerm{\vctx \proves x : \sort}_\gamma &= \gamma(x) \\ \semTerm{\vctx \proves \sigfn(\term_1, \dots, \term_n) : \type_{n+1}}_\gamma &= \Sem{\sigfn}(\semTerm{\vctx \proves \term_1 : \type_1}_\gamma, \dots, \semTerm{\vctx \proves \term_n : \type_n}_\gamma) \ \WHEN \sigfn : \type_1, \dots, \type_n \to \type_{n+1} \in \SigFn \\ \semTerm{\vctx \proves \Lam x. \term : \sort \to \sort'}_\gamma &= \Lam v : \semSort{\sort}. \semTerm{\vctx, x : \sort \proves \term : \sort'}_{\gamma[x \mapsto v]} \\ \semTerm{\vctx \proves \term~\termB : \sort'}_\gamma &= \semTerm{\vctx \proves \term : \sort \to \sort'}_\gamma(\semTerm{\vctx \proves \termB : \sort}_\gamma) \\ \semTerm{\vctx \proves \unitterm : \unitsort}_\gamma &= \star \\ \semTerm{\vctx \proves (\term_1, \term_2) : \sort_1 \times \sort_2}_\gamma &= (\semTerm{\vctx \proves \term_1 : \sort_1}_\gamma, \semTerm{\vctx \proves \term_2 : \sort_2}_\gamma) \\ \semTerm{\vctx \proves \pi_i~\term : \sort_1}_\gamma &= \pi_i(\semTerm{\vctx \proves \term : \sort_1 \times \sort_2}_\gamma) \end{align*} % \begin{align*} \semTerm{\vctx \proves \mzero : \textsort{Monoid}}_\gamma &= \mzero \\ \semTerm{\vctx \proves \munit : \textsort{Monoid}}_\gamma &= \munit \\ \semTerm{\vctx \proves \melt \mtimes \meltB : \textsort{Monoid}}_\gamma &= \semTerm{\vctx \proves \melt : \textsort{Monoid}}_\gamma \mtimes \semTerm{\vctx \proves \meltB : \textsort{Monoid}}_\gamma \end{align*} % \begin{align*} \semTerm{\vctx \proves t =_\sort u : \Prop}_\gamma &= \Lam W. \{\, (n, r) \mid \semTerm{\vctx \proves t : \sort}_\gamma \nequiv{n+1} \semTerm{\vctx \proves u : \sort}_\gamma \,\} \\ \semTerm{\vctx \proves \FALSE : \Prop}_\gamma &= \Lam W. \emptyset \\ \semTerm{\vctx \proves \TRUE : \Prop}_\gamma &= \Lam W. \mathbb{N} \times \textdom{Res} \\ \semTerm{\vctx \proves P \land Q : \Prop}_\gamma &= \Lam W. \semTerm{\vctx \proves P : \Prop}_\gamma(W) \cap \semTerm{\vctx \proves Q : \Prop}_\gamma(W) \\ \semTerm{\vctx \proves P \lor Q : \Prop}_\gamma &= \Lam W. \semTerm{\vctx \proves P : \Prop}_\gamma(W) \cup \semTerm{\vctx \proves Q : \Prop}_\gamma(W) \\ \semTerm{\vctx \proves P \Ra Q : \Prop}_\gamma &= \Lam W. \begin{aligned}[t] \{\, (n, r) &\mid \All n' \leq n. \All W' \geq W. \All r' \geq r. \\ &\qquad (n', r') \in \semTerm{\vctx \proves P : \Prop}_\gamma(W')~ \\ &\qquad \implies (n', r') \in \semTerm{\vctx \proves Q : \Prop}_\gamma(W') \,\} \end{aligned} \\ \semTerm{\vctx \proves \All x : \sort. P : \Prop}_\gamma &= \Lam W. \{\, (n, r) \mid \All v \in \semSort{\sort}. (n, r) \in \semTerm{\vctx, x : \sort \proves P : \Prop}_{\gamma[x \mapsto v]}(W) \,\} \\ \semTerm{\vctx \proves \Exists x : \sort. P : \Prop}_\gamma &= \Lam W. \{\, (n, r) \mid \Exists v \in \semSort{\sort}. (n, r) \in \semTerm{\vctx, x : \sort \proves P : \Prop}_{\gamma[x \mapsto v]}(W) \,\} \end{align*} % \begin{align*} \semTerm{\vctx \proves \always{\prop} : \Prop}_\gamma &= \always{\semTerm{\vctx \proves \prop : \Prop}_\gamma} \\ \semTerm{\vctx \proves \later{\prop} : \Prop}_\gamma &= \later \semTerm{\vctx \proves \prop : \Prop}_\gamma\\ \semTerm{\vctx \proves \MU x. \pred : \sort \to \Prop}_\gamma &= \mathit{fix}(\Lam v : \semSort{\sort \to \Prop}. \semTerm{\vctx, x : \sort \to \Prop \proves \pred : \sort \to \Prop}_{\gamma[x \mapsto v]}) \\ \semTerm{\vctx \proves \prop * \propB : \Prop}_\gamma &= \begin{aligned}[t] \Lam W. \{\, (n, r) &\mid \Exists r_1, r_2. r = r_1 \bullet r_2 \land{} \\ &\qquad (n, r_1) \in \semTerm{\vctx \proves \prop : \Prop}_\gamma \land{} \\ &\qquad (n, r_2) \in \semTerm{\vctx \proves \propB : \Prop}_\gamma \,\} \end{aligned} \\ \semTerm{\vctx \proves \prop \wand \propB : \Prop}_\gamma &= \begin{aligned}[t] \Lam W. \{\, (n, r) &\mid \All n' \leq n. \All W' \geq W. \All r'. \\ &\qquad (n', r') \in \semTerm{\vctx \proves \prop : \Prop}_\gamma(W') \land r \sep r' \\ &\qquad \implies (n', r \bullet r') \in \semTerm{\vctx \proves \propB : \Prop}_\gamma(W') \} \end{aligned} \\ \semTerm{\vctx \proves \knowInv{\iname}{\prop} : \Prop}_\gamma &= inv(\semTerm{\vctx \proves \iname : \textsort{InvName}}_\gamma, \semTerm{\vctx \proves \prop : \Prop}_\gamma) \\ \semTerm{\vctx \proves \ownGGhost{\melt} : \Prop}_\gamma &=  Ralf Jung committed Jan 31, 2016 494  \Lam W. \{\, (n, \rs) \mid \rs.\ghostRes \geq \semTerm{\vctx \proves \melt : \textsort{Monoid}}_\gamma \,\} \\  Ralf Jung committed Jan 31, 2016 495  \semTerm{\vctx \proves \ownPhys{\state} : \Prop}_\gamma &=  Ralf Jung committed Jan 31, 2016 496  \Lam W. \{\, (n, \rs) \mid \rs.\pres = \semTerm{\vctx \proves \state : \textsort{State}}_\gamma \,\}  Ralf Jung committed Jan 31, 2016 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 \end{align*} % \begin{align*} \semTerm{\vctx \proves \pvsA{\prop}{\mask_1}{\mask_2} : \Prop}_\gamma &= \textdom{vs}^{\semTerm{\vctx \proves \mask_2 : \textsort{InvMask}}_\gamma}_{\semTerm{\vctx \proves \mask_1 : \textsort{InvMask}}_\gamma}(\semTerm{\vctx \proves \prop : \Prop}_\gamma) \\ \semTerm{\vctx \proves \dynA{\expr}{\pred}{\mask} : \Prop}_\gamma &= \textdom{wp}_{\semTerm{\vctx \proves \mask : \textsort{InvMask}}_\gamma}(\semTerm{\vctx \proves \expr : \textsort{Exp}}_\gamma, \semTerm{\vctx \proves \pred : \textsort{Val} \to \Prop}_\gamma) \\ \semTerm{\vctx \proves \wtt{\timeless{\prop}}{\Prop}}_\gamma &= \textdom{timeless}(\semTerm{\vctx \proves \prop : \Prop}_\gamma) \end{align*} \typedsection{Interpretation of entailment}{\Sem{\vctx \mid \pfctx \proves \prop} : 2 \in \mathit{Sets}} \Sem{\vctx \mid \pfctx \proves \propB} \eqdef \begin{aligned}[t] \MoveEqLeft \forall n \in \mathbb{N}.\; \forall W \in \textdom{World}.\;  Ralf Jung committed Jan 31, 2016 516 \forall \rs \in \textdom{Res}.\;  Ralf Jung committed Jan 31, 2016 517 518 \forall \gamma \in \semSort{\vctx},\; \\&  Ralf Jung committed Jan 31, 2016 519 520 \bigl(\All \propB \in \pfctx. (n, \rs) \in \semTerm{\vctx \proves \propB : \Prop}_\gamma(W)\bigr) \implies (n, \rs) \in \semTerm{\vctx \proves \prop : \Prop}_\gamma(W)  Ralf Jung committed Jan 31, 2016 521 522 \end{aligned}