Course Notes for TPIL

These are the notes for M1697: Interactive theorem proving alongside computers in Lean 4, taught in Fall 2026 at UC Berkeley’s Splash program for high schoolers. If you are a prospective student, please instead check the course homepage.

These notes are also available as a PDF here.

Please note that this PDF is autogenerated from the same source code as this webpage, therefore it may contain unintended rendering errors.

Notions

Proofs are fundamentally about propositions, and their truth values. A proposition is basically a statement that could be either true or false.

There is a proposition called , read “bottom,” which is always true. This is similar to the boolean value False in programming languages.

We can compose propositions using certain logical rules. For propositions and ,

  • Conjunction: is true only if both and are both true. This is the logical AND.
  • Disjunction: is true only if at least one of or is true. This is the logical OR.
  • Negation: is true only if is false. This is the logical NOT.
  • Implication: . We read this as the sentence “If , then .” The rule is that if is true, and is true, then is true. This is a rule called modus ponens and is somewhat unintuitive. This is because as long as is true, is always true, even if its semantic meaning is nonsense. What we mean by semantic meaning is the concept actually represented by the implication rather than the pure logical relationship.

    Here are some clear examples of implication:

    • If , then . (This is the sentence from of .)

    Now here are some “bogus” examples that are still true implications, even though they are semantically non-sequitur.

    • If I eat lunch today, then the sky is blue.
    • If , then .
    • If the universe doesn’t exist, then I am alive.

We can define the value , called “top,” which is always true. This is like the boolean value True in programming.

Deciding the truth value of a proposition is quite intuitive. Just apply the rules above iteratively. To formally state this process, a lot more theory about logic will be needed that we don’t want to mess with right now.

For now, just observe that propositions essentially form our basic, natural intuition about logic, quantifying what it means to make a true or false statement and how to deduce further true/false statements.

If you take nothing away from this section, just remember the bold statement above. Propositions are just our natural human logical thinking, codified.

Types and logic

There is a truly wondrous relationship between types, as in type checking of programming languages, and logic, as in propositions.

To truly appreciate it, we need to think about how we make inferences in logic. I’ll give a few examples.

Firstly, if and are both true, then we can infer that in fact is true (that is, the statement “ and are both true” is true).

Conversely, if we know that is true, we can infer both and are individually true.

Now for a more interesting example.

Say we know the fact that . Careful! This, on its own, says nothing about the truth of or . It just says that if is true, then must be true.

Now suppose that we know that in fact is true. Combined with the fact that , we must have that is true. We were able to infer that is true by combining the facts and .

Here’s another application. Suppose instead that we know is false. We can now infer that must be false, because if were true, then must be true, which contradicts the known fact that is false. This is called reductio ad absurdum, or proof by contradiction.

This is the basic process by which we make inferences in propositional logic, which closely mirrors how we naturally reason logically as humans. We combine known facts with a set of natural logical rules that allow us to derive more facts from what we already know. What’s interesting is that this process happens to correspond exactly with the type checking of computer programs. To establish this, we will pair up each concept in logic with its corresponding concept in programming language types. But first, we need to establish the concept of type checking a program.

Basic type theory

If you have ever programmed in a strongly typed language like C or Java, this will be easy to understand. We’ll use pseudocode to illustrate this.

In programming, every variable has a type. For example

Integer a = 0;

defines the variable , holding the value 0, which has the type of Integer.

Boolean t = True;
Boolean f = False;

These variables have type Boolean, which means they hold a truth or false value.

Now we want to write some more code using these variables. Let’s define a boolean value that is the conjunction of t and f.

Boolean con = t and f;

Now the variable con has the value False. So far all the code makes sense, and if we implemented this in any sane programming language the compiler would accept and run it, no problem.

Now what if we try to assign an integer to a value that is supposed to be a boolean?

Boolean bogus = 2;

The compiler will type-check the code and complain that we tried to do this bogus assignment, rejecting the program. Type-checking makes sure the type signatures of our program are correct and well-defined.

Now we are ready to study the proposition and types correspondence.

The correspondence

The first equivalence is that of propositions and types themselves. In logic world, we deal propositions as our basic object. Each proposition has truth value.

In type theory world, we deal with types as the basic object. Instead of truth value, we have something called inhabitance. We say a type is inhabited if there actually exists a value of type . For instance, the type Integer is inhabited, and one value of type Integer is 1 (there are many more).

So in logic world, having a proposition that is either true or false corresponds in type theory world to a type that is either inhabited or uninhabited.

Next we’d like to talk about logical conjunctions and disjunctions, that is the logical AND and OR respectively. In type theory world, conjunctions are product types and disjunctions are sum types. A sum type is what type theorists call a type union, and a product type is a struct.

Think about why these make sense. In a logical conjunction, if and are true, then is true. In this case, we require both and to be true to establish . Recall that in type theory, the propositions correspond to inhabited types and . In this case, the product type might look something like

union P_and_Q {
P left;
Q right;
};

In order to show that P_and_Q is inhabited, we need to construct a value.