Rodin HandbookThis work is sponsored by the Deploy Project This work is licensed under a Creative Commons Attribution 3.0 Unported License |
3.2.3 MachinesA machine describes the dynamic behavior of a model by means of variables whose values are changed by events. There are two basic things that must be proven for a machine:
3.2.3.1 Refinement and Abstract machinesA machine can refine at most one other machine. We refer to the refined machine as the abstract machine and refer to the refinement as the concrete machine. More generally, a machine Basically, a refinement consists of two aspects:
The full invariant of the machine consists of both abstract and concrete invariants. The invariants are accumulated during refinements.
3.2.3.2 Seeing a context If the machine sees a context, the sets and constants declared in the context can be used in all predicates and expressions. The conjunction of axioms 3.2.3.3 Variables and invariants Variables can be declared by adding their unique name (an identifier) to the Variables section. The type of the variables must be inferable by the invariants of the machine. We denote the variables of the abstract machines An invariant is a statement that must hold at each state of the machine. Each invariant We write Invariants that are marked as theorems derive their correctness from the preservation of other invariants, so their preservation does not need to be proven. The proof obligation can be found in 3.2.5.2. If an invariant contains a well-definedness condition, a corresponding proof obligation is generated (see 3.2.4.2). 3.2.3.3.1 Common variables between machines With some restrictions, the abstract variables 3.2.3.4 EventsA possible state change of a machine is defined by an event. The condition under which an event can be executed is given by a guard. The event’s action describes how the new and old state relate to each other. Events occur atomically (i.e. one event happens at a time) leading to a new state. Two events never happen at the same time. Time is also not factored into the execution of the event. An event has the following elements:
An event can refine one or more events of an abstract machine. To keep things simple, we will first consider events with only one refined event. If there are several refinement steps – e.g. event 3.2.3.4.1 Parameters An event may have an arbitrary number of parameters. Their names must be unique, i.e. there must be no constant or variable with the same name. The types of the parameters must be inferable by the guards of the event. We denote the parameters of all abstract events with Similarly to variables, an event can have parameters in common with the event it refines. If the refined event has a parameter 3.2.3.4.2 Guards Each guard consist of a label and a predicate We write Like axioms and invariants, guards can be marked as theorems, too. The proof obligation can be found in 3.2.5.3. If the guard contains WD-conditions, a proof obligation is generated See 3.2.4.3 for the proof obligation. 3.2.3.4.3 ActionsAn action is composed of a label and an assignment. Section 3.3.8 gives an overview of how they are assigned. They can be put into two groups: deterministic and non-deterministic assignments. Each assignment affects one or more concrete variables. If an event has more than one action, they are executed in parallel. An error will occur if a new value is assigned to a variable in more than one action. All variables to which no new value is assigned keep the same value in new and old state. We now define the before-after-predicate Please note that Rodin optimizes proof obligations when a before-after-predicate is a hypothesis. 3.2.3.4.4 WitnessesWitnesses are composed of a label and a predicate that are is to establish a link between the values of the variables and parameters of the concrete and abstract events. Most of the time, this predicate is a simple equality.
If the user does not specify a witness, Rodin uses the default witness Witnesses are necessary in the following circumstances:
We denote the conjunction of all witnesses of an event with The feasibility of the witness must be proven, i.e. that there is actually a value such that the predicate holds.
A witness may contain well-definedness conditions, see 3.2.4.4 for the corresponding proof obligation. 3.2.3.4.5 Initialization The initialization of a machine is given by a special event called INITIALISATION. Unlike other events, the initialization must not contain guards and parameters. The actions must not make use of variable values before the initialization event occurs. All variables must have a value assigned to them. If there is no assignment for the variable 3.2.3.4.6 Ensuring machine consistencyThe following proof obligations are generated for events: The assignment of each action must be well-defined when the event is enabled, see 3.2.4.5 for the corresponding proof obligation. If the event’s guard is enabled, every action must be feasible. This is trivially true in the case of the deterministic assignments. For a non-deterministic assignment
For each invariant
Rodin simplifies this proof obligations by replacing There are special cases regarding initialisation:
3.2.3.5 Ensuring a correct refinementAn event can refine one or more events of the abstract machine. We first consider the refinement of only one event. For refining more than one event (i.e. merging events), please see below in Section 3.2.3.6. If an event does not refine an abstract event, it is implicitly assumed that it refines skip, the event that is always enabled (i.e. its guard is 3.2.3.5.1 Guard strengthening A concrete event must only be enabled if the abstract event is enabled. This condition is called guard strengthening. For each abstract guard
3.2.3.5.2 Action simulation If an abstract event’s action
When the assignments are deterministic or the witnesses are equations, the proof obligation can usually be simplified by Rodin. 3.2.3.5.3 Preserved variables If
3.2.3.6 Merging eventsRefining more than one abstract event by a single event is called merging of events. To merge events, two conditions must be taken into account.
Instead of the guard strengthening proof obligation, the following proof obligation is created with
The other proof obligations are the same than refining a single event. Also the same rules for defining witnesses apply. 3.2.3.7 Extending eventsInstead of refining another event, an event can extend it. In this case the refined event will implicitly have all the parameters, guards and actions of the refined event. It can have additional parameters, guards and actions. The ability to extend an event is just syntactic sugar – the same effect can be achieved by manually copying the parameters, guards and actions. This is especially usefull when additional features are gradually introduced into a model by refinement, which is also called “superposition refinement”. 3.2.3.8 Termination Event-B makes it possible to prove the termination of events in a model. Termination means that a chosen set of events are enabled only a finite number of times before an event that is not marked as terminating occurs. To support proofs for termination, a variant Events can be marked as
Informally, termination is proven by stating that the convergent events strictly decrease the variant which has a lower bound. If a model contains a convergent event, a variant must be specified. If only anticipated events are declared, it is sufficient to assume a default constant variant such that all anticipated events do not increase the variant. When an event is marked as anticipated, one must just prove that the event does not increase the variant. The proof of termination is then delayed to the refinements of the anticipated event. A refinement of an anticipated event must be either anticipated or convergent. If the convergence of an event is proven, the convergence its refinements is also guaranteed due to the guard strengthening. A variant must be well-defined, the corresponding well-definedness proof obligations can be found in 3.2.4.6. The following other proof obligations are generated: 3.2.3.8.1 Numeric variantIf the variant is numeric an anticipated or convergent event must only be enabled when the variant is non-negative.
A convergent event must decrease the variant
and an anticipated event must not increase the variant.
3.2.3.8.2 Set variantIf the variant is a set t must be proven that the set is always finite:
A convergent event must remove elements from the set
and an anticipated event must not add elements.
|