From 095de633eae0bf46dcebfe7d81ddeb6a2b96aecb Mon Sep 17 00:00:00 2001
From: Robbert Krebbers <mail@robbertkrebbers.nl>
Date: Mon, 17 Oct 2016 14:24:45 +0200
Subject: [PATCH] Remove obsolete file encodings.tex.

---
 docs/encodings.tex | 568 ---------------------------------------------
 1 file changed, 568 deletions(-)
 delete mode 100644 docs/encodings.tex

diff --git a/docs/encodings.tex b/docs/encodings.tex
deleted file mode 100644
index 06b00d319..000000000
--- a/docs/encodings.tex
+++ /dev/null
@@ -1,568 +0,0 @@
-% !TEX root = ./appendix.tex
-
-\section{Monoid constructions}
-
-We will use the notation $\mcarp{M} \eqdef |M| \setminus \{\mzero_M\}$ for the carrier of monoid $M$ without zero. When we define a carrier, a zero element is always implicitly added (we do not explicitly give it), and all cases of multiplication that are not defined (including those involving a zero element) go to that element.
-
-To disambiguate which monoid an element is part of, we use the notation $a : M$ to denote an $a$ s.t.\ $a \in |M|$.
-
-When defining a monoid, we will show some \emph{frame-preserving updates} $\melt \mupd \meltsB$ that it supports.
-Remember that
-\[
-	\melt \mupd \meltsB \eqdef \always\All \melt_f. \melt \sep \melt_f \Ra \Exists \meltB \in \meltsB. \meltB \sep \melt_f.
-\]
-The rule \ruleref{FpUpd} (and, later, \ruleref{GhostUpd}) allows us to use such updates in Hoare proofs.
-The following principles generally hold for frame-preserving updates.
-\begin{mathpar}
-	\infer{
-		\melt \mupd \meltsB
-	}{
-		\melt \mupd \meltsB \cup \meltsB'
-	}
-	\and
-	\infer{
-		\melt \mupd \meltsB
-	}{
-		\melt \mtimes \melt_f \mupd \{ \meltB \mtimes \melt_f \mid \meltB \in \meltsB \}
-	}
-\end{mathpar}
-
-Some of our constructions require or preserve \emph{cancellativity}:
-\[
-	\text{$\monoid$ cancellative} \eqdef
-	\All \melt_f, \melt, \meltB \in \mcar{\monoid}. \melt_f \mtimes \melt = \melt_f \mtimes \meltB \neq \mzero \Ra \melt = \meltB
-\]
-
-
-\subsection{Exclusive monoid}
-
-Given a set $X$, we define a monoid such that at most one $x \in X$ can be owned.
-Let $\exm{X}$ be the monoid with carrier $X \uplus \{ \munit \}$ and multiplication
-\[
-\melt \cdot \meltB \;\eqdef\;
-\begin{cases}
-  \melt & \mbox{if } \meltB = \munit \\
-  \meltB & \mbox{if } \melt = \munit
-\end{cases}
-\]
-
-The frame-preserving update
-\begin{mathpar}
-\inferH{ExUpd}
-  {x \in X}
-  {x \mupd \melt}
-\end{mathpar}
-is easily shown, as the only possible frame for $x$ is $\munit$.
-
-Exclusive monoids are cancellative.
-\begin{proof}[Proof of cancellativity]
-If $\melt_f = \munit$, then the statement is trivial.
-If $\melt_f \neq \munit$, then we must have $\melt = \meltB = \munit$, as otherwise one of the two products would be $\mzero$.
-\end{proof}
-
-\subsection{Agreement monoid}
-
-Given a set $X$, we define a monoid such that everybody agrees on which $x \in X$ has been chosen.
-Let $\agm{X}$ be the monoid with carrier $X \uplus \{ \munit \}$ and multiplication
-\[
-\melt \cdot \meltB \;\eqdef\;
-\begin{cases}
-\melt & \mbox{if } \meltB = \munit \lor \melt = \meltB \\
-\meltB & \mbox{if } \melt = \munit
-\end{cases}
-\]
-
-Agreement monoids are cancellative.
-\begin{proof}[Proof of cancellativity]
-	If $\melt_f = \munit$, then the statement is trivial.
-	If $\melt_f \neq \munit$, then if $\melt = \munit$, we must have $\meltB = \munit$ and we are done.
-	Similar so for $\meltB = \munit$.
-	So let $\melt \neq \munit \neq \meltB$ and $\melt_f \mtimes \melt = \melt_f \mtimes \meltB \neq \mzero$.
-	It follows immediately that $\melt = \melt_f = \meltB$.
-\end{proof}
-
-\subsection{Finite Powerset Monoid}
-
-Given an infinite set $X$, we define a monoid $\textmon{PowFin}$ with carrier $\mathcal{P}^{\textrm{fin}}(X)$ as follows:
-\[
-\melt \cdot \meltB \;\eqdef\; \melt \cup \meltB \quad \mbox{if } \melt \cap \meltB = \emptyset
-\]
-
-We obtain:
-\begin{mathpar}
-	\inferH{PowFinUpd}{}
-		{\emptyset \mupd \{ \{x\} \mid x \in X  \}}
-\end{mathpar}
-
-\begin{proof}[Proof of \ruleref{PowFinUpd}]
-	Assume some frame $\melt_f \sep \emptyset$. Since $\melt_f$ is finite and $X$ is infinite, there exists an $x \notin \melt_f$.
-	Pick that for the result.
-\end{proof}
-
-The powerset monoids is cancellative.
-\begin{proof}[Proof of cancellativity]
-	Let $\melt_f \mtimes \melt = \melt_f \mtimes \meltB \neq \mzero$.
-	So we have $\melt_f \sep \melt$ and $\melt_f \sep \meltB$, and we have to show $\melt = \meltB$.
-	Assume $x \in \melt$. Hence $x \in \melt_f \mtimes \melt$ and thus $x \in \melt_f \mtimes \meltB$.
-	By disjointness, $x \notin \melt_f$ and hence $x \in meltB$.
-	The other direction works the same way.
-\end{proof}
-
-\subsection{Product monoid}
-\label{sec:prodm}
-
-Given a family $(M_i)_{i \in I}$ of monoids ($I$ countable), we construct a product monoid.
-Let $\prod_{i \in I} M_i$ be the monoid with carrier $\prod_{i \in I} \mcarp{M_i}$ and point-wise multiplication, non-zero when \emph{all} individual multiplications are non-zero.
-For $f \in \prod_{i \in I} \mcarp{M_i}$, we write $f[i \mapsto a]$ for the disjoint union $f \uplus [i \mapsto a]$.
-
-Frame-preserving updates on the $M_i$ lift to the product:
-\begin{mathpar}
-  \inferH{ProdUpd}
-  {a \mupd_{M_i} B}
-  {f[i \mapsto a] \mupd \{ f[i \mapsto b] \mid b \in B\}}
-\end{mathpar}
-\begin{proof}[Proof of \ruleref{ProdUpd}]
-Assume some frame $g$ and let $c \eqdef g(i)$.
-Since $f[i \mapsto a] \sep g$, we get $f \sep g$ and $a \sep_{M_i} c$.
-Thus there exists $b \in B$ such that $b \sep_{M_i} c$.
-It suffices to show $f[i \mapsto b] \sep g$.
-Since multiplication is defined pointwise, this is the case if all components are compatible.
-For $i$, we know this from $b \sep_{M_i} c$.
-For all the other components, from $f \sep g$.
-\end{proof}
-
-If every $M_i$ is cancellative, then so is $\prod_{i \in I} M_i$.
-\begin{proof}[Proof of cancellativity]
-Let $\melt, \meltB, \melt_f \in \prod_{i \in I} \mcarp{M_i}$, and assume $\melt_f \mtimes \melt = \melt_f \mtimes \meltB \neq \mzero$.
-By the definition of multiplication, this means that for all $i \in I$ we have $\melt_f(i) \mtimes \melt(i) = \melt_f(i) \mtimes \meltB(i) \neq \mzero_{M_i}$.
-As all base monoids are cancellative, we obtain $\forall i \in I.\; \melt(i) = \meltB(i)$ from which we immediately get $\melt = \meltB$.
-\end{proof}
-
-\subsection{Fractional monoid}
-\label{sec:fracm}
-
-Given a monoid $M$, we define a monoid representing fractional ownership of some piece $\melt \in M$.
-The idea is to preserve all the frame-preserving update that $M$ could have, while additionally being able to do \emph{any} update if we own the full state (as determined by the fraction being $1$).
-Let $\fracm{M}$ be the monoid with carrier $(((0, 1] \cap \mathbb{Q}) \times M) \uplus \{\munit\}$ and multiplication
-\begin{align*}
- (q, a) \mtimes (q', a') &\eqdef (q + q', a \mtimes a') \qquad \mbox{if $q+q'\le 1$} \\
- (q, a) \mtimes \munit &\eqdef (q,a) \\
- \munit \mtimes (q,a) &\eqdef (q,a).
-\end{align*}
-
-We get the following frame-preserving update.
-\begin{mathpar}
-	\inferH{FracUpdFull}
-		{a, b \in M}
-		{(1, a) \mupd (1, b)}
-  \and\inferH{FracUpdLocal}
-	  {a \mupd_M B}
-	  {(q, a) \mupd \{q\} \times B}
-\end{mathpar}
-
-\begin{proof}[Proof of \ruleref{FracUpdFull}]
-Assume some $f \sep (1, a)$. This can only be $f = \munit$, so showing $f \sep (1, b)$ is trivial.
-\end{proof}
-
-\begin{proof}[Proof of \ruleref{FracUpdLocal}]
-	Assume some $f \sep (q, a)$. If $f = \munit$, then $f \sep (q, b)$ is trivial for any $b \in B$. Just pick the one we obtain by choosing $\munit_M$ as the frame for $a$.
-	
-	In the interesting case, we have $f = (q_f, a_f)$.
-	Obtain $b$ such that $b \in B \land b \sep a_f$.
-	Then $(q, b) \sep f$, and we are done.
-\end{proof}
-
-$\fracm{M}$ is cancellative if $M$ is cancellative.
-\begin{proof}[Proof of cancellativitiy]
-If $\melt_f = \munit$, we are trivially done.
-So let $\melt_f = (q_f, \melt_f')$.
-If $\melt = \munit$, then $\meltB = \munit$ as otherwise the fractions could not match up.
-Again, we are trivially done.
-Similar so for $\meltB = \munit$.
-So let $\melt = (q_a, \melt')$ and $\meltB = (q_b, \meltB')$.
-We have $(q_f + q_a, \melt_f' \mtimes \melt') = (q_f + q_b, \melt_f' \mtimes \meltB')$.
-We have to show $q_a = q_b$ and $\melt' = \meltB'$.
-The first is trivial, the second follows from cancellativitiy of $M$.
-\end{proof}
-
-\subsection{Finite partial function monoid}
-\label{sec:fpfunm}
-
-Given a countable set $X$ and a monoid $M$, we construct a monoid representing finite partial functions from $X$ to (non-unit, non-zero elements of) $M$.
-Let $\fpfunm{X}{M}$ be the product monoid $\prod_{x \in X} M$, as defined in \secref{sec:prodm} but restricting the carrier to functions $f$ where the set $\dom(f) \eqdef \{ x \mid f(x) \neq \munit_M \}$ is finite.
-This is well-defined as the set of these $f$ contains the unit and is closed under multiplication.
-(We identify finite partial functions from $X$ to $\mcarp{M}\setminus\{\munit_M\}$ and total functions from $X$ to $\mcarp{M}$ with finite $\munit_M$-support.)
-
-We use two frame-preserving updates:
-\begin{mathpar}
-  \inferH{FpFunAlloc}
-  {a \in \mcarp{M}}
-  {f \mupd \{ f[x \mapsto a] \mid x \notin \dom(f) \}}
-  \and
-  \inferH{FpFunUpd}
-  {a \mupd_M B}
-  {f[i \mapsto a] \mupd \{ f[i \mapsto b] \mid b \in B\}}
-\end{mathpar}
-Rule \ruleref{FpFunUpd} simply restates \ruleref{ProdUpd}.
-
-\begin{proof}[Proof of \ruleref{FpFunAlloc}]
-  Assume some $g \sep f$. Since $\dom(f \mtimes g)$ is finite, there will be some undefined element $x \notin \dom(f \mtimes g)$. Let $f' \eqdef f[x \mapsto a]$. This is compatible with $g$, so we are done.
-\end{proof}
-
-We write $[x \mapsto a]$ for the function mapping $x$ to $a$ and everything else in $X$ to $\munit$.
-
-%\subsection{Disposable monoid}
-%
-%Given a monoid $M$, we construct a monoid where, having full ownership of an element $\melt$ of $M$, one can throw it away, transitioning to a dead element.
-%Let \dispm{M} be the monoid with carrier $\mcarp{M} \uplus \{ \disposed \}$ and multiplication
-%% The previous unit must remain the unit of the new monoid, as is is always duplicable and hence we could not transition to \disposed if it were not composable with \disposed
-%\begin{align*}
-%  \melt \mtimes \meltB &\eqdef \melt \mtimes_M \meltB & \IF \melt \sep[M] \meltB \\
-%  \disposed \mtimes \disposed &\eqdef \disposed \\
-%  \munit_M \mtimes \disposed &\eqdef \disposed \mtimes \munit_M \eqdef \disposed
-%\end{align*}
-%The unit is the same as in $M$.
-%
-%The frame-preserving updates are
-%\begin{mathpar}
-% \inferH{DispUpd}
-%   {a \in \mcarp{M} \setminus \{\munit_M\} \and a \mupd_M B}
-%   {a \mupd B}
-% \and
-% \inferH{Dispose}
-%  {a \in \mcarp{M} \setminus \{\munit_M\} \and \All b \in \mcarp{M}. a \sep b \Ra b = \munit_M}
-%  {a \mupd \disposed}
-%\end{mathpar}
-%
-%\begin{proof}[Proof of \ruleref{DispUpd}]
-%Assume a frame $f$. If $f = \disposed$, then $a = \munit_M$, which is a contradiction.
-%Thus $f \in \mcarp{M}$ and we can use $a \mupd_M B$.
-%\end{proof}
-%
-%\begin{proof}[Proof of \ruleref{Dispose}]
-%The second premiss says that $a$ has no non-trivial frame in $M$. To show the update, assume a frame $f$ in $\dispm{M}$. Like above, we get $f \in \mcarp{M}$, and thus $f = \munit_M$. But $\disposed \sep \munit_M$ is trivial, so we are done.
-%\end{proof}
-
-\subsection{Authoritative monoid}\label{sec:auth}
-
-Given a monoid $M$, we construct a monoid modeling someone owning an \emph{authoritative} element $x$ of $M$, and others potentially owning fragments $\melt \le_M x$ of $x$.
-(If $M$ is an exclusive monoid, the construction is very similar to a half-ownership monoid with two asymmetric halves.)
-Let $\auth{M}$ be the monoid with carrier
-\[
-	\SET{ (x, \melt) }{ x \in \mcarp{\exm{\mcarp{M}}} \land \melt \in \mcarp{M} \land (x = \munit_{\exm{\mcarp{M}}} \lor \melt \leq_M x) }
-\]
-and multiplication
-\[
-(x, \melt) \mtimes (y, \meltB) \eqdef
-     (x \mtimes y, \melt \mtimes \meltB) \quad \mbox{if } x \sep y \land \melt \sep \meltB \land (x \mtimes y = \munit_{\exm{\mcarp{M}}} \lor \melt \mtimes \meltB \leq_M x \mtimes y)
-\]
-Note that $(\munit_{\exm{\mcarp{M}}}, \munit_M)$ is the unit and asserts no ownership whatsoever, but $(\munit_{M}, \munit_M)$ asserts that the authoritative element is $\munit_M$.
-
-Let $x, \melt \in \mcarp M$.
-We write $\authfull x$ for full ownership $(x, \munit_M):\auth{M}$ and $\authfrag \melt$ for fragmental ownership $(\munit_{\exm{\mcarp{M}}}, \melt)$ and $\authfull x , \authfrag \melt$ for combined ownership $(x, \melt)$.
-If $x$ or $a$ is $\mzero_{M}$, then the sugar denotes $\mzero_{\auth{M}}$.
-
-\ralf{This needs syncing with the Coq development.}
-The frame-preserving update involves a rather unwieldy side-condition:
-\begin{mathpar}
-	\inferH{AuthUpd}{
-		\All\melt_f\in\mcar{\monoid}. \melt\sep\meltB \land \melt\mtimes\melt_f \le \meltB\mtimes\melt_f \Ra \melt'\mtimes\melt_f \le \melt'\mtimes\meltB \and
-		\melt' \sep \meltB
-	}{
-		\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \melt' \mtimes \meltB, \authfrag \melt'
-	}
-\end{mathpar}
-We therefore derive two special cases.
-
-\paragraph{Local frame-preserving updates.}
-
-\newcommand\authupd{f}%
-Following~\cite{scsl}, we say that $\authupd: \mcar{M} \ra \mcar{M}$ is \emph{local} if
-\[
-	\All a, b \in \mcar{M}. a \sep b \land \authupd(a) \neq \mzero \Ra \authupd(a \mtimes b) = \authupd(a) \mtimes b
-\]
-Then,
-\begin{mathpar}
-	\inferH{AuthUpdLocal}
-	{\text{$\authupd$ local} \and \authupd(\melt)\sep\meltB}
-	{\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \authupd(\melt) \mtimes \meltB, \authfrag \authupd(\melt)}
-\end{mathpar}
-
-\paragraph{Frame-preserving updates on cancellative monoids.}
-
-Frame-preserving updates are also possible if we assume $M$ cancellative:
-\begin{mathpar}
- \inferH{AuthUpdCancel}
-  {\text{$M$ cancellative} \and \melt'\sep\meltB}
-  {\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \melt' \mtimes \meltB, \authfrag \melt'}
-\end{mathpar}
-
-\subsection{Fractional heap monoid}
-\label{sec:fheapm}
-
-By combining the fractional, finite partial function, and authoritative monoids, we construct two flavors of heaps with fractional permissions and mention their important frame-preserving updates.
-Hereinafter, we assume the set $\textdom{Val}$ of values is countable.
-
-Given a set $Y$, define $\FHeap(Y) \eqdef \fpfunm{\textdom{Val}}{\fracm{Y}}$ representing a fractional heap with codomain $Y$.
-From \S\S\ref{sec:fracm} and~\ref{sec:fpfunm} we obtain the following frame-preserving updates as well as the fact that $\FHeap(Y)$ is cancellative.
-\begin{mathpar}
-	\axiomH{FHeapUpd}{h[x \mapsto (1, y)] \mupd h[x \mapsto (1, y')]} \and
-	\axiomH{FHeapAlloc}{h \mupd \{\, h[x \mapsto (1, y)] \mid x \in \textdom{Val} \,\}}
-\end{mathpar}
-We will write $qh$ with $h : \textsort{Val} \fpfn Y$ for the function in $\FHeap(Y)$ mapping every $x \in \dom(h)$ to $(q, h(x))$, and everything else to $\munit$.
-
-Define $\AFHeap(Y) \eqdef \auth{\FHeap(Y)}$ representing an authoritative fractional heap with codomain $Y$.
-We easily obtain the following frame-preserving updates.
-\begin{mathpar}
-	\axiomH{AFHeapUpd}{
-		(\authfull h[x \mapsto (1, y)], \authfrag [x \mapsto (1, y)]) \mupd (\authfull h[x \mapsto (1, y')], \authfrag [x \mapsto (1, y')])
-	}
-	\and
-	\inferH{AFHeapAdd}{
-		x \notin \dom(h)
-	}{
-		\authfull h \mupd (\authfull h[x \mapsto (q, y)], \authfrag [x \mapsto (q, y)])
-	}
-	\and
-	\axiomH{AFHeapRemove}{
-		(\authfull h[x \mapsto (q, y)], \authfrag [x \mapsto (q, y)]) \mupd \authfull h
-	}
-\end{mathpar}
-
-\subsection{STS with tokens monoid}
-\label{sec:stsmon}
-
-\ralf{This needs syncing with the Coq development.}
-
-Given a state-transition system~(STS) $(\STSS, \ra)$, a set of tokens $\STSS$, and a labeling $\STSL: \STSS \ra \mathcal{P}(\STST)$ of \emph{protocol-owned} tokens for each state, we construct a monoid modeling an authoritative current state and permitting transitions given a \emph{bound} on the current state and a set of \emph{locally-owned} tokens.
-
-The construction follows the idea of STSs as described in CaReSL \cite{caresl}.
-We first lift the transition relation to $\STSS \times \mathcal{P}(\STST)$ (implementing a \emph{law of token conservation}) and define upwards closure:
-\begin{align*}
- (s, T) \ra (s', T') \eqdef&\, s \ra s' \land \STSL(s) \uplus T = \STSL(s') \uplus T' \\
- \textsf{frame}(s, T) \eqdef&\, (s, \STST \setminus (\STSL(s) \uplus T)) \\
- \upclose(S, T) \eqdef&\, \SET{ s' \in \STSS}{\exists s \in S.\; \textsf{frame}(s, T) \ststrans \textsf{frame}(s', T) }
-\end{align*}
-
-\noindent
-We have
-\begin{quote}
-	If $(s, T) \ra (s', T')$\\
-	and $T_f \sep (T \uplus \STSL(s))$,\\
-	then $\textsf{frame}(s, T_f) \ra \textsf{frame}(s', T_f)$.
-\end{quote}
-\begin{proof}
-This follows directly by framing the tokens in $\STST \setminus (T_f \uplus T \uplus \STSL(s))$ around the given transition, which yields $(s, \STST \setminus (T_f \uplus \STSL{T}(s))) \ra (s', T' \uplus (\STST \setminus (T_f \uplus T \uplus \STSL{T}(s))))$.
-This is exactly what we have to show, since we know $\STSL(s) \uplus T = \STSL(s') \uplus T'$.
-\end{proof}
-
-Let $\STSMon{\STSS}$ be the monoid with carrier
-\[
-	\SET{ (s, S, T) \in \exm{\STSS} \times \mathcal{P}(\STSS) \times \mathcal{P}(\STST) }{ \begin{aligned} &(s = \munit \lor s \in S) \land \upclose(S, T) = S   \land{} \\& S \neq \emptyset \land \All s \in S. \STSL(s) \sep T  \end{aligned} }
-\]
-and multiplication
-\[
-	(s, S, T) \mtimes (s', S', T') \eqdef (s'' \eqdef s \mtimes_{\exm{\STSS}} s', S'' \eqdef S \cap S', T'' \eqdef T \cup T') \quad \text{if }\begin{aligned}[t] &(s = \munit \lor s' = \munit) \land T \sep T' \land{} \\& S'' \neq \emptyset \land (s'' \neq \munit \Ra s'' \in S'') \end{aligned}
-\]
-
-Some sugar makes it more convenient to assert being at least in a certain state and owning some tokens: $(s, T) : \STSMon{\STSS} \eqdef (\munit, \upclose(\{s\}, T), T) : \STSMon{\STSS}$, and
-$s : \STSMon{\STSS} \eqdef (s, \emptyset) : \STSMon{\STSS}$.
-
-We will need the following frame-preserving update.
-\begin{mathpar}
-	\inferH{StsStep}{(s, T) \ststrans (s', T')}
-	 {(s, S, T) \mupd (s', \upclose(\{s'\}, T'), T')}
-\end{mathpar}
-\begin{proof}[Proof of \ruleref{StsStep}]
-Assume some upwards-closed $S_f, T_f$ (the frame cannot be authoritative) s.t.\ $s \in S_f$ and $T_f \sep (T \uplus \STSL(s))$. We have to show that this frame combines with our final monoid element, which is the case if $s' \in S_f$ and $T_f \sep T'$.
-By upward-closedness, it suffices to show $\textsf{frame}(s, T_f) \ststrans \textsf{frame}(s', T_f)$.
-This follows by induction on the path $(s, T) \ststrans (s', T')$, and using the lemma proven above for each step.
-\end{proof}
-
-\section{Derived constructions}
-
-In this section we describe some constructions that we will use throughout the rest of the appendix.
-
-\subsection{Global monoid}
-
-Hereinafter we assume the global monoid (served up as a parameter to Iris) is obtained from a family of monoids $(M_i)_{i \in I}$ by first applying the construction for finite partial functions to each~(\Sref{sec:fpfunm}), and then applying the product construction~(\Sref{sec:prodm}):
-\[ M \eqdef \prod_{i \in I} \fpfunm{\textdom{GhName}}{M_i} \]
-We don't care so much about what concretely $\textdom{GhName}$ is, as long as it is countable and infinite.
-We write $\ownGhost{\gname}{\melt : M_i}$ (or just $\ownGhost{\gname}{\melt}$ if $M_i$ is clear from the context) for $\ownGGhost{[i \mapsto [\gname \mapsto \melt]]}$ when $\melt \in \mcarp {M_i}$, and for $\FALSE$ when $\melt = \mzero_{M_i}$.
-In other words, $\ownGhost{\gname}{\melt : M_i}$ asserts that in the current state of monoid $M_i$, the name $\gname$ is allocated and has at least value $\melt$.
-
-From~\ruleref{FpUpd} and the multiplications and frame-preserving updates in~\Sref{sec:prodm} and~\Sref{sec:fpfunm}, we have the following derived rules.
-\begin{mathpar}
-	\axiomH{NewGhost}{
-		\TRUE \vs \Exists\gname. \ownGhost\gname{\melt : M_i}
-	}
-	\and
-	\inferH{GhostUpd}
-    {\melt \mupd_{M_i} B}
-    {\ownGhost\gname{\melt : M_i} \vs \Exists \meltB\in B. \ownGhost\gname{\meltB : M_i}}
-  \and
-  \axiomH{GhostEq}
-    {\ownGhost\gname{\melt : M_i} * \ownGhost\gname{\meltB : M_i} \Lra \ownGhost\gname{\melt\mtimes\meltB : M_i}}
-
-  \axiomH{GhostUnit}
-    {\TRUE \Ra \ownGhost{\gname}{\munit : M_i}}
-
-  \axiomH{GhostZero}
-    {\ownGhost\gname{\mzero : M_i} \Ra \FALSE}
-
-  \axiomH{GhostTimeless}
-    {\timeless{\ownGhost\gname{\melt : M_i}}}
-\end{mathpar}
-
-\subsection{STSs with interpretation}\label{sec:stsinterp}
-
-Building on \Sref{sec:stsmon}, after constructing the monoid $\STSMon{\STSS}$ for a particular STS, we can use an invariant to tie an interpretation, $\pred : \STSS \to \Prop$, to the STS's current state, recovering CaReSL-style reasoning~\cite{caresl}.
-
-An STS invariant asserts authoritative ownership of an STS's current state and that state's interpretation:
-\begin{align*}
-  \STSInv(\STSS, \pred, \gname) \eqdef{}& \Exists s \in \STSS. \ownGhost{\gname}{(s, \STSS, \emptyset):\STSMon{\STSS}} * \pred(s) \\
-  \STS(\STSS, \pred, \gname, \iname) \eqdef{}& \knowInv{\iname}{\STSInv(\STSS, \pred, \gname)}
-\end{align*}
-
-We can specialize \ruleref{NewInv}, \ruleref{InvOpen}, and \ruleref{InvClose} to STS invariants:
-\begin{mathpar}
- \inferH{NewSts}
-  {\infinite(\mask)}
-  {\later\pred(s) \vs[\mask] \Exists \iname \in \mask, \gname.   \STS(\STSS, \pred, \gname, \iname) * \ownGhost{\gname}{(s, \STST \setminus \STSL(s)) : \STSMon{\STSS}}}
- \and
- \axiomH{StsOpen}
-  {  \STS(\STSS, \pred, \gname, \iname) \vdash \ownGhost{\gname}{(s_0, T) : \STSMon{\STSS}} \vsE[\{\iname\}][\emptyset] \Exists s\in \upclose(\{s_0\}, T). \later\pred(s) * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T):\STSMon{\STSS}}}
- \and
- \axiomH{StsClose}
-  {  \STS(\STSS, \pred, \gname, \iname), (s, T) \ststrans (s', T')  \proves \later\pred(s') * \ownGhost{\gname}{(s, S, T):\STSMon{\STSS}} \vs[\emptyset][\{\iname\}] \ownGhost{\gname}{(s', T') : \STSMon{\STSS}} }
-\end{mathpar}
-\begin{proof}
-\ruleref{NewSts} uses \ruleref{NewGhost} to allocate $\ownGhost{\gname}{(s, \upclose(s, T), T) : \STSMon{\STSS}}$ where $T \eqdef \STST \setminus \STSL(s)$, and \ruleref{NewInv}.
-
-\ruleref{StsOpen} just uses \ruleref{InvOpen} and \ruleref{InvClose} on $\iname$, and the monoid equality $(s, \upclose(\{s_0\}, T), T) = (s, \STSS, \emptyset) \mtimes (\munit, \upclose(\{s_0\}, T), T)$.
-
-\ruleref{StsClose} applies \ruleref{StsStep} and \ruleref{InvClose}.
-\end{proof}
-
-Using these view shifts, we can prove STS variants of the invariant rules \ruleref{Inv} and \ruleref{VSInv}~(compare the former to CaReSL's island update rule~\cite{caresl}):
-\begin{mathpar}
- \inferH{Sts}
-  {\All s \in \upclose(\{s_0\}, T). \hoare{\later\pred(s) * P}{\expr}{\Ret \val. \Exists s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * Q}[\mask]
-   \and \physatomic{\expr}}
-  {  \STS(\STSS, \pred, \gname, \iname) \vdash \hoare{\ownGhost{\gname}{(s_0, T):\STSMon{\STSS}} * P}{\expr}{\Ret \val. \Exists s', T'. \ownGhost{\gname}{(s', T'):\STSMon{\STSS}} * Q}[\mask \uplus \{\iname\}]}
- \and
- \inferH{VSSts}
-  {\forall s \in \upclose(\{s_0\}, T).\; \later\pred(s) * P \vs[\mask_1][\mask_2] \exists s', T'.\; (s, T) \ststrans (s', T') * \later\pred(s') * Q}
-  {  \STS(\STSS, \pred, \gname, \iname) \vdash \ownGhost{\gname}{(s_0, T):\STSMon{\STSS}} * P \vs[\mask_1 \uplus \{\iname\}][\mask_2 \uplus \{\iname\}] \Exists s', T'. \ownGhost{\gname}{(s', T'):\STSMon{\STSS}} * Q}
-\end{mathpar}
-
-\begin{proof}[Proof of \ruleref{Sts}]\label{pf:sts}
- We have to show
- \[\hoare{\ownGhost{\gname}{(s_0, T):\STSMon{\STSS}} * P}{\expr}{\Ret \val. \Exists s', T'. \ownGhost{\gname}{(s', T'):\STSMon{\STSS}} * Q}[\mask \uplus \{\iname\}]\]
- where $\val$, $s'$, $T'$ are free in $Q$.
- 
- First, by \ruleref{ACsq} with \ruleref{StsOpen} and \ruleref{StsClose} (after moving $(s, T) \ststrans (s', T')$ into the view shift using \ruleref{VSBoxOut}), it suffices to show
- \[\hoareV{\Exists s\in \upclose(\{s_0\}, T). \later\pred(s) * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)} * P}{\expr}{\Ret \val. \Exists s, T, S, s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * \ownGhost{\gname}{(s, S, T):\STSMon{\STSS}} * Q(\val, s', T')}[\mask]\]
-
- Now, use \ruleref{Exist} to move the $s$ from the precondition into the context and use \ruleref{Csq} to (i)~fix the $s$ and $T$ in the postcondition to be the same as in the precondition, and (ii)~fix $S \eqdef \upclose(\{s_0\}, T)$.
- It remains to show:
- \[\hoareV{s\in \upclose(\{s_0\}, T) * \later\pred(s) * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)} * P}{\expr}{\Ret \val. \Exists s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)} * Q(\val, s', T')}[\mask]\]
- 
- Finally, use \ruleref{BoxOut} to move $s\in \upclose(\{s_0\}, T)$ into the context, and \ruleref{Frame} on $\ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)}$:
- \[s\in \upclose(\{s_0\}, T) \vdash \hoare{\later\pred(s) * P}{\expr}{\Ret \val. \Exists s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * Q(\val, s', T')}[\mask]\]
- 
- This holds by our premise.
-\end{proof}
-
-\begin{proof}[Proof of \ruleref{VSSts}]
-This is similar to above, so we only give the proof in short notation:
-
-\hproof{%
-	Context: $\knowInv\iname{\STSInv(\STSS, \pred, \gname)}$ \\
-	\pline[\mask_1 \uplus \{\iname\}]{
-		\ownGhost\gname{(s_0, T)} * P
-	} \\
-	\pline[\mask_1]{%
-		\Exists s. \later\pred(s) * \ownGhost\gname{(s, S, T)} * P
-	} \qquad by \ruleref{StsOpen} \\
-	Context: $s \in S \eqdef \upclose(\{s_0\}, T)$ \\
-	\pline[\mask_2]{%
-		 \Exists s', T'. \later\pred(s') * Q(s', T') * \ownGhost\gname{(s, S, T)}
-	} \qquad by premiss \\
-	Context: $(s, T) \ststrans (s', T')$ \\
-	\pline[\mask_2 \uplus \{\iname\}]{
-		\ownGhost\gname{(s', T')} * Q(s', T')
-	} \qquad by \ruleref{StsClose}
-}
-\end{proof}
-
-\subsection{Authoritative monoids with interpretation}\label{sec:authinterp}
-
-Building on \Sref{sec:auth}, after constructing the monoid $\auth{M}$ for a cancellative monoid $M$, we can tie an interpretation, $\pred : \mcarp{M} \to \Prop$, to the authoritative element of $M$, recovering reasoning that is close to the sharing rule in~\cite{krishnaswami+:icfp12}.
-
-Let $\pred_\bot$ be the extension of $\pred$ to $\mcar{M}$ with $\pred_\bot(\mzero) = \FALSE$.
-Now define
-\begin{align*}
-  \AuthInv(M, \pred, \gname) \eqdef{}& \exists \melt \in \mcar{M}.\; \ownGhost{\gname}{\authfull \melt:\auth{M}} * \pred_\bot(\melt) \\
-  \Auth(M, \pred, \gname, \iname) \eqdef{}& M~\textlog{cancellative} \land \knowInv{\iname}{\AuthInv(M, \pred, \gname)}
-\end{align*}
-
-The frame-preserving updates for $\auth{M}$ gives rise to the following view shifts:
-\begin{mathpar}
- \inferH{NewAuth}
-  {\infinite(\mask) \and M~\textlog{cancellative}}
-  {\later\pred_\bot(a) \vs[\mask] \exists \iname \in \mask, \gname.\; \Auth(M, \pred, \gname, \iname) * \ownGhost{\gname}{\authfrag a : \auth{M}}}
- \and
- \axiomH{AuthOpen}
-  {\Auth(M, \pred, \gname, \iname) \vdash \ownGhost{\gname}{\authfrag \melt : \auth{M}} \vsE[\{\iname\}][\emptyset] \exists \melt_f.\; \later\pred_\bot(\melt \mtimes \melt_f) * \ownGhost{\gname}{\authfull \melt \mtimes \melt_f, \authfrag a:\auth{M}}}
- \and
- \axiomH{AuthClose}
-  {\Auth(M, \pred, \gname, \iname) \vdash \later\pred_\bot(\meltB \mtimes \melt_f) * \ownGhost{\gname}{\authfull a \mtimes \melt_f, \authfrag a:\auth{M}} \vs[\emptyset][\{\iname\}] \ownGhost{\gname}{\authfrag \meltB : \auth{M}} }
-\end{mathpar}
-
-These view shifts in turn can be used to prove variants of the invariant rules:
-\begin{mathpar}
- \inferH{Auth}
-  {\forall \melt_f.\; \hoare{\later\pred_\bot(a \mtimes \melt_f) * P}{\expr}{\Ret\val. \exists \meltB.\; \later\pred_\bot(\meltB\mtimes \melt_f) * Q}[\mask]
-   \and \physatomic{\expr}}
-  {\Auth(M, \pred, \gname, \iname) \vdash \hoare{\ownGhost{\gname}{\authfrag a:\auth{M}} * P}{\expr}{\Ret\val. \exists \meltB.\; \ownGhost{\gname}{\authfrag \meltB:\auth{M}} * Q}[\mask \uplus \{\iname\}]}
- \and
- \inferH{VSAuth}
-  {\forall \melt_f.\; \later\pred_\bot(a \mtimes \melt_f) * P \vs[\mask_1][\mask_2] \exists \meltB.\; \later\pred_\bot(\meltB \mtimes \melt_f) * Q(\meltB)}
-  {\Auth(M, \pred, \gname, \iname) \vdash
-   \ownGhost{\gname}{\authfrag a:\auth{M}} * P \vs[\mask_1 \uplus \{\iname\}][\mask_2 \uplus \{\iname\}]
-   \exists \meltB.\; \ownGhost{\gname}{\authfrag \meltB:\auth{M}} * Q(\meltB)}
-\end{mathpar}
-
-
-\subsection{Ghost heap}
-\label{sec:ghostheap}%
-
-We define a simple ghost heap with fractional permissions.
-Some modules require a few ghost names per module instance to properly manage ghost state, but would like to expose to clients a single logical name (avoiding clutter).
-In such cases (\eg \Sref{sec:mcas}), we use these ghost heaps.
-
-We seek to implement the following interface:
-\newcommand{\GRefspecmaps}{\textsf{GMapsTo}}%
-\begin{align*}
- \exists& {\fgmapsto[]} : \textsort{Val} \times \mathbb{Q}_{>} \times \textsort{Val} \ra \textsort{Prop}.\;\\
-  & \All x, q, v. x \fgmapsto[q] v \Ra x \fgmapsto[q] v \land q \in (0, 1] \\
-  &\forall x, q_1, q_2, v, w.\; x \fgmapsto[q_1] v * x \fgmapsto[q_2] w \Leftrightarrow x \fgmapsto[q_1 + q_2] v * v = w\\
-  & \forall v.\; \TRUE \vs[\emptyset] \exists x.\; x \fgmapsto[1] v \\
-  & \forall x, v, w.\; x \fgmapsto[1] v \vs[\emptyset] x \fgmapsto[1] w
-\end{align*}
-We write $x \fgmapsto v$ for $\exists q.\; x \fgmapsto[q] v$ and $x \gmapsto v$ for $x \fgmapsto[1] v$.
-Note that $x \fgmapsto v$ is duplicable but cannot be boxed (as it depends on resources); \ie we have $x \fgmapsto v \Lra x \fgmapsto v * x \fgmapsto v$ but not $x \fgmapsto v \Ra \always x \fgmapsto v$.
-
-To implement this interface, allocate an instance $\gname_G$ of $\FHeap(\textdom{Val})$ and define
-\[
-	x \fgmapsto[q] v \eqdef
-	  \begin{cases}
-    	\ownGhost{\gname_G}{x \mapsto (q, v)} & \text{if $q \in (0, 1]$} \\
-    	\FALSE & \text{otherwise}
-    \end{cases}
-\]
-The view shifts in the specification follow immediately from \ruleref{GhostUpd} and the frame-preserving updates in~\Sref{sec:fheapm}.
-The first implication is immediate from the definition.
-The second implication follows by case distinction on $q_1 + q_2 \in (0, 1]$.
-
-- 
GitLab