This document discusses behavior modeling using behavior algebra and Akka actors. It provides an example of modeling a coffee machine as a behavior using behavior algebra equations and then implementing it in Scala with Akka actors. Key points covered include:
- Defining behaviors as labeled transition systems (LTS) with states, actions, and transitions between states via actions
- Composing behaviors using operations like sequential composition, choice composition, and recursion to build larger behaviors from smaller ones
- Modeling a basic coffee machine as a behavior that can accept coins and button presses and dispense coffee
- Expanding the model to add features like accumulating credit from multiple coins and disabling/enabling the machine
- Implementing the coffee machine
2. // BASIC QUESTIONS //
BEHAVIOR DESCRIPTION
• What is a behavior ?
• How we can specify behavior ? (math / akka)
• Qustions with answer:
• Can we bring to programming/verification well-known
techniques from mathematics ?
• Questions without answer:
• Limit of applicability. When this can be useful ?
3. // WHAT IS A BEHAVIOR(?)//
.
Delta = End
STATE (S)
ACTION (A) (EVENTS)
B = E × S → S
4. // WHAT IS A BEHAVIOR(?)//
BEHAVIOR DESCRIPTION
Delta = End
STATE
ACTION (EVENTS)
BLTS = A × S → S
LTS = Labelled Transition System
s ∈ S
a ∈ A
→a ⊆ S × A × S
5. // WHAT IS A BEHAVIOR(?: AKKA)//
BEHAVIOR DESCRIPTION
STATE
ACTION (EVENTS)
Delta = End
BS
Akka ≈ A × BS
Akka → BS
Akka
val behavior(state) = Behaviors.onMessage {
case message => behavior(change(state))
}
Global Context
6. // WHAT IS A BEHAVIOR(?: AKKA)//
BEHAVIOR DESCRIPTION
STATE
ACTION (EVENTS)
Delta = End
BS
Akka ≈ A × BS
Akka → BS
Akka
BS
Akka ≈ BLTS × S
BLTS ≈ A × S → S
Classical OOP / FP difference
7. MAKE BIGGER BEHAVIOR BY COMPOSING RECURSIVE
EQUATIONS
BEHAVIOUR OPERATIONS
0
-1
B =
- 2
1
2
3
Left . (_ + 1) × B +
Right . (_ − 1) × B
Left . (_ + 1)
Right . (_ − 1)
20. BEHAVIOUR LOGIC
[μ]P
Henessy-Milner modal logic with recursion =
P will necessary hold after event
first-order logic +
< μ > P P is possible after event
Words to google: μ − calculus
Behavior Algebra Insertion Modelling
http://garuda.ai
21. BEHAVIOUR LOGIC
[μ]P
Henessy-Milner modal logic with recursion =
first-order logic + < μ > P
http://garuda.ai (demo)
+
We can automatically check feasibility of properties
Non-technical problems:
- verification != business value
- it is possible to kill the project with verification
23. BEHAVIOR ALGEBRA: CONCLUSION
Consider using Behavior Algebra interpreter
onTop/instead
- Actors,
- State-Machines
- Streams
when state graph is not trivial
-
It is possible to analyze properties of you system
completeness, liveness, safety ..
in automated way
// this will be mainstream during next 10-100 years