Table of Contents
This book is an introduction to programming language theory using
Dependent Haskell (-XDependentTypes in
Tritlo/ghc, branch dependent-haskell),
adapted from Philip Wadler, Wen Kokke, and Jeremy G. Siek's
Programming Language Foundations in Agda
(dev branch, commit c088569657,
CC BY 4.0).
Every plain Haskell code block in this book is extracted into a standalone
.hs module and checked with GHC's Core Lint and STG Lint. Where Dependent
Haskell cannot yet express a PLFA theorem directly without workarounds,
we mark it with a [WIP NOTICE] and publish a minimal reproducer for the
compiler team.
Comments, bug reports, and pull requests are welcome on GitHub.
Front matter
- Preface: Propositions as Types, totality discipline, and yardstick goals
- Setup: Compiling
Tritlo/ghc,shell.nix, flags, GHCi, and Hakyll preview
Part 1: Logical Foundations
- Naturals: Natural numbers,
times,monus,pow,BinChecked - Induction: Proof by induction (
+-assoc,HaskLib.rewrite,+-comm,cong/+-rearrange,+-swap,*-comm,0∸n≡0,∸-+-assoc,+*^,Bin-laws) Checked - Relations: Inductive relations (
_≤_,_<_, trichotomy,DiffWitness,Even/Odd, canonicalOne/Canbijection) Checked - Equality: Equality,
RequiredTypeArgumentschains,substP @Even, and Leibniz equality with%Uand inline type lambdas Checked - Isomorphism: Polymorphic
_≃_(Iso,isoRefl,isoSym,isoTrans),_≲_(Embed,embedRefl,embedTrans,binEmbedding), and_⇔_(Iff) Checked - Connectives: Conjunction, disjunction, truth, falsehood, polymorphic
prodCommIso/sumCommIso, currying, distributivity, exponential laws Checked - Negation: Intuitionistic negation, De Morgan, order-negation laws, and classical equivalences (EM ⇔ DNE ⇔ Peirce ⇔ ImpOr ⇔ DeMorganNot) Checked
- Quantifiers: Erased
Exists, retainedSigma(some), andEven/Oddexistential witnesses Checked - Decidable: Negation, decidable equality/ordering/parity/
Bin,Reflects, and inlineSigma(plusExists) Checked - Lists: Prelude
List a,(++),map,HaskLiblength laws,shunt,rev/revAppend/revInvolutive/shuntRev/reverses,downFrom,foldrPlusSeed/foldrPlusAppend(GHC.Internal.List.foldr), matchability-polyAll/Any/In,notAnyIffAllNot,allToIn/inToAll,anyIsoWitness(Iso (Any p xs) (AnyWitness p xs)),decAll/decAny/decInChecked
Part 2: Programming Language Foundations
- Lambda: Simply-typed lambda calculus syntax, values, same-module
substTerm, reduction (Step/Steps), and typing Checked - Properties: Canonical forms, Progress, Determinism, 8-constructor Preservation,
preserveSteps, and verified evaluatorevalChecked - DeBruijn: Intrinsically-typed terms, renaming, substitution, promoted
Value,checkValue, 8-rule functionalStep(substSingle), and complete unconditionalprogressChecked - Inference: Sound & complete bidirectional
Dec-based STLC type inference (synthesize,inherit,eraseSynth/eraseInherit,synthUnique, plusinfer/check) Checked - Untyped: Well-scoped untyped lambda calculus, sound relational
SubstAtU, promotedNeutral/Normal/BetaStep, and constructive normal-orderstepNormal/evalNormalChecked - More: Extended STLC (
let,Unit,Prod,Sum,Void,List),substSingle/substDouble, 27-rule functionalStep, and complete 19-branchprogressChecked - Bisimulation: Relating
letto(λx. n) m(SimRel,simRefl/simTrans, bidirectionalsimValue/simValueInv,valNoStep, 20-constructorsimRename, 20-constructorsimExt/simSubst, 27-rulesim&simInv,simSteps/simStepsInv) simRename/simSubst + 27-rule Bisim ✓ · SubstCompat WIP - BigStep: Call-by-name big-step semantics (
Env,Clos,EvalBig,evalDeterm,omegaDiverges, same-module functionalEvalFun(lookupEnv), unconditionalcbnToReduce) Checked - Substitution: σ-calculus simultaneous renaming & substitution combinators Algebra ✓ · Eqs WIP
- Confluence: Parallel reduction,
parRefl,betaToPar,parShift/parSubst,parDiamond, Strip Lemma, Par Confluence, unconditional Church-Rosser, anduniqueNormalFormChecked
Part 3: Denotational Semantics
- Denotational: Filter model (GADT
Value,Sub,dom/cod, nestedsubInvDist,subInv,arrSubArrInv,Denotes,envSubMono) Checked - Compositional: Semantic curry & application (
lamEquiv/lamCong,appEquiv/appCong),UCtx/plug, and fullcompositionalityChecked - Soundness: 100% unconditional weakening, strengthening, substitution, forward preservation, subject expansion, and
denotEquivStepsChecked - Adequacy:
decAboveFun,LogVLam/LogE, fullsubLogVLam, fullfundamental, unconditionaladequacyBigStep/adequacy/reduceToCbn, andomegaNotAboveFunBig-Step ✓ - ContextualEquivalence: Open-term
CtxEquiv(UCtx/plug), unconditionaldenotEqualCtxBigStep, unconditionaldenotEqualCtxEquiv, and unconditionalbetaCtxEquivChecked
Yardstick & Backmatter
- Yardstick Status: Full theorem-by-theorem ledger, HaskLib reuse, negative controls, and minimal compiler reproducers
- How to Cite & Licence: CC BY 4.0 licence and attribution to upstream PLFA