Formal Software Verification

3.1. From Proofs to Programs🔗

Lecture 1 presented a proof as a term whose type is the proposition it proves. The same type theory classifies data. A type such as ℕ collects values, and a term of type ℕ → ℕ is a program that consumes and produces values. The #check below reads exactly like the #check of a proof term, with types in place of propositions.W. A. Howard, The Formulae-as-Types Notion of Construction, in To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, Academic Press, 1980, pp. 479–490.

fun n => n + 1 : #check fun n : => n + 1
fun n => n + 1 :   

This lecture defines types and functions and states theorems about them. The proofs of those theorems wait for the coming lectures, which develop structural induction. This lecture also imports the LoVe library, and through it Mathlib, the mathematical library of the Lean community.The mathlib Community, The Lean Mathematical Library, in Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2020), pp. 367–381. Mathlib is a single monolithic development that formalises algebra, order theory, topology, analysis and the standard data structures, and supplies the notations, lemmas and tactics that the rest of these lectures rely on. The notations ℕ and ℤ for the natural numbers and the integers come from it and are used from here on.