Links between computer science and mathematical logic
April, 20th
Tech talk
Paul-Elliot Anglès d'Auriac
Plan
  1. Thesis: Gödel's completeness theorem Curry-Howard correspondance
  2. Antithesis: Gödel's incompleteness theorem Turing machines
  3. Synthesis: ? Computations without computers
What is Mathematical Logic?

It is the study of mathematics, through the lens of mathematics:

  1. Give a formal definition of formal definitions, formulas, theorems, proof, theory, ...
  2. Prove theorems on proof of theorems,
  3. Conclude

Example!

  1. A theory is [...]
  2. "A recursively enumerable theory is either incomplete or inconsistent",
  3. Mathematics is doomed for humans

A toy model of Mathematics

A formula is either:
  • A base predicate \(P\in\mathbb P\)
  • An implication \(A \Rightarrow B\), where \(A,B\) are formulas.
  • A conjuction \(A \land B\), where \(A,B\) are formulas.
type formula =
  | Predicate of predicate
  | Implication of formula * formula
  | Conjunction of formula * formula
A proof in context \(\mathbb C\) is either:
  • The use of the context: \(F\in\mathbb C\). We conclude \(F\). if \(F\in\mathbb C\).
  • A combination of two proofs:
    \(T_1\) is a proof of \(P_1\). \(T_2\) is a proof of \(P_2\). We conclude \(P_1\land P_2\)
  • A "specialization" of a stronger result:
    \(T\) is a proof of \(P\land Q\). We conclude \(P\)
  • The introduction of an hypothesis in the context:
    Suppose \(P_1\). \(T\) is proof of \(P_2\). We conclude \(P_1\Rightarrow P_2\)
    where \(T\) is a proof of \(P_2\) in context \(\{P_1\}\cup\mathbb C\)
  • The use of a lemma
    \(T_q\) is a proof of \(Q\). \(T_p\) is a proof of \(Q\Rightarrow P\). We conclude \(P\).
type context = formula list (* [F_0 ; ... ; F_n] *)
and proof = context * proof_desc
and proof_desc =
  | Axiom of int
  | And_intro of proof * proof
  | And_elim_left of proof
  | And_elim_right of proof
  | Implication_intro of proof
  | Implication_elim of proof * proof

A theorem on the toy model

(FALSE) A formula is provable if and only if it is true "for any interpretation of the predicates".

A model is an interpretation of all predicates:

type model = predicate -> bool

A formula is true in a model if:

let rec validity formula m = match formula with
  | Predicate p -> m p
  | Implication (f1, f2) ->
      if validity f1 m then validity f2 m else true
  | Conjuction (f1, f2) -> validity f1 m && validity f2 m 
A formula is provable with context \(((P\Rightarrow Q)\Rightarrow P)\Rightarrow P\) if and only if it is true "for any interpretation of the predicates".
A formula is provable if and only if it is true "for any Kripke-interpretation of the predicates".

Less toy model:

  • Refinements on logic connectors: include \(\bot\), \(\lor\), \(\forall\), \(\exists\), ... in the language!
  • Refinement on predicates: add equality, arithmetic language, group theory language, set language, ... to the predicates!
  • Start with a non-empty set of axioms: Peano axioms (for arithmetics), ZF axioms (for set theory).
What is Computer Science? Computer science is... OCaml!

OCaml has types:

type type_ =
  | Var of var
  | Arrow of type_ * type_
  | Tuple2 of type_ * type_
  | ...

OCaml has typed values:

type context = type_ list (* [t_0 ; ... ; t_n ] *)
and value_ = context * value_desc
and value_desc =
  | Var of int
  | Tuple_construct of value_ * value_
  | Tuple_destruct_left of value_
  | And_destruct_right of value_
  | Arrow_construct of value_          (* [fun x -> ] *)
  | Arrow_destruct of value_ * value_  (* f x         *)
  | ...

Wait a minute... We've seen that already!

Logic Computer-science
Formulas Types
\(A\Rightarrow A\) a -> a
\((A\land B)\Rightarrow (A\Rightarrow C)\Rightarrow C\) (a * b) -> (a -> c) -> c
Proofs Programs
Suppose A then A by assumption fun x -> x
Suppose \(A\land B\), suppose \(A\Rightarrow C\), we have \(A\land B\) by hypothesis so we conclude \(A\), we have \(A\Rightarrow C\) by hypothesis, so we conclude \(C\), so we conclude \((A\Rightarrow C)\Rightarrow C\), so we conclude \((A\land B)\Rightarrow(A\Rightarrow C)\Rightarrow C\) fun (a, b) f -> f a
Using a lemma Applying a function
There is a proof of \(F\) There is a value of type t
\(A\) is not provable No value has type 'a
\(((P\Rightarrow Q)\Rightarrow P)\Rightarrow P\) is not provable No value has type
(('p -> 'q) -> 'p) -> 'p
\(\bot\) type impossible = | ;;
\(A\lor B\) type or = A of a | B of b ;;
... ...

What CS brings to Mathematics

  • Automatic prover, proof assistant
  • New things to study
  • New tools (e.g. classical realizability)
  • Expertise in structure of big proofs

What Mathematics brings to CS

  • Theoretical foundations for programming language
Computability

First, we modeled the mathematics, inside the mathematics.

Now, let's be a mathematician, modeling a mathematician, in mathematics.

A mathematician is:
  • A mind, with finitely many states.
  • An infinite notebook, whose page are all finite.
  • The mathematician can read, erase and write on a page, as well as turn a page.
Can a mathematician be so strong that they can recognize what's true and what is not?

We will prove this superperson does not exist, going through computer science!

  • A mathematician is a Turing Machine!
  • A Turing Machine is as powerful as an OCaml program!
Therefore, a mathematician is an OCaml program.
Can an OCaml program be so cool that it can recognize what's true and what is not?
Can an OCaml program be so cool that it can know if a program will terminate?
No OCaml program can decide whether an OCaml program (given as input) will terminate when executed.
Suppose you have:
val terminates : program:string -> input:string -> bool
(** tells whether the program with given input would terminate *)
let grumpy program =
  if terminates ~program input:program then
    while true do done
  else
    () ;;

grumpy "let grumpy program = [...]"

If grumpy "<grumpy>" terminates... it enters an infinite loop!

And if it does not terminate,... it terminates and returns unit!
No axiomatic system accessible to a mathematician proves exactly what's true.
Suppose everything is provable in a system. Implement terminates as follows:
let look_for_proof formula =
  Seq.find (is_proof_of formula) all_proofs_seq

let terminates program =
  let terminates = formula (program ^ " terminates") in
  Eio.first
    (() -> look_for_proof terminates ; true)
    (() -> look_for_proof (Not (terminates)) ; false)
Contradiction.

What CS brings to Mathematics

  • Definition of what is computable, apply to (meta)mathematics
  • Lighter formalism in mathematics

What Mathematics brings to CS

module type I = sig
  module type A
  module F : functor
    (X : sig
       module type A = A
       module F : functor (X : A) -> sig end
     end)
    -> sig end
end

module type J = sig
  module type A = I
  module F : functor (X : I) -> sig end
end

module Loop (X : J) : I = X
Computations without computers

Usual behaviour of computability theorists:

  1. Define a computational model (\(\lambda\)-calculus, Turing Machine, Register Machines, General recursive functions, Cellular Automaton, OCaml, ...)
  2. Show that it is equivalent to all the others

Actually, no need to do all of this: computability was hidden in all mathematic all along!

Subsets of the integers

  • There are a lot of subsets of the integers: \[\mathcal P(\mathbb N)\text{ is uncountable}\]
  • Our language can only produce countably many sentences \[\{x : x\text{ is an English sentence}\}\text{ is countable}\]
  • Therefore, we can't speak (specifically) about most sets.
  • What sets can we speak about?
A set \(A\subseteq \mathbb N\) is definable if there is a formula \(\phi\) such that: \[A = \{ i \in\mathbb N\ :\ \phi(i) \} \]
A set \(A\subseteq \mathbb N\) is simply definable if there is a formula \(\phi_0\) without unbounded quantification such that: \[A = \{ i \in\mathbb N\ :\ {\exists x\in\mathbb N},\ \phi_0(x,i) \} \]
\(A\) and \(\mathbb N\setminus A\) are simply definable iff:
val f : int -> bool
(** {math n \in A} iff [f n] is [true] *)
can be implemented in OCaml.

What CS brings to Mathematics

  • Useful restriction of sets to "meaningful sets"
  • which allows to prove things for all sets

What Mathematics brings to CS

  • Fun?
Thanks for your attention! Any questions?

(Presentation powered by slipshow)