Topology, computation, monads, games and proofs Mart n Escard o 3 - - PowerPoint PPT Presentation

topology computation monads games and proofs
SMART_READER_LITE
LIVE PREVIEW

Topology, computation, monads, games and proofs Mart n Escard o 3 - - PowerPoint PPT Presentation

Topology, computation, monads, games and proofs Mart n Escard o 3 4 of this talk is joint work with Paulo Oliva from Queen Mary, London. MFPS 2010, Ottawa, May 6-10, 2010 Contents plan I. Topology in computation. Exhaustive search.


slide-1
SLIDE 1

Topology, computation, monads, games and proofs

Mart´ ın Escard´

  • 3

4 of this talk is joint work with Paulo Oliva from Queen Mary, London.

MFPS 2010, Ottawa, May 6-10, 2010

slide-2
SLIDE 2

Contents plan

  • I. Topology in computation.

Exhaustive search.

  • II. The selection monad.

Selection functions for generalized quantifiers.

  • III. Game theory.

Optimal plays and strategies.

  • IV. Proof theory.

Computational extraction of witnesses from classical proofs.

1

slide-3
SLIDE 3

Unifying concept: selection functions for quantifiers

A certain countable product of selection functions implements:

  • I. Topology in computation: Tychonoff theorem.
  • II. The selection monad: Strength.
  • III. Game theory: Optimal plays and strategies.
  • IV. Proof theory: Double-negation shift. Bar recursion.

2

slide-4
SLIDE 4

Time plan

Each part has half of the time allocated to the previous part. Even though it probably deserves twice as much.

3

slide-5
SLIDE 5
  • I. Topology and computation.

Old theorem. A set of natural numbers is exhaustively searchable iff it is finite. Intuition: How could one possibly check infinitely many cases in finite time? Proof: Removed from this intuition (Halting problem, diagonalization).

4

slide-6
SLIDE 6

Common wisdom

A set of whatever-you-can-think-of is exhaustively searchable iff it is finite. E.g. types in

  • 1. System T, PCF
  • 2. FPC, ML, Haskell etc.

5

slide-7
SLIDE 7

Can’t always trust common wisdom

E.g. The total elements of Nat → Bool are exhaustively searchable. Many other examples.

6

slide-8
SLIDE 8

Corollary

The type (Nat → Bool) → Nat has decidable equality.

  • Proof. Given f, g: (Nat → Bool) → Nat.

Check whether f(α) = g(α) for every α: Nat → Bool.

7

slide-9
SLIDE 9

Exhaustible set

A set K ⊆ X is exhaustible iff there is an an algorithm s.t.

  • 1. Input: p: X → Bool decidable.
  • 2. Output: True or False.
  • 3. Specification: output True iff ∃k ∈ K.p(k) = True.

The algorithm has higher type (X → Bool) → Bool.

8

slide-10
SLIDE 10

Searchable set

A set K ⊆ X is searchable iff there is an an algorithm s.t.

  • 1. Input: p: X → Bool decidable.
  • 2. Output: Either fail or some k ∈ K.
  • 3. Specification: output fail if ∀k ∈ K.p(k) = False,
  • r else k ∈ K with p(k) = True.

The algorithm has higher type (X → Bool) → 1 + X.

9

slide-11
SLIDE 11

Of course

Searchable = ⇒ exhaustible. This is so by definition.

10

slide-12
SLIDE 12

Searchable set, slightly different notion and formulation

A set K ⊆ X is searchable iff there is an an algorithm s.t.

  • 1. Input: p: X → Bool decidable.
  • 2. Output: k ∈ K.
  • 3. Specification: If ∃x ∈ K.p(x) = True then p(k) = True.

Otherwise p(k) = False, of course. Only difference: previous accounts for the empty set, this doesn’t. The algorithm has higher type (X → Bool) → X.

11

slide-13
SLIDE 13

Still

Searchable = ⇒ exhaustible. Given the potential example k ∈ K, check whether p(k) = True or p(k) = False. Better: the answer to the exhaustion procedure is just p(k).

12

slide-14
SLIDE 14

Summary of the two notions

K ⊆ X Exhaustible: algorithm ∃K : (X → Bool) → Bool. The boolean existential quantifier is computable. Searchable: algorithm εK : (X → Bool) → X. The set K has a computable a selection function. Derived functions: ∃K(p) = p(εK(p)). ∀K(p) = ¬∃K(¬ ◦ p).

13

slide-15
SLIDE 15

Theorem (LMCS’2008, ENTCS’2004)

Exhaustible sets (hence searchable sets) are topologically compact. Types with decidable equality are topologically discrete.

14

slide-16
SLIDE 16

First examples and counter-examples

  • 1. A set of natural numbers is compact iff it is finite.
  • 2. The maximal elements of the lazy natural numbers are searchable.

(Which amount to the one-point compactification of discrete natural numbers.)

  • 3. The set of all sequences α: Nat → Nat is not searchable.
  • 4. The set of sequences α: Nat → Nat such that αk < 17 is searchable.
  • 5. The set of sequences α: Nat → Nat such that αk < k is searchable.
  • 6. The set of sequences α: Nat → Nat such that αk < βk is searchable, for any

given sequence β : Nat → Nat.

15

slide-17
SLIDE 17

More examples (LMCS’2008)

Consider the types defined by the following grammar: compact ::= 1| compact + compact | compact × compact | discrete → compact, discrete ::= 1| Nat | discrete + discrete | discrete × discrete | compact → discrete . Theorem.

  • 1. Compact types are searchable.
  • 2. Discrete types have decidable equality of total elements.

E.g. (((Nat → 1 + 1) → Nat) → 1 + 1 + 1) → ((Nat → 1 + 1 + 1 + 1) → Nat) has decidable equality.

16

slide-18
SLIDE 18

Dictionary between topology and computation

Open set. Semi-decidable set. Closed and open set. Decidable set. Continuous map. Computable function. Compact set. Exhaustively searchable set. Discrete space. Type with decidable equality. Hausdorff space. Space with semi-decidable apartness. Take a theorem in topology, apply the dictionary, get a theorem in computability theory. Unfortunately you have to come up with a new proof.

17

slide-19
SLIDE 19

Theorems (LMCS’2008)

  • 1. The non-empty exhaustible sets are the computable images of the Cantor space

(Nat → Bool).

  • 2. Searchable sets are closed under computable images.
  • 3. Hence hence the non-empty exhaustible sets are searchable.

(Given yes/no algorithm, get an algorithm for witnesses.)

  • 4. Searchable sets are closed under countable products.

(Tychonoff theorem.)

  • 5. And under intersections with decidable sets.
  • 6. They are retracts of the types where they live.

18

slide-20
SLIDE 20

Is this feasible?

I have some counter-intuitively fast examples to show you.

19

slide-21
SLIDE 21
  • II. Selection functions for generalized quantifiers.

Pause to look at some motivating examples.

20

slide-22
SLIDE 22

Mean-value theorem

1

0 f = f(a).

The mean value is attained. If you travelled from London to Ottawa and your journey took 12 hours, then at some point you were travelling at 5379/12 ≈ 440km/h.

21

slide-23
SLIDE 23

Maximum-value theorem

sup1

0 f = f(a).

The maximum value is attained.

22

slide-24
SLIDE 24

Universal-value theorem

∀p = p(a). The universal value is attained. Known as Drinker paradox: In every pub there is a person a such that everybody drinks iff a drinks.

23

slide-25
SLIDE 25

Existential-value theorem

∃p = p(a). The existential value is attained. Another version of the Drinker paradox: In every pub there is a person a such somebody drinks iff a drinks.

24

slide-26
SLIDE 26

General pattern

φ(p) = p(a). R type of results. p: X → R. φ: (X → R) → R. Lives in the continuation monad. a ∈ X. We want to find a from given p, as a = ε(p). ε: (X → R) → X. Lives in the selection monad. φ(p) = p(ε(p)).

25

slide-27
SLIDE 27

Continuation monad

KX = ((X → R) → R). Well known, with many theoretical and practical uses.

26

slide-28
SLIDE 28

Selection monad

JX = ((X → R) → X). Images of searchable sets are searchable: f : X → Y Jf : JX → JY , Jfε = λq.f(ε(λx.f(q(x)). Singletons are searchable: η: X → JX, η(x) = λp.x. The union of a searchable set of searchable sets is searchable: µ: JJX → JX, µ(E) = λp.E(λε.p(ε(p)))(p).

27

slide-29
SLIDE 29

Monad morphism J → K

ε → φ where φ(p) = p(ε(p)). We write φ = ε. Then ε(p) = p(ε(p)). Definition. A quantifier φ ∈ KX is attainable if it has a selection function ε ∈ JX: φ = ε.

28

slide-30
SLIDE 30

J and K are strong

The strengths X × TY → T(X × Y ). extend to ⊗: TX × TY → T(X × Y ).

  • NB. The monads are not commutative.

The extension of the co-strengths TX × Y → T(X × Y ) give different maps ⊗′: TX × TY → T(X × Y ).

29

slide-31
SLIDE 31

Terminology and examples

  • 1. ⊗: KX × KY → K(X × Y ).

Product of quantifiers. (∀X ⊗ ∃Y )(p) = ∀x ∈ X.∃y ∈ Y.p(x, y). ∃X ⊗ ∃Y = ∃X×Y .

  • 2. ⊗: JX × JY → J(X × Y ).

Product of selection functions. (ε ⊗ δ)(p) = (a, b(a)) where b(x) = δ(λy.p(x, y), a = ε(λx.p(x, b(x)).

30

slide-32
SLIDE 32

Theorem

Attainable quantifiers are closed under finite products. Proof. The monad morphism gives ε ⊗ δ = ε ⊗ δ. Hence if φ = ε and γ = δ, then φ ⊗ γ = ε ⊗ δ, and so ε ⊗ δ is a selection function for φ ⊗ γ.

31

slide-33
SLIDE 33

Example 1

Binary Tychonoff theorem. The product of two searchable sets is searchable. Proof. ε ∈ JX selection function for ∃K ∈ KX with K ⊆ X. δ ∈ JY selection function for ∃L ∈ KY with L ⊆ Y . ε ⊗ δ selection function for ∃K ⊗ ∃L = ∃K×L ∈ K(X × Y ).

32

slide-34
SLIDE 34

Example 2

In every pub there are a man a and a woman b such that every man buys a drink to some woman iff a buys a drink to b. Proof. This amounts to (∀x ∈ X.∃y ∈ Y.p(x, y)) = p(a, b). By the Drinker paradoxes, the quantifiers ∀X and ∃Y have selection functions A and E. By the above theorem, the quantifier ∀X ⊗∃Y has a selection function A⊗E. Hence we can take (a, b) = (A ⊗ E)(p).

33

slide-35
SLIDE 35

Countable Tychonoff theorem for searchable sets

Arbitrary products of compact sets are compact. Countable products of searchable sets are searchable. Countable “strength”: :

i JXi → J i Xi,

characterized by

  • i εi = ε0 ⊗

i εi+1.

  • NB. This exists only in particular categories.

34

slide-36
SLIDE 36
  • III. Game theory.

Products of selection functions calculate

  • 1. optimal plays, and
  • 2. optimal strategies.

35

slide-37
SLIDE 37

Example 1

  • 1. Two-person game that finishes after exactly n moves.
  • 2. Eloise starts and alternates playing with Abelard. One of them wins.
  • 3. i-th move is an element of the set Xi.
  • 4. A predicate p: n−1

i=0 Xi → Bool tells whether Eloise wins.

  • 5. Eloise can win iff

∃x0 ∈ X0 ∀x1 ∈ X1 ∃x2 ∈ X2 ∀x3 ∈ X3 · · · p(x0, . . . , xn−1).

  • 6. If φ2i = ∃X2i and φ2i+1 = ∀X2i+1, this amounts to (n

i=1 φi) (p).

36

slide-38
SLIDE 38

Example 2

  • 1. Two-person game that finishes after exactly n moves.
  • 2. Eloise starts and alternates playing with Abelard. Lose, draw, win.
  • 3. i-th move is an element of the set Xi.
  • 4. A predicate p: n−1

i=0 Xi → {−1, 0, 1}.

  • 5. The optimal outcome of the game is

sup

x0∈X0

inf

x1∈X1

sup

x2∈X2

inf

x3∈X3 · · ·

p(x0, . . . , xn−1).

  • 6. If φ2i = supX2i and φ2i+1 = infX2i+1, this again amounts to (n

i=1 φi) (p).

37

slide-39
SLIDE 39

Sequential game of length n

X0, . . . , Xn−1 sets of possible moves at rounds 0, . . . , n − 1. p: n−1

i=0 Xi → R outcome (or pay-off) function.

φ0 ∈ KX0, . . . , φn−1 ∈ KXn−1 quantifiers for each round. We don’t stipulate who plays at each round. This is implicit in the choice of quantifiers.

38

slide-40
SLIDE 40

Subgame

Determined by a partial play a = (a0, . . . , an−1) ∈ k−1

i=0 Xi for k ≤ n:

(Xi, pa, φi). Here pa: n−1

i=k Xi → R is defined by

pa(xk, . . . , xn−1) = p(a0, . . . , ak−1, xk, . . . , xn−1), Like the original game but starts at the position determined by the moves a.

39

slide-41
SLIDE 41

Optimal outcomes and plays

  • 1. The optimal outcome of the game is w =

n−1

i=0 φi

  • (p).
  • 2. A play (a0, . . . , an−1) is optimal if

w() = w(a0) = w(a0,a1) = w(a0,a1,a2) = · · · = w(a0,a1,...,an−1). All players have played as best as they could.

40

slide-42
SLIDE 42

Example

The optimal outcome for tic-tac-toe is a draw. An optimal play is X X O X X O X X O O X X O O X X X O O O X X X O O O X X X X O O O X X O X X O O O X X O X

41

slide-43
SLIDE 43

Optimal moves and strategies

  • 1. A move ak ∈ Xk is optimal for a subgame (a0, . . . , ak−1) ∈ k−1

i=0 Xi if it

doesn’t change the optimal outcome. w(a0,...,ak−1) = w(a0,...,ak−1,ak).

  • 2. A strategy is a family of functions,

nextk :

k−1

  • i=0

Xi → Xk.

  • 3. A strategy is optimal if the move nextk(a) is optimal for every partial play a.

42

slide-44
SLIDE 44

Policy functions for the game

A policy is a sequence of selection functions εi: (Xi → R) → Xi for the game quantifiers. E.g., if the policy of the player is to maximize the payoff, then ε(p) is a point where p attains its maximum value.

43

slide-45
SLIDE 45

Calculating optimal plays and strategies

  • Theorem. Let (Xi, p, φi) be a game with policy functions εi.
  • 1. An optimal play is given by

a = n−1

  • i=k

εi

  • (p).
  • 2. An optimal strategy is given by

nextk(a) = n−1

  • i=k

εi

  • (pa)
  • .

44

slide-46
SLIDE 46

Nash equilibria for sequential games

Calculated as in the theorem, with R = Rn and φi = sup. (Simultaneous games are a completely different story.)

45

slide-47
SLIDE 47

Dependent product of selection functions

Sometimes the allowed moves depend on the played moves at previous rounds. Consider “dependent product” TX × (X → TY ) → T(X × Y ). E.g., (∃x ∈ X.∀y ∈ Yx.p(x, y)) = (φ ⊗ γ)(p) for φ = ∃X and γ(x) = ∀Yx. Iterating this (in)finitely often, we get

  • i
  • k<i

Xk → TXi

  • → T
  • i

Xi

  • .

Optimal plays and strategies calculated using this.

46

slide-48
SLIDE 48

Let’s run an example in the computer

If there is enough time left.

47

slide-49
SLIDE 49
  • IV. Proof theory.

Algebras of the monad J: JA → A. ((A → R) → A) → A. Propositions that satisfy Peirce’s Law. Get proof translation that eliminates Peirce’s Law directly. Connection with the double-negation translation via the morphism J → K.

48

slide-50
SLIDE 50

Double negation shift

∀i ∈ N.¬¬A(i) = ⇒ ¬¬∀i ∈ N.A(i). Used by Spector (1962) to interpret the classical axiom of countable choice. Can be written as a K-shift: ∀i ∈ N.KA(i) = ⇒ K∀i ∈ N.A(i). Non-intuitionistic principle, realized by Spector bar recursion.

49

slide-51
SLIDE 51

J-shift

The countable product functional :

i JXi → J i Xi realizes the J-shift

∀i ∈ N.JA(i) = ⇒ J∀i ∈ N.A(i). More general than the K-shift. is yet another form of bar recursion.

50

slide-52
SLIDE 52

Unifying concept: selection functions for quantifiers

  • I. Topology in computation.

Exhaustive search.

  • II. The selection monad.

Selection functions for generalized quantifiers.

  • III. Game theory.

Optimal plays and strategies.

  • IV. Proof theory.

Computational extraction of witnesses from classical proofs.

51

slide-53
SLIDE 53

Unifying concept: selection functions for quantifiers

The product of selection functions :

i JXi → J i Xi gives:

  • I. Topology in computation: Tychonoff theorem.
  • II. The selection monad: Strength.
  • III. Game theory: Optimal plays and strategies.
  • IV. Proof theory: Generalized double-negation shift, bar recursion.

52

slide-54
SLIDE 54

Unifying concept: selection functions for quantifiers

The product of selection functions :

i JXi → J i Xi gives:

  • I. Topology in computation: Tychonoff theorem.
  • II. The selection monad: Strength.
  • III. Game theory: Optimal plays and strategies.
  • IV. Proof theory: Generalized double-negation shift, bar recursion.

Thanks!

53

slide-55
SLIDE 55

References

  • 1. MHE. Synthetic topology of data types and classical spaces. ENTCS’2004.
  • 2. MHE. Infinite sets that admit fast exhaustive search. LICS’2007.
  • 3. MHE. Exhaustible sets in higher-type computation. LMCS’2008.
  • 4. MHE. Computability of continuous solutions of higher-type equations, LNCS’2009.
  • 5. MHE & PO. Selection functions, bar recursion, and backward induction, MSCS’2010.
  • 6. MHE & PO. Searchable Sets, Dubuc-Penon Compactness, Omniscience Principles,

and the Drinker Paradox. CiE’2010.

  • 7. MHE & PO. The Peirce translation and the double negation shift. LNCS’2010.
  • 8. MHE & PO. Computational interpretations of analysis via products of selection functions,

LNCS’2010.

54

slide-56
SLIDE 56

Links

http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/ http://math.andrej.com/2008/11/21/a-haskell-monad-for-infinite-search-in-finite-time/ http://www.cs.bham.ac.uk/~mhe/papers/index.html Maybe add links to the Haskell programs here.

55