Chapter 19 — A part that may be absent
A twilight sensor can be added to the installation, indicating whether it is dark outside: with the sensor, the light switches on only when it is dark; without it, it always switches on. Whoever composes the system decides whether to fit it, and the choice stays fixed for the whole operation. This chapter describes how to write that the entity must work in both cases.
The optional part
An optional part is a part that whoever composes the system may fit or not fit; the choice stays fixed for the
whole operation.
It is written with the minimum 0 in the multiplicity: crepuscolare : Crepuscolare [0 .. 1] means “without
twilight sensor, or with one twilight sensor”. In general [0 .. n] means “without the part, or with a
number of copies from 1 to n”.
The sensor indicates to the button whether it is dark outside, with the CSC Buio:
-- The twilight sensor, as seen by the button.
CSC Buio VERSION 0.1
STATUS HYPOTHESIS
PURPOSE "The twilight sensor indicates to the button whether it is dark outside"
STATE buio : Boolean INITIAL true
GUARANTEE b1: VERBAL "The state buio becomes true when the outside light falls below 20 lux and false when it exceeds 40 lux"
VERIFY BY JUDGEMENT "a person with a lux meter next to the sensor, at sunset and at dawn"
END
-- The twilight sensor, a part that may be absent.
ENTITY Crepuscolare VERSION 0.1
STATUS HYPOTHESIS
PURPOSE "The twilight sensor measures the outside light and indicates it to the button"
OFFERS Buio
USES Alimentazione
END
The button now uses Buio and moves to version 0.2:
-- The staircase button, one of the parts of the light.
-- VERSION 0.2: takes the twilight sensor into account, if present. Pending approval.
ENTITY Pulsante VERSION 0.2
STATUS HYPOTHESIS
PURPOSE "The button receives the press and commands the lamp"
OFFERS Pressione
OFFERS Comando
USES Buio
GUARANTEE pu1: VERBAL "Each press is followed by an accendi within 0.1 s, if it is dark or if the twilight sensor is not present"
VERIFY BY INSPECTION "the recorded presses, sensor state and commands"
END
The entity lists the sensor as an optional part:
-- The staircase light, with or without the twilight sensor.
ENTITY LuceScale VERSION 0.1
STATUS HYPOTHESIS
PURPOSE "The person on the stairs presses the button and has light to go up or down"
OFFERS Pressione
OFFERS Luce
USES Alimentazione
COMPOSED OF
pulsante : Pulsante
lampada : Lampada
crepuscolare : Crepuscolare [0 .. 1]
GUARANTEE ls1: VERBAL "When someone presses the button, the light switches on, if it is dark or if the twilight sensor is not present"
VERIFY BY JUDGEMENT "a person who presses the button and watches, by day and by night"
GUARANTEE ls2: VERBAL "The light switches off 90 s after the last press, with a tolerance of 5 s"
VERIFY BY JUDGEMENT "a person who measures with a stopwatch the time between the last press and switch-off"
END
The compositions
A composition is each of the complete forms in which an entity can be assembled. With an optional
part there are two compositions: with the part and without it. The entity must hold in each, and bcdd
checks them separately.
An entity guarantee holds in every composition. The guarantee “when someone presses the button, the light switches
on” is violated with the twilight sensor and by day. For this reason ls1 is rewritten: “…if it is dark or if the
twilight sensor is not present”. bcdd does not detect this, because the guarantee is written in words.
In the composition without the sensor no part provides Buio and no one keeps its guarantees. The guarantee
b1 is not violated, because the CSC Buio is not provided.
The report
$ bcdd check --strict LuceScale.csc
bcdd check --strict LuceScale.csc
lines: 20 (recognised 15, comments 1, blank 4, unrecognised 0)
blocks: 1
line 3: ENTITY LuceScale VERSION 0.1, STATUS HYPOTHESIS
line 7: OFFERS Pressione in Pressione.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
line 8: OFFERS Luce in Luce.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
line 9: USES Alimentazione in Alimentazione.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
line 12: pulsante : Pulsante in Pulsante.csc at line 4: VERSION 0.2, STATUS HYPOTHESIS, no errors
line 13: lampada : Lampada in Lampada.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
line 14: crepuscolare : Crepuscolare in Crepuscolare.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
1. ERRORS: 0
2. DEGREE OF THE CONTRACTUAL LINES
verbal: 2
formal: 0
declared extension: 0
unrecognised: 0
line 16: GUARANTEE ls1 verbal
line 18: GUARANTEE ls2 verbal
3. UNDECIDED: 0
4. PENDING APPROVAL, NOT CONTRACT: 2
line 16: GUARANTEE ls1
line 18: GUARANTEE ls2
5. UNRECOGNISED LINES: 0
6. UNDECLARED TYPES: 0
7. CSCs NAMED BUT NOT CHECKED: 0
8. USES WITHIN ENTITIES: 5
line 12: pulsante uses Buio: it is provided by crepuscolare (line 14) (in: with crepuscolare)
line 12: pulsante uses Buio: nobody provides it (in: without crepuscolare)
line 13: lampada uses Comando: it is provided by pulsante (line 12)
line 13: lampada uses Alimentazione: LuceScale uses it from outside (line 9)
line 14: crepuscolare uses Alimentazione: LuceScale uses it from outside (line 9) (in: with crepuscolare)
9. COMPOSITIONS: 2
line 3: ENTITY LuceScale: 2
with crepuscolare
without crepuscolare
10. DECLARED ABSENCES: 1
line 12: without crepuscolare: the part pulsante uses connector Buio: no other part of LuceScale provides it, nor does LuceScale use it from outside
outcome: no errors
The report has two new sections.
Section 9, COMPOSITIONS, lists the compositions of every entity that has more than one: here with crepuscolare and without crepuscolare.
Section 10, DECLARED ABSENCES, lists what is missing only when the optional part is absent. Without
the sensor, the button uses Buio and no part provides it; with the sensor present the gap does not exist. What
is missing only without the part is not an error, but a declared absence. It appears in section 10,
preceded by without and by the name of the part, and is not included in the count of the outcome line.
In section 8 some entries end with (in: …): the suffix indicates the compositions in which the entry
holds. pulsante uses Buio: it is provided by crepuscolare (line 14) (in: with crepuscolare) holds only when the
sensor is present. An entry without a suffix holds in all compositions. The same suffix accompanies errors.
Sections 9 and 10 appear only if the file contains an entity with more than one composition.
What an optional part is not
An optional part is present or absent for the whole operation of the installation. It does not describe a part that appears and disappears while the installation is operating, for example a sensor that is disconnected by day and reconnected by night, nor a part that operates only in certain operating modes: the language does not provide a form for these cases.
Summary
- An optional part is written with the multiplicity
[0 .. n]: the entity has two compositions, with the part and without it, each fixed for the whole operation. - Entity guarantees hold in every composition.
bcddchecks every composition; what is missing only without the part is a declared absence, listed in section 10 and not counted among the errors.- The suffix
(in: …)indicates the compositions in which an entry or an error holds.
Special cases
Error in a single composition. If the entity contains the button of version 0.1, which does not use Buio,
in the composition with the sensor no part uses what the sensor provides:
1. ERRORS: 1
line 14: [E17] the part crepuscolare provides connector Buio: no other part of LuceScale uses it, nor does LuceScale provide it from outside (in: with crepuscolare)
The error holds only in the composition with the sensor, as the suffix indicates.
Optional part without the required OFFERS line. If the sensor does not declare OFFERS Buio, no part
provides Buio to the button, even when the sensor is present:
1. ERRORS: 1
line 12: [E14] the part pulsante uses connector Buio: no other part of LuceScale provides it, nor does LuceScale use it from outside
…
8. USES WITHIN ENTITIES: 4
line 12: pulsante uses Buio: nobody provides it
…
10. DECLARED ABSENCES: 0
The error appears in both compositions, hence without a suffix. It is not a declared absence, because the error does not disappear even when the part is present: a declared absence concerns only what is explained by the absence of the part.
No copies. The multiplicity [0 .. 0] is an error, because it describes a part that is never present:
1. ERRORS: 1
line 14: [E19] the part crepuscolare has an invalid number of copies: [0 .. 0]. Write [minimum .. maximum] with two integers: the minimum 0 or more, the maximum at least 1 and not smaller than the minimum

