\( % Latex Preamble definitions here (mostly usepackage) \usepackage% %[dvipsnames] {xcolor} % make sure this is before the loading font packages \newcommand\hmmax{0} \newcommand\bmmax{0} \usepackage{amssymb} \usepackage{amsmath} \usepackage{mathtools} \usepackage %[dvipsnames] {graphicx} \usepackage{float} %\usepackage[numbers]{natbib} \usepackage[document]{ragged2e} % % enumitem doesn't seem to work with beamer %\usepackage[inline]{enumitem} \usepackage{wrapfig} \usepackage{stackrel} % extensible arrows \usepackage{extpfeil} % \usepackage{trfrac} \usepackage{amsthm} \usepackage{tikz} \usepackage{tikz-cd} \usepackage{tikz} \usepackage{tikz-qtree} \usetikzlibrary{automata, positioning, arrows, shapes.geometric} \usepackage{turnstile} \usepackage{comment} %https://tex.stackexchange.com/questions/21334/is-there-a-package-that-has-the-clockwise-gapped-circle-arrow-in-it % \usepackage{mathbx} \usepackage{datetime} \usepackage{datetime2} %% Also See %% http://u.cs.biu.ac.il/~tsaban/Pdf/LaTeXCommonErrs.pdf %% for general tips \usepackage{listings} \usepackage{subfigure} \usepackage{bm} \usepackage{amsfonts} %% - also included by amssymb \usepackage{mathpazo} %% - because the OP uses mathpazo, optional %\usepackage{tufte-latex} \usepackage{comment} \usepackage{mathtools} \usepackage{bussproofs} \usepackage{hyperref} %\usepackage{cleveref} \)
\( %% Your math definitions here % \newcommand{\alphaequiv}{{\underset{\raise 0.7em\alpha}{=}}} \newcommand{\yields}{\Rightarrow} \newcommand{\derives}{\overset{*}{\yields}} \newcommand{\alphaequiv}{=_{\alpha}} \newcommand{\tto}[2]{{\overset{#1}{\underset{#2}{\longrightarrow}}}} \newcommand{\transitsto}[2]{{\overset{#1}{\underset{#2}{\longrightarrow}}}} \newcommand{\xtransitsto}[2]{{\underset{#2}{\xrightarrow{#1}}}} \newcommand{\xtransitsfrom}[2]{{\underset{#2}{\xleftarrow{#1}}}} \newcommand{\xto}[2]{{\xtransitsto{#1}{#2}}} \newcommand{\xfrom}[2]{{\xtransitsfrom{#1}{#2}}} \newcommand{\xreaches}[2]{{\underset{#2}{\xtwoheadrightarrow{#1}}}} \newcommand{\reaches}[2]{{\underset{#2}{\xtwoheadrightarrow{#1}}}} %\newcommand{\reaches}[2]{{\overset{#1}{\underset{#2}{\twoheadrightarrow}}}} %\newcommand{\goesto}[2]{\transitsto{#1}{#2}} %\newcommand{\betareducesto}{{\underset{\beta}{\rightarrow}}} \newcommand{\betareducesto}{\rightarrow_{\beta}} %\newcommand{\etareducesto}{{\underset{\eta}{\rightarrow}}} \newcommand{\etareducesto}{\rightarrow_{\eta}} %\newcommand{\betaetareducesto}{{\underset{\beta\ \eta}{\rightarrow}}} \newcommand{\betaetareducesto}{\rightarrow_{\beta\eta}} \newcommand{\preducesto}{\rhd} \newcommand{\psimplifiesto}{\stackrel{\scriptstyle{*}}{\rhd}} \newcommand{\lreducesto}{\rightsquigarrow} \newcommand{\lsimplifiesto}{\stackrel{\scriptstyle{*}}{\lreducesto}} \newcommand{\rewritesto}{\hookrightarrow} \newcommand{\goesto}[1]{\stackrel{#1}{\rightarrow}} \newcommand{\xgoesto}[1]{\xrightarrow{#1}} \newcommand{\reducesto}{\stackrel{}{\rightarrow}} \newcommand{\simplifiesto}{\stackrel{\scriptstyle{*}}{\rightarrow}} \newcommand{\connected}[1]{\stackrel{#1}{\leftrightarrow}} \newcommand{\joins}{\downarrow} \newcommand{\evaluatesto}{\Longrightarrow} %\newcommand{\lit}[1]{\hbox{\sf{#1}}} \newcommand{\lit}[1]{{\sf{#1}}} \newcommand{\true}{\lit{true}} \newcommand{\false}{\lit{false}} \def\Z{\mbox{${\mathbb Z}$}} \def\N{\mbox{${\mathbb N}$}} \def\P{\mbox{${\mathbb P}$}} \def\R{\mbox{${\mathbb R}$}} \def\T{\mbox{${\mathbb T}$}} \newcommand{\Rp}{{\mathbb{R}}^+} \def\Bool{\mbox{${\mathbb B}$}} \def\Q{\mbox{${\mathbb Q}$}} \def\sA{\mbox{${\cal A}$}} \def\sB{\mbox{${\cal B}$}} \def\sC{\mbox{${\cal C}$}} \def\sD{\mbox{${\cal D}$}} \def\sF{\mbox{${\cal F}$}} \def\sG{\mbox{${\cal G}$}} \def\sL{\mbox{${\cal L}$}} \def\sP{\mbox{${\cal P}$}} \def\sM{\mbox{${\cal M}$}} \def\sN{\mbox{${\cal N}$}} \def\sR{\mbox{${\cal R}$}} \def\sS{\mbox{${\cal S}$}} \def\sO{\mbox{${\cal O}$}} \def\sT{\mbox{${\cal T}$}} \def\sU{\mbox{${\cal U}$}} \def\th{\mbox{$\widetilde{h}$}} \def\tg{\mbox{$\widetilde{g}$}} \def\tP{\mbox{$\widetilde{P}$}} \def\norm{\mbox{$\parallel$}} \def\osum{${{\bigcirc}}\!\!\!\!{\rm s}~$} \def\pf{\noindent {\bf Proof}~~} \def\exec{\mathit{exec}} \def\Act{\mathit{A\!ct}} \def\Traces{\mathit{Traces}} \def\Spec{\mathit{Spec}} \def\uns{\mathit{unless}} \def\ens{\mathit{ensures}} \def\lto{\mathit{leads\!\!-\!\!to}} \def\a{\alpha} \def\b{\beta} \def\c{\gamma} \def\d{\delta} \def\sP{\mbox{${\cal P}$}} \def\sM{\mbox{${\cal M}$}} \def\sA{\mbox{${\cal A}$}} \def\sB{\mbox{${\cal B}$}} \def\sC{\mbox{${\cal C}$}} \def\sI{\mbox{${\cal I}$}} \def\sS{\mbox{${\cal S}$}} \def\sD{\mbox{${\cal D}$}} \def\sF{\mbox{${\cal F}$}} \def\sG{\mbox{${\cal G}$}} \def\sR{\mbox{${\cal R}$}} \def\tg{\mbox{$\widetilde{g}$}} \def\ta{\mbox{$\widetilde{a}$}} \def\tb{\mbox{$\widetilde{b}$}} \def\tc{\mbox{$\widetilde{c}$}} \def\tx{\mbox{$\widetilde{x}$}} \def\ty{\mbox{$\widetilde{y}$}} \def\tz{\mbox{$\widetilde{z}$}} \def\tI{\mbox{$\widetilde{I}$}} \def\norm{\mbox{$\parallel$}} \def\sL{\mbox{${\cal L}$}} \def\sM{\mbox{${\cal M}$}} \def\sN{\mbox{${\cal N}$}} \def\th{\mbox{$\widetilde{h}$}} \def\tg{\mbox{$\widetilde{g}$}} \def\tP{\mbox{$\widetilde{P}$}} \def\norm{\mbox{$\parallel$}} \def\to{\rightarrow} \def\ov{\overline} \def\gets{\leftarrow} \def\too{\longrightarrow} \def\To{\Rightarrow} %\def\points{\mapsto} %\def\yields{\mapsto^{*}} \def\un{\underline} \def\vep{$\varepsilon$} \def\ep{$\epsilon$} \def\tri{$\bigtriangleup$} \def\Fi{$F^{\infty}$} \def\Di{\Delta^{\infty}} \def\ebox\Box \def\emp{\emptyset} \def\leadsto{\rightharpoondown^{*}} \newcommand{\benum}{\begin{enumerate}} \newcommand{\eenum}{\end{enumerate}} \newcommand{\bdes}{\begin{description}} \newcommand{\edes}{\end{description}} \newcommand{\bt}{\begin{theorem}} \newcommand{\et}{\end{theorem}} \newcommand{\bl}{\begin{lemma}} \newcommand{\el}{\end{lemma}} % \newcommand{\bp}{\begin{prop}} % \newcommand{\ep}{\end{prop}} \newcommand{\bd}{\begin{defn}} \newcommand{\ed}{\end{defn}} \newcommand{\brem}{\begin{remark}} \newcommand{\erem}{\end{remark}} \newcommand{\bxr}{\begin{exercise}} \newcommand{\exr}{\end{exercise}} \newcommand{\bxm}{\begin{example}} \newcommand{\exm}{\end{example}} \newcommand{\beqa}{\begin{eqnarray*}} \newcommand{\eeqa}{\end{eqnarray*}} \newcommand{\bc}{\begin{center}} \newcommand{\ec}{\end{center}} \newcommand{\bcent}{\begin{center}} \newcommand{\ecent}{\end{center}} % \newcommand{\la}{\langle} % \newcommand{\ra}{\rangle} \newcommand{\bcor}{\begin{corollary}} \newcommand{\ecor}{\end{corollary}} \newcommand{\bds}{\begin{defns}} \newcommand{\eds}{\end{defns}} \newcommand{\brems}{\begin{remarks}} \newcommand{\erems}{\end{remarks}} \newcommand{\bxrs}{\begin{exercises}} \newcommand{\exrs}{\end{exercises}} \newcommand{\bxms}{\begin{examples}} \newcommand{\exms}{\end{examples}} \newcommand{\bfig}{\begin{figure}} \newcommand{\efig}{\end{figure}} \newcommand{\set}[1]{\{#1\}} \newcommand{\pair}[1]{\langle #1\rangle} \newcommand{\tuple}[1]{\langle #1\rangle} \newcommand{\size}[1]{| #1 |} \newcommand{\union}{\cup} \newcommand{\Union}{\bigcup} \newcommand{\intersection}{\cap} \newcommand{\Intersection}{\bigcap} \newcommand{\B}{\textbf{B}} %\newcommand{\be}[2]{\begin{equation} \label{#1} \tag{#2} \end{equation}} \newcommand{\abs}[1]{{\lvert}#1{\rvert}} \newcommand{\id}[1]{\mathit{#1}} \newcommand{\pfun}{\rightharpoonup} \newcommand{\ra}[1]{\kern-1.5ex\xrightarrow{\ \ #1\ \ }\phantom{}\kern-1.5ex} \newcommand{\ras}[1]{\kern-1.5ex\xrightarrow{\ \ \smash{#1}\ \ }\phantom{}\kern-1.5ex} \newcommand{\da}[1]{\bigg\downarrow\raise.5ex\rlap{\scriptstyle#1}} \newcommand{\ua}[1]{\bigg\uparrow\raise.5ex\rlap{\scriptstyle#1}} % \newcommand{\lift}[1]{#1_{\bot}} \newcommand{\signal}[1]{\tilde{#1}} \newcommand{\ida}{\stackrel{{\sf def}}{=}} \newcommand{\eqn}{\doteq} \newcommand{\deduce}[1]{\sststile{#1}{}} %% These don't sit very well with MathJax %% so we don't plan to use theorem like environments %% in org documents. %% instead we plan to use headings with %% 1. property drawers with a CLASS property identifying %% the environment %% 2. A tag with the same name as the CLASS property %% In LaTeX export, these turn into (sub)sections. %% See http://u.cs.biu.ac.il/~tsaban/Pdf/LaTeXCommonErrs.pdf %% \newtheorem{prop}[thm]{Proposition} %% \theoremstyle{plain}%default %% \newtheorem{theorem}{Theorem}[section] %% \newtheorem{lemma}{Lemma}[section] %% \newtheorem{corollary}{Corollary}[section] %% \newtheorem{definition}{Definition}[section] %% \newtheorem{remark}{Remark}[section] %% \newtheorem{example}{Example}[section] %% \newtheorem{exercise}{Exercise}[section] \newcommand{\less}[1]{#1_{<}} \newcommand{\pfn}{\rightharpoonup} \newcommand{\ffn}{\stackrel{{\sf fin}}{\rightharpoonup}} \newcommand{\stkout}[1]{\ifmmode\text{\sout{\ensuremath{#1}}}\else\sout{#1}\fi} % Caution: Not supported by MathJax! % ---------------------------------- % \DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39} % \usepackage{amsfonts} %% <- also included by amssymb % \DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39} \usepackage{mathpazo} %% <- because the OP uses mathpazo, optional \newcommand{\mbf}[1]{\mathbf{#1}} \newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil} \newcommand{\rel}{\twoheadrightarrow} \newcommand{\map}{\rightarrow} %\newcommand{\fixed}{\boldsymbol{\circlearrowleft}} \newcommand{\terminal}{\not\xto{}{}} \newcommand{\fixed}{\bm\circlearrowleft} \newcommand{\imp}{\rightarrow} \newcommand{\dimp}{\leftrightarrow} % double implication \newcommand{\lequiv}{\Longleftrightarrow} % logical equivalence \newcommand{\limplies}{\Rightarrow} \newcommand{\lxor}{\veebar} \)
UP | HOME

POPL Lecture notes: PARLANG – a parallel interlude

Table of Contents

Changelog

UNNUMBERED: notoc
[2022-10-06 Thu]
Added definition of lexicographic order. Added proofs of termination and unique normal form for statements.

1 Introduction

The purpose of this short excursion is to investigate the behaviour of PARLANG, small parallel language, while we warm up for studying the confluence property for λ calculus. The language is a small, but with sufficiently interesting behaviour that allows us to conclude that it is a language that does not exhibit confluence. Recall that confluence is a property that says that if an expression simplifies to two expressions, then those two expressions further simplify to some common third expression. In PARLANG, a program's execution may result in multiple, possible answers. Answers depend on which of the permitted orders of execution are taken by the system.

In languages like PARLANG, non-confluence is a feature of the semantics. It is used to model phenomena like race conditions.

2 Abstract Syntax

The language consists of statements, variables and numbers:

\begin{align*} s ::= & & \scriptstyle{STMT} & \qquad \mbox{Statement}\\ & \textbf{done} & \scriptstyle{DONE} & \qquad \mbox{Done}\\ & x:=n & \scriptstyle{SET} & \qquad \mbox{Assignment}\\ & s; s & \scriptstyle{SEQ} & \qquad \mbox{Sequential}\\ & s | s & \scriptstyle{PAR} & \qquad \mbox{Parallel}\\ \\ x ::= & & \scriptstyle{IDENT} & \qquad \mbox{Identifiers}\\ \\ n ::= & & \scriptstyle{NUM} & \qquad \mbox{Numbers}\\ \\ \end{align*}

The language is small; there is no lexical scoping, if, functions, or primitive operations on numbers.

3 Stores

Stores map identifiers to values.

\begin{align*} G : \id{IDENT} \rightarrow \id{NUM} & \qquad \qquad \scriptstyle{STORE}\\ \end{align*}

4 PARLANG abstract machine configurations

In the abstract PARLANG machine, a program is `executed' in the context of a store. A store is a map from identifiers to values.

A configuration is a pair \(G,s\) where \(G\) is a store and \(s\) is a statement.

5 Rewrite Rules

\begin{align*} {G,x:=n \rewritesto \set{x:n}G, \textbf{done}}\qquad \scriptstyle{ASSGN}\\ \\ {G,(\textbf{done}; s)\rewritesto G,s}\qquad \scriptstyle{SEQ-DONE}\\ \\ {G,(s_1\ |\ s_2)\rewritesto G,(s_1;s_2)}\qquad \scriptstyle{PAR-1}\\ \\ {G,(s_1\ |\ s_2)\rewritesto G,(s_2;s_1)}\qquad \scriptstyle{PAR-2} \end{align*}

6 Reduction

\begin{align*} \frac{G,s \rewritesto G',s'}{G,s\reducesto G',s'}\qquad \scriptstyle{REWRITE}\\ \\ \frac{G,s_1\reducesto G', s_1'}{G,(s_1; s_2)\reducesto G', (s_1'; s_2)}\qquad \scriptstyle{SEQ-COMP}\\ \\ \end{align*}

7 Lexicographic ordering

Let \((A, <)\) be a (strict) partial order. A relation \((A^*, \sqsubset)\) is a (strict) lexicographic order over \((A,<)\) defined as \(a\sqsubset b\) iff

  1. \(a\) is a proper prefix of \(b\), OR
  2. there exists elements \(x,y\in A\) and strings \(p,q,r\in A^*\) such that
    • \(a=pxq\)
    • \(b=pyr\)
    • \(x < y\)

8 Normal forms, termination and non-confluence

8.1 Lemma (Termination): The PARLANG reduction system \(\goesto{}\) is terminating.

8.1.1 Proof

For a statement \(s\), define the following:

  • 1. \(\id{parsym}(s)\): the number of `|' symbols in \(s\).
  • 2. \(\id{seqsym}(s)\): the number of `;' symbols in \(s\).
  • 3. \(\id{setsym}(s)\): the number of `:=' symbols in \(s\).
  • 4. \(\id{donesym}(s)\): the number of \textbf{done} symbols in \(s\).

For any \(s\in \id{Stmt}\), let \(|s|: \N^4\) be defined as

\[|s| = \pair{\id{parsym}(s), \id{seqsym}(s), \id{setsym}, \id{donesym}(s)}\]

Examples:

  • 1. \(|(x:=5 | \textbf{done})| = [1, 0, 1, 0]\)
  • 2. \(|(\textbf{done} ; \textbf{done})| = [0, 0, 0, 2]\)
  • 3. \(|((x:=4; \textbf{done}) | (x:=3 | y:=2))| = [1, 1, 3, 1]\)

Now, let \((\N^4, \sqsubset)\) be the subset of the lexicographic ordering over the total ordering \((\N, <)\). Clearly, \((\N^4, \sqsubset)\) is a strict well-ordering (a strict total order with every subset having a least element) and hence well-founded.

To show that \(\goesto{}\) terminates, we show the following:

\[ \text{if}\ (G,s) \goesto{} (G', s'), \text{then}\ |s'| \sqsubset |s| \]

In each case, we verify that a reduction reduces the size of the statement.

Case REWRITE: Then \((G,s)\rewritesto{} (G',s')\) for some stores \(G,G'\).

  • 1. case ASSGN: \(s=\ (x:=n)\): Then \(s' = \textbf{done}\). and \([0,0,0,1] = |s'| \sqsubset |s| = [0,0,1,0]\).
  • 2. case SEQ-DONE: \(s=\textbf{done}; s'\). If \(s=[i,j,k,l]\) where \(l>0\) and \(j>0\), then \(|s'|=(i, j-1, k, l-1)\). Clearly, \(|s'| \sqsubset |s|\).
  • 3. cases PAR-1 and PAR-2: Exercise.

Case SEQ-COMP: Left as an exercise.

QED.

8.2 Exercise (non-confluence)

Show that \(\set{x:1} (x:=3\ | \ x:=4)\) simplifies to any of the following: \(\set{x:3}, \textbf{done}\) or \(\set{x:4}, \textbf{done}\).

8.3 Derived reduction relation \(\xto{}{S}\)

8.3.1 Rewrite rules

\begin{align*} {x:=n \rewritesto \textbf{done}}\qquad \scriptstyle{ASSGN'}\\ \\ {\textbf{done}; s\rewritesto s}\qquad \scriptstyle{SEQ-DONE'}\\ \\ {s_1\ |\ s_2\rewritesto s_1;s_2}\qquad \scriptstyle{PAR-1'}\\ \\ {s_1\ |\ s_2\rewritesto s_2;s_1}\qquad \scriptstyle{PAR-2'} \end{align*}

8.3.2 Reduction rules

\begin{align*} \frac{s \rewritesto s'}{s\xto{}{S} s'}\qquad \scriptstyle{REWRITE'}\\ \\ \frac{s_1\xto{}{S} s_1'}{s_1; s_2\xto{}{S} s_1'; s_2}\qquad \scriptstyle{SEQ-COMP'}\\ \\ \end{align*}

\(\xto{}{S}\) is terminating since \(\goesto{}\) is.

Note that \(\textbf{done}\) is a normal form. We prove that for any statement \(s\), either \(s = \textbf{done}\), or \(s\xto{}{S}s'\) for some \(s'\). Since the reduction relation is terminating, it follows that every statement \(s\) simplifies to the normal form \(\textbf{done}\).

8.4 Lemma (Progress): Either \(s=\textbf{done}\) or \(s\xto{}{S}\)

8.4.1 Proof

The proof is by induction on the structure of \(s\):

  • 1. \(\textbf{done}\), so the proposition is trivially true
  • 2. \(s=(x:=n)\): Then we have
    • 2.1: \(s\rewritesto{} \textbf{done}\) (using \(\id{ASSIGN'}\))
    • 2.2: \(s\xto{}{S} \textbf{done}\) (from 2.1 using \(\id{REWRITE'}\))
  • 3. \(s=(s_1|s_2)\): Then we have the deduction
    • 3.1: \(s \rewritesto{} (s_1;s_2)\) (using \(\id{PAR-1'}\))
    • 3.2: \(s\xto{}{S} (s_1;s_2)\) (from 3.1 using \(\id{REWRITE'}\))
  • 4. \(s=(s_1;s_2)\): We apply the induction hypothesis on \(s_1\). This yields two cases:
    • a. \(s_1=\textbf{done}\): Then we have the deduction
      • 4.a.1: \(s\rewritesto{} s_2\) (using \(\id{DONE'}\))
      • 4.a.2: \(s\xto{}{S}s_2\) (from 4.a.1 using \(\id{REWRITE'}\))
    • b. \(s_1\xto{}{S}\): Then, we have the deduction
      • 4.b.1: \(s_1\xto{}{S}s'_1\) for some \(s'_1\)
      • 4.b.2: \(s_1;s_2\xto{}{S}(s'_1;s_2)\) (from 4.b.1 using \(\id{SEQ-COMP'}\))

QED.

8.5 Corollary (Unique Normal Form): Every statement \(s\) simplifies under \(\xto{}{S}\) to \(\textbf{done}\) and to no other statement.

8.5.1 Proof

This is a direct consequence of the Progress Lemma and the termination of \(\xto{}{S}\).

9 References and online resources

Spacek and Eremondi course slides on Pi calculus
The π calculus, used to model concurrency and communication is another example of a language that is not confluent.

Author: Venkatesh Choppella

Created: 2023-11-25 Sat 09:15

Validate