A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Happened-Before Relation and Causal Ordering

Research Depth 96 in the knowledge graph ☐ I know this ☆ Set as goal
28topics build on this
362prerequisites beneath it
See this on the map →
Logical Clocks and Event OrderingVector Clocks and Capturing Causality+1 more→→Causal ConsistencyConsistency Models in Distributed Systems+2 more
causality ordering logical-clocks partial-order

Core Idea

The happened-before relation (→) defines a partial order on events: event A happened before event B if A caused B (through message exchange or local sequencing). This relation is the foundation for reasoning about distributed computations without requiring synchronized physical clocks, and it distinguishes causally-dependent events from concurrent ones.

How It's Best Learned

Draw message diagrams with labeled events and identify the partial order. Use Lamport timestamps and vector clocks to detect causality. Understand that concurrency (neither A→B nor B→A) means events can be ordered arbitrarily without violating causality.

Common Misconceptions

Explainer

From your work with Lamport timestamps and vector clocks, you have the tools to assign logical timestamps to events. The happened-before relation is the conceptual framework that gives those tools their meaning. Defined by Leslie Lamport in 1978, it captures the idea of potential causality in a distributed system: event A happened before event B (written A → B) if A could have influenced B. This is a precise, formal replacement for the intuitive but unreliable notion of "A occurred earlier than B in real time."

The relation is defined by three rules. First, if A and B are events in the same process and A occurs before B in that process's local execution order, then A → B. Second, if A is the sending of a message and B is the receipt of that same message by another process, then A → B — because the send necessarily precedes the receive. Third, the relation is transitive: if A → B and B → C, then A → C. These three rules — local ordering, message causality, and transitivity — are the only ways to establish happened-before. If none of these chains connect two events, they are concurrent (written A ‖ B), meaning neither could have caused the other, regardless of what wall-clock time says.

This is why the relation is a partial order rather than a total order. In a total order, every pair of events is comparable — one always comes before the other. In the happened-before partial order, concurrent events are genuinely incomparable. Two users on different continents editing different documents at the "same time" have no causal connection, and the system need not — and should not — impose an artificial ordering between them. Lamport timestamps give you a total order that is *consistent with* happened-before (if A → B then L(A) < L(B)), but the converse is not true: L(A) < L(B) does not mean A → B. Vector clocks are more powerful because they capture the full partial order: V(A) < V(B) if and only if A → B.

The practical consequence is that any distributed system that needs to reason about causality — whether for consistent snapshots, causal message delivery, conflict detection in replicated data, or debugging concurrent operations — must track the happened-before relation rather than relying on synchronized physical clocks. Physical clocks drift, have finite precision, and can disagree across machines. The happened-before relation depends only on the actual communication pattern between processes, making it robust to clock skew and physically meaningful: it tells you exactly which events could have influenced which others, and nothing more.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Kernel Architecture and OS Structure → System Calls and User/Kernel Mode → Processes and the Process Control Block → Logical Clocks and Event Ordering → Vector Clocks and Capturing Causality → Happened-Before Relation and Causal Ordering

Longest path: 97 steps · 362 total prerequisite topics

Prerequisites (3)

Leads To (4)