I am trying to develop a B specification for a small stock management system and I am battling with the error:
Lhs of binary operator should be a sequence (given type is POW(POW(INTEGERS * ORDERs)))
This is my Abstract Machine:
MACHINE
stock(ORDER, order_limit)
CONSTRAINTS
order_limit: NAT1
SETS
PART_COSTS;
PARTS;
ORDERS
CONSTANTS
backlog_limit
PROPERTIES
backlog_limit: NAT1 & backlog_limit <= 20
VARIABLES
limit,
backlog,
part_quantity
INVARIANT
backlog = iseq(ORDERS) & limit : NAT1 & card(backlog) <= limit & limit <= 20 &
part_quantity : NAT1 & part_quantity >= 200
INITIALISATION
limit := order_limit || backlog := iseq(ORDERS) || part_quantity := 0
OPERATIONS
receiveorder(order) =
PRE
order : ORDER & limit > card(backlog)
THEN
backlog := backlog <- order
END
END
I don't understand why I am getting this error since backlog is literally a sequence ( I initialised it as a sequence of the set (ORDERS)?
The first occurrence (after its declaration) of the symbol
backlog
is in the following typing predicate:backlog = iseq(ORDERS)
. Sobacklog
is the set of all injective sequences ofORDERS
values. You probably wanted to havebacklog: iseq(ORDERS)
, i.e.,backlog
is some injective sequence ofORDERS
.Of course, you need to change the initialization for
backlog
. You may initialize it with:backlog := []
backlog :: iseq(ORDERS)
iseq(ORDERS)
Finally, in operation
receiveorder
, the type for the input parameterorder
should be the type of the elements of thebacklog
sequence, that isORDERS
, and notORDER
(and you do not need machine parameters).