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 moreAbstract 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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesFinite State Machines (FSMs)Deterministic Finite Automata (DFA)Nondeterministic Finite Automata (NFA)Two-Way Finite AutomataNFA to DFA Conversion (Subset Construction)DFA Properties and Minimization AlgorithmsRegular Languages: Definition and CharacterizationContext-Free Grammars (CFGs)Context-Free Grammar Properties and AmbiguityParse Trees, Derivations, and Ambiguity in CFGsContext-Free Grammars in Compiler DesignCompiler Phases and OrganizationGrammar Design for CompilationDomain-Specific Language Design and ImplementationProgramming Language Semantics

Longest path: 93 steps · 428 total prerequisite topics

Prerequisites (3)

Leads To (6)