Structured reasoning about actor systems

Leonardo Angel - Mateo Sanabria Ardila

Leonardo estoy preparando clase para manana, en la noche o mas tarde le doy a las diapostivas

:D

3. Expressing local actor computation

module Clock-Actors {
     ...

     datatype Name := Ticker | Clock
     datatype TLS := local1 | local2 | local3
     datatype CLS := (local N)
     datatype TCLS := (ticker TLS) | (clock CLS)
     ...

     declare config: [(TP Name TCLS)] -> (Cfg (Actor Name TCLS))
     declare next: [TCLS (Step Name)] -> TCLS
     declare ready-to: [TCLS (Step Name)] -> Boolean
     ...
}

Ticker (definitions)

module Ticker {
 assert ready-to-definition :=
  (fun
   [(ls ready-to (send Ticker Ticker 'continue)) <==>
      (ls = ticker local1)  
    (ls ready-to (send Ticker Clock 'tick)) <==>
      (ls = ticker local2)  
    (ls ready-to (send Ticker id c)) <==> 
      [false  when (~ (id = Ticker & c = 'continue) &
                    ~ (id = Clock & c = 'tick))]
    (ls ready-to (receive Ticker Ticker 'continue)) <==>
      (ls = ticker local3)  
    (ls ready-to (receive Ticker fr c)) <==>
      [false  when (~ (fr = Ticker & c = 'continue))]
    (ls ready-to (create Ticker id')) <==> false])
 ...

 }

TICKER (DEFINITIONS)

module Ticker {
...
  assert next-definition :=
    (fun
     [(next (ticker local1) step) =
        [(ticker local2)  when (step = (send Ticker Ticker 'continue))
         (ticker local1)  when (step =/= (send Ticker Ticker 'continue))]
      (next (ticker local2) step) =
        [(ticker local3)  when (step = (send Ticker Clock 'tick))
         (ticker local2)  when (step =/= (send Ticker Clock 'tick))]
      (next (ticker local3) step) =
        [(ticker local1)  when (step = (receive Ticker Ticker 'continue))
         (ticker local3)  when (step =/= (receive Ticker Ticker 'continue))]])
...
}

CLOCK (DEFINITIONS)

module Clock {
  assert ready-to-definition :=
    (fun
     [(ls ready-to (receive Clock fr c))
         <==> (fr = Ticker & c = 'tick & exists t . ls = clock local t)
      (ls ready-to (send Clock to c)) <==> false
      (ls ready-to (create Clock id')) <==> (exists t . ls = clock local t)])
...
}

CLOCK (DEFINITIONS)

module Clock {
...
  assert next-definition :=
    (fun
     [(next (clock (local t)) (receive id fr c)) =
        [(clock (local (S t))) when (id = Clock & fr = Ticker & c = 'tick)
         (clock (local t))     when (~ (id = Clock & fr = Ticker & c = 'tick))]
      (next (clock (local t)) (send id to c)) = (clock (local t))
      (next (clock (local t)) (create id id')) = (clock (local t))])
}

Progress

module Progress {
 define Theory := 
  (theory-clone [Progress.Theory 'Clock CA] 
		 'Clock-Actors.Progress.Theory)
 define Theory1 := 
  (theory-clone [Theory 'Clone1 [sender Ticker  receiver Ticker]]
		 'Clock-Actors.Progress.Theory1)
 define Theory2 := 
  (theory-clone [Theory 'Clone2 [sender Ticker  receiver Clock]]
		 'Clock-Actors.Progress.Theory2)
}

Qué es theory-clone?

PATH example

define P :=
  ( Initial then (create Clock Ticker)
            then (send Ticker Ticker ’continue)
            then (send Ticker Clock ’tick)
            then (receive Clock Ticker ’tick)
            then (receive Ticker Ticker ’continue)
            then (send Ticker Ticker ’continue)
            then (send Ticker Clock ’tick)
            then (receive Ticker Ticker ’continue)
            then (send Ticker Ticker ’continue)
            then (send Ticker Clock ’tick)
            then (receive Clock Ticker ’tick))

PATH example

define M :=
	(One (message’ Ticker ls0 Clock ’tick))
define CM :=
	(One (message’ Ticker ls0 Ticker ’continue))
    
define P-result :=
  (config Initial =
  	s0 ++ (actor Clock (clock local zero) &
  (unique-ids
  	(config Initial) ++
  	(actor Ticker
  		(new-ls (clock local zero)))) &
  (clock (local zero ))
	ready-to (create Clock Ticker)
  ==>
  config P =
	s0 ++ (actor Clock
		(clock local (S (S zero )))) ++
	(actor Ticker (ticker local3)) ++ M ++ CM)
module Clock-Actors {
     ...

     datatype Name := Ticker | Clock
     datatype TLS := local1 | local2 | local3
     datatype CLS := (local N)
     datatype TCLS := (ticker TLS) | (clock CLS)
     ...

     declare config: [(TP Name TCLS)] -> (Cfg (Actor Name TCLS))
     declare next: [TCLS (Step Name)] -> TCLS
     declare ready-to: [TCLS (Step Name)] -> Boolean
     ...
}

Expressing local actor computation

Main sub-modules from Clock-Actors module:

- Ticker:

     Ticker can send continue messages to itself and tick messages to Clock.

- Clock:

     Each time Clock receives a tick from Ticker, increments its time.

- precedes

- Progress

actors

By Mateo Sanabria Ardila

actors

Reasoning about actor systems

  • 51