Inventories and requirement contexts [000W]
- November 3, 2025
In order to be able to properly express typing rules for the command monad, we first need to develop some additional machinery.
XXX note inventories are kind of like the free commutative monoid over entities, but with possibility of infinite cardinality. Like a free "star-commutative monoid". Star commutative monoid = commutative monoid with an additional operation a^* satisfying the axiom a^* = aa^*?
Definition Extended natural numbers [0013]
- November 4, 2025
We write \mathbb {N}_\infty = \mathbb {N} \cup \{\infty \} to denote the natural numbers extended with a special positive infinity value.
- Addition on \mathbb {N}_\infty satisfies n + \infty = \infty + n = \infty for all n \in \mathbb {N}_\infty , and is standard on \mathbb {N}.
- a \leq b if and only if there exists c \in \mathbb {N}_\infty such that a + c = b. In other words, \leq is standard on \mathbb {N}, and n \leq \infty for all n.
- Multiplication is standard on \mathbb {N}, with 0 \times \infty = \infty \times 0 = 0 and n \times \infty = \infty \times n = \infty for n > 0.
Under these definitions, (\mathbb {N}_\infty , +, 0, \times , 1) forms a (naturally ordered) commutative semiring.
Definition Inventories [0012]
- November 4, 2025
An inventory is a multiset of entities, that is, a function \mathbf {E} \to \mathbb {N}_\infty assigning a nonnegative (possibly infinite) multiplicity to each entity.
Definition Inventory union [001H]
- November 13, 2025
We define the union of inventories, I \cup J, as the inventory \lambda e.\; I(e) + J(e), the componentwise sum of inventories I and J. Inventories form a monoid under union, with the empty inventory \lambda e.\; 0 as the identity element.
Definition Inventory ordering [001I]
- November 13, 2025
If I and J are inventories, we write I \subseteq J to mean that I(e) \leq J(e) for every e \in \mathbf {E}, that is, J contains at least as many copies of each entity e as I does. Equivalently, I \subseteq J iff there exists an inventory K such that I \cup K = J.
Definition Inventory replication [001J]
- November 13, 2025
If k \in \mathbb {N}_\infty and I is an inventory, we define k \cdot I as the inventory \lambda e.\; k \times I(e); that is, intuitively, k \cdot I consists of the union of k copies of I. The inventory monoid together with this action by \mathbb {N}_\infty forms a left semimodule.
Notation Converting sets to inventories [00H3]
- June 12, 2026
If E \subseteq \mathbf {E} is a set of entities, then we write \lceil E\rceil to denote the inventory with exactly one copy of every element of E.
Definition Requirement contexts [000Z]
- November 3, 2025
A requirement context \Phi is a triple (\Delta ,D,I) where
- \Delta \subseteq \mathbf {C} is a set expression over capabilities, representing a set of capabilities that a robot should have;
- D \subseteq \mathbf {E} is a set expression over entities, representing a set of devices that should be equipped;
- I is a bag expression over entities, representing the inventory that a robot should possess.
Definition Requirement context notation [001K]
- November 13, 2025
We write \varnothing for the empty requirement context (\varnothing , \varnothing , \lambda e.\; 0). Also, for convenience, we sometimes write a bare set of capabilities \Delta to denote the requirement context (\Delta , \varnothing , \lambda e.\; 0), or a bare capability c to denote (\{c\}, \varnothing , \lambda e.\; 0); and likewise for bare entity sets or inventories.
Definition Requirement context satisfaction [0010]
- November 3, 2025
A robot with equipped device set Q and inventory V satisfies the requirement context \Phi = (\Delta ,D,I) if \Delta \subseteq \mathsf {caps}(Q), D \subseteq Q, and I \subseteq V. In other words, a robot satisfies a requirement context if its equipped devices provide at least the required capabilities, it has all the required devices equipped, and its inventory contains at least the required entity counts.
XXX need to take expressions into account.
Remark Requirement context motivation [0011]
- November 3, 2025
It's worth discussing the motivation for each of the components of a requirement context.
- The capability set \Delta is used to record capabilities needed to execute certain commands, use certain language constructs, and so on.
The device set D is used to record specific devices required by a
requiredirective. For example, theboatdevice confers the capability to traverse water, and does not correspond to a specific command or language construct, so the programmer needs a way to require it specifically. Also, since multiple devices may provide a given capability, the programmer may have reasons for requiring a specific device rather than letting the system choose.One might still wonder why we need both \Delta and D; wouldn't it be simpler to just have a set of required devices D? However, since the relationship between devices and capabilities can be many-to-many, we cannot reliably pick a concrete device for a required capability in a nicely compositional way. We prefer to wait until the last possible minute to pick a concrete set of devices to provide a given set of capabilities (using the provisioning oracle).
- The inventory I has several purposes. One is simply to record inventory required by a
stockdirective. For example,stock 10 "rock"requires a robot to have 10 rocks in its inventory. More importantly, however, thebuildcommand (which constructs a robot to execute a given program) turns device requirements into inventory requirements. That is, if executing programPrequires having device d equipped, then executingbuild {P}will require possessing d in the inventory (in order to equip the device on the newly constructed robot).
Requirement context union [0016]
- November 5, 2025
We define the union of requirement contexts componentwise, that is, \Phi _1 \cup \Phi _2 = (\Delta _1, D_1, I_1) \cup (\Delta _2, D_2, I_2) = (\Delta _1 \cup \Delta _2, D_1 \cup D_2, I_1 \cup I_2), where the first two unions are set union, and the last is inventory (multiset) union.
Also, as a notational convenience, when \Delta _1 is a capability set and \Phi _2 = (\Delta _2, D_2, I_2) is a requirement context, we write \Delta _1 \cup \Phi _2 as a shorthand for (\Delta _1 \cup \Delta _2, D_2, I_2).
Definition Requirement context replication [001L]
- November 13, 2025
For k \in \mathbb {N}_\infty we can also define k \cdot \Phi = k \cdot (\Delta ,D,I) = (k \cdot \Delta , k \cdot D, k \cdot I), where k \cdot I is inventory replication, and for any set S we define 0 \cdot S = \varnothing and k \cdot S = S for k > 0. Again, the idea is that k \cdot \Phi represents the union of k copies of \Phi .