Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming With Non-Recursive Maps Last Update: Swansea, September, 2004 Stefano Berardi Università di Torino

Similar presentations


Presentation on theme: "Programming With Non-Recursive Maps Last Update: Swansea, September, 2004 Stefano Berardi Università di Torino"— Presentation transcript:

1 Programming With Non-Recursive Maps Last Update: Swansea, September, 2004 Stefano Berardi Università di Torino http://www.di.unito.it/~stefano

2 Summary 1. A Dream 2. Dynamic Objects 3. Event Structures 4. Equality and Convergence over Dynamic Objects 5. A Model Of  0 2 -maps 6. An example. 2

3 References This talk introduces the paper: An Intuitionistic Model of  0 2 -maps … in preparation. 3

4 1. A Dream If only we had a magic Wand … 4

5 Just Dreaming... A program would be easier to write using an oracle O for simply existential statements, i.e., using  0 2 -maps. O is no recursive map, it is rather a kind of magic wand, solving any question  x.f(x)=0, with f recursive map, in just one step. Our dream. To define a model simulating O and  0 2 -maps in a recursive way, closely enough to solve concrete problems. 5

6 The role of Intuitionistic Logic We define a model of  0 2 -maps using Intuitionistic Logic, in order to avoid any possibly circularity. Classical logic implicitely makes use of non- recursive maps. We want to avoid describing  0 2 -maps in term of themselves. 6

7 An example of  0 2 -map Denote by N  N the set of integer codes for total recursive maps over integers. Using Classical Logic, we may prove there is a map F:(N  N)  N, picking, for any f:N  N, some m = F(f) which is a minimum point for f:  x  N. f(m)  f(x) 7

8 An example of  0 2 -map Here is m=F(f): y=f(m) x=m x y y=f(x) 8

9 F is not recursive There is no way of finding the minimum point m of f just by looking through finitely may values of f. y=f(x) m x y Area explored by a recursive F 9

10  0 2 -maps solve equations faster Fix any three f, g, h:N  N. Suppose we want to solve in x the unequation system: f(x)  f(g(x)) f(x)  f(h(x)) x=F(f) is a solution: by the choice of x, we have f(x)  f(y) for all y , in particular for y=g(x), h(x). (1) 10

11 Did we really find a solution? Using the  0 2 -map F, we solved the system rather quickly, with x=F(f). The solution x=F(f), however, cannot be computed. Apparently, using non-recursive maps we only prove the existence of the solution. 11

12 Blind Search The only evident way to find the solution is blind search: to look for the first x  N such that f(x)  f(g(x)) f(x)  f(h(x)) This is rather inefficient in general. It makes no use of the ideas of the proof. (1) 12

13 Our Goal We want to define approximations of  0 2 -maps, in order to use them to solve problems like the previous system. 13

14 2. Dynamic Objects Truth may change with time … 14

15 An Oracle for Simply Existential Statements Our first step towards a model of  0 2 -maps is: to define, for any recursive map f:N  N, some approximation of an oracle O (f)  {True,False} for  x  N.f(x)=0. O is no recursive map. What do we know about  x  N.f(x)=0 in general? 15

16 What do we know about  x  N.f(x)=0? We have, in general, an incomplete knowledge about  x  N.f(x)=0. Assume that, for some x 1,..., x n, we checked if f(x 1 )=0,..., f(x n )=0 If the answer is sometimes yes, we do know:  x  N.f(x)=0 is True. If the answer is always no, all we do know is:  x  {x 1,..., x n }.f(x)=0 is false 16

17 The idea: introducing a new object Since we cannot compute the truth value of  x  N.f(x)=0, we represent it by introducing a new object: the family of all incomplete computations of  x  N.f(x)=0. That is: the family of truth values of all  x  {x 1,..., x n }.f(x)=0 for {x 1,..., x n } finite set of integers. 17

18 A notion of State We formalize the idea of incomplete computation of the truth value of  x  N.f(x)=0 by introducing a set T of computation states or “instants of time”. T is any partial ordering. Each t  T is characterized by a set a (t) of actions, taking place before t. In our case: a (t)={x 1,..., x n } Any “action” corresponds to some x  N for which we checked whether f(x)=0. 18

19 The truth value for  x  N.f(x)=0 The “truth value” V of  x  N.f(x)=0 is a family: {V(t)} t  T indexed over computation states, with V(t) = truth value of (  x  a (t).f(x)=0). The statement (  x  a (t).f(x)=0) is the restriction of (  x  N.f(x)=0) to the finite set a (t)  N associated to t. 19

20 V(t 0 )=V(u 0 )=V(v 0 )=F f(5)=7 f(4)=0 f(8)=2 f(2)=11 f(5)=7 f(9)=0 f(8)=2 f(6)=6 V(t 3 )=T V(t 2 )=T V(u 3 )=T V(t 1 )=F f(3)=1 V(u 1 )=F V(v 3 )=F V(v 2 )=F t3t3 t2t2 t1t1 V(u 2 )=F v3 v2v2 v1v1 u2u2 u1u1 u3u3 t0=u0=v0t0=u0=v0 20 In each t  T, we compute f(x) for some new x T

21 3. Event Structures We record all we did … 21

22 A notion of Event Structure An Event Structure consists of: 1. An inhabited recursive partial ordering T of states. 2. a recursive set A of actions, which we may execute in any state t  T, and which may fail. 3. A recursive map a : T  {finite subsets of A } a (t) = set of all actions executed before state t a is weakly increasing. 22

23 Covering Assumption Every action may be executed in any state: for any t  T, x  A, there is some possibly future u  t such that x  a (u) (x is executed before u). action x is executed here (it may fail) t u T (states) 23

24 An example of Event Structure We consider actions of the form : “send the datum d to the memory of name i”. A (actions) = Data  MemoryNames T (states) = List( A ) a (t) (actions before t)= { |  t} Any t  T describes a computation up to the state t. Most of the information in t is intended only as comment to the computation.

25 Positive Informations Assume  a (t): we sent datum d to the memory i before state t. Then d is paired with i in all possible futures u of t (in all u  t), because a is weakly increasing. In Event Structure we represent only positive informations: erasing is not a primitive operation. Erasing may be represented by using a fresh name for any new state of the memory i:,,, …

26 Erasing in Event Structures When memory i is in the state number n, its current content are only all d such that >  a (t) When the state number changes, the current content d of memory i is lost forever. Every action a = > referring to a state m different from the current state (with m  n) “fails” (by this we mean: a is recorded, but d is never used).

27 Dynamic Objects Fix any recursive set X. We call any recursive L: T  X a dynamic object over X Dyn(X) = {dynamic objects over X} Dyn(Bool) is the set of dynamic booleans. The value of a dynamic object may change with time, and it may depends on all data we sent to any memory. 27

28 Embedding X in Dyn(X) Static objects (objects whose value does not change with time) are particular dynamic objects. There is an embedding (.)°:X  Dyn(X), mapping each x  X into the dynamic object x°  Dyn(X), defined by x°(t) = x for all t  T 28

29 Morphisms over Dynamic Objects Fix any recursive sets X, X’, Y. Any recursive application f : X, X’  Y may be raised pointwise to a recursive application: f° : Dyn(X), Dyn(X’)  Dyn(Y) defined by f°(L)(t) = f(L(t)), for all t  T. For instance we set: (L +° M)(t) = L(t) + M(t) We consider all maps of the form f° as morphisms over dynamic objects. 29

30 Morphisms over Dynamic Objects A morphism over dynamic objects should take the current value L(t)  X of a dynamic object and return the current value f(L(t))  Y of another one In general, however, f(L(t)) could be itself dynamic, that is, it could depend on time. The same value L(t) could correspond to different values f(L(t)) for different t. Thus, a morphism will be, in general, some map L, t  f(L(t))(t) 30

31 Morphisms over Dynamic Objects Fix any recursive sets X, Y. We call an application  : Dyn(X)  Dyn(Y) a morphism if  (L)(t) depends only over the current value L(t) of L, and on t  T :  ( L )(t) =  ( L(t)° )(t) for all t  T 31

32 Raising a map to a morphism For all recursive X, Y, every recursive f:X  Dyn(Y) may be raised to a unique morphism f* :Dyn(X)  Dyn(Y) Set, for all t  T, and all L  Dyn(X): f*(L)(t) = f(L(t))(t)  Y f*(L) is called a synchronous application: the output f(.)(t) and the input L(t) have the same clock t  T 32

33 L(t 0 ) L(t 1 ) L(t 2 ) XY f* 33 f(L(t 1 ))(t 1 ) f(L(t 2 ))(t 2 ) f(L(t 0 ))(t 0 )

34 4. Convergence and Equality for Dynamic Objects We interpret parallel computations in Event Structures. 34

35 Some terminology for Parallel Computations Computation states. They include local states of processes, and the state of a common memory. Computation. An asyncronous parallel execution for a finite set of processes. Agents. Processes modifying the common memory. Clusters of Agents. Finite sets of agent, whose composition may change with time. 35

36 Interpreting Computation States Any t  T describes a possible state of a computation. Any weakly increasing succession  :N  T represents a possible history of a computation. 36

37 Interpreting Computations A computation is any weakly increasing total recursive succession  :N  T of states.  (0)  (1)  (2)  (3) T (states) 37

38 Execution of an Agent An agent outputs actions, possibly at very long intervals of time. Any action may take very long time to be executed. We allow actions to be executed in any order. Many other actions, from different agents, may be executed at the same time: there is no priority between agent. 38

39 Interpreting Agents A agent is a way of choosing the next state in a computation. A agent is any total recursive map A : T  A taking an state t, and returning some action A(t)  A to execute from t. If  is any computation, we define the set of actions of  by  n  N a  (n)) 39

40 Computations executing an Agent We say that a computation  :N  T executes a agent A, or  :A for short, iff for infinitely many i  N: A(  (i))   {actions of  } That is: for infinitely many times, the action output by A at some step of  are executed in some step in  (maybe much later) If  : F, and  is subsuccession of , we set by definition  : F. 40

41 Computations executing an Agent If a computation  executes a agent A, then A “steers”  : for infinitely many times, the next position in  is partly determined by the action output by A.  (0)  (1) Constraint: a (  (2))  A(  (1))  (3)  (2) T (states) 41

42 Computations executing many Agents Many agents A, B, C, … may “steer” infinitely many times the same computation  : "  (0)  (1) Constraints: a (  (2))  A(  (1)), B(  (1))  (4)  (2)  (3) Constraint: a (  (4))  C(  (3)) T (states) 42

43 Interpreting Clusters of Agents A cluster is a set of agents variable in time, represented by a total recursive map F : T  {finite sets of agents} taking an state t  T, and returning the finite set of agents which are part of the cluster in the state t. The agent A corresponds to the cluster constantly equal to {A}. 43

44 Computation executing a Cluster We say that  executes a cluster F, or  : F, iff for all agents A there are infinitely many i  N such that if A  F  i)  then A  i)   {actions of  } In infinitely many steps of , provided A is currently in  F, the action output by A takes place (maybe much later) in  If  : F, and  is subsuccession of a , we set by definition  : F. 44

45 Two Sets of of Computations Let  :N  T be any computation, L, M: T  X any dynamic objects. L  is the set of computations  :N  T such that L  (n) = L  (n+1) : X, for some n  N (L=M) is the set of computations  :N  T such that L  (n) = M  (n) : X, for some n  N 45

46 Forcing We say that a cluster F forces a set P of computations, and we write F : P iff  : F implies  P (if all computations executing F have the property P ). 46

47 Convergence and Equality for Dynamic Objects Let L, M: T  X be any dynamic objects. L is convergent iff F : L  for some F L,M areequivalent iff F : (L=M) for some F We think of a convergent dynamic object as a process “learning” a value. Let P: T  Bool be any dynamic boolean. P is trueiff F :(P=True°)for some F 47

48 A “steers”  forcing L  Assume A:L  48 Constraint: a (  (6))  A(  (5)) Constraint: a (  (2))  A(  (1))  (0)  (1)  (2)  (3)  (4) L(  (4))=13  (5) L(  (5))=13  (6) L(  (6))=13 …

49 About Convergence Assume F forces L  to converge. Classically, we may prove that if  : F, then L  is stationary. However: On two different computations following F, L may converge to different values. On some computation not following F, L may diverge.

50 L  (0)=7 L  (2)=3 L  (1)=2 L  (3)=3 L  (2)=4 L  (1)=4 L  (1)=1 L  (2)=9  : F  L  is convergent  : F  L  is convergent 50  does not follows F : L  can diverge

51 Termination for clusters The clusters F and  ° are both dynamic objects over P fin ( A ). A cluster F is call terminating iff F : ( F =  °) (if we execute F, eventually F becomes empty) If F is terminating, and  follows F, then F (  (i))=  for some i  N. 51

52 5. An Intuitionistic Model Of  0 2 -maps Just a bit of Category Theory … 52

53 The Category Eff Eff is the Category of Countable Effective Sets. Objects of Eff are: Partial Equivalent Relations over N Morphisms of Eff are: Recursive Maps compatible with such Relations 53

54 The extension L X of X For all X  Eff, we call L X the set of convergent dynamic objects, quotiented up to equivalence. L is a Subcategory of Eff, whose morphisms are the morphism over dynamic objects preserving: 1. convergence of a dynamic object 2.equivalence of two dynamic objects. 54

55 L X is an Universal Construction Theorem ( L X is an Universal Construction). (.)°:X  L X is a universal morphism for the Category Eff w.r.t. the Category L. 55

56 Lifting a map to L X  L Y Since (.)°:X  L X is a universal morphism, we may lift every total recursive map f:X  Y to some map f°: L X  L Y, defined by: f° = (f  (.)°)* or, alternatively, by: f°(L)(t) = f(L(t)) for all t  T Lemma (Density). If f(x)=g(x) is true for all x  X, then f°(L)=g°(L) is true for all L  L X. 56

57 L N is a model of  0 2 -maps Theorem ( L N is a model  0 2 -maps). 1.Morphisms over L N are the smallest class: including oracles for  0 1 -statements, Including any (lifting of) total recursive map over N closed under minimalization. 2. L N may be defined using only terminating clusters.

58 L X is a Conservative Extension of X For all total recursive f, g:X  Y, any equation f(x)=g(x) over x  X may be raised to some equation f°(L)=g°(L) over L  L X. Theorem (Conservativity). If F : f°(L)=g°(L) for some L  L X, then f(x)=g(x) for some x  X. Conservativity allow to use L X in order to solve concrete problems about X. 58

59 Solving equations in X In order to find some solution x  X to f(x)=g(x), it is enough to find some convergent dynamic solution L  L X of f°(L)=g°(L), then turn L into a solution x  X of f(x)=g(x). x may be effectively computed out of L and the cluster F forcing f°(L)=g°(L). F is the constructive content of a classical proof of f°(L)=g°(L). 59

60 Solving equations in X: a Rule of Thumb Assume F : f°(L)=g°(L). We may assume F terminating. 1.Pick any  following F. 2.Look for the first i such that F (  (i))=  (there is some because F is terminating). 3. Now x=L(  (i)) is a solution of f(x)=g(x). 60

61 6. An Example: Solving System (1) Is it a game or is it real? 61

62 Solving f°(x)  f°(g°(x)) f°(x)  f°(h°(x)) (1)° is the corresponding of (1) in L N. Classically, and in N, a solution of (1) is any minimum point x  N of f on N. Intuitionistically, and in L N, a solution of (1)° is any minimum point M  L N of f°on L N. Any solution of (1)° in L N may be effectively turned into some solution of (1) in N. (1)° 62

63 Minimum point as dynamical object Fix f:N  N total recursive. There is some M  L N such that f°(M)  f°(L) for all L  L N. We may define M: T  N, on all t  T, by M(t) = first minimum point of f over a (t)  {0} M is convergent if restricted to any computation, because it changes value at most f(0) times. 63

64 Minimum point as dynamical object M(t) is, in fact, the minimum point of f over the finite set of integers we explored up to the state t  T. a (t)  {0} M(t) y=f(x) x y 64

65 Minimum point as dynamical object A agent forcing ( f°(M)  f°(x°) ) = True° for x  N is Add(x): T  A, defined for all t  T by: Add(x)(t) = if f(M(t))  f(x) then  else {x} In any computation  which follows Add(x), we have f(M(  (i)))  f(x) true, from some i  N on. From the same i on we have Add(x)(  (i)) =  : Add(x) is terminating 65

66 Minimum point as dynamical object (f°(M)  f°(L)) is true for all L  L N. We may check that a agent forcing (f°(M)  f°(L)) to be true is obtained by lifting Add: Add*(L) : T  A 66

67 An integer solution of system (1) x=M  L (N) solves f°(x)  f°(g°(x)) f°(x)  f°(h°(x)) By the previous page, a cluster forcing (1) is F = { Add*(g°(M)), Add*(h°(M)) } We may check that F is terminating. We may effectively turn M into a solution x=m  N of (1). How is computed m? (1)° 67

68 The agent Add*(g°(M)) Just by definition unfolding: Add*(g°(M))(t) = (by definition of *) Add(g°(M)(t))(t) = (by definition of °) Add(g(M(t)))(t) = (by definition of Add) if f(M(t))  f(g(M(t))) then  else {g(M(t))} Add*(g°(M)) adds g(M(t)) to a (t), if the dynamic boolean f(M(t))  f(g(M(t))) is false. 68

69 The agent Add*(h°(M)) Same as before: Add*(h°(M))(t) = if f(M(t))  f(h(M(t))) then  else {h(M(t))} Add*(h°(M)) adds h(M(t)) to a (t), if the dynamic boolean f(M(t))  f(h(M(t))) is false. 69

70 The cluster F Pick any computation  which follows F = {Add*(g°(M)), Add*(h°(M)) At each step i  N, if for x=M(  (i)) either f(x)  f(g(x)) or f(x)  f(h(x)) are false, we form a (  (i+1)) by adding either g(x) or h(x) to a (  (i)). Otherwise we add nothing, F (  (i))=  becomes empty, and x=M(  (i)) is a solution of (1). 70

71 An algorithm solving system (1) The intuitionistic proof of solvability of system (1) in L N implicitely contains a non-deterministic algorithm finding a solution of (1) in N: 1. Start from x:=0. 2. Set x:=g(x) or x:=h(x) if, respectively, f(x) > f(g(x)) or f(x) > f(h(x)). 3. Continue until f(x)  f(g(x))  f(x)  f(h(x)) 71

72 Conclusions If we have to find some x 1, …, x n  N such that P(x 1, …, x n ), for some total recursive property P, it is enough to find some L 1, …, L n  L N and a cluster F forcing P°(L 1, …, L n )=True°. If F is terminating, to solve P(x 1, …, x n )=True we pick any computation  following F. We look for the first i such that F (  (i))= . Eventually, we set x 1 =L 1 (  (i)), …, x n =L n (  (i)). This method is no blind search. In fact it makes no reference to P, only to F. 72


Download ppt "Programming With Non-Recursive Maps Last Update: Swansea, September, 2004 Stefano Berardi Università di Torino"

Similar presentations


Ads by Google