An Operational Semantics for Probabilistic Concurrent Constraint ...

5 downloads 258 Views 218KB Size Report
Alessandra Di Pierro and Herbert Wiklicky. March 1998. ISSN 1364-4009. City University. Dept. of Computer Science. Northampton Square. London EC1V 0HB.
Computer Science Technical Reports

Technical Report No. 1998/01

An Operational Semantics for Probabilistic Concurrent Constraint Programming Alessandra Di Pierro and Herbert Wiklicky March 1998

ISSN 1364-4009

City University Dept. of Computer Science Northampton Square London EC1V 0HB United Kingdom

An Operational Semantics for Probabilistic Concurrent Constraint Programming Alessandra Di Pierro and Herbert Wiklicky fadp,[email protected]

Department of Computer Science City University London Northampton Square London EC1V OHB

Abstract This paper investigates a probabilistic version of the concurrent constraint programming paradigm (CCP). The aim is to introduce the possibility to formulate so called \randomised algorithms" within the CCP framework. Di erently from common approaches in (imperative) high-level programming languages, which rely on some kind of random() function, we introduce randomness in the very de nition of the language by means of a probabilistic choice construct. This allows a program to make stochastic moves during its execution. We call the resulting language Probabilistic Concurrent Constraint Programming (PCCP). We present an operational semantics for PCCP by means of a probabilistic transition system such that the execution of a PCCP program may be seen as a stochastic process, i.e. as a random walk on the transition graph. The transition probabilities are given explicitly. This semantics captures a notion of observables which combines results of computations and the probability of those results being computed. This embedding of randomness within the semantics of a well structured programming paradigm, like CCP, also aims at providing a sound framework for formalising and reasoning about randomised algorithms and programs. Additionally, we give some examples of PCCP programs and we show how well-known randomised algorithms can be implemented very naturally in the new language.

1 Introduction Algorithms incorporating randomness (e.g. a \coin ipping" device), such as those for calculating  or more generally the integration of complicated functions, have been known in mathematics for a long time (e.g. Monte Carlo algorithms). However, it is only in the last decade that algorithms where the ow of information is determined by an element of random choice (so called randomised algorithms) have found widespread application in many di erent areas of computer science, for example as a tool in computational geometry and number theory. They are intensively studied especially from a complexity theoretic point of view. Various randomised algorithms and procedures have been investigated, of which we mention just a few examples: simulated annealing in combinatorial optimisation 1

[1], genetic algorithms [5], probabilistic primality tests in particular for use in crypto-systems [19], and randomised proof procedures (e.g. for linear logic [15]). The bene ts of randomisation at the base of the tremendous growth of interest in such algorithms are simplicity and speed. For this reason the best known algorithms for many problems are nowaday randomised. In this paper we introduce a method for expressing randomness in concurrent constraint programming (CCP), to the purpose of using this paradigm to formalise randomised algorithms. In our approach we incorporate this element of randomness in the form of a probabilistic choice directly within the semantics. This is di erent from other approaches where randomness is introduced either in an ad-hoc way by referring to some \external" function or procedure call (like random() in imperative languages such as C or FORTRAN), or by means of random variables [13, 8]. The resulting language, which we call Probabilistic CCP (PCCP), is then the concurrent constraint programming language where nondeterministic choice is replaced by a probabilistic one. This allows a program to make stochastic moves during its execution. We de ne an operational semantics for PCCP by using the inductive style of Plotkin's SOS, i.e. by means of a transition system which describes the evolution of a program in a structural way [20]. Randomness is expressed by labels representing the probability that a transition takes place. Based on this we de ne a notion of observables which captures the ( nite) results of computation together with their probability of being computed. Since our intent is to randomise programs rather than data, we do not need to base our language on any kind of fuzzy or belief system [12]. Therefore, it is sucient for our purpose to maintain the same standard (cylindric) constraint system as in CCP. The embedding of randomness within the semantics of a well structured programming paradigm, like CCP, also aims at providing a sound framework for reasoning about randomised algorithms and programs. In fact, as already mentioned before, up to now probabilistic algorithms have been written by using imperative languages extended with random facilities like pseudo-random number generators, and have been analysed largely only by ad-hoc methods. However, real problems are normally quite complicated and intuition is very likely to fail. Therefore, a formal deductive system would be much more handy in such cases. The task of de ning such a system, which in imperative languages is a very complicated one, can be accomplished in CCP more easily, due to the \declarativeness" of this paradigm and its well-established denotational semantics simple and mathematically rigorous at the same time.

2 Probabilistic Nondeterminism Before introducing the probabilistic concurrent constraint (PCCP) language we discuss the basic question of what a probabilistic choice is and how it is di erent from a (purely) nondeterministic one.

2

2.1 Nondeterminism Nondeterminism in its pure form is not a computational concept: it just indicates all possible transitions in a machine, a deductive system, etc. but says nothing on how to make an actual choice among the various alternatives. Of course, in any physical realisation of a nondeterministic machine one has to deal with the problem of actually making choices. As a consequence, a \realistic" interpretation of a nondeterministic system is usually that nondeterministic choices, though beyond the control of the system itself, are supposed to be resolved by a scheduler. The scheduler is traditionally thought of as a ctitious entity called \adversary", for it is supposed to make the worst nondeterministic decisions (as a worst case context is normally considered in the study and analysis of algorithms). Alternatively, the problem of nondeterminism can be approached as the absence of information which needs to be speci ed for the system be able to continue its computation. In this case the solution is to \re ne" the notion of nondeterminism so as that some additional requirement on how the choice has to be made is available together with the possibility itself to make a choice. One example of such a \re nement" is the notion of a fair choice where it is required that all the possible choices are actually made sometime. Note that this only speci es something (additional) about the computation we might expect to observe, but does not change the (number of) possibilities of how to continue with that computation. Another example of providing more information of how possible branches of computation will be realised is the notion of a probabilistic choice. Here we put some requirement on the frequency of choices. We specify how likely it is (repeating the same computation `suciently' often) that a certain possible continuation of the computation is actually performed. In this paper we present a method of introducing a probabilistic nondeterminism in CCP. We explain the idea behind this notion by discussing an example well-known in probability theory, namely the random walk [6, 7].

2.2 Random Walk In order to illustrate the di erence between pure nondeterminism and our approach to a probabilistic version of nondeterminism consider a (directed or non-directed) graph ? = (N; E ). To each edge of ? is assigned a probability p(v) of choosing it. It is therefore reasonable (and necessary) to require that the sum of all probabilities assigned to the edges leaving one node is one. A so-called random walk on ? can be then described as follows: We start at an initial node and (according to the assigned probabilities) choose one adjacent node to go to. From there we repeat this procedure. We obtain this way some (random) path through the graph. In this setting we might not only ask if two nodes are connected, i.e. if a path exists, but also how likely it is to nd a path from one node to another. A very simple example of such a process is obtained by considering a random walk on a graph where each node corresponds to an integer, and two nodes are connected if they di er only by 1. If we further assume that the probability to go from one integer to its successor or to its predecessor is each 50% we get a process usually referred to as a symmetric random walk 3

P ::= D:A D ::=  j D:D j p(x) : ?A A ::= stop j tell(c) j

en

i=1 ci jpi

! Ai j A k A j 9xA j p(x)

Table 1: The syntax for PCCP. in one dimension, which perhaps resembles a drunken sailor's way staggering along a narrow street. We can calculate the probability p of how likely it is that after one step, or two steps, etc. we will be at position n in this graph. Let us express this by an ordered pair . Suppose we start at the origin 0, that is the initial situation is given by : with certainty we are at the origin. After one step, with probability 21 we will be either at position +1 or position ?1. If we continue this walk we get the following picture (where impossible positions, i.e. with p = 0 are omitted): 

fg