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, Bin Checked
  • 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, canonical One/Can bijection) Checked
  • Equality: Equality, RequiredTypeArguments chains, substP @Even, and Leibniz equality with %U and 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, retained Sigma (some), and Even/Odd existential witnesses Checked
  • Decidable: Negation, decidable equality/ordering/parity/Bin, Reflects, and inline Sigma (plusExists) Checked
  • Lists: Prelude List a, (++), map, HaskLib length laws, shunt, rev/revAppend/revInvolutive/shuntRev/reverses, downFrom, foldrPlusSeed/foldrPlusAppend (GHC.Internal.List.foldr), matchability-poly All/Any/In, notAnyIffAllNot, allToIn/inToAll, anyIsoWitness (Iso (Any p xs) (AnyWitness p xs)), decAll/decAny/decIn Checked

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 evaluator eval Checked
  • DeBruijn: Intrinsically-typed terms, renaming, substitution, promoted Value, checkValue, 8-rule functional Step (substSingle), and complete unconditional progress Checked
  • Inference: Sound & complete bidirectional Dec-based STLC type inference (synthesize, inherit, eraseSynth/eraseInherit, synthUnique, plus infer/check) Checked
  • Untyped: Well-scoped untyped lambda calculus, sound relational SubstAtU, promoted Neutral/Normal/BetaStep, and constructive normal-order stepNormal/evalNormal Checked
  • More: Extended STLC (let, Unit, Prod, Sum, Void, List), substSingle/substDouble, 27-rule functional Step, and complete 19-branch progress Checked
  • Bisimulation: Relating let to (λx. n) m (SimRel, simRefl/simTrans, bidirectional simValue/simValueInv, valNoStep, 20-constructor simRename, 20-constructor simExt/simSubst, 27-rule sim & simInv, simSteps/simStepsInv) simRename/simSubst + 27-rule Bisim ✓ · SubstCompat WIP
  • BigStep: Call-by-name big-step semantics (Env, Clos, EvalBig, evalDeterm, omegaDiverges, same-module functional EvalFun (lookupEnv), unconditional cbnToReduce) 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, and uniqueNormalForm Checked

Part 3: Denotational Semantics

  • Denotational: Filter model (GADT Value, Sub, dom/cod, nested subInvDist, subInv, arrSubArrInv, Denotes, envSubMono) Checked
  • Compositional: Semantic curry & application (lamEquiv/lamCong, appEquiv/appCong), UCtx/plug, and full compositionality Checked
  • Soundness: 100% unconditional weakening, strengthening, substitution, forward preservation, subject expansion, and denotEquivSteps Checked
  • Adequacy: decAboveFun, LogVLam/LogE, full subLogVLam, full fundamental, unconditional adequacyBigStep/adequacy/reduceToCbn, and omegaNotAboveFun Big-Step ✓
  • ContextualEquivalence: Open-term CtxEquiv (UCtx/plug), unconditional denotEqualCtxBigStep, unconditional denotEqualCtxEquiv, and unconditional betaCtxEquiv Checked

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