Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Iris
examples
Commits
08670a05
Commit
08670a05
authored
Oct 13, 2016
by
Zhen Zhang
Browse files
Add docs folder back
parent
e3c94895
Changes
7
Hide whitespace changes
Inline
Side-by-side
docs/tex/.gitignore
0 → 100644
View file @
08670a05
*.pdf
*.aux
*.log
*.out
*.synctex.gz
*.txss
*.thm
*.toc
*.bbl
*.blg
*.bcf
*.run.xml
_*_.tex
auto/*.el
docs/tex/atomic.tex
0 → 100644
View file @
08670a05
\documentclass
[10pt]
{
article
}
\usepackage
{
lmodern
}
\usepackage
[T1]
{
fontenc
}
\usepackage
[utf8]
{
inputenc
}
\usepackage
{
fontspec
}
\setmonofont
{
Source Code Pro
}
\newif\ifslow\slowfalse
%\slowtrue
\ifslow
\usepackage
[english]
{
babel
}
\usepackage
[babel=true]
{
microtype
}
\fi
\usepackage
[top=1in, bottom=1in, left=1.25in, right=1.25in]
{
geometry
}
\usepackage
[backend=biber]
{
biblatex
}
\bibliography
{
bib
}
\newcommand
{
\bdia
}{
\blacklozenge
}
\newcommand
{
\dia
}{
\Diamond
}
\newcommand
{
\injR
}{
\texttt
{
injR
}}
\newcommand
{
\injL
}{
\texttt
{
injL
}}
\input
{
setup
}
\begin{document}
\title
{
\bfseries
iris-atomic
}
\author
{
Zhen Zhang
}
\maketitle
\section
{
sync.v
}
\[
\begin
{
aligned
}
\text
{
synced
}
(
R, f', f
)
\eqdef
\All
P, Q, x.
&
\hoare
{
R
*
P
(
x
)
}{
f
(
x
)
}{
v.
\,
R
*
Q
(
x,v
)
}
\ra
\\
&
\hoare
{
P
(
x
)
}{
f'
(
x
)
}{
v.
\,
Q
(
x,v
)
}
\end
{
aligned
}\]
\[
\text
{
is
\_
syncer
}
(
R, s
)
\eqdef
\All
f.
\wpre
{
s
(
f
)
}{
f'.
\,
\text
{
synced
}
(
R, f', f
)
}
\]
\[
mk
\_
syncer
\_
spec
(
mk
\_
syncer
)
:
=
\All
R.
\hoare
{
R
}{
mk
\_
syncer
()
}{
s.
\,\always
(
is
\_
syncer
(
R, s
)
}
\]
\section
{
atomic.v
}
Logically atomic triple:
\[
\lahoare
{
g.
\,
\alpha
(
g
)
}{
e
}{
v.
\,
\beta
(
g, v
)
}
[
E
_
i
][
E
_
o
]
\eqdef
\All
P, Q.
\begin
{
aligned
}
&
P
\vs
[
Eo
][
Ei
]
\Exists
g,
\alpha
(
g
)
*
(
\alpha
(
g
)
\vsW
[
Ei
][
Eo
]
P
\land
\All
v.
\beta
(
g, v
)
\vsW
[
Ei
][
Eo
]
Q
(
g, v
))
\wand
\\
&
\hoare
{
P
}{
e
}{
v.
\,
\Exists
g. Q
(
g, v
)
}
\end
{
aligned
}\]
\section
{
simple
\_
sync.v
}
\begin{verbatim}
mk
_
sync :=
λ: <>,
let l := newlock() in
λ: f x,
acquire l;
let ret := f x in
release l;
ret.
\end{verbatim}
\section
{
atomic
\_
sync.v
}
Specialized logically atomic triple:
\[
\lahoare
{
g.
\,
\ownGhost
{
\gname
}{
g
^{
1
/
2
}}
*
\always
\alpha
(
g
)
}
{
f
(
x
)
}
{
v.
\,
\Exists
g'.
\ownGhost
{
\gname
}{
g'
^{
1
/
2
}}
*
\beta
(
x, g, g', v
)
}
[
E
_
i
][
E
_
o
]
\]
\begin{verbatim}
sync(mk
_
syncer) :=
λ: f
_
seq l,
let s := mk
_
syncer() in
s (f
_
seq l).
\end{verbatim}
\[
seq
\_
spec
(
f,
\phi
,
\alpha
,
\beta
, E
)
\eqdef
\All
l.
\hoare
{
\top
}{
f
(
l
)
}{
f'.
\,
\begin
{
aligned
}
\pure
&
\All
x,
\Phi
, g.
\\
&
\phi
(
l, g
)
*
\always
\alpha
(
x
)
*
\\
&
(
\All
v, g'.
\phi
(
l, g'
)
\wand
\beta
(
x, g, g', v
)
\wand
\pvs
[
E
][
E
]
\Phi
(
v
))
\\
&
\proves
\wpre
{
f'
(
x
)
}
[
E
]
{
\Phi
}
\end
{
aligned
}
}\]
\[
\begin
{
aligned
}
&
\text
{
atomic
\_
spec
}
(
mk
\_
syncer, f
\_
seq, l,
\phi
,
\alpha
,
\beta
, E
_
i
)
\eqdef\\
&
\All
g
_
0
.
seq
\_
spec
(
f
\_
seq,
\phi
,
\alpha
,
\beta
,
\top
)
\ra
mk
\_
syncer
\_
spec
(
mk
\_
syncer
)
\ra\\
&
\phi
(
l, g
_
0
)
\proves
\wpre
{
sync
(
mk
\_
syncer, f
\_
seq, l
)
}{
f.
\,
\Exists
\gname
.
\ownGhost
{
\gname
}{
g
_
0
^{
1
/
2
}}
*
\All
x.
\always
\lahoare
{
g.
\,
\ownGhost
{
\gname
}{
g
^{
1
/
2
}}
*
\always
\alpha
(
g
)
}{
f
(
x
)
}
{
v.
\,
\Exists
g'.
\ownGhost
{
\gname
}{
g'
^{
1
/
2
}}
*
\beta
(
x, g, g', v
)
}
[
E
_
i
][
\top
]
}
\end
{
aligned
}
\]
\[
(
\Exists
g.
\phi
(
l, g'
)
*
\ownGhost
{
\gname
}{
g
^{
1
/
2
}}
*
P x
\]
\section
{
treiber.v
}
\begin{verbatim}
push s x :=
let hd := !s in
let s' := ref SOME (x, hd) in
if CAS s hd s'
then ()
else push s x.
pop s :=
let hd := !s in
match !hd with
| SOME (x, hd') =>
if: CAS s hd hd'
then SOME x
else pop s
| NONE => NONE
end.
iter hd f :=
match !hd with
| NONE => ()
| SOME (x, hd') => f x ; iter hd' f
end.
\end{verbatim}
Logiall atomic spec (version 1):
\[
\lahoare
{
xs.
\,
stack
(
s, xs
)
}{
push
(
s, x
)
}{
stack
(
s, x::xs
)
}
[
heapN
][
\top
]
\]
\[
\lahoare
{
xs.
\,
stack
(
s, xs
)
}{
pop
(
s
)
}{
v.
\begin
{
split
}
(
&
\Exists
x, xs'. v
=
SOME
(
x
)
*
stack
(
s, xs'
))
\lor\\
(
&
v
=
NONE
*
xs
=
\emptyset
*
stack
(
s,
\emptyset
))
\end
{
split
}}
[
heapN
][
\top
]
\]
Logiall atomic spec (version 2):
\[
\lahoare
{
hd, xs.
\,
s
\mapsto
hd
*
list
(
hd, xs
)
}{
push
(
s, x
)
}{
\Exists
hd'. s
\mapsto
hd'
*
hd'
\mapsto
SOME
(
x, hd
)
*
list
(
hd, xs
)
}
[
heapN
][
\top
]
\]
\[
\lahoare
{
hd, xs.
\,
s
\mapsto
hd
*
list
(
hd, xs
)
}{
pop
(
s
)
}{
v.
\begin
{
split
}
(
&
\Exists
x, xs', hd'. v
=
SOME
(
x
)
*
hd
\mapsto
SOME
(
x, hd'
)
*
s
\mapsto
hd'
*
list
(
hd', xs'
))
\lor\\
(
&
v
=
NONE
*
xs
=
\emptyset
*
hd
\mapsto
NONE
)
\end
{
split
}
}
[
heapN
][
\top
]
\]
\section
{
peritem.v
}
A crappy but working spec:
\[
f
\_
spec
(
\gname
, xs, s, f, Rf, RI
)
\eqdef
\All
x.
\hoare
{
x
\in
xs
*
\knowInv\iname
{
\Exists
xs. stack'
(
\gname
, xs, s
)
*
RI
}
*
Rf
}{
f
(
x
)
}{
v.
\,
v
=
()
}
.
\]
\[
\begin
{
split
}
iter
\_
spec
(
\gname
, s, Rf, RI
)
\eqdef
&
\All
xs, hd, f.
\\
&
f
\_
spec
(
xs, s, f', Rf, RI
)
\ra\\
&
\hoare
{
\knowInv\iname
{
\Exists
xs. stack'
(
xs, s
)
*
RI
}
*
list'
(
\gname
, hd, xs
)
*
Rf
}{
iter
(
hd, f
)
}{
v.
\,
v
=
()
*
Rf
}
\end
{
split
}\]
\[
push
\_
spec
(
\gname
, s, x, RI
)
\eqdef
\hoare
{
R
(
x
)
*
\knowInv\iname
{
\Exists
xs. stack'
(
xs, s
)
*
RI
}}{
push
(
s, x
)
}{
v.
\,
v
=
()
*
(
\Exists
hd. ev
(
\gname
, hd, x
))
}\]
\section
{
flat.v
}
\begin{verbatim}
doOp :=
λ: p,
match !p with
| InjL (f, x) => p <- InjR (f x)
| InjR
_
=> ()
end.
try
_
srv :=
λ: lk s,
if try
_
acquire lk
then let hd := !s in
iter hd doOp;
release lk
else ().
loop p s lk :=
match !p with
| InjL
_
=>
try
_
srv lk s;
loop p s lk
| InjR r => r
end.
install :=
λ: f x s,
let p := ref (InjL (f, x)) in
push s p;
p.
mk
_
flat :=
λ: <>,
let lk := newlock() in
let s := new
_
stack() in
λ: f x,
let p := install f x s in
let r := loop p s lk in
r.
\end{verbatim}
\[
p
\mapsto
\injR
(-)
\]
\[
p
\mapsto
\texttt
{
injL
}
(
f, x
)
\]
\[
p
\mapsto
\injR
(
y
)
\]
\[
\circ
_
i,
\bullet
_
i,
\dia
_
i,
\bdia
,
\dia
_
i
\circ
_
i,
\dia
_
i
\bullet
_
i,
\bdia
\bullet
_
i
\]
\begin{align*}
&
\Exists
y.
&&
p
\fmapsto
[1/2]
\injR
(-) *
\dia
_
i *
\circ
_
i
\\
\lor
&
\Exists
f, x, P, Q.
&&
p
\fmapsto
[1/2]
\injL
(f, x) *
\ownGhost
{
\gname
}{
x
^{
1/2
}}
*
P(x) * (
\hoare
{
R * P(x)
}{
f(x)
}{
v.
\,
R * Q(x, v)
}
) *
\gamma
\mapstoprop
Q(x) *
\dia
_
i *
\bullet
_
i
\\
\lor
&
\Exists
x.
&&
p
\fmapsto
[1/2]
\injL
(-, x) *
\ownGhost
{
\gname
}{
x
^{
1/4
}}
*
\bdia
*
\bullet
_
i
\\
\lor
&
\Exists
x, y.
&&
p
\fmapsto
[1/2]
\injR
(y) *
\ownGhost
{
\gname
}{
x
^{
1/2
}}
*
\gamma
\mapstoprop
Q(x) * Q(x, y) *
\dia
_
i *
\bullet
_
i
\end{align*}
\[
\alpha
=
\alpha
_
a
*
\alpha
_
o,
\alpha
=
\alpha
_
a'
*
\alpha
_
o
\]
\[
\alpha
=
\alpha
_
o
*
\alpha
_
a,
\alpha
_
a'
*
\alpha
_
o
=
\beta
\]
\[
\alpha
=
\alpha
_
a
*
\alpha
_
o,
\alpha
=
\alpha
_
a'
*
\alpha
_
o
\]
\end{document}
docs/tex/iris.sty
0 → 100644
View file @
08670a05
\NeedsTeXFormat
{
LaTeX2e
}
[1999/12/01]
\ProvidesPackage
{
iris
}
\RequirePackage
{
tikz
}
\RequirePackage
{
scalerel
}
\RequirePackage
{
array
}
\RequirePackage
{
dashbox
}
\RequirePackage
{
tensor
}
\RequirePackage
{
xparse
}
\RequirePackage
{
xstring
}
\RequirePackage
{
mathtools
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SETUP
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usetikzlibrary
{
shapes
}
%\usetikzlibrary{snakes}
\usetikzlibrary
{
arrows
}
\usetikzlibrary
{
calc
}
\usetikzlibrary
{
arrows.meta
}
\tikzstyle
{
state
}
=[circle, draw, minimum size=1.2cm, align=center]
\tikzstyle
{
trans
}
=[arrows=
{
->[scale=1.4]
}
]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MATH SYMBOLS & NOTATION & IDENTIFIERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand
{
\nat
}{
\mathbb
{
N
}}
\DeclareMathOperator*
{
\Sep
}{
\scalerel*
{
\ast
}{
\sum
}}
\newcommand*
{
\disj
}
[1][]
{
\mathrel
{
\#
_{
#1
}}}
\newcommand\pord
{
\sqsubseteq
}
\newcommand\dplus
{
\mathbin
{
+
\kern
-1.0ex+
}}
\newcommand
{
\upclose
}{
\mathord
{
\uparrow
}}
\newcommand
{
\ALT
}{
\
|
\
}
\newcommand
{
\spac
}{
\,
}
% a space
\def\All
#1.
{
\forall
#1.
\spac
}
%
\def\Exists
#1.
{
\exists
#1.
\spac
}
%
\def\Ret
#1.
{
#1.
\spac
}
%
\newcommand
{
\any
}{{
\rule
[-.2ex]
{
1ex
}{
.4pt
}}}
%
\newcommand
{
\judgment
}
[2][]
{
\paragraph
{
#1
}
\hspace
{
\stretch
{
1
}}
\fbox
{$
#
2
$}}
\newcommand
{
\pfn
}{
\rightharpoonup
}
\newcommand\fpfn
{
\xrightharpoonup
{
\kern
-0.25ex
\textrm
{
fin
}
\kern
-0.25ex
}}
\newcommand
{
\la
}{
\leftarrow
}
\newcommand
{
\ra
}{
\rightarrow
}
\newcommand
{
\Ra
}{
\Rightarrow
}
\newcommand
{
\Lra
}{
\Leftrightarrow
}
\newcommand\monra
{
\xrightarrow
{
\kern
-0.15ex
\textrm
{
mon
}
\kern
-0.05ex
}}
\newcommand\nfn
{
\xrightarrow
{
\kern
-0.15ex
\textrm
{
ne
}
\kern
-0.05ex
}}
\newcommand
{
\eqdef
}{
\triangleq
}
\newcommand
{
\bnfdef
}{
\vcentcolon\vcentcolon
=
}
% \newcommand{\lor}{\wedge}
\newcommand
{
\maybe
}
[1]
{
#1
^
?
}
\newcommand*\setComp
[2]
{
\left\{
#1
\spac\middle
|
\spac
#2
\right\}
}
\newcommand*\set
[1]
{
\left\{
#1
\right\}
}
\newcommand*\record
[1]
{
\left\{\spac
#1
\spac\right\}
}
\newcommand*\recordComp
[2]
{
\left\{\spac
#1
\spac\middle
|
\spac
#2
\spac\right\}
}
\newenvironment
{
inbox
}
[1][]
{
\begin{array}
[#1]
{
@
{}
l@
{}}
}{
\end{array}
}
\newcommand
{
\dom
}{
\mathrm
{
dom
}}
\newcommand
{
\cod
}{
\mathrm
{
cod
}}
\newcommand
{
\chain
}{
\mathrm
{
chain
}}
\newcommand
{
\pset
}
[1]
{
\wp
(#1)
}
% Powerset
\newcommand
{
\psetdown
}
[1]
{
\wp
^
\downarrow
(#1)
}
\newcommand
{
\finpset
}
[1]
{
\wp
^
\mathrm
{
fin
}
(#1)
}
\newcommand
{
\Func
}{
F
}
% functor
\newcommand
{
\subst
}
[3]
{{
#1
}
[
{
#3
}
/
{
#2
}
]
}
\newcommand
{
\mapinsert
}
[3]
{
#3[#1:=#2]
}
\newcommand
{
\nil
}{
\epsilon
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MODEL-SPECIFIC SYMBOLS & NOTATION & IDENTIFIERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand
{
\textdom
}
[1]
{
\textit
{
#1
}}
\newcommand
{
\wIso
}{
\xi
}
\newcommand
{
\rs
}{
r
}
\newcommand
{
\rsB
}{
s
}
\newcommand
{
\rss
}{
R
}
\newcommand
{
\pres
}{
\pi
}
\newcommand
{
\wld
}{
w
}
\newcommand
{
\ghostRes
}{
g
}
%% Various pieces of syntax
\newcommand
{
\wsat
}
[3]
{
#1
\models
_{
#2
}
#3
}
\newcommand
{
\wsatpre
}{
\textdom
{
pre-wsat
}}
\newcommand
{
\wtt
}
[2]
{
#1 : #2
}
% well-typed term
\newcommand
{
\nequiv
}
[1]
{
\ensuremath
{
\mathrel
{
\stackrel
{
#1
}{
=
}}}}
\newcommand
{
\notnequiv
}
[1]
{
\ensuremath
{
\mathrel
{
\stackrel
{
#1
}{
\neq
}}}}
\newcommand
{
\nequivset
}
[2]
{
\ensuremath
{
\mathrel
{
\stackrel
{
#1
}{
=
}_{
#2
}}}}
\newcommand
{
\nequivB
}
[1]
{
\ensuremath
{
\mathrel
{
\stackrel
{
#1
}{
\equiv
}}}}
\newcommand
{
\latert
}{
\mathord
{
\blacktriangleright
}}
\newcommand
{
\latertinj
}{
\textlog
{
next
}}
\newcommand
{
\Sem
}
[1]
{
\llbracket
#1
\rrbracket
}
\newcommand
{
\sembox
}
[1]
{
\hfill
\normalfont
\mbox
{
\fbox
{\(
#
1
\)}}}
\newcommand
{
\typedsection
}
[2]
{
\subsubsection*
{
\rm\em
#1
\sembox
{
#2
}}}
%% Some commonly used identifiers
\newcommand
{
\SProp
}{
\textdom
{
SProp
}}
\newcommand
{
\UPred
}{
\textdom
{
UPred
}}
\newcommand
{
\mProp
}{
\textdom
{
Prop
}}
% meta-level prop
\newcommand
{
\iProp
}{
\textdom
{
iProp
}}
\newcommand
{
\iPreProp
}{
\textdom
{
iPreProp
}}
\newcommand
{
\Wld
}{
\textdom
{
Wld
}}
\newcommand
{
\Res
}{
\textdom
{
Res
}}
\newcommand
{
\State
}{
\textdom
{
State
}}
\newcommand
{
\Val
}{
\textdom
{
Val
}}
\newcommand
{
\Loc
}{
\textdom
{
Loc
}}
\newcommand
{
\Expr
}{
\textdom
{
Expr
}}
\newcommand
{
\cofe
}{
T
}
\newcommand
{
\cofeB
}{
U
}
\newcommand
{
\COFEs
}{
\mathcal
{
COFE
}}
% category of COFEs
\newcommand
{
\iFunc
}{
\Sigma
}
\newcommand
{
\fix
}{
\textdom
{
fix
}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CMRA (RESOURCE ALGEBRA) SYMBOLS & NOTATION & IDENTIFIERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand
{
\textmon
}
[1]
{
\textsc
{
#1
}}
\newcommand
{
\monoid
}{
M
}
\newcommand
{
\mval
}{
\mathcal
{
V
}}
\newcommand
{
\melt
}{
a
}
\newcommand
{
\meltB
}{
b
}
\newcommand
{
\meltC
}{
c
}
\newcommand
{
\melts
}{
A
}
\newcommand
{
\meltsB
}{
B
}
\newcommand
{
\f
}{
\mathrm
{
f
}}
% for "frame"
\newcommand
{
\mcar
}
[1]
{
|#1|
}
\newcommand
{
\mcarp
}
[1]
{
\mcar
{
#1
}^{
+
}}
\newcommand
{
\munit
}{
\varepsilon
}
\newcommand
{
\mcore
}
[1]
{{
\mid
}
#1
{
\mid
}}
% using "|" here makes LaTeX diverge. WTF.
\newcommand
{
\mnocore
}
\top
\newcommand
{
\mtimes
}{
\mathbin
{
\cdot
}}
\newcommand
{
\mupd
}{
\rightsquigarrow
}
\newcommand
{
\mincl
}
[1][]
{
\ensuremath
{
\mathrel
{
\stackrel
{
#1
}{
\preccurlyeq
}}}}
\newcommand
{
\CMRAs
}{
\mathcal
{
CMRA
}}
% category of CMRAs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOGIC SYMBOLS & NOTATION & IDENTIFIERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand
{
\textlog
}
[1]
{
\textsf
{
#1
}}
\newcommand
{
\Sig
}{
\mathcal
{
S
}}
\newcommand
{
\SigType
}{
\mathcal
{
T
}}
\newcommand
{
\SigFn
}{
\mathcal
{
F
}}
\newcommand
{
\SigAx
}{
\mathcal
{
A
}}
\newcommand
{
\sigtype
}{
T
}
\newcommand
{
\sigfn
}{
F
}
\newcommand
{
\sigax
}{
A
}
\newcommand
{
\type
}{
\tau
}
\newcommand
{
\typeB
}{
\sigma
}
\newcommand
{
\var
}{
x
}
\newcommand
{
\varB
}{
y
}
\newcommand
{
\varC
}{
z
}
\newcommand
{
\term
}{
t
}
\newcommand
{
\termB
}{
u
}
\newcommand
{
\vctx
}{
\Gamma
}
\newcommand
{
\pfctx
}{
\Theta
}
\newcommand
{
\prop
}{
P
}
\newcommand
{
\propB
}{
Q
}
\newcommand
{
\propC
}{
R
}
% pure propositions
\newcommand
{
\pprop
}{
\phi
}
\newcommand
{
\ppropB
}{
\psi
}
\newcommand
{
\pred
}{
\varPhi
}
\newcommand
{
\predB
}{
\Psi
}
\newcommand
{
\predC
}{
\Zeta
}
\newcommand
{
\gname
}{
\gamma
}
\newcommand
{
\iname
}{
\iota
}
\newcommand
{
\mask
}{
\mathcal
{
E
}}
\newcommand
{
\namesp
}{
\mathcal
{
N
}}
\newcommand
{
\namecl
}
[1]
{{
#1
^{
\kern
0.2ex
\uparrow
}}}
%% various pieces of Syntax
\def\MU
#1.
{
\mu
#1.
\spac
}
%
\def\Lam
#1.
{
\lambda
#1.
\spac
}
%
\newcommand
{
\proves
}{
\vdash
}
\newcommand
{
\provesCoq
}{
\mathrel
{
\vdash
_{
\mbox
{
\!\includegraphics
[width=0.7em]
{
rooster.jpg
}}}}}
\newcommand
{
\provesIff
}{
\mathrel
{
\dashv\vdash
}}
\newcommand
{
\wand
}{
\mathrel
{
-
\!\!*
}}
% oh my... I have to wrap the "-" in a \mathrm, otherwise all hell breaks lose...
\newcommand
{
\fmapsto
}
[1][]
{
\xmapsto
{
#1
}}
\newcommand
{
\gmapsto
}{
\hookrightarrow
}
%
\newcommand
{
\fgmapsto
}
[1][
\mathrm
{
-
}
]
{
\xhookrightarrow
{
#1
}}
%
\NewDocumentCommand\wpre
{
m O
{}
m
}
%
{
\textlog
{
wp
}_{
#2
}
\spac
#1
\spac
{
\big\{
#3
\big\}
}}
\newcommand
{
\later
}{
\mathop
{
\triangleright
}}
\newcommand
{
\always
}{
\mathop
{
\Box
}}
\newcommand
{
\pure
}{
\mathop
{
\blacksquare
}}
%% Invariants and Ghost ownership
% PDS: Was 0pt inner, 2pt outer.
% \boxedassert [tikzoptions] contents [name]
\tikzstyle
{
boxedassert
_
border
}
= [sharp corners,line width=0.2pt]
\NewDocumentCommand
\boxedassert
{
O
{}
m o
}{
%
\tikz
[baseline=(m.base)]
{
% \node[rectangle, draw,inner sep=0.8pt,anchor=base,#1] (m) {${#2}\mathstrut$};
\node
[rectangle,inner sep=0.8pt,outer sep=0.2pt,anchor=base]
(m)
{${
\,
#
2
\,
}
\mathstrut
$}
;
\draw
[#1,boxedassert_border]
(
$
(
m.south west
)
+
(
0
,
0
.
65
pt
)
$
) rectangle (
$
(
m.north east
)
+
(
0
,
0
.
7
pt
)
$
);
}
\IfNoValueF
{
#3
}{^{
\,
#3
}}
%
}
\newcommand*
{
\knowInv
}
[2]
{
\boxedassert
{
#2
}
[#1]
}
\newcommand*
{
\ownGhost
}
[2]
{
\boxedassert
[densely dashed]
{
#2
}
[#1]
}
\newcommand*
{
\ownGGhost
}
[1]
{
\boxedassert
[densely dashed]
{
#1
}}
\newcommand
{
\ownM
}
[1]
{
\textlog
{
Own
}
(#1)
}
\newcommand
{
\ownPhys
}
[1]
{
\lfloor\,
#1
\,
\rfloor
}
%% View Shifts
\NewDocumentCommand
\vsGen
{
O
{}
m O
{}}
%
{
\mathrel
{
%
\ifthenelse
{
\equal
{
#3
}{}}{
%
% Just one mask, or none
{
#2
}_{
#1
}
%
}{
%
% Two masks
\tensor*
[^{#1}]
{
#2
}{^{
#3
}}
}
%
}}
%
\NewDocumentCommand
\vs
{
O
{}
O
{}}
{
\vsGen
[#1]
{
\Rrightarrow
}
[#2]
}
\NewDocumentCommand
\vsL
{
O
{}
O
{}}
{
\vsGen
[#1]
{
\Lleftarrow
}
[#2]
}
\NewDocumentCommand
\vsE
{
O
{}
O
{}}
%
{
\vsGen
[#1]
{
\Lleftarrow\!\!\!\Rrightarrow
}
[#2]
}
\NewDocumentCommand
\pvs
{
O
{}
O
{}}
{
\mathord
{
\vsGen
[#1]
{{
\mid\kern
-0.4ex
\Rrightarrow\kern
-0.25ex
}}
[#2]
\kern
0.2ex
}}
\newcommand\vsWand
{
\kern
0.1ex
\tikz
[baseline=(base),line width=0.375pt]
{
%
\draw
(0, 0) -- (0.4, 0);
\draw
(0, -0.075) -- (0.28, -0.075);
\draw
(0, 0.075) -- (0.28, 0.075);
\node
at (0.4, -0.235) (ast)
{$
\smash
{
\scaleto
{
\ast
}{
1
.
2
em
}}$}
;
\node
at (0.4, -0.095) (base)
{}
;
}{
\vphantom
{
\Rrightarrow
}}
\kern
-1.2ex
}
\NewDocumentCommand
\vsW
{
O
{}
O
{}}
{
\vsGen
[#1]
{
\vsWand
}
[#2]
}
% for now, the update modality looks like a pvs without masks.
\NewDocumentCommand
\upd
{}
{
\mathop
{
\mid\kern
-0.4ex
\Rrightarrow\kern
-0.25ex
}}
%% Hoare Triples
\newcommand*
{
\hoaresizebox
}
[1]
{
%
\hbox
{$
\mathsurround
=
0
pt
{
#
1
}
\mathstrut
$}}
\newcommand*
{
\hoarescalebox
}
[2]
{
%
\hbox
{
\scalerel*
[1ex]
{
#1
}{
#2
}}}
\newcommand
{
\triple
}
[5]
{
%
\setbox
0=
\hoaresizebox
{{
#3
}{
#5
}}
%
\setbox
1=
\hoarescalebox
{
#1
}{
\copy
0
}
%
\setbox
2=
\hoarescalebox
{
#2
}{
\copy
0
}
%
\copy
1
{
#3
}
\copy
2
%
\;
#4
\;
%
\copy
1
{
#5
}
\copy
2
}
\newcommand
{
\bracket
}
[4][]
{
%
\setbox
0=
\hbox
{$
\mathsurround
=
0
pt
{
#
1
}{
#
4
}
\mathstrut
$}
%
\scalerel*
[1ex]
{
#2
}{
\copy
0
}
%
{
#4
}
%
\scalerel*
[1ex]
{
#3
}{
\copy
0
}}
% \curlybracket[other] x
\newcommand
{
\curlybracket
}
[2][]
{
\bracket
[{#1}]
\{\}
{
#2
}}
\newcommand
{
\anglebracket
}
[2][]
{
\bracket
[{#1}]
\langle\rangle
{
#2
}}
\NewDocumentCommand
\hoare
{
m m m O
{}}{
\curlybracket
{
#1
}
\spac
#2
\spac
\curlybracket
{
#3
}_{
#4
}
%
}
\NewDocumentCommand
\lahoare
{
m m m O
{}
O
{}}{
\anglebracket
{
#1
}
\spac
#2
\spac
\anglebracket
{
#3
}_{
#4
}^{
#5
}
%
}
% \hoareV[t] pre c post [mask]
\NewDocumentCommand
\hoareV
{
O
{
c
}
m m m O
{}}{
{
\begin{aligned}
[#1]
&
\curlybracket
{
#2
}
\\
&
\quad
{
#3
}
\\
&{
\curlybracket
{
#4
}}_{
#5
}
\end{aligned}
}
%
}
% \hoareHV[t] pre c post [mask]
\NewDocumentCommand
\hoareHV
{
O
{
c
}
m m m O
{}}{
{
\begin{aligned}
[#1]
&
\curlybracket
{
#2
}
\;
{
#3
}
\\
&{
\curlybracket
{
#4
}}_{
#5
}
\end{aligned}
}
%
}
%% Some commonly used identifiers
\newcommand
{
\timeless
}
[1]
{
\textlog
{
timeless
}
(#1)
}
\newcommand
{
\persistent
}
[1]
{
\textlog
{
persistent
}
(#1)
}
\newcommand
{
\physatomic
}
[1]
{
\textlog
{
atomic
}
(
$
#
1
$
)
}
\newcommand
{
\infinite
}{
\textlog
{
infinite
}}
\newcommand
{
\Prop
}{
\textlog
{
Prop
}}
\newcommand
{
\Pred
}{
\textlog
{
Pred
}}
\newcommand
{
\TRUE
}{
\textlog
{
True
}}
\newcommand
{
\FALSE
}{
\textlog
{
False
}}
\newcommand
{
\TLam
}{
\Lambda\spac
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% GENERIC LANGUAGE SYNTAX AND SEMANTICS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand
{
\expr
}{
e
}
\newcommand
{
\val
}{
v
}
\newcommand
{
\valB
}{
w
}
\newcommand
{
\state
}{
\sigma
}
\newcommand
{
\step
}{
\ra
}
\newcommand
{
\hstep
}{
\ra
_{
\mathsf
{
h
}}}
\newcommand
{
\tpstep
}{
\ra
_{
\mathsf
{
tp
}}}
\newcommand
{
\lctx
}{
K
}
\newcommand
{
\Lctx
}{
\textdom
{
Ctx
}}
\newcommand
{
\toval
}{
\mathrm
{
to
\_
val
}}
\newcommand
{
\ofval
}{
\mathrm
{
val2expr
}}