Agents
An agent is a process template: local attributes plus process equations over transitions.
agent Name(param1 : Type1, param2 : Type2) {
attributes {
attr1 : Type = initialValue ;
}
process {
Eq1 = <behavior expression> ;
Eq2 = <behavior expression> ;
}
invariants { // optional
Eq1 : <expression> ;
}
}Parts#
- Parameters — instantiation parameters (for example an agent ID). The parentheses are required, even when empty; a parameter without a type is an
Int. attributes { }— local state. The block is required; it may be empty. The compact forms (name lists, ranges, overrides) of schemas work here too.process { }— named process equations (Name = behavior ;). The first equation is the initial behavior.behavior { }is accepted as an alias ofprocess { }.invariants { }— optional formulas attached to equations of this agent:Eq : φ ;attaches the formulaφto equationEq. The analyzer's STL phase checks whether the transitions ofEqpreserve it and, with--verbose, printsinvariant-checked Eq: preserved,not-preservedorundecided. Naming an equation the agent does not have is an error.
The behavior operators (., +, ||, guards, branch, atomic, …) are described in Process Calculus.
Example#
type PhilState = { THINKING, HUNGRY, EATING } ;
agent Philosopher(id : Int) {
attributes {
state : PhilState = THINKING ;
}
process {
Think = getHungry(id) . TryForks ;
TryForks = pickLeft(id) . pickRight(id) . Eat
+ pickRight(id) . pickLeft(id) . Eat ;
Eat = startEating(id) . Release ;
Release = putLeftFork(id) . putRightFork(id) .
finishEating(id) . Think ;
}
invariants {
Eat : state == HUNGRY || state == EATING ;
}
}Philosopher loops through Think, TryForks, Eat and Release. The + in TryForks is the nondeterministic choice of which fork is picked up first.