On the constructive content of proofs in abstract analysis Ulrich - - PowerPoint PPT Presentation

on the constructive content of proofs in abstract analysis
SMART_READER_LITE
LIVE PREVIEW

On the constructive content of proofs in abstract analysis Ulrich - - PowerPoint PPT Presentation

On the constructive content of proofs in abstract analysis Ulrich Berger Swansea University j.w.w. Hideki Tsuiki Kyoto University Proof and translation: Glivenkos theorem 90 years after CLMPST, Prague, August 9, 2019 1 / 44 From


slide-1
SLIDE 1

On the constructive content of proofs in abstract analysis

Ulrich Berger Swansea University j.w.w. Hideki Tsuiki Kyoto University Proof and translation: Glivenko’s theorem 90 years after CLMPST, Prague, August 9, 2019

1 / 44

slide-2
SLIDE 2

From Glivenko to Kleene

From a pragmatic point of view the interest in intuitionistic logic lies not so much in its higher ’trustability’ but rather in the fact that its proofs contain computational information which proofs of classical logic lack.

2 / 44

slide-3
SLIDE 3

From Glivenko to Kleene

From a pragmatic point of view the interest in intuitionistic logic lies not so much in its higher ’trustability’ but rather in the fact that its proofs contain computational information which proofs of classical logic lack. The translations by Glivenko, G¨

  • del, Kolmogorov, . . . show that

classical logic covers only the computationally uninformative fragment of intuitionistic logic

2 / 44

slide-4
SLIDE 4

From Glivenko to Kleene

From a pragmatic point of view the interest in intuitionistic logic lies not so much in its higher ’trustability’ but rather in the fact that its proofs contain computational information which proofs of classical logic lack. The translations by Glivenko, G¨

  • del, Kolmogorov, . . . show that

classical logic covers only the computationally uninformative fragment of intuitionistic logic Kleene’s realizability interpretation makes explicit the computational content of the parts that classical logic misses.

2 / 44

slide-5
SLIDE 5

Computational content in the ’real’ mathematical world

When trying to apply the ideas of Glivenko, G¨

  • del and Kleene to

’real’ mathematics one faces two interesting challenges:

3 / 44

slide-6
SLIDE 6

Computational content in the ’real’ mathematical world

When trying to apply the ideas of Glivenko, G¨

  • del and Kleene to

’real’ mathematics one faces two interesting challenges:

◮ Besides logic, mathematics uses strong axioms which, on the

surface, are not constructive. Examples are choice principles and (suitable versions) of Zorn’s Lemma. The translations of these principles require new forms of computation, for example, bar recursion and related recursions. This challenge will be briefly discussed in the next talk.

3 / 44

slide-7
SLIDE 7

Computational content in the ’real’ mathematical world

When trying to apply the ideas of Glivenko, G¨

  • del and Kleene to

’real’ mathematics one faces two interesting challenges:

◮ Besides logic, mathematics uses strong axioms which, on the

surface, are not constructive. Examples are choice principles and (suitable versions) of Zorn’s Lemma. The translations of these principles require new forms of computation, for example, bar recursion and related recursions. This challenge will be briefly discussed in the next talk.

◮ Another obstacle is that classical mathematicians like to work

with abstract structures without committing to concrete representations. This talk will show that computational content may still be extracted, using the theory of real numbers as a running example.

3 / 44

slide-8
SLIDE 8

The fundamental idea of program extraction

4 / 44

slide-9
SLIDE 9

The fundamental idea of program extraction

A proof is a construction, represented by a text or a finite tree, that convinces us that a formula is true.

4 / 44

slide-10
SLIDE 10

The fundamental idea of program extraction

A proof is a construction, represented by a text or a finite tree, that convinces us that a formula is true. But often, a formula can also be understood as a computational problem.

4 / 44

slide-11
SLIDE 11

The fundamental idea of program extraction

A proof is a construction, represented by a text or a finite tree, that convinces us that a formula is true. But often, a formula can also be understood as a computational problem. For example, the formula stating that there are infinitely many prime numbers, ∀x ∃y (y > x ∧ Prime(y)) can be understood as the problem of computing for every natural number x a prime number y that is greater than x.

4 / 44

slide-12
SLIDE 12

The fundamental idea of program extraction

A proof is a construction, represented by a text or a finite tree, that convinces us that a formula is true. But often, a formula can also be understood as a computational problem. For example, the formula stating that there are infinitely many prime numbers, ∀x ∃y (y > x ∧ Prime(y)) can be understood as the problem of computing for every natural number x a prime number y that is greater than x. Program extraction is based on the observation that a proof not

  • nly represents an argument why a formula is true but also contains

a program that solves the computational problem it expresses.

4 / 44

slide-13
SLIDE 13

Goals

5 / 44

slide-14
SLIDE 14

Goals

Extract useful and fully verified programs.

5 / 44

slide-15
SLIDE 15

Goals

Extract useful and fully verified programs. Discover the logical and mathematical principles corresponding to programming paradigms: logic functional programming induction recursion ? concurrency ? memory management ? lazyness . . .

5 / 44

slide-16
SLIDE 16

Minlog

http://www.mathematik.uni-muenchen.de/~logik/minlog/ Minlog is an interactive proof system that supports program extraction form proofs. Most of the applications of program extraction presented in this talk have been carried out in Minlog. Minlog is under active development at the Universities of Munich (lead), Kyoto and Swansea.

6 / 44

slide-17
SLIDE 17

Overview

◮ Program extraction via realizability ◮ Intuitionistic fixed point logic (IFP) ◮ Realizability interpretation of IFP ◮ Brouwer’s Thesis and Wellfounded Induction ◮ Archimedian Induction ◮ Application: From signed digits to inifinit Gray code ◮ Further applications

7 / 44

slide-18
SLIDE 18

Realizability

Realizability attaches meaning to the Curry-Howard correspondence (in a similar way as Tarskian semantics attaches meaning to predicate logic).

8 / 44

slide-19
SLIDE 19

Realizability

Realizability attaches meaning to the Curry-Howard correspondence (in a similar way as Tarskian semantics attaches meaning to predicate logic). Intuitively: If M : A (that is, M codes an intuitionistic ND proof of A), then M solves the problem A according to the BHK-interpretation.

8 / 44

slide-20
SLIDE 20

Realizability

Realizability attaches meaning to the Curry-Howard correspondence (in a similar way as Tarskian semantics attaches meaning to predicate logic). Intuitively: If M : A (that is, M codes an intuitionistic ND proof of A), then M solves the problem A according to the BHK-interpretation. This intuition is made precise in Kleene’s realizability interpretation

  • f HA by numbers (’number realizability’, 1945).

8 / 44

slide-21
SLIDE 21

Kleene’s number realizability

For every closed formula A and every natural number e one defines what it means for e to realize A, e r A. e r A ≡ A (A atomic) e r (A ∧ B) ≡ e = P(a, b) ∧ a r A ∧ b r B e r (A → B) ≡ ∀a (a r A → {e}(a) r B) e r (A ∨ B) ≡ (e = P(0, a) ∧ a r A) ∨ (e = P(1, b) ∧ b r B) e r (∀x A(x)) ≡ ∀n ({e}(n) r A(n)) e r (∃x A(x)) ≡ e = P(n, a) ∧ a r A(n) where P : N × N → N is some computable bijection, and {e}(a) r B means that the partial recursive function (or Turing machine) with code e when applied to a terminates with some number b ∈ N such that b r B.

9 / 44

slide-22
SLIDE 22

Soundness Theorem

If HA ⊢ A, then HA ⊢ e r A for some e.

10 / 44

slide-23
SLIDE 23

Soundness Theorem

If HA ⊢ A, then HA ⊢ e r A for some e. Remarks:

  • 1. The proof of the Soundness Theorem proceeds by induction
  • n the given derivation of HA ⊢ A.
  • 2. For the logical rules the extracted realizer e is essentially a

code of the lambda-term provided by the Curry-Howard correspondence.

  • 3. For the induction axiom the extracted realizer codes a

primitive recursion (iterator).

10 / 44

slide-24
SLIDE 24

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic.

11 / 44

slide-25
SLIDE 25

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic. Then HA ⊢ e r (∀x ∃y A(x, y)), for some e, by Soundness.

11 / 44

slide-26
SLIDE 26

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic. Then HA ⊢ e r (∀x ∃y A(x, y)), for some e, by Soundness. This means HA ⊢ ∀n A(n, proj1({e}(n))), that is, the function f (n) Def = proj1({e}(n)) solves the computational problem expressed by the formula ∀x ∃y A(x, y).

11 / 44

slide-27
SLIDE 27

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic. Then HA ⊢ e r (∀x ∃y A(x, y)), for some e, by Soundness. This means HA ⊢ ∀n A(n, proj1({e}(n))), that is, the function f (n) Def = proj1({e}(n)) solves the computational problem expressed by the formula ∀x ∃y A(x, y). We generalize and improve program extraction by

◮ permitting abstract structures (instead of only natural

numbers),

11 / 44

slide-28
SLIDE 28

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic. Then HA ⊢ e r (∀x ∃y A(x, y)), for some e, by Soundness. This means HA ⊢ ∀n A(n, proj1({e}(n))), that is, the function f (n) Def = proj1({e}(n)) solves the computational problem expressed by the formula ∀x ∃y A(x, y). We generalize and improve program extraction by

◮ permitting abstract structures (instead of only natural

numbers),

◮ adding stronger axioms (instead of only induction on natural

numbers),

11 / 44

slide-29
SLIDE 29

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic. Then HA ⊢ e r (∀x ∃y A(x, y)), for some e, by Soundness. This means HA ⊢ ∀n A(n, proj1({e}(n))), that is, the function f (n) Def = proj1({e}(n)) solves the computational problem expressed by the formula ∀x ∃y A(x, y). We generalize and improve program extraction by

◮ permitting abstract structures (instead of only natural

numbers),

◮ adding stronger axioms (instead of only induction on natural

numbers),

◮ permitting limited classical logic and choice principles,

11 / 44

slide-30
SLIDE 30

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic. Then HA ⊢ e r (∀x ∃y A(x, y)), for some e, by Soundness. This means HA ⊢ ∀n A(n, proj1({e}(n))), that is, the function f (n) Def = proj1({e}(n)) solves the computational problem expressed by the formula ∀x ∃y A(x, y). We generalize and improve program extraction by

◮ permitting abstract structures (instead of only natural

numbers),

◮ adding stronger axioms (instead of only induction on natural

numbers),

◮ permitting limited classical logic and choice principles, ◮ extracting programs in a realistic programming language

(instead of codes e),

11 / 44

slide-31
SLIDE 31

Program extraction for HA

Assume HA ⊢ ∀x ∃y A(x, y) where A(x, y) is atomic. Then HA ⊢ e r (∀x ∃y A(x, y)), for some e, by Soundness. This means HA ⊢ ∀n A(n, proj1({e}(n))), that is, the function f (n) Def = proj1({e}(n)) solves the computational problem expressed by the formula ∀x ∃y A(x, y). We generalize and improve program extraction by

◮ permitting abstract structures (instead of only natural

numbers),

◮ adding stronger axioms (instead of only induction on natural

numbers),

◮ permitting limited classical logic and choice principles, ◮ extracting programs in a realistic programming language

(instead of codes e),

◮ extracting simpler programs.

11 / 44

slide-32
SLIDE 32

Including abstract mathematics

12 / 44

slide-33
SLIDE 33

Including abstract mathematics

Kleene realizability is chained to concrete computational structures since in the clauses for quantifiers the elements of the structure are

12 / 44

slide-34
SLIDE 34

Including abstract mathematics

Kleene realizability is chained to concrete computational structures since in the clauses for quantifiers the elements of the structure are

◮ used as inputs of programs:

e r (∀x A(x)) ≡ ∀n ({e}(n) r A(n))

12 / 44

slide-35
SLIDE 35

Including abstract mathematics

Kleene realizability is chained to concrete computational structures since in the clauses for quantifiers the elements of the structure are

◮ used as inputs of programs:

e r (∀x A(x)) ≡ ∀n ({e}(n) r A(n))

◮ and returned as outputs of programs:

e r (∃x A(x)) ≡ e = P(n, a) ∧ a r A(n)

12 / 44

slide-36
SLIDE 36

Including abstract mathematics

Kleene realizability is chained to concrete computational structures since in the clauses for quantifiers the elements of the structure are

◮ used as inputs of programs:

e r (∀x A(x)) ≡ ∀n ({e}(n) r A(n))

◮ and returned as outputs of programs:

e r (∃x A(x)) ≡ e = P(n, a) ∧ a r A(n) Abstract structures can be included by interpreting quantifiers uniformly: a r ∀x A(x) ≡ ∀x a r A(x) a r ∃x A(x) ≡ ∃x a r A(x)

12 / 44

slide-37
SLIDE 37

Including abstract mathematics

Kleene realizability is chained to concrete computational structures since in the clauses for quantifiers the elements of the structure are

◮ used as inputs of programs:

e r (∀x A(x)) ≡ ∀n ({e}(n) r A(n))

◮ and returned as outputs of programs:

e r (∃x A(x)) ≡ e = P(n, a) ∧ a r A(n) Abstract structures can be included by interpreting quantifiers uniformly: a r ∀x A(x) ≡ ∀x a r A(x) a r ∃x A(x) ≡ ∃x a r A(x) This uniform interpretation of quantifiers is also used for interpreting second-order arithmetic and set theory. Kleene’s interpretation of quantifiers can be recovered by relativization: ∀x (x ∈ N → A(x)), ∃x (x ∈ N ∧ A(x)).

12 / 44

slide-38
SLIDE 38

Induction

Recall induction on natural numbers: P(0) ∀x (P(x) → P(x + 1)) ∀x ∈ N P(x)

13 / 44

slide-39
SLIDE 39

Induction

Recall induction on natural numbers: P(0) ∀x (P(x) → P(x + 1)) ∀x ∈ N P(x) Assume “n r N(x)” is defined as “n is the unary representation of x ∈ N”.

13 / 44

slide-40
SLIDE 40

Induction

Recall induction on natural numbers: P(0) ∀x (P(x) → P(x + 1)) ∀x ∈ N P(x) Assume “n r N(x)” is defined as “n is the unary representation of x ∈ N”. Then induction is realized as follows: a r P(0) f r (∀x (P(x) → P(x + 1))) It(a, f ) r (∀x ∈ N P(x))

13 / 44

slide-41
SLIDE 41

Induction

Recall induction on natural numbers: P(0) ∀x (P(x) → P(x + 1)) ∀x ∈ N P(x) Assume “n r N(x)” is defined as “n is the unary representation of x ∈ N”. Then induction is realized as follows: a r P(0) f r (∀x (P(x) → P(x + 1))) It(a, f ) r (∀x ∈ N P(x)) where

◮ a : τ(P)

(τ(P) = type of realizers of P) ,

◮ f : τ(P) → τ(P)

13 / 44

slide-42
SLIDE 42

Induction

Recall induction on natural numbers: P(0) ∀x (P(x) → P(x + 1)) ∀x ∈ N P(x) Assume “n r N(x)” is defined as “n is the unary representation of x ∈ N”. Then induction is realized as follows: a r P(0) f r (∀x (P(x) → P(x + 1))) It(a, f ) r (∀x ∈ N P(x)) where

◮ a : τ(P)

(τ(P) = type of realizers of P) ,

◮ f : τ(P) → τ(P)

and It(a, f ) : N → τ(P) is defined recursively by It(a, f )(0) = a It(a, f )(n + 1) = f (It(a, f )(n))

13 / 44

slide-43
SLIDE 43

Other forms of induction

14 / 44

slide-44
SLIDE 44

Other forms of induction

Induction on natural numbers is a special case of a more general form of induction which also includes, for example:

14 / 44

slide-45
SLIDE 45

Other forms of induction

Induction on natural numbers is a special case of a more general form of induction which also includes, for example: Induction on lists, trees, . . . P([]) ∀x ∈ A ∀l (P(l) → P(x : l)) ∀x ∈ List(A) P(x)

14 / 44

slide-46
SLIDE 46

Other forms of induction

Induction on natural numbers is a special case of a more general form of induction which also includes, for example: Induction on lists, trees, . . . P([]) ∀x ∈ A ∀l (P(l) → P(x : l)) ∀x ∈ List(A) P(x) Induction on ordinals (or any wellfounded relation <) ∀x ((∀y < x P(y)) → P(x)) ∀x < α P(x)

14 / 44

slide-47
SLIDE 47

Other forms of induction

Induction on natural numbers is a special case of a more general form of induction which also includes, for example: Induction on lists, trees, . . . P([]) ∀x ∈ A ∀l (P(l) → P(x : l)) ∀x ∈ List(A) P(x) Induction on ordinals (or any wellfounded relation <) ∀x ((∀y < x P(y)) → P(x)) ∀x < α P(x) Bar induction . . .

14 / 44

slide-48
SLIDE 48

A unifying approach: Monotone induction

15 / 44

slide-49
SLIDE 49

A unifying approach: Monotone induction

Let U be a set and P(U) the powerset of U.

15 / 44

slide-50
SLIDE 50

A unifying approach: Monotone induction

Let U be a set and P(U) the powerset of U. An operator Φ : P(X) → P(X) is monotone if for all X, Y ∈ P(U) X ⊆ Y → Φ(X) ⊆ Φ(Y )

15 / 44

slide-51
SLIDE 51

A unifying approach: Monotone induction

Let U be a set and P(U) the powerset of U. An operator Φ : P(X) → P(X) is monotone if for all X, Y ∈ P(U) X ⊆ Y → Φ(X) ⊆ Φ(Y ) Every monotone operator Φ : P(X) → P(X) has a least fixed point, µ(Φ) ∈ P(U), which can be defined by µ(Φ) Def =

  • {X ∈ P(U) | Φ(X) ⊆ X}

15 / 44

slide-52
SLIDE 52

A unifying approach: Monotone induction

Let U be a set and P(U) the powerset of U. An operator Φ : P(X) → P(X) is monotone if for all X, Y ∈ P(U) X ⊆ Y → Φ(X) ⊆ Φ(Y ) Every monotone operator Φ : P(X) → P(X) has a least fixed point, µ(Φ) ∈ P(U), which can be defined by µ(Φ) Def =

  • {X ∈ P(U) | Φ(X) ⊆ X}

but also by µ(Φ) Def =

  • {Φα(∅) | α ∈ Ordinals}

15 / 44

slide-53
SLIDE 53

Closure and induction

One can show that indeed µ(Φ) is a fixed point of Φ, that is, Φ(µ(Φ)) = µ(Φ), and it is the least element of the set {X ∈ P(U) | Φ(X) ⊆ X}. Therefore the following rules hold: Cl Φ(µ(Φ)) ⊆ µ(Φ) Φ(X) ⊆ X Ind µ(Φ) ⊆ X Similarly for coinduction: Cocl ν(Φ) ⊆ Φ(ν(Φ)) X ⊆ Φ(X) Coind X ⊆ ν(Φ) No guardedness condition.

16 / 44

slide-54
SLIDE 54

Intuitionistic Fixed Point logic (IFP)

◮ Intuitionistic first-order logic with equality. ◮ Constants, function symbols and atomic predicates (not

necessarily decidable), depending on applications.

◮ Free predicate variables X, Y , . . .. ◮ Inductive and coinductive definitions as least and largest fixed

points of monotone predicate transformers. Monotonicity is enforced by strict positivity.

◮ Axioms consisting of non-computational (nc), that is,

disjunction-free, formulas that are (classically) true. The choice of axiom depends on applications.

17 / 44

slide-55
SLIDE 55

Programs

Programs are type free lambda terms with constructors, pattern matching and recursion: Programs ∋ M, N ::= a, b variables | Nil | L(M) | R(M) | P(M, N) | case M of {Cl1; . . . ; Cln} | λa. M | M N | rec M Clauses ∋ Cl ::= C(a1, . . . , an) → M (C ∈ Nil, L, R, P) Programs are interpreted lazily in the Scott domain D defined by the recursive domain equation D = (Nil + L(D) + R(D) + P(D × D) + F(D → D))⊥ and have an adequate lazy operational semantics. Assigning them recursive types we get a fragment of Haskell.

18 / 44

slide-56
SLIDE 56

Realizability for non-Harrop formulas

A formula is Harrop if it contains no disjunction or free predicate variables at a strictly positive position. H(A) is realizability by Nil for Harrop formulas (next slide). a r A = (a = Nil ∧ H(A)) (A Harrop) a r P( t) = R(P)( t, a) (P non-H.) c r (A ∧ B) = ∃a, b (c = P(a, b) ∧ a r A ∧ b r B) (A, B non-H.) a r (A ∧ B) = a r A ∧ H(B) (B Harrop, A non-H.) b r (A ∧ B) = H(A) ∧ b r B (A Harrop, B non-H.) c r (A ∨ B) = ∃a (c = L(a) ∧ a r A) ∨ ∃b (c = R(b) ∧ b r B) c r (A → B) = ∀a (a r A → (c a) r B) (A, B non-H.) b r (A → B) = H(A) → b r B (A Harrop, B non-H.) a r ♦x A = ♦x (a r A) (♦ ∈ {∀, ∃}, A non-H.)

19 / 44

slide-57
SLIDE 57

Realizability for non-Harrop predicates

To every predicate variable X is assigned a predicate variable ˜ X with an extra argument for realizers. R(P) means λ( x, a) . a r P( x). R(X) = ˜ X R(λ x A) = λ( x, a) (a r A) (A non-H.) R((Φ)) = (R(Φ)) ( ∈ {µ, ν}, Φ non-H.) R(λX P) = λ ˜ X R(P) (P non-H.)

20 / 44

slide-58
SLIDE 58

Realizability for Harrop formulas and predicates

r A Def = ∃a . a r A. H(P( t)) = H(P)( t) (P Harrop) H(A ∧ B) = H(A) ∧ H(B) (A, B Harrop) H(A → B) = rA → H(B) (B Harrop) H(♦x A) = ♦x H(A) (♦ ∈ {∀, ∃}, A Harrop) H(P) = P (P a predicate constant) H(λ x A) = λ x H(A) (A Harrop) H((Φ)) = (H(Φ)) ( ∈ {µ, ν}, Φ Harrop) H(λY P) = λY HY (P) (P Y -Harrop)

21 / 44

slide-59
SLIDE 59

Soundness for IFP

Let RIFP be the extension of IFP by a sort for realizers and axioms describing the equational theory of programs.

22 / 44

slide-60
SLIDE 60

Soundness for IFP

Let RIFP be the extension of IFP by a sort for realizers and axioms describing the equational theory of programs. Theorem If Γ, ∆ ⊢IFP A, where Γ are nc- and ∆ Harrop-formulas, then Γ, H(∆) ⊢RIFP M r A for some program M. Realizers of induction and coinduction: s r (Φ(P) ⊆ P) Ind rec (λf . s ◦ map f ) r (µ(Φ) ⊆ P) s r (P ⊆ Φ(P)) Coind rec (λf . map f ◦ s) r (P ⊆ ν(Φ)) No guarded recursion.

22 / 44

slide-61
SLIDE 61

Example: Real and natural numbers

◮ Variables x, y, . . . are intended to range over abstract real

numbers

◮ Constants and function symbols: 0, 1, +, −, ∗, /, | · |, . . .. ◮ Atomic predicates: <, ≤, . . .. ◮ Nc axioms: ∀x . x + 0 = x, . . . .

23 / 44

slide-62
SLIDE 62

Example: Real and natural numbers

◮ Variables x, y, . . . are intended to range over abstract real

numbers

◮ Constants and function symbols: 0, 1, +, −, ∗, /, | · |, . . .. ◮ Atomic predicates: <, ≤, . . .. ◮ Nc axioms: ∀x . x + 0 = x, . . . . ◮ Inductive predicate defining the natural numbers as a subset

  • f the reals numbers: N Def

= µ Φ, where Φ = λX λx . x = 0 ∨ X(x − 1). We write this more intuitively as N(x)

µ

= x = 0 ∨ N(x − 1).

23 / 44

slide-63
SLIDE 63

Example: Real and natural numbers

◮ Variables x, y, . . . are intended to range over abstract real

numbers

◮ Constants and function symbols: 0, 1, +, −, ∗, /, | · |, . . .. ◮ Atomic predicates: <, ≤, . . .. ◮ Nc axioms: ∀x . x + 0 = x, . . . . ◮ Inductive predicate defining the natural numbers as a subset

  • f the reals numbers: N Def

= µ Φ, where Φ = λX λx . x = 0 ∨ X(x − 1). We write this more intuitively as N(x)

µ

= x = 0 ∨ N(x − 1).

◮ Coinductive predicate defining those real numbers that can be

approximated by dyadic rationals: A Def = ν Ψ, where Ψ = λX λx . ∃n ∈ N |x − n| ≤ 1 ∧ X(2x). Intuitive notation A(x) ν = ∃n ∈ N |x − n| ≤ 1 ∧ A(2x).

23 / 44

slide-64
SLIDE 64

Example: Real and natural numbers

◮ Variables x, y, . . . are intended to range over abstract real

numbers

◮ Constants and function symbols: 0, 1, +, −, ∗, /, | · |, . . .. ◮ Atomic predicates: <, ≤, . . .. ◮ Nc axioms: ∀x . x + 0 = x, . . . . ◮ Inductive predicate defining the natural numbers as a subset

  • f the reals numbers: N Def

= µ Φ, where Φ = λX λx . x = 0 ∨ X(x − 1). We write this more intuitively as N(x)

µ

= x = 0 ∨ N(x − 1).

◮ Coinductive predicate defining those real numbers that can be

approximated by dyadic rationals: A Def = ν Ψ, where Ψ = λX λx . ∃n ∈ N |x − n| ≤ 1 ∧ X(2x). Intuitive notation A(x) ν = ∃n ∈ N |x − n| ≤ 1 ∧ A(2x). One can prove A(x) ↔ ∀k ∈ N ∃q ∈ Q |x − q| ≤ 2−k where Q is the set of the rational numbers, defined as usual.

23 / 44

slide-65
SLIDE 65

Accessible induction

The accessible part of a binary relation ≺ is defined inductively by Acc≺(x)

µ

= ∀y ≺ x Acc≺(y) that is, Acc≺ = µ(Φ) where Φ Def = λX λx ∀y ≺ x X(y). P is progressive if Φ(P) ⊆ P, that is, Prog≺(P) holds where Prog≺(P) Def = ∀x (∀y ≺ xP(y) → P(x)) . Accessible induction, is an instance of the rule of s.p. induction: Prog≺(P) Acc≺ ⊆ P AccI≺(P)

24 / 44

slide-66
SLIDE 66

Realizing accessible induction

Assume P is non-Harrop and ≺ is Harrop (the most common case). s r Prog≺(P) (rec s) r (Acc≺ ⊆ P) WfI≺(P)

25 / 44

slide-67
SLIDE 67

Brouwer’s Thesis and Wellfounded induction

Elements beginning an infinite descending sequence can be characterized coinductively by Path≺(x) ν = ∃y ≺ x Path≺(y) ¬Path≺(x) and Acc≺(x) are equivalent and both are Harrop formulas (provided ≺ is disjunction-free). Therefore we can postulate the axiom BT≺ ∀x (¬Path≺(x) → Acc≺(x)) which can be viewed as an abstract version of Brouwer’s Thesis (stating that barred sequences of natural numbers are inductively barred). BT≺ implies Wellfounded Induction: Prog≺(P) ¬Path≺ ⊆ P WfI≺(P) Wellfounded induction has the same realizer as accessible induction.

26 / 44

slide-68
SLIDE 68

The Archimedean property

The Archimedean property of real numbers can be expressed by stating that there are no infinite numbers: AP ∀x ¬∞(x) where infinite numbers are characterized coinductively: ∞(x)

ν

= x ≥ 0 ∧ ∞(x − 1) . Lemma ∀x (∞(x) ↔ ∀y ∈ N y ≤ x). Proof ∀y ∈ N ∀x (∞(x) → y ≤ x), by induction. ∀x ((∀y ∈ N y ≤ x) → ∞(x)), by coinduction.

27 / 44

slide-69
SLIDE 69

Archimedean Induction

Setting y ≺ x Def = x ≥ 0 ∧ y = x − 1, clearly ∞(x) ↔ Path≺(x). Therefore, by the Archimedean property, Path≺ is empty, and hence, by wellfounded induction, ∀x ((x ≥ 0 → P(x − 1)) → P(x)) ∀x P(x) AI(P) We call this Archimedean Induction. Equivalent (more useful) form (q is any fixed positive rational): ∀x ∈ B \ {0} (P(x) ∨ (|x| ≤ q ∧ B(2x) ∧ (P(2x) → P(x)))) ∀x ∈ B \ {0} P(x) AIBq(B, P)

28 / 44

slide-70
SLIDE 70

Application: From signed digits to infinite Gray code

Coinductive characterizations of reals that have

◮ a signed digit representation

C(x) ν = ∃d ∈ {−1, 0, 1} (|x − d/2| ≤ 1/2 ∧ C(2x − d)),

◮ an infinite Gray code

G(x) ν = (−1 ≤ x ≤ 1)∧(x = 0 → x ≤ 0∨x ≥ 0)∧G(1−2|x|). Realizers of C(x) are total streams of signed digits. Realizers of G(x) are streams of binary digits (L,R) that may be undefined at one point. Both are admissible representations of the reals but infinite Gray code is in addition unique. Using Archimedean induction one can show C ⊆ G and extract a conversion between the two representations.

29 / 44

slide-71
SLIDE 71

Extracted program (C ⊆ G)

stog :: SDrep -> InfGrayCode stog p = case head p of {

  • 1 -> L : stog (tail p) ;

1 -> R : nh (nall (tail p)) ; 0 -> let { q = stog (tail p) } in head q : R : nh (tail q) } nall (L : q) = R : neg q nall (R : q) = L : neg q nh (L : q) = R : q nh (R : q) = L : q

30 / 44

slide-72
SLIDE 72

Extracted program of the converse inclusion (G ⊆ C)

stog :: InfGrayCode -> SDrep stog q = case head q of { L:q’ -> (-1) : gtos p’ ; R:q’ -> 1 : gtos (nh q’) ; c:R:q’’ -> 0 : gtos (c : nh q’’) } This program can be extracted as well - but not in IFP! Why?

31 / 44

slide-73
SLIDE 73

Programs and rules for concurrency

◮ Add a new formula construct S2(A) which admits 2

concurrent processes as realizers . . .

32 / 44

slide-74
SLIDE 74

Programs and rules for concurrency

◮ Add a new formula construct S2(A) which admits 2

concurrent processes as realizers . . .

◮ . . . and add a new program constructor Amb(a1, a2) for the

concurrent execution of the processes ai (motivated by McCarthy’s Amb).

32 / 44

slide-75
SLIDE 75

Programs and rules for concurrency

◮ Add a new formula construct S2(A) which admits 2

concurrent processes as realizers . . .

◮ . . . and add a new program constructor Amb(a1, a2) for the

concurrent execution of the processes ai (motivated by McCarthy’s Amb).

◮ Amb(a1, a2) realizes S2(A) iff at least one ai is defined and all

defined ai realize A.

32 / 44

slide-76
SLIDE 76

Overview of further applications of program extraction

33 / 44

slide-77
SLIDE 77

Overview of further applications of program extraction

◮ Discrete structures

◮ Quotient and remainder on natural numbers. ◮ Dijkstra’s algorithm (1997, Benl, Schwichtenberg):

Reachable nodes in a weighted graph

◮ Warshall Algorithm (2001, Schwichtenberg, Seisenberger, B):

Transitive closure of a relation

33 / 44

slide-78
SLIDE 78

Overview of further applications of program extraction

◮ Discrete structures

◮ Quotient and remainder on natural numbers. ◮ Dijkstra’s algorithm (1997, Benl, Schwichtenberg):

Reachable nodes in a weighted graph

◮ Warshall Algorithm (2001, Schwichtenberg, Seisenberger, B):

Transitive closure of a relation

◮ Programs from classical proofs

◮ GCD (1995, B, Schwichtenberg):

Uses the Friedman/Dragalin A-translation

◮ Dickson’s Lemma (2001, Schwichtenberg, Seisenberger, B):

F/D A-translation in infinite combinatorics

◮ Higman’s Lemma (2008, Seisenberger):

Uses F/D A-translation and classical countable choice

◮ Fibonacci numbers from a classical proofs (2002, Buchholz,

Schwichtenberg, B): Uses F/D A-translation to obtain fast program

33 / 44

slide-79
SLIDE 79

◮ Lambda calculus:

◮ Extraction of normalization-by-evaluation (NbE) (2006,

Berghofer, Letouzey, Schwichtenberg, B): Extraction of NbE from Tait’s proof of strong normalization for the typed lambda calculus (in Isabelle, Coq, Minlog)

34 / 44

slide-80
SLIDE 80

◮ Lambda calculus:

◮ Extraction of normalization-by-evaluation (NbE) (2006,

Berghofer, Letouzey, Schwichtenberg, B): Extraction of NbE from Tait’s proof of strong normalization for the typed lambda calculus (in Isabelle, Coq, Minlog)

◮ Real numbers

◮ Cauchy sequences vs signed digit representation (SD):

Function vs stream representation, arithmetic operations.

◮ Integration w.r.t. SD (2011, B):

Real functions are given by trees realizing a nested coinductive/inductive definition

34 / 44

slide-81
SLIDE 81

◮ Lambda calculus:

◮ Extraction of normalization-by-evaluation (NbE) (2006,

Berghofer, Letouzey, Schwichtenberg, B): Extraction of NbE from Tait’s proof of strong normalization for the typed lambda calculus (in Isabelle, Coq, Minlog)

◮ Real numbers

◮ Cauchy sequences vs signed digit representation (SD):

Function vs stream representation, arithmetic operations.

◮ Integration w.r.t. SD (2011, B):

Real functions are given by trees realizing a nested coinductive/inductive definition

◮ Lists

◮ List reversal

Uses F/D A-translation to extract linear program from naive proof

◮ In-place Quicksort (2014, Seisenberger, Woods, B):

Extracts an ’imperative’ program

34 / 44

slide-82
SLIDE 82

◮ Satisfiabilty testing

◮ Extraction of a SAT-solver from completeness proof for DPLL

(2015, B, Forsberg, Lawrence, Seisenberger)

35 / 44

slide-83
SLIDE 83

◮ Satisfiabilty testing

◮ Extraction of a SAT-solver from completeness proof for DPLL

(2015, B, Forsberg, Lawrence, Seisenberger)

◮ Parsing

◮ Extraction of monadic parser combinators and left-recursion

elimination (Jones, Seisenberger, B)

35 / 44

slide-84
SLIDE 84

◮ Satisfiabilty testing

◮ Extraction of a SAT-solver from completeness proof for DPLL

(2015, B, Forsberg, Lawrence, Seisenberger)

◮ Parsing

◮ Extraction of monadic parser combinators and left-recursion

elimination (Jones, Seisenberger, B)

◮ Extensions: Extraction of

◮ concurrent programs (Miyamoto, Petrovska, Schwichtenberg,

Spreen, Takayama, Tsuiki, B)

◮ imperative programs with explicit memory management from

Separation Logic (Reus, B)

◮ modulus of uniform continuity from Fan Theorem (B) 35 / 44

slide-85
SLIDE 85

Concluding remarks

◮ The Curry-Howard correspondence and program extraction are

usually associated with constructive type theory (CTT), which is implemented, e.g., in Coq and Agda.

36 / 44

slide-86
SLIDE 86

Concluding remarks

◮ The Curry-Howard correspondence and program extraction are

usually associated with constructive type theory (CTT), which is implemented, e.g., in Coq and Agda.

◮ CTT rejects the classical notions of ’structure’ and ’truth’ and

identifies proofs with programs.

36 / 44

slide-87
SLIDE 87

Concluding remarks

◮ The Curry-Howard correspondence and program extraction are

usually associated with constructive type theory (CTT), which is implemented, e.g., in Coq and Agda.

◮ CTT rejects the classical notions of ’structure’ and ’truth’ and

identifies proofs with programs.

◮ The agenda of CTT (in particular its homotopic version) is

foundational: CTT proposes a new kind of mathematics.

36 / 44

slide-88
SLIDE 88

Concluding remarks

◮ The Curry-Howard correspondence and program extraction are

usually associated with constructive type theory (CTT), which is implemented, e.g., in Coq and Agda.

◮ CTT rejects the classical notions of ’structure’ and ’truth’ and

identifies proofs with programs.

◮ The agenda of CTT (in particular its homotopic version) is

foundational: CTT proposes a new kind of mathematics.

◮ In contrast, program extraction is rooted in first-order logic

with a classical Tarskian semantics.

36 / 44

slide-89
SLIDE 89

Concluding remarks

◮ The Curry-Howard correspondence and program extraction are

usually associated with constructive type theory (CTT), which is implemented, e.g., in Coq and Agda.

◮ CTT rejects the classical notions of ’structure’ and ’truth’ and

identifies proofs with programs.

◮ The agenda of CTT (in particular its homotopic version) is

foundational: CTT proposes a new kind of mathematics.

◮ In contrast, program extraction is rooted in first-order logic

with a classical Tarskian semantics.

◮ Program extraction is a technique to obtain provably correct

programs from proofs in ’ordinary’ mathematics.

36 / 44

slide-90
SLIDE 90

Some references

A S Troelstra, D van Dalen, Constructivism in Mathematics, Vol. I, N-H, 1988. D van Dalen, Logic and Structure, 3rd edition, Springer, 1994. B, K Miyamoto, H Schwichtenberg, M Seisenberger, Minlog - A Tool for Program Extraction for Supporting Algebra and Coalgebra, LNCS 6859, 2011. B, From coinductive proofs to exact real arithmetic: theory and applications, Logical Methods in Comput. Sci. 7, 2011,

37 / 44

slide-91
SLIDE 91

H Schwichtenberg, S S Wainer, Proofs and Computations, Cambridge University Press, 2012. H Tsuiki. Real Number Computation through Gray Code

  • Embedding. Theor. Comput. Sci. 284, 2002.

B, A Lawrence, F Nordvall, M Seisenberger. Extracting verified decision procedures: DPLL and Resolution. Logical Methods in Computer Science 11, 2015. B, O Petrovska. Optimized program extraction for induction and coinduction CiE 2018, LNCS 10936, 2018.

38 / 44

slide-92
SLIDE 92

Extracting the fan functional

Given: A continuous functional F : (N → B) → N (B = {0, 1})

39 / 44

slide-93
SLIDE 93

Extracting the fan functional

Given: A continuous functional F : (N → B) → N (B = {0, 1}) Since N → B is compact, F is uniformly continuous (fan theorem).

39 / 44

slide-94
SLIDE 94

Extracting the fan functional

Given: A continuous functional F : (N → B) → N (B = {0, 1}) Since N → B is compact, F is uniformly continuous (fan theorem). Wanted: The modulus of uniform continuity of F.

39 / 44

slide-95
SLIDE 95

Extracting the fan functional

Given: A continuous functional F : (N → B) → N (B = {0, 1}) Since N → B is compact, F is uniformly continuous (fan theorem). Wanted: The modulus of uniform continuity of F. That is, the least n such that for all α, β : N → B, if α(k) = β(k) for all k < n, then F(α) = F(β).

39 / 44

slide-96
SLIDE 96

Extracting the fan functional

Given: A continuous functional F : (N → B) → N (B = {0, 1}) Since N → B is compact, F is uniformly continuous (fan theorem). Wanted: The modulus of uniform continuity of F. That is, the least n such that for all α, β : N → B, if α(k) = β(k) for all k < n, then F(α) = F(β). The function F → n is called fan functional.

39 / 44

slide-97
SLIDE 97

Extracting the fan functional

Given: A continuous functional F : (N → B) → N (B = {0, 1}) Since N → B is compact, F is uniformly continuous (fan theorem). Wanted: The modulus of uniform continuity of F. That is, the least n such that for all α, β : N → B, if α(k) = β(k) for all k < n, then F(α) = F(β). The function F → n is called fan functional. We show that a program computing the fan functional can be extracted from a proof that F is uniformly continuous.

39 / 44

slide-98
SLIDE 98

Extracting the fan functional

Given: A continuous functional F : (N → B) → N (B = {0, 1}) Since N → B is compact, F is uniformly continuous (fan theorem). Wanted: The modulus of uniform continuity of F. That is, the least n such that for all α, β : N → B, if α(k) = β(k) for all k < n, then F(α) = F(β). The function F → n is called fan functional. We show that a program computing the fan functional can be extracted from a proof that F is uniformly continuous. The proof takes place in an extension of IFP by a ’bang operator’.

39 / 44

slide-99
SLIDE 99

Is the fan functional really computable?

Computing the fan functional seems an impossible task since we have: Theorem It is impossible to compute from a continuous functional F : (N → N) → N a modulus of (pointwise) continuity.

40 / 44

slide-100
SLIDE 100

The extracted program

Declarations: type N = Int

  • - 0,1,2,...

type B = Int

  • - 0,1

type B1 = N -> B

  • - Cantor space

type B2 = B1 -> N (***) :: [B] -> B1 -> B1 s *** alpha = \n-> if n < length s then s !! n else alpha (n - length s)

41 / 44

slide-101
SLIDE 101

The extracted program

minarg, maxarg :: B2 -> [B] -> B1

  • - minarg f s = some alpha s.t. f (s *** alpha) is minimal

minarg f s = let { s0 = s ++ [0] ; s1 = s ++ [1] ; alpha0 = minarg f s0 ; alpha1 = minarg f s1 } in if f (s0 *** alpha0) <= f (s1 *** alpha1) then [0] *** alpha0 else [1] *** alpha1 maxarg f s = ...

42 / 44

slide-102
SLIDE 102

Fan functional

  • - testing constancy

isconst :: B2 -> [B] -> Bool isconst f s = f (s *** (minarg f s)) == f (s *** (maxarg f s)) fan :: B2 -> N fan f = aux [] where

  • aux :: [B] -> N

aux s = if isconst f s then 0 else 1 + max (aux (s++[0])) (aux (s++[1]))

43 / 44

slide-103
SLIDE 103

Bang!

If A is a formula, then !A is a Harrop formula with a r !A Def = a = Nil ∧ ∀a (a r A).

44 / 44

slide-104
SLIDE 104

Bang!

If A is a formula, then !A is a Harrop formula with a r !A Def = a = Nil ∧ ∀a (a r A). For example, Nil r !(⊥ → A) since, a r (⊥ → A) ≡ ⊥ → a r A.

44 / 44

slide-105
SLIDE 105

Bang!

If A is a formula, then !A is a Harrop formula with a r !A Def = a = Nil ∧ ∀a (a r A). For example, Nil r !(⊥ → A) since, a r (⊥ → A) ≡ ⊥ → a r A. But !(0 = 0 ∨ 0 = 1) is not realizable.

44 / 44

slide-106
SLIDE 106

Bang!

If A is a formula, then !A is a Harrop formula with a r !A Def = a = Nil ∧ ∀a (a r A). For example, Nil r !(⊥ → A) since, a r (⊥ → A) ≡ ⊥ → a r A. But !(0 = 0 ∨ 0 = 1) is not realizable. Intuitively, !A expresses that A is true (realizable) for trivial reasons.

44 / 44

slide-107
SLIDE 107

Bang!

If A is a formula, then !A is a Harrop formula with a r !A Def = a = Nil ∧ ∀a (a r A). For example, Nil r !(⊥ → A) since, a r (⊥ → A) ≡ ⊥ → a r A. But !(0 = 0 ∨ 0 = 1) is not realizable. Intuitively, !A expresses that A is true (realizable) for trivial reasons. A realizable version of the law of excluded middle: ¬A → B A → !B !LEM B

44 / 44

slide-108
SLIDE 108

Bang!

If A is a formula, then !A is a Harrop formula with a r !A Def = a = Nil ∧ ∀a (a r A). For example, Nil r !(⊥ → A) since, a r (⊥ → A) ≡ ⊥ → a r A. But !(0 = 0 ∨ 0 = 1) is not realizable. Intuitively, !A expresses that A is true (realizable) for trivial reasons. A realizable version of the law of excluded middle: ¬A → B A → !B !LEM B Realizing !LEM: Assume a r (¬A → B) and Nil r (A → !B), that is, ¬∃c c r A → a r B and ∃c c r A → ∀b b r B. Using the (classical) law of excluded middle, we conclude a r B.

44 / 44