iris.sty 12.5 KB
Newer Older
1 2 3 4 5
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{iris}

\RequirePackage{tikz}
\RequirePackage{scalerel}
6 7 8 9 10 11 12
\RequirePackage{array}
\RequirePackage{dashbox}
\RequirePackage{tensor}
\RequirePackage{xparse}
\RequirePackage{xstring}
\RequirePackage{mathtools}

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

31 32
\newcommand{\nat}{\mathbb{N}}

33
\DeclareMathOperator*{\Sep}{\scalerel*{\ast}{\sum}}
Ralf Jung's avatar
Ralf Jung committed
34 35
\newcommand*{\disj}[1][]{\mathrel{\#_{#1}}}
\newcommand\pord{\sqsubseteq}
36 37 38 39
\newcommand\dplus{\mathbin{+\kern-1.0ex+}}
\newcommand{\upclose}{\mathord{\uparrow}}
\newcommand{\ALT}{\ |\ }

40
\newcommand{\spac}{\,} % a space
41 42 43 44 45 46 47

\def\All #1.{\forall #1.\spac}%
\def\Exists #1.{\exists #1.\spac}%
\def\Ret #1.{#1.\spac}%

\newcommand{\any}{{\rule[-.2ex]{1ex}{.4pt}}}%

Ralf Jung's avatar
Ralf Jung committed
48
\newcommand{\judgment}[2][]{\paragraph{#1}\hspace{\stretch{1}}\fbox{$#2$}}
49 50 51

\newcommand{\pfn}{\rightharpoonup}
\newcommand\fpfn{\xrightharpoonup{\kern-0.25ex\textrm{fin}\kern-0.25ex}}
Ralf Jung's avatar
Ralf Jung committed
52
\newcommand{\la}{\leftarrow}
53 54 55
\newcommand{\ra}{\rightarrow}
\newcommand{\Ra}{\Rightarrow}
\newcommand{\Lra}{\Leftrightarrow}
56 57
\newcommand\monra{\xrightarrow{\kern-0.15ex\textrm{mon}\kern-0.05ex}}
\newcommand\nfn{\xrightarrow{\kern-0.15ex\textrm{ne}\kern-0.05ex}}
58
\newcommand{\eqdef}{\triangleq}
Ralf Jung's avatar
Ralf Jung committed
59 60
\newcommand{\bnfdef}{\vcentcolon\vcentcolon=}

Ralf Jung's avatar
Ralf Jung committed
61 62
\newcommand{\maybe}[1]{#1^?}

63 64
\newcommand*\setComp[2]{\left\{#1\spac\middle|\spac#2\right\}}
\newcommand*\set[1]{\left\{#1\right\}}
65
\newcommand*\record[1]{\left\{\spac#1\spac\right\}}
Ralf Jung's avatar
Ralf Jung committed
66
\newcommand*\recordComp[2]{\left\{\spac#1\spac\middle|\spac#2\spac\right\}}
67 68 69 70 71 72 73

\newenvironment{inbox}[1][]{
  \begin{array}[#1]{@{}l@{}}
}{
  \end{array}
}

Ralf Jung's avatar
Ralf Jung committed
74
\newcommand{\op}{\textrm{op}}
75 76 77 78 79 80
\newcommand{\dom}{\mathrm{dom}}
\newcommand{\cod}{\mathrm{cod}}
\newcommand{\chain}{\mathrm{chain}}

\newcommand{\pset}[1]{\wp(#1)} % Powerset
\newcommand{\psetdown}[1]{\wp^\downarrow(#1)}
Ralf Jung's avatar
Ralf Jung committed
81
\newcommand{\finpset}[1]{\wp^\mathrm{fin}(#1)}
82 83 84

\newcommand{\Func}{F} % functor

85 86 87
\newcommand{\subst}[3]{{#1}[{#3} / {#2}]}

\newcommand{\mapinsert}[3]{#3[#1:=#2]}
88 89
\newcommand{\mapsingleton}[2]{[#1:=#2]}
\newcommand{\mapsingletonComp}[3]{\left[ #1 := #2 \spac\middle|\spac #3 \right]}
90 91 92

\newcommand{\nil}{\epsilon}

93 94 95 96 97 98 99 100 101
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MODEL-SPECIFIC SYMBOLS & NOTATION & IDENTIFIERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\textdom}[1]{\textit{#1}}

\newcommand{\wIso}{\xi}

\newcommand{\rs}{r}
\newcommand{\rsB}{s}
Ralf Jung's avatar
Ralf Jung committed
102
\newcommand{\rss}{R}
103 104 105 106 107 108

\newcommand{\pres}{\pi}
\newcommand{\wld}{w}
\newcommand{\ghostRes}{g}

%% Various pieces of syntax
Ralf Jung's avatar
Ralf Jung committed
109 110
\newcommand{\wsat}[3]{#1 \models_{#2} #3}
\newcommand{\wsatpre}{\textdom{pre-wsat}}
111 112 113 114 115 116 117 118

\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}}
Ralf Jung's avatar
Ralf Jung committed
119
\newcommand{\latertinj}{\textlog{next}}
120 121 122 123 124 125 126 127

\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
Ralf Jung's avatar
Ralf Jung committed
128
\newcommand{\SProp}{\textdom{SProp}}
129
\newcommand{\UPred}{\textdom{UPred}}
Ralf Jung's avatar
Ralf Jung committed
130 131
\newcommand{\mProp}{\textdom{Prop}} % meta-level prop
\newcommand{\iProp}{\textdom{iProp}}
Ralf Jung's avatar
Ralf Jung committed
132
\newcommand{\iPreProp}{\textdom{iPreProp}}
Ralf Jung's avatar
Ralf Jung committed
133
\newcommand{\Wld}{\textdom{Wld}}
Ralf Jung's avatar
Ralf Jung committed
134
\newcommand{\Res}{\textdom{Res}}
135 136 137 138
\newcommand{\State}{\textdom{State}}
\newcommand{\Val}{\textdom{Val}}
\newcommand{\Loc}{\textdom{Loc}}
\newcommand{\Expr}{\textdom{Expr}}
139 140
\newcommand{\Var}{\textdom{Var}}
\newcommand{\ThreadPool}{\textdom{ThreadPool}}
141

Ralf Jung's avatar
Ralf Jung committed
142 143
\newcommand{\cofe}{T}
\newcommand{\cofeB}{U}
Ralf Jung's avatar
Ralf Jung committed
144
\newcommand{\COFEs}{\mathcal{COFE}} % category of COFEs
145
\newcommand{\iFunc}{\Sigma}
Ralf Jung's avatar
Ralf Jung committed
146
\newcommand{\fix}{\textdom{fix}}
147 148 149 150 151 152 153

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CMRA (RESOURCE ALGEBRA) SYMBOLS & NOTATION & IDENTIFIERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\textmon}[1]{\textsc{#1}}

\newcommand{\monoid}{M}
Ralf Jung's avatar
Ralf Jung committed
154
\newcommand{\mval}{\mathcal{V}}
155 156 157 158 159 160 161

\newcommand{\melt}{a}
\newcommand{\meltB}{b}
\newcommand{\meltC}{c}
\newcommand{\melts}{A}
\newcommand{\meltsB}{B}

Ralf Jung's avatar
Ralf Jung committed
162 163
\newcommand{\f}{\mathrm{f}} % for "frame"

164
\newcommand{\munit}{\varepsilon}
Ralf Jung's avatar
Ralf Jung committed
165
\newcommand{\mcore}[1]{{\mid}#1{\mid}} % using "|" here makes LaTeX diverge. WTF.
166
\newcommand{\mnocore}\top
167 168 169
\newcommand{\mtimes}{\mathbin{\cdot}}

\newcommand{\mupd}{\rightsquigarrow}
170
\newcommand{\mincl}[1][]{\ensuremath{\mathrel{\stackrel{#1}{\preccurlyeq}}}}
171

Ralf Jung's avatar
Ralf Jung committed
172
\newcommand{\CMRAs}{\mathcal{CMRA}} % category of CMRAs
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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}
188
\newcommand{\typeB}{\sigma}
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

\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}

204 205 206 207 208 209 210
% pure propositions
\newcommand{\pprop}{\phi}
\newcommand{\ppropB}{\psi}

\newcommand{\pred}{\varPhi}
\newcommand{\predB}{\Psi}
\newcommand{\predC}{\Zeta}
211 212 213 214 215 216

\newcommand{\gname}{\gamma}
\newcommand{\iname}{\iota}

\newcommand{\mask}{\mathcal{E}}
\newcommand{\namesp}{\mathcal{N}}
Ralf Jung's avatar
Ralf Jung committed
217
\newcommand{\namecl}[1]{{#1^{\kern0.2ex\uparrow}}}
218 219

%% various pieces of Syntax
220
\def\MU #1.{\mu\spac #1.\spac}%
221 222 223
\def\Lam #1.{\lambda #1.\spac}%

\newcommand{\proves}{\vdash}
Ralf Jung's avatar
Ralf Jung committed
224
\newcommand{\provesIff}{\mathrel{\dashv\vdash}}
225

226
\newcommand{\wand}{\mathrel{-\!\!*}}
227 228

% oh my... I have to wrap the "-" in a \mathrm, otherwise all hell breaks lose...
229
\newcommand{\fmapsto}[1][]{\xmapsto{#1}}
230 231 232
\newcommand{\gmapsto}{\hookrightarrow}%
\newcommand{\fgmapsto}[1][\mathrm{-}]{\xhookrightarrow{#1}}%

233
\NewDocumentCommand\wpre{m O{} m}%
234
  {\textlog{wp}_{#2}\spac#1\spac{\left\{#3\right\}}}
235

236 237 238
\newcommand{\later}{\mathop{\triangleright}}
\newcommand{\always}{\mathop{\Box}}
\newcommand{\pure}{\mathop{\blacksquare}}
239 240 241 242 243 244 245 246

%% 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$};
247
		\node[rectangle,inner sep=0.8pt,outer sep=0.2pt,anchor=base] (m) {${\,#2\,}\mathstrut$};
248 249 250 251 252
		\draw[#1,boxedassert_border] ($(m.south west) + (0,0.65pt)$) rectangle ($(m.north east) + (0, 0.7pt)$);
	}\IfNoValueF{#3}{^{\,#3}}%
}
\newcommand*{\knowInv}[2]{\boxedassert{#2}[#1]}
\newcommand*{\ownGhost}[2]{\boxedassert[densely dashed]{#2}[#1]}
Ralf Jung's avatar
Ralf Jung committed
253 254
\newcommand*{\ownM}[1]{\textlog{Own}(#1)}
\newcommand*{\ownPhys}[1]{\textlog{Phy}(#1)}
255 256 257 258 259 260 261 262 263 264 265 266

%% View Shifts
\NewDocumentCommand \vsGen {O{} m O{}}%
  {\mathrel{%
    \ifthenelse{\equal{#3}{}}{%
      % Just one mask, or none
      {#2}_{#1}%
    }{%
      % Two masks
      \tensor*[^{#1}]{#2}{^{#3}}
    }%
  }}%
267
\NewDocumentCommand \vs {O{} O{}} {\kern-0.5ex\vsGen[#1]{\Rrightarrow}[#2]}
Ralf Jung's avatar
Ralf Jung committed
268
\NewDocumentCommand \vsL {O{} O{}} {\kern-0.5ex\vsGen[#1]{\Lleftarrow}[#2]}
269
\NewDocumentCommand \vsE {O{} O{}} %
270
  {\kern-0.5ex\vsGen[#1]{\Lleftarrow\!\!\!\Rrightarrow}[#2]}
271 272
\NewDocumentCommand \pvs {O{} O{}} {\mathord{\vsGen[#1]{{\mid\kern-0.4ex\Rrightarrow\kern-0.25ex}}[#2]\kern0.2ex}}

Ralf Jung's avatar
Ralf Jung committed
273 274 275 276 277 278 279
\newcommand\vsWand{\kern0.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.2em}}$};
	\node at (0.4, -0.095) (base) {};
}{\vphantom{\Rrightarrow}}\kern-1.2ex}
\NewDocumentCommand \vsW {O{} O{}} {\vsGen[#1]{\vsWand}[#2]}

280
% for now, the update modality looks like a pvs without masks.
281
\NewDocumentCommand \upd {} {\mathop{\mid\kern-0.4ex\Rrightarrow\kern-0.25ex}}
282

283 284 285 286 287 288 289 290 291 292 293

%% Hoare Triples
\newcommand*{\hoaresizebox}[1]{%
  \hbox{$\mathsurround=0pt{#1}\mathstrut$}}
\newcommand*{\hoarescalebox}[2]{%
  \hbox{\scalerel*[1ex]{#1}{#2}}}
\newcommand{\triple}[5]{%
  \setbox0=\hoaresizebox{{#3}{#5}}%
  \setbox1=\hoarescalebox{#1}{\copy0}%
  \setbox2=\hoarescalebox{#2}{\copy0}%
  \copy1{#3}\copy2%
294
  \; #4 \;%
295 296 297 298 299 300 301 302 303 304
  \copy1{#5}\copy2}

\newcommand{\bracket}[4][]{%
  \setbox0=\hbox{$\mathsurround=0pt{#1}{#4}\mathstrut$}%
  \scalerel*[1ex]{#2}{\copy0}%
  {#4}%
  \scalerel*[1ex]{#3}{\copy0}}
% \curlybracket[other] x
\newcommand{\curlybracket}[2][]{\bracket[{#1}]\{\}{#2}}
\newcommand{\anglebracket}[2][]{\bracket[{#1}]\langle\rangle{#2}}
305 306 307 308 309

\NewDocumentCommand \hoare {m m m O{}}{
	\curlybracket{#1}\spac #2 \spac \curlybracket{#3}_{#4}%
}

310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
% \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)}
329
\newcommand{\persistent}[1]{\textlog{persistent}(#1)}
330
\newcommand{\physatomic}[1]{\textlog{atomic}($#1$)}
331 332 333 334 335 336 337 338 339
\newcommand{\infinite}{\textlog{infinite}}

\newcommand{\Prop}{\textlog{Prop}}
\newcommand{\Pred}{\textlog{Pred}}

\newcommand{\TRUE}{\textlog{True}}
\newcommand{\FALSE}{\textlog{False}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ralf Jung's avatar
Ralf Jung committed
340
% GENERIC LANGUAGE SYNTAX AND SEMANTICS
341 342 343 344 345 346
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\expr}{e}
\newcommand{\val}{v}
\newcommand{\valB}{w}
\newcommand{\state}{\sigma}
\newcommand{\step}{\ra}
347 348
\newcommand{\hstep}{\ra_{\mathsf{h}}}
\newcommand{\tpstep}{\ra_{\mathsf{tp}}}
349
\newcommand{\lctx}{K}
350
\newcommand{\Lctx}{\textdom{Ctx}}
351

352 353
\newcommand{\toval}{\mathrm{expr\any to\any val}}
\newcommand{\ofval}{\mathrm{val\any to\any expr}}
354 355
\newcommand{\atomic}{\mathrm{atomic}}
\newcommand{\red}{\mathrm{red}}
356 357 358 359 360 361
\newcommand{\Lang}{\Lambda}

\newcommand{\tpool}{T}

\newcommand{\cfg}[2]{{#1};{#2}}

362 363
\def\fill#1[#2]{#1 {[}\, #2\,{]} }

364 365 366 367
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STANDARD DERIVED CONSTRUCTIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Ralf Jung's avatar
Ralf Jung committed
368 369 370
\newcommand{\unittt}{()}
\newcommand{\unit}{1}

371 372
% Agreement
\newcommand{\agm}{\ensuremath{\textmon{Ag}}}
Ralf Jung's avatar
Ralf Jung committed
373
\newcommand{\aginj}{\textlog{ag}}
374 375 376 377 378 379

% Fraction
\newcommand{\fracm}{\ensuremath{\textmon{Frac}}}

% Exclusive
\newcommand{\exm}{\ensuremath{\textmon{Ex}}}
Ralf Jung's avatar
Ralf Jung committed
380
\newcommand{\exinj}{\textlog{ex}}
381 382 383 384 385 386 387 388 389

% Auth
\newcommand{\authm}{\textmon{Auth}}
\newcommand{\authfull}{\mathord{\bullet}\,}
\newcommand{\authfrag}{\mathord{\circ}\,}

\newcommand{\AuthInv}{\textsf{AuthInv}}
\newcommand{\Auth}{\textsf{Auth}}

Ralf Jung's avatar
Ralf Jung committed
390 391 392 393 394
% Sum
\newcommand{\csumm}{\mathrel{+_{\!\bot}}}
\newcommand{\cinl}{\textsf{inl}}
\newcommand{\cinr}{\textsf{inr}}

Ralf Jung's avatar
Ralf Jung committed
395 396 397 398 399 400
% One-Shot
\newcommand{\oneshotm}{\ensuremath{\textmon{OneShot}}}
\newcommand{\ospending}{\textlog{pending}}
\newcommand{\osshot}{\textlog{shot}}

% STSs
401 402
\newcommand{\STSCtx}{\textlog{StsCtx}}
\newcommand{\STSSt}{\textlog{StsSt}}
403 404 405
\newcommand{\STSclsd}{\textlog{closed}}
\newcommand{\STSauth}{\textlog{auth}}
\newcommand{\STSfrag}{\textlog{frag}}
406 407 408
\newcommand{\STSS}{\mathcal{S}} % states
\newcommand{\STST}{\mathcal{T}} % tokens
\newcommand{\STSL}{\mathcal{L}} % labels
409
\newcommand{\stsstep}{\ra}
410
\newcommand{\ststrans}{\ra^{*}}%	the relation relevant to the STS rules
411 412
\newcommand{\stsfstep}[1]{\xrightarrow{#1}}
\newcommand{\stsftrans}[1]{\stsfstep{#1}^{*}}
413 414 415 416 417

\tikzstyle{sts} = [->,every node/.style={rectangle, rounded corners, draw, minimum size=1.2cm, align=center}]
\tikzstyle{sts_arrows} = [arrows={->[scale=1.5]},every node/.style={font=\sffamily\small}]

%% Stored Propositions
418
\newcommand{\mapstoprop}{\mathrel{\kern-0.5ex\tikz[baseline=(m)]{\node at (0,0) (m){}; \draw[line cap=round] (0,0.16) -- (0,-0.004);}\kern-1.5ex\Ra}}
419 420

\endinput
421