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

Programming Language Semantics

Research Depth 92 in the knowledge graph ☐ I know this ☆ Set as goal
25topics build on this
428prerequisites beneath it
See this on the map →
Lambda Calculus FoundationsContext-Free Grammars (CFGs)+1 more→→Abstract InterpretationFunctional Programming Paradigm+4 more
semantics formal-methods language-design

Core Idea

Semantics defines what a program means—its runtime behavior. Formal semantics uses denotational (functions mapping programs to meanings), operational (step-by-step execution rules), or axiomatic (assertions about properties) approaches. These frameworks allow compilers to reason about correctness and optimization validity.

Explainer

A grammar tells you whether `x = 3 + y` is a syntactically valid program, but it says nothing about what the program *does*. Programming language semantics fills that gap — it is the formal study of program meaning. If syntax is the grammar of sentences, semantics is what those sentences actually say. Your background in lambda calculus gives you the right foundation here, because lambda calculus is itself a minimal programming language with precisely defined semantics, and much of formal semantics extends its ideas.

Operational semantics is the most concrete approach. It defines meaning by specifying evaluation rules — literally, "given this expression in this state, the next step produces that expression in that state." For example, an operational rule might say: to evaluate `if true then e1 else e2`, evaluate `e1`. These rules resemble an interpreter specification. There are two flavors: small-step (structural) operational semantics breaks evaluation into individual reduction steps, making it easy to reason about intermediate states and non-termination. Big-step (natural) semantics jumps directly from an expression to its final value, which is closer to how you intuitively think about evaluation but hides intermediate computation.

Denotational semantics takes a more mathematical approach. Instead of describing how a program executes step by step, it maps each program to a mathematical object — its "denotation." A variable maps to its value in an environment, a function maps to a mathematical function from inputs to outputs, and a while loop maps to a fixed point. This builds directly on the function-as-value idea from lambda calculus. The advantage is compositionality: the meaning of a compound expression is built entirely from the meanings of its parts, which makes it possible to prove program equivalences algebraically.

Axiomatic semantics, most associated with Hoare logic, defines meaning through the properties you can prove about a program. A Hoare triple `{P} S {Q}` says: if precondition P holds before executing statement S, then postcondition Q holds after. For instance, `{x > 0} x = x - 1 {x >= 0}`. This approach is less about what the program computes and more about what guarantees it provides, making it the foundation for formal verification. For compiler writers, all three frameworks matter: operational semantics guides interpreter and code generator design, denotational semantics justifies optimization (two expressions with the same denotation can be freely substituted), and axiomatic semantics validates that transformations preserve program correctness.

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 → Finite State Machines (FSMs) → Deterministic Finite Automata (DFA) → Nondeterministic Finite Automata (NFA) → Two-Way Finite Automata → NFA to DFA Conversion (Subset Construction) → DFA Properties and Minimization Algorithms → Regular Languages: Definition and Characterization → Context-Free Grammars (CFGs) → Context-Free Grammar Properties and Ambiguity → Parse Trees, Derivations, and Ambiguity in CFGs → Context-Free Grammars in Compiler Design → Compiler Phases and Organization → Grammar Design for Compilation → Domain-Specific Language Design and Implementation → Programming Language Semantics

Longest path: 93 steps · 428 total prerequisite topics

Prerequisites (3)

Leads To (6)