• No se han encontrado resultados

CANTO XIII*

In document Homero ILÍADA CANTO I (página 106-118)

The idea of macro-trajectories was suggested by the observation that

5.4. TRAJECTORIES OF COALGEBRAIC DYNAMICAL SYSTEMS 69

for the case of the specific f we had considered. Indeed, for an arbitrary argument to beh, this property does not hold:

levels ((beh (pair (id, \n -> if even n then [n-1, n+1] else []))) 3) ==> [3]

levels ((beh (pair (id, \n -> if even n then [n-1, n+1] else []))) 4) ==> [[4],[3,5]]

while in both cases the list on the right-hand side will be infinite. The reason this did not happen in the example we had is that the predicate given as first argument to the unfoldl function in levels, namely null , was always returning False. We can make a similar clame to the above if we replace levels by

levels0 = unfoldl (const False) (map getObs) (concat · map getNext ) · wrap where

getObs (Node (o, rts)) = o getNext (Node (o, rts)) = rts wrap rt = [rt ]

The infinite list on the right-hand side of the equation is computed by

[φ n [x ] | n ← [0 . .]] =

unfoldl (const False) id (concat · map f ) (wrap x )

(remember that φ 1 = concat · map f ).

We want to generalize levels0and the construction of φ in order to define macro-trajectories for other functors, but there are obvious dependencies in our definitions on [ ]-specific functions: map, concat and wrap. It is natural to think of restricting the functors F for which we can define macro- trajectories to those that come equipped with similar functions, but what does “similar” mean? What properties of map, concat and wrap are required for the above equation to hold? In order to answer this question, we have only one solution: we must prove the above equation (which is not really obvious anyway), and check which properties of the three [ ] specific functions are used.

Proposition 3 For any f :: X → [X ]

levels0· beh (pair (id , f )) = [φ n [x ] | n ← [0 . .]] Proof.

70 CHAPTER 5. DYNAMICAL SYSTEMS

unfoldl (const False) (map getObs) (concat · map (getNext )) · wrap · beh (pair (id , f ))

=

unfoldl (const False) id (concat · map f ) · wrap

It is tempting to try to fuse the computations on each side of the equation. Unfortunately, the fusion theorem cannot be applied for any side. For ex- ample, on the right-hand side, the fusion theorem would require finding a function g0 such that

concat · map f · wrap = wrap · g0

The right-hand side always creates a singleton, but the one on the left-hand side in general does not, therefore there is no such g0.

We need to guess an intermediate step, one to which we might apply fusion. For example, let us try to find an equality which holds when we throw away the wrap on the right-hand side of the original equality. A moment’s thought suggests the following

Lemma

unfoldl (const False) (map getObs) (concat · map (getNext )) · map (beh (pair (id , f )))

=

unfoldl (const False) id (concat · map f ) End of Lemma.

Assume we have shown the Lemma. Then, composing each side with wrap, we get on the right-hand side the desired result, and on the left we have

unfoldl (const False) (map getObs) (concat · map (getNext )) · map (beh (pair (id , f ))) · wrap

= { wrap natural transformation Id → [ ] }

unfoldl (const False) (map getObs) (concat · map (getNext )) · wrap · beh (pair (id , f ))

which is equal to the desired left-hand side. Therefore, we can establish the result if we can prove the Lemma. We note that we have used the naturality of wrap.

To prove the Lemma, we only need to check the three conditions for the application of fusion. We use the notation in Section 2.4, so that p = const False, f = map getObs, g = concat · map (getNext ), h = map (beh (pair (id , f ))), p0 = const False, f0 = id , g0 = concat · map f . We have to check

1. p0 = p · h

5.4. TRAJECTORIES OF COALGEBRAIC DYNAMICAL SYSTEMS 71

2. f0 = f · h

Expanding f · h we have

(map getObs) · map (beh (pair (id , f ))) = { map functor }

map (getObs · beh (pair (id , f ))) = { Definitions of getObs and beh }

map id

= { map functor } id

which is f0. We have used the functoriality of map, which will translate to the functoriality of fmap for a general functor F .

3. g · h = h · g0

Expanding the left-hand side, we have

(concat · map getNext ) · map (beh (pair (id , f ))) = { map functor }

concat · map (getNext · beh (pair (id , f ))) = { Definitions of getNext and beh }

concat · map (map (beh (pair (id , f ))) · f ) = { map functor }

concat · map (map (beh (pair (id , f )))) · map f = { concat natural transformation [[ ]] → [ ] }

map (beh (pair (id , f ))) · concat · map f

which is the right-hand side. Again we have used the functoriality of map, and, additionally, the naturality of concat .

All conditions check out: thus we have shown the Lemma, and conse- quently the Proposition.



We can now generalize this proposition to any functor F which is equipped with two natural transformations wrap::a → F a and concat ::F (Fa) → F a. The equivalent of Rose trees for such a functor is Tree F X , and the general breadth-first traversal is written as

bft = unfoldl (const False) (fmap getObs) (concat · fmap getNext ) · wrap where

getObs (T (o, xf )) = o getNext (T (o, xf )) = xf

72 CHAPTER 5. DYNAMICAL SYSTEMS

We have

Theorem 6 (General breadth-first traversal) For any colagebra f ::X → F X , the general breadth-first traversal of behavior (pair (id , f )) starting from a state x is equal to the trajectory of the classical discrete dynamical system given by the transition function

φ 1 = concat · fmap f That is:

bft (unfoldT (pair (id , f ))) = [φ n (wrap x ) | n ← [0 . .]]

By now, any Haskell programmer will have recognized that we propose to restrict our attention to the case in which F is a monad, replacing wrap by return and concat by join. This restriction is sufficient, although not necessary for the above result. For example, we could use, instead of the usual wrap for lists, the natural transformation λx → [x , x ], which no longer constructs a monad with the usual concat (it violates the law concat ·wrap = id ), but with which we still have the above result.

However, the cases encountered in practice, such as [ ]. SP and so on, are all monads. Therefore, the over-specialization does not seem excessive.

As an example, let us consider a stochastic version of our simple non- deterministic system:

st :: Integer → SimpleProb Integer st n = SP [(n − 1, 0.4), (n + 1, 0.6)] Using bft , we obtain:

bft (unfoldT (pair (id, st)) 3)

==> [SP [(3,1.0)],SP [(2,0.4),(4,0.6)], SP [(1,0.16),(3,0.48),(5,0.36)], ...

These are indeed the successive probability distributions over the states of the system st . The first one is the concentrated probability distribution corresponding to the given argument, and the rest result from the application of the conditional probability formula represented by st to the previous distribution. Such a computation is useful, for example, in many stochastic sequential decision problems where the control goal is to reach a certain macrostate after a number of states.

Perhaps surprisingly, since addHist does not change the functor of a coalgebraic system, we can use bft also to compute the micro-trajectories of the system:

bft (unfoldT (pair (id, addHist st)) [3])

==> [SP [([3],1.0)],SP [([2,3],0.4),([4,3],0.6)],

In document Homero ILÍADA CANTO I (página 106-118)

Documento similar