title: Logical Clocks: Lamport Timestamps
body: <p>I am currently trying to understand Lamport timestamps. Consider two processes <strong>P1</strong> (producing events <strong>a1</strong>, <strong>a2</strong>,...) and <strong>P2</strong> (producing events <strong>b1</strong>, <strong>b2</strong>,...). Let <strong>C(e)</strong> denote the Lamport timestamp associated with event an <strong>e</strong>. I created timestamps for each event as described in the <a href="https://en.wikipedia.org/wiki/Lamport_timestamps" rel="noreferrer">Wikipedia article about Lamport timestamps</a>:</p>
  
  <p><img src="https://i.stack.imgur.com/ty7wg.png" alt="enter image description here"></p>
  
  <p>According to Wikipedia, the following relation is true for all events <strong>e1</strong>, <strong>e2</strong>:</p>
  
  <p><strong>If e1 happened before e2, then C(e1) &lt; C(e2).</strong></p>
  
  <p>Let's look at <strong>a1</strong> and <strong>b2</strong>. Clearly <strong>a1</strong> happened before <strong>b2</strong>, and since  <strong>C(a1) = 1</strong> and <strong>C(b2) = 3</strong>, the relation holds true: <strong>C(a1) &lt; C(b2)</strong>.</p>
  
  <p><strong>Problem</strong>: The relation doesn't hold true for <strong>b3</strong> and <strong>a3</strong>. Obviously, <strong>b3</strong> happened before <strong>a3</strong>. However, <strong>C(b3) = 4</strong> and <strong>C(a3) = 3</strong>. So <strong>C(b3) &lt; C(a3)</strong> does <strong>not</strong> apply.</p>
  
  <p>What did I misunderstand? Help is much appreciated!</p>