Part 0 · Prologue

Why Any of This Matters

Three problems that look nothing like “logic,” that logic quietly solves anyway — and the one idea that ties this entire course together.

Before computer science existed as a discipline, there was mathematics — and mathematics needed a language precise enough that two people could never disagree about whether a proof was valid. That language is logic. Computer science inherited it, and then discovered logic was exactly what it needed to answer questions like:

  • Syntax — what counts as a well-formed program?
  • Type systems — what counts as a well-typed program?
  • Semantics — if I run this program, what happens?
  • Specification — what is the program supposed to do?
  • Verification — can we prove the program meets its specification and never crashes?
  • Complexity — how much time or memory does it need?

All of these are active industrial and research topics, and all of them lean on the two logics this course teaches. To make the stakes concrete, here are three problems from the very first lecture that look nothing like “logic” — and yet are all instances of the same underlying question.

01 The Sudoku Puzzle

A Sudoku grid can be encoded as a giant propositional formula. Introduce a Boolean variable $x_{ijd}$ meaning “cell $(i,j)$ contains digit $d$.” Then write down constraints such as “every cell has at least one digit” and “every cell has at most one digit,” plus “every row / column / box contains each digit at most once.”

The resulting formula is satisfiable exactly when the puzzle is solvable — and finding a satisfying assignment is finding the solution. Deciding whether a propositional formula is satisfiable is called SAT (the Boolean satisfiability problem), and programs that do it are SAT solvers. This is not a metaphor: real Sudoku solvers work exactly like this.

02 The Boolean Pythagorean Triples Problem

Can every natural number be coloured either red or blue so that no Pythagorean triple $a^2+b^2=c^2$ (like $3^2+4^2=5^2$) has all three numbers the same colour? This sounds like recreational number theory — but it was resolved in 2016 by encoding it as a giant SAT formula and letting a solver grind through it.

The answer is no, once $n \ge 7825$ — and the proof, generated by a supercomputer in two days, was 200 terabytes long. It made the pages of Nature.

03 The Printer Manager

Two users, A and B, share a printer. At any moment each user is either idle ($I$), requesting to print ($R$), or printing ($P$) — giving states like $I_AI_B$, $R_AI_B$, $P_AR_B$, and so on.

B idle
B req.
B print
A idle
IAIB
IARB
IAPB
A req.
RAIB
RARB
RAPB
A print
PAIB
PARB
PAPB
reachable state — eight of them impossible — one printer, one job at a time
Every configuration of a two-user print queue. Each user moves idle → requesting → printing → idle, independently of the other, except that only one can print at a time. Questions like “is every print preceded by a request?” are questions about paths through this state space — which is exactly a finite automaton.

The thread connecting all three: encode a hard problem as a question about a formal system, then let a mechanical procedure answer the question for you. Propositional and predicate logic give you two encoding languages of increasing power. Automata theory studies what happens when the “mechanical procedure” itself is stripped down to the bare minimum. That’s the whole course.