Logic Applied to Computer Science — Lecture Notes
These are the lecture notes for the course PCC116 / BCC244 — Logic Applied to Computer Science, offered by the Department of Computing of the Federal University of Ouro Preto (UFOP), Brazil. The text follows the slides and the code developed in class and was written using Verso, the documentation tool of the Lean language. Every piece of Lean code that appears in these notes is checked by Lean itself while the document is generated: definitions compile, examples are evaluated and theorems have their proofs checked.
The notes are organized in four parts.
-
Part I presents the foundations: functional programming, propositional and predicate logic, natural deduction and the sequent calculus, the lambda calculus (untyped and typed), the Curry-Howard isomorphism and the Calculus of Constructions — the type theory on which Lean is built.
-
Part II introduces Lean as a programming language and proof assistant: terms and types, inductive types, tactics, structured proofs, inductive predicates, property-based testing, well-founded recursion and programming with dependent types.
-
Part III applies these tools to the semantics and verification of programs: operational semantics, the imperative language IMP, Hoare logic, verification condition generation and separation logic.
-
Part IV uses Lean and the Mathlib library to formalize mathematics: sets and functions (including Cantor's and the Schröder–Bernstein theorems), elementary number theory (irrationality of
\sqrt{2}, infinitude of the primes) and discrete mathematics (finite sets and types, counting arguments and inductive types).
The main references for the course are the book Functional Programming in Lean, by David T. Christiansen, available online, and the book Type Theory and Formal Proof, by Rob Nederpelt and Herman Geuvers (Cambridge University Press, 2014). Part IV follows the book Mathematics in Lean, by Jeremy Avigad and Patrick Massot, available online.