Skip to content
Snippets Groups Projects
Commit dc1a177c authored by Ralf Jung's avatar Ralf Jung
Browse files

preparations for describing agreement in The Iris Documentation

parent 25118e82
No related branches found
No related tags found
No related merge requests found
% !TEX root = ./appendix.tex % !TEX root = ./appendix.tex
\section{Monoid constructions} \section{CMRA 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. % 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|$. % 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. % When defining a monoid, we will show some \emph{frame-preserving updates} $\melt \mupd \meltsB$ that it supports.
Remember that % Remember that
\[ % \[
\melt \mupd \meltsB \eqdef \always\All \melt_f. \melt \sep \melt_f \Ra \Exists \meltB \in \meltsB. \meltB \sep \melt_f. % \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 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. % The following principles generally hold for frame-preserving updates.
\begin{mathpar} % \begin{mathpar}
\infer{ % \infer{
\melt \mupd \meltsB % \melt \mupd \meltsB
}{ % }{
\melt \mupd \meltsB \cup \meltsB' % \melt \mupd \meltsB \cup \meltsB'
} % }
\and % \and
\infer{ % \infer{
\melt \mupd \meltsB % \melt \mupd \meltsB
}{ % }{
\melt \mtimes \melt_f \mupd \{ \meltB \mtimes \melt_f \mid \meltB \in \meltsB \} % \melt \mtimes \melt_f \mupd \{ \meltB \mtimes \melt_f \mid \meltB \in \meltsB \}
} % }
\end{mathpar} % \end{mathpar}
Some of our constructions require or preserve \emph{cancellativity}: \subsection{Agreement}
\[
\text{$\monoid$ cancellative} \eqdef \ralf{Copy some stuff from the paper, at least in case we find that there are things which are too long for the paper.}
\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.
\subsection{Exclusive monoid} % Let $\exm{X}$ be the monoid with carrier $X \uplus \{ \munit \}$ and multiplication
% \[
Given a set $X$, we define a monoid such that at most one $x \in X$ can be owned. % \melt \cdot \meltB \;\eqdef\;
Let $\exm{X}$ be the monoid with carrier $X \uplus \{ \munit \}$ and multiplication % \begin{cases}
\[ % \melt & \mbox{if } \meltB = \munit \\
\melt \cdot \meltB \;\eqdef\; % \meltB & \mbox{if } \melt = \munit
\begin{cases} % \end{cases}
\melt & \mbox{if } \meltB = \munit \\ % \]
\meltB & \mbox{if } \melt = \munit
\end{cases} % The frame-preserving update
\] % \begin{mathpar}
% \inferH{ExUpd}
The frame-preserving update % {x \in X}
\begin{mathpar} % {x \mupd \melt}
\inferH{ExUpd} % \end{mathpar}
{x \in X} % is easily shown, as the only possible frame for $x$ is $\munit$.
{x \mupd \melt}
\end{mathpar} % Exclusive monoids are cancellative.
is easily shown, as the only possible frame for $x$ is $\munit$. % \begin{proof}[Proof of cancellativity]
% If $\melt_f = \munit$, then the statement is trivial.
Exclusive monoids are cancellative. % If $\melt_f \neq \munit$, then we must have $\melt = \meltB = \munit$, as otherwise one of the two products would be $\mzero$.
\begin{proof}[Proof of cancellativity] % \end{proof}
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$. % \subsection{Agreement monoid}
\end{proof}
% Given a set $X$, we define a monoid such that everybody agrees on which $x \in X$ has been chosen.
\subsection{Agreement monoid} % Let $\agm{X}$ be the monoid with carrier $X \uplus \{ \munit \}$ and multiplication
% \[
Given a set $X$, we define a monoid such that everybody agrees on which $x \in X$ has been chosen. % \melt \cdot \meltB \;\eqdef\;
Let $\agm{X}$ be the monoid with carrier $X \uplus \{ \munit \}$ and multiplication % \begin{cases}
\[ % \melt & \mbox{if } \meltB = \munit \lor \melt = \meltB \\
\melt \cdot \meltB \;\eqdef\; % \meltB & \mbox{if } \melt = \munit
\begin{cases} % \end{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.
Agreement monoids are cancellative. % If $\melt_f \neq \munit$, then if $\melt = \munit$, we must have $\meltB = \munit$ and we are done.
\begin{proof}[Proof of cancellativity] % Similar so for $\meltB = \munit$.
If $\melt_f = \munit$, then the statement is trivial. % So let $\melt \neq \munit \neq \meltB$ and $\melt_f \mtimes \melt = \melt_f \mtimes \meltB \neq \mzero$.
If $\melt_f \neq \munit$, then if $\melt = \munit$, we must have $\meltB = \munit$ and we are done. % It follows immediately that $\melt = \melt_f = \meltB$.
Similar so for $\meltB = \munit$. % \end{proof}
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$. % \subsection{Finite Powerset Monoid}
\end{proof}
% Given an infinite set $X$, we define a monoid $\textmon{PowFin}$ with carrier $\mathcal{P}^{\textrm{fin}}(X)$ as follows:
\subsection{Finite Powerset Monoid} % \[
% \melt \cdot \meltB \;\eqdef\; \melt \cup \meltB \quad \mbox{if } \melt \cap \meltB = \emptyset
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}{}
We obtain: % {\emptyset \mupd \{ \{x\} \mid x \in X \}}
\begin{mathpar} % \end{mathpar}
\inferH{PowFinUpd}{}
{\emptyset \mupd \{ \{x\} \mid x \in X \}} % \begin{proof}[Proof of \ruleref{PowFinUpd}]
\end{mathpar} % 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.
\begin{proof}[Proof of \ruleref{PowFinUpd}] % \end{proof}
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. % The powerset monoids is cancellative.
\end{proof} % \begin{proof}[Proof of cancellativity]
% Let $\melt_f \mtimes \melt = \melt_f \mtimes \meltB \neq \mzero$.
The powerset monoids is cancellative. % So we have $\melt_f \sep \melt$ and $\melt_f \sep \meltB$, and we have to show $\melt = \meltB$.
\begin{proof}[Proof of cancellativity] % Assume $x \in \melt$. Hence $x \in \melt_f \mtimes \melt$ and thus $x \in \melt_f \mtimes \meltB$.
Let $\melt_f \mtimes \melt = \melt_f \mtimes \meltB \neq \mzero$. % By disjointness, $x \notin \melt_f$ and hence $x \in meltB$.
So we have $\melt_f \sep \melt$ and $\melt_f \sep \meltB$, and we have to show $\melt = \meltB$. % The other direction works the same way.
Assume $x \in \melt$. Hence $x \in \melt_f \mtimes \melt$ and thus $x \in \melt_f \mtimes \meltB$. % \end{proof}
By disjointness, $x \notin \melt_f$ and hence $x \in meltB$.
The other direction works the same way. % \subsection{Product monoid}
\end{proof} % \label{sec:prodm}
\subsection{Product monoid} % Given a family $(M_i)_{i \in I}$ of monoids ($I$ countable), we construct a product monoid.
\label{sec:prodm} % 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]$.
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. % Frame-preserving updates on the $M_i$ lift to the product:
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]$. % \begin{mathpar}
% \inferH{ProdUpd}
Frame-preserving updates on the $M_i$ lift to the product: % {a \mupd_{M_i} B}
\begin{mathpar} % {f[i \mapsto a] \mupd \{ f[i \mapsto b] \mid b \in B\}}
\inferH{ProdUpd} % \end{mathpar}
{a \mupd_{M_i} B} % \begin{proof}[Proof of \ruleref{ProdUpd}]
{f[i \mapsto a] \mupd \{ f[i \mapsto b] \mid b \in B\}} % Assume some frame $g$ and let $c \eqdef g(i)$.
\end{mathpar} % Since $f[i \mapsto a] \sep g$, we get $f \sep g$ and $a \sep_{M_i} c$.
\begin{proof}[Proof of \ruleref{ProdUpd}] % Thus there exists $b \in B$ such that $b \sep_{M_i} c$.
Assume some frame $g$ and let $c \eqdef g(i)$. % It suffices to show $f[i \mapsto b] \sep g$.
Since $f[i \mapsto a] \sep g$, we get $f \sep g$ and $a \sep_{M_i} c$. % Since multiplication is defined pointwise, this is the case if all components are compatible.
Thus there exists $b \in B$ such that $b \sep_{M_i} c$. % For $i$, we know this from $b \sep_{M_i} c$.
It suffices to show $f[i \mapsto b] \sep g$. % For all the other components, from $f \sep g$.
Since multiplication is defined pointwise, this is the case if all components are compatible. % \end{proof}
For $i$, we know this from $b \sep_{M_i} c$.
For all the other components, from $f \sep g$. % If every $M_i$ is cancellative, then so is $\prod_{i \in I} M_i$.
\end{proof} % \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$.
If every $M_i$ is cancellative, then so is $\prod_{i \in I} M_i$. % 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}$.
\begin{proof}[Proof of cancellativity] % As all base monoids are cancellative, we obtain $\forall i \in I.\; \melt(i) = \meltB(i)$ from which we immediately get $\melt = \meltB$.
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$. % \end{proof}
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$. % \subsection{Fractional monoid}
\end{proof} % \label{sec:fracm}
\subsection{Fractional monoid} % Given a monoid $M$, we define a monoid representing fractional ownership of some piece $\melt \in M$.
\label{sec:fracm} % 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
Given a monoid $M$, we define a monoid representing fractional ownership of some piece $\melt \in M$. % \begin{align*}
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$). % (q, a) \mtimes (q', a') &\eqdef (q + q', a \mtimes a') \qquad \mbox{if $q+q'\le 1$} \\
Let $\fracm{M}$ be the monoid with carrier $(((0, 1] \cap \mathbb{Q}) \times M) \uplus \{\munit\}$ and multiplication % (q, a) \mtimes \munit &\eqdef (q,a) \\
\begin{align*} % \munit \mtimes (q,a) &\eqdef (q,a).
(q, a) \mtimes (q', a') &\eqdef (q + q', a \mtimes a') \qquad \mbox{if $q+q'\le 1$} \\ % \end{align*}
(q, a) \mtimes \munit &\eqdef (q,a) \\
\munit \mtimes (q,a) &\eqdef (q,a). % We get the following frame-preserving update.
\end{align*} % \begin{mathpar}
% \inferH{FracUpdFull}
We get the following frame-preserving update. % {a, b \in M}
\begin{mathpar} % {(1, a) \mupd (1, b)}
\inferH{FracUpdFull} % \and\inferH{FracUpdLocal}
{a, b \in M} % {a \mupd_M B}
{(1, a) \mupd (1, b)} % {(q, a) \mupd \{q\} \times B}
\and\inferH{FracUpdLocal} % \end{mathpar}
{a \mupd_M B}
{(q, a) \mupd \{q\} \times B} % \begin{proof}[Proof of \ruleref{FracUpdFull}]
\end{mathpar} % 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{FracUpdFull}]
Assume some $f \sep (1, a)$. This can only be $f = \munit$, so showing $f \sep (1, b)$ is trivial. % \begin{proof}[Proof of \ruleref{FracUpdLocal}]
\end{proof} % 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$.
\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)$. % In the interesting case, we have $f = (q_f, a_f)$.
Obtain $b$ such that $b \in B \land b \sep a_f$. % Obtain $b$ such that $b \in B \land b \sep a_f$.
Then $(q, b) \sep f$, and we are done. % Then $(q, b) \sep f$, and we are done.
\end{proof} % \end{proof}
$\fracm{M}$ is cancellative if $M$ is cancellative. % $\fracm{M}$ is cancellative if $M$ is cancellative.
\begin{proof}[Proof of cancellativitiy] % \begin{proof}[Proof of cancellativitiy]
If $\melt_f = \munit$, we are trivially done. % If $\melt_f = \munit$, we are trivially done.
So let $\melt_f = (q_f, \melt_f')$. % So let $\melt_f = (q_f, \melt_f')$.
If $\melt = \munit$, then $\meltB = \munit$ as otherwise the fractions could not match up. % If $\melt = \munit$, then $\meltB = \munit$ as otherwise the fractions could not match up.
Again, we are trivially done. % Again, we are trivially done.
Similar so for $\meltB = \munit$. % Similar so for $\meltB = \munit$.
So let $\melt = (q_a, \melt')$ and $\meltB = (q_b, \meltB')$. % 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 $(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'$. % We have to show $q_a = q_b$ and $\melt' = \meltB'$.
The first is trivial, the second follows from cancellativitiy of $M$. % The first is trivial, the second follows from cancellativitiy of $M$.
\end{proof} % \end{proof}
\subsection{Finite partial function monoid} % \subsection{Finite partial function monoid}
\label{sec:fpfunm} % \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$. % 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$.
\ralf{all outdated} % \ralf{all outdated}
Let ${X} \fpfn {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. % Let ${X} \fpfn {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. % 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 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: % We use two frame-preserving updates:
\begin{mathpar} % \begin{mathpar}
\inferH{FpFunAlloc} % \inferH{FpFunAlloc}
{a \in \mcarp{M}} % {a \in \mcarp{M}}
{f \mupd \{ f[x \mapsto a] \mid x \notin \dom(f) \}} % {f \mupd \{ f[x \mapsto a] \mid x \notin \dom(f) \}}
\and % \and
\inferH{FpFunUpd} % \inferH{FpFunUpd}
{a \mupd_M B} % {a \mupd_M B}
{f[i \mapsto a] \mupd \{ f[i \mapsto b] \mid b \in B\}} % {f[i \mapsto a] \mupd \{ f[i \mapsto b] \mid b \in B\}}
\end{mathpar} % \end{mathpar}
Rule \ruleref{FpFunUpd} simply restates \ruleref{ProdUpd}. % Rule \ruleref{FpFunUpd} simply restates \ruleref{ProdUpd}.
\begin{proof}[Proof of \ruleref{FpFunAlloc}] % \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. % 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} % \end{proof}
We write $[x \mapsto a]$ for the function mapping $x$ to $a$ and everything else in $X$ to $\munit$. % We write $[x \mapsto a]$ for the function mapping $x$ to $a$ and everything else in $X$ to $\munit$.
%\subsection{Disposable monoid} % %\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. % %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 % %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 % %% 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*} % %\begin{align*}
% \melt \mtimes \meltB &\eqdef \melt \mtimes_M \meltB & \IF \melt \sep[M] \meltB \\ % % \melt \mtimes \meltB &\eqdef \melt \mtimes_M \meltB & \IF \melt \sep[M] \meltB \\
% \disposed \mtimes \disposed &\eqdef \disposed \\ % % \disposed \mtimes \disposed &\eqdef \disposed \\
% \munit_M \mtimes \disposed &\eqdef \disposed \mtimes \munit_M \eqdef \disposed % % \munit_M \mtimes \disposed &\eqdef \disposed \mtimes \munit_M \eqdef \disposed
%\end{align*} % %\end{align*}
%The unit is the same as in $M$. % %The unit is the same as in $M$.
% % %
%The frame-preserving updates are % %The frame-preserving updates are
%\begin{mathpar} % %\begin{mathpar}
% \inferH{DispUpd} % % \inferH{DispUpd}
% {a \in \mcarp{M} \setminus \{\munit_M\} \and a \mupd_M B} % % {a \in \mcarp{M} \setminus \{\munit_M\} \and a \mupd_M B}
% {a \mupd B} % % {a \mupd B}
% \and % % \and
% \inferH{Dispose} % % \inferH{Dispose}
% {a \in \mcarp{M} \setminus \{\munit_M\} \and \All b \in \mcarp{M}. a \sep b \Ra b = \munit_M} % % {a \in \mcarp{M} \setminus \{\munit_M\} \and \All b \in \mcarp{M}. a \sep b \Ra b = \munit_M}
% {a \mupd \disposed} % % {a \mupd \disposed}
%\end{mathpar} % %\end{mathpar}
% % %
%\begin{proof}[Proof of \ruleref{DispUpd}] % %\begin{proof}[Proof of \ruleref{DispUpd}]
%Assume a frame $f$. If $f = \disposed$, then $a = \munit_M$, which is a contradiction. % %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$. % %Thus $f \in \mcarp{M}$ and we can use $a \mupd_M B$.
%\end{proof} % %\end{proof}
% % %
%\begin{proof}[Proof of \ruleref{Dispose}] % %\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. % %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} % %\end{proof}
\subsection{Authoritative monoid}\label{sec:auth} % \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$. % 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.) % (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 % Let $\auth{M}$ be the monoid with carrier
\[ % \[
\setComp{ (x, \melt) }{ x \in \mcarp{\exm{\mcarp{M}}} \land \melt \in \mcarp{M} \land (x = \munit_{\exm{\mcarp{M}}} \lor \melt \leq_M x) } % \setComp{ (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 % and multiplication
\[ % \[
(x, \melt) \mtimes (y, \meltB) \eqdef % (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) % (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$. % 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$. % 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)$. % 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}}$. % If $x$ or $a$ is $\mzero_{M}$, then the sugar denotes $\mzero_{\auth{M}}$.
\ralf{This needs syncing with the Coq development.} % \ralf{This needs syncing with the Coq development.}
The frame-preserving update involves a rather unwieldy side-condition: % The frame-preserving update involves a rather unwieldy side-condition:
\begin{mathpar} % \begin{mathpar}
\inferH{AuthUpd}{ % \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 % \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 % \melt' \sep \meltB
}{ % }{
\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \melt' \mtimes \meltB, \authfrag \melt' % \authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \melt' \mtimes \meltB, \authfrag \melt'
} % }
\end{mathpar} % \end{mathpar}
We therefore derive two special cases. % We therefore derive two special cases.
\paragraph{Local frame-preserving updates.} % \paragraph{Local frame-preserving updates.}
\newcommand\authupd{f}% % \newcommand\authupd{f}%
Following~\cite{scsl}, we say that $\authupd: \mcar{M} \ra \mcar{M}$ is \emph{local} if % 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 % \All a, b \in \mcar{M}. a \sep b \land \authupd(a) \neq \mzero \Ra \authupd(a \mtimes b) = \authupd(a) \mtimes b
\] % \]
Then, % Then,
\begin{mathpar} % \begin{mathpar}
\inferH{AuthUpdLocal} % \inferH{AuthUpdLocal}
{\text{$\authupd$ local} \and \authupd(\melt)\sep\meltB} % {\text{$\authupd$ local} \and \authupd(\melt)\sep\meltB}
{\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \authupd(\melt) \mtimes \meltB, \authfrag \authupd(\melt)} % {\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \authupd(\melt) \mtimes \meltB, \authfrag \authupd(\melt)}
\end{mathpar} % \end{mathpar}
\paragraph{Frame-preserving updates on cancellative monoids.} % \paragraph{Frame-preserving updates on cancellative monoids.}
Frame-preserving updates are also possible if we assume $M$ cancellative: % Frame-preserving updates are also possible if we assume $M$ cancellative:
\begin{mathpar} % \begin{mathpar}
\inferH{AuthUpdCancel} % \inferH{AuthUpdCancel}
{\text{$M$ cancellative} \and \melt'\sep\meltB} % {\text{$M$ cancellative} \and \melt'\sep\meltB}
{\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \melt' \mtimes \meltB, \authfrag \melt'} % {\authfull \melt \mtimes \meltB, \authfrag \melt \mupd \authfull \melt' \mtimes \meltB, \authfrag \melt'}
\end{mathpar} % \end{mathpar}
\subsection{Fractional heap monoid} % \subsection{Fractional heap monoid}
\label{sec:fheapm} % \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. % 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. % Hereinafter, we assume the set $\textdom{Val}$ of values is countable.
Given a set $Y$, define $\FHeap(Y) \eqdef \textdom{Val} \fpfn \fracm(Y)$ representing a fractional heap with codomain $Y$. % Given a set $Y$, define $\FHeap(Y) \eqdef \textdom{Val} \fpfn \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. % 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} % \begin{mathpar}
\axiomH{FHeapUpd}{h[x \mapsto (1, y)] \mupd h[x \mapsto (1, y')]} \and % \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} \,\}} % \axiomH{FHeapAlloc}{h \mupd \{\, h[x \mapsto (1, y)] \mid x \in \textdom{Val} \,\}}
\end{mathpar} % \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$. % 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$. % Define $\AFHeap(Y) \eqdef \auth{\FHeap(Y)}$ representing an authoritative fractional heap with codomain $Y$.
We easily obtain the following frame-preserving updates. % We easily obtain the following frame-preserving updates.
\begin{mathpar} % \begin{mathpar}
\axiomH{AFHeapUpd}{ % \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')]) % (\authfull h[x \mapsto (1, y)], \authfrag [x \mapsto (1, y)]) \mupd (\authfull h[x \mapsto (1, y')], \authfrag [x \mapsto (1, y')])
} % }
\and % \and
\inferH{AFHeapAdd}{ % \inferH{AFHeapAdd}{
x \notin \dom(h) % x \notin \dom(h)
}{ % }{
\authfull h \mupd (\authfull h[x \mapsto (q, y)], \authfrag [x \mapsto (q, y)]) % \authfull h \mupd (\authfull h[x \mapsto (q, y)], \authfrag [x \mapsto (q, y)])
} % }
\and % \and
\axiomH{AFHeapRemove}{ % \axiomH{AFHeapRemove}{
(\authfull h[x \mapsto (q, y)], \authfrag [x \mapsto (q, y)]) \mupd \authfull h % (\authfull h[x \mapsto (q, y)], \authfrag [x \mapsto (q, y)]) \mupd \authfull h
} % }
\end{mathpar} % \end{mathpar}
\subsection{STS with tokens monoid} % \subsection{STS with tokens monoid}
\label{sec:stsmon} % \label{sec:stsmon}
\ralf{This needs syncing with the Coq development.} % \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. % 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}. % 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: % 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*} % \begin{align*}
(s, T) \ra (s', T') \eqdef&\, s \ra s' \land \STSL(s) \uplus T = \STSL(s') \uplus T' \\ % (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)) \\ % \textsf{frame}(s, T) \eqdef&\, (s, \STST \setminus (\STSL(s) \uplus T)) \\
\upclose(S, T) \eqdef&\, \setComp{ s' \in \STSS}{\exists s \in S.\; \textsf{frame}(s, T) \ststrans \textsf{frame}(s', T) } % \upclose(S, T) \eqdef&\, \setComp{ s' \in \STSS}{\exists s \in S.\; \textsf{frame}(s, T) \ststrans \textsf{frame}(s', T) }
\end{align*} % \end{align*}
\noindent % \noindent
We have % We have
\begin{quote} % \begin{quote}
If $(s, T) \ra (s', T')$\\ % If $(s, T) \ra (s', T')$\\
and $T_f \sep (T \uplus \STSL(s))$,\\ % and $T_f \sep (T \uplus \STSL(s))$,\\
then $\textsf{frame}(s, T_f) \ra \textsf{frame}(s', T_f)$. % then $\textsf{frame}(s, T_f) \ra \textsf{frame}(s', T_f)$.
\end{quote} % \end{quote}
\begin{proof} % \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 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'$. % This is exactly what we have to show, since we know $\STSL(s) \uplus T = \STSL(s') \uplus T'$.
\end{proof} % \end{proof}
Let $\STSMon{\STSS}$ be the monoid with carrier % Let $\STSMon{\STSS}$ be the monoid with carrier
\[ % \[
\setComp{ (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} } % \setComp{ (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 % 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} % (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 % 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}$. % $s : \STSMon{\STSS} \eqdef (s, \emptyset) : \STSMon{\STSS}$.
We will need the following frame-preserving update. % We will need the following frame-preserving update.
\begin{mathpar} % \begin{mathpar}
\inferH{StsStep}{(s, T) \ststrans (s', T')} % \inferH{StsStep}{(s, T) \ststrans (s', T')}
{(s, S, T) \mupd (s', \upclose(\{s'\}, T'), T')} % {(s, S, T) \mupd (s', \upclose(\{s'\}, T'), T')}
\end{mathpar} % \end{mathpar}
\begin{proof}[Proof of \ruleref{StsStep}] % \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'$. % 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)$. % 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. % This follows by induction on the path $(s, T) \ststrans (s', T')$, and using the lemma proven above for each step.
\end{proof} % \end{proof}
%%% Local Variables: %%% Local Variables:
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
\clearpage\begingroup \clearpage\begingroup
\input{algebra} \input{algebra}
\endgroup\clearpage\begingroup \endgroup\clearpage\begingroup
\input{constructions}
% temporarily disabled, to generate the Iris 2.0 appendix % temporarily disabled, to generate the Iris 2.0 appendix
%\input{constructions}
%\endgroup\clearpage\begingroup %\endgroup\clearpage\begingroup
%\input{logic} %\input{logic}
%\endgroup\clearpage\begingroup %\endgroup\clearpage\begingroup
...@@ -46,5 +46,6 @@ ...@@ -46,5 +46,6 @@
%\input{derived} %\input{derived}
%\endgroup\clearpage\begingroup %\endgroup\clearpage\begingroup
\printbibliography \printbibliography
\endgroup
\end{document} \end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment