I'm writing an operation schema in Z. This operation AssignValue maps a property to one or more values.
One property may be linked to one or more values, and one value may be linked to one or more properties, forming a many-to-many relation, R ⊆ Property × Value.
I'm not sure how to write this operation to indicate that one property could be mapped to one or more values. I have two versions here. Version A seems to map one property to only one value.
Version A:
--AssignValue---
| p? : Property
| v? : Value
-------
|R′ = R ∪ { p? ↦ v? }
-------
In Version B, I have added a powerset in the declaration of v? to indicate that v? is a set of values (more than one value).
Version B:
--AssignValue---
| p? : Property
| v? : P Value
-------
|R′ = R ∪ { p? ↦ v? }
-------
Which version is correct? or there is a better way to represent this? I'm new to z-notation, any help would be greatly appreciated. Thanks!
You have not shown the whole schema. I assume that you have a state schema
S
with a relationR : Property<->Value
(equivalent toR ⊆ Property × Value
) andAssignValue
includes∆S
.Both styles could work, although your version B is probably not what you intended.
A relation is allowed to have many pairs with the same domain element, so starting with
You could call
AssignValueA
withp?=p0
,v?=v16
to get a state withthat is,
p0
is now mapped to three separate values.In your version B you have exactly the same thing, but your values are now sets of values. What you probably intended was that
R
would be a total function of typeProperty → Value
. Now, assuming only propertiesp0
throughp3
, you would have the initialR
asYou need to define
This has the same interface as
AssignValueA
, allowing addition of a single value to a single property per call.In both models a property may have no, one or many associated values, but the operation only allows one property to be assigned one extra value per call.
Exercise: try defining an operation that allows multiple properties to be assigned multiple extra values per call.