Chapter 2 — The first CSC
In chapter 1 the staircase light is described in words. In this chapter the same description is written in a file, in a form that a program can read.
The file
A CSC is a text file with the extension .csc, which is opened and edited with any text editor.
The file UsoLuce.csc describes the staircase light from the point of view of the person on the stairs:
-- The staircase light, as seen by the person on the stairs.
CSC UsoLuce VERSION 0.1
PURPOSE "The person on the stairs presses a button and has light to go up or down"
EVENT IN premuto
STATE accesa : Boolean INITIAL false
GUARANTEE g1: VERBAL "When someone presses the button, the light switches on"
VERIFY BY JUDGEMENT "a person who presses the button and watches"
GUARANTEE g2: VERBAL "The light switches off by itself after a while"
VERIFY BY JUDGEMENT "a person with a watch"
END
The file consists of thirteen lines, described below one at a time.
Line by line
The first line begins with two hyphens, --: it is a comment, that is a note for the reader, which the
program ignores. A comment can appear anywhere, even at the end of a line.
CSC UsoLuce VERSION 0.1 opens the description. CSC marks the beginning of a CSC; UsoLuce is the name
given to the CSC; VERSION 0.1 is its version number. When the CSC changes, the number changes too
(chapter 10).
The words written in upper case, such as CSC, VERSION and PURPOSE, are the keywords of the language:
fixed words, in English, that the program recognises. Everything else is chosen by the writer.
PURPOSE introduces the purpose, a sentence that states what the boundary is for. It is the first line to
write and also the most important, because the rest of the CSC serves to make this sentence precise.
EVENT IN premuto states what arrives at the boundary from the other side: someone presses the button. It
is an input event. An event is something that happens at an instant and is then over; premuto
is the name given to the event.
STATE accesa : Boolean INITIAL false states instead what is observed at the boundary at every instant: whether the
light is on. A state, unlike an event, does not happen and then end: it always has a value.
After the colon its type is given, that is the set of values it can take. Boolean denotes a logical
value, true or false, written true or false. INITIAL false, finally, is the initial value: when the installation starts the
light is off.
The first guarantee is GUARANTEE g1: VERBAL "…". GUARANTEE is the keyword for a guarantee. g1 is its
short name, which serves to cite the guarantee in the program's reports and in documents. VERBAL indicates
that the guarantee is written in words, in a natural language, as it would be written for a person. The text
is enclosed in quotation marks; a text in quotation marks is called a string.
Immediately below, VERIFY BY JUDGEMENT "…" is the verification of that guarantee. JUDGEMENT means “by
judgement”: a person performs a test and judges. The quotation marks enclose who judges and on what. If
instead it is enough to examine something already written or recorded, VERIFY BY INSPECTION is used, “by
inspection”: for example VERIFY BY INSPECTION "the log of switch-ons".
The second guarantee, g2, has the same form. The expression “after a while” is vague; for now it is
acceptable, and in chapter 8 it is made precise.
Finally, END closes the description.
Three writing rules
A CSC like this one is written following three rules.
- Every line, except comments and blank lines, begins with a keyword, in English and in upper case.
Other keywords (
VERSION,INITIAL,VERBAL,BY) appear inside the line. Spaces at the beginning of a line serve only the reader: the program ignores them. - Free text, that is purpose, guarantees and verifications, goes in quotation marks, in the language chosen by the writer. The names
chosen by the writer, such as
UsoLuce,premutoandaccesa, can also be in Italian. - Every
GUARANTEEhas itsVERIFY, normally written on the following line.
This CSC is already valid
A CSC written entirely in words, like this one, is already valid and is sufficient as a starting point: a person or a language model can already implement the light from it. It remains vague, however, because “after a while” does not state how long; precision is added in the following chapters. The two guarantees, moreover, are still pending approval.
From chapter 21 onwards the guarantees are also written in forms that a program can check on its own. Each new form is added when it is needed, one line at a time.
The first check
The program is called bcdd. It is a command-line program: it is started by typing its name in the
terminal. If it is distributed together with the manual, the executable is the file bcdd, and there are two
possibilities. The first is starting it from the folder that contains the .csc file, giving the path of the
executable. The second is copying it into a folder included in the program search path (PATH) and starting it by
name only, as in the examples of this manual.
The bcdd check command reads a .csc file and reports whether it is written correctly and what it contains; the file
is never modified. The option --strict, that is an addition to the command that changes its
behaviour, makes the check stricter, in the way described below.
$ bcdd check --strict UsoLuce.csc
bcdd check --strict UsoLuce.csc
lines: 13 (recognised 9, comments 1, blank 3, unrecognised 0)
blocks: 1
line 3: CSC UsoLuce VERSION 0.1, without STATUS
1. ERRORS: 0
2. DEGREE OF THE CONTRACTUAL LINES
verbal: 2
formal: 0
declared extension: 0
unrecognised: 0
line 9: GUARANTEE g1 verbal
line 11: GUARANTEE g2 verbal
3. UNDECIDED: 0
4. PENDING APPROVAL, NOT CONTRACT: 2
line 9: GUARANTEE g1
line 11: GUARANTEE g2
5. UNRECOGNISED LINES: 0
6. UNDECLARED TYPES: 0
7. CSCs NAMED BUT NOT CHECKED: 0
outcome: no errors
The report is read from the top.
At the start of the report bcdd gives the number of lines of the file (lines). Each line belongs to exactly one category (recognised, comment,
blank or unrecognised), so that no line is lost. Next comes the list of blocks (blocks), that is of the
descriptions contained in the file: here there is only one, the CSC at line 3. The label without STATUS indicates that
it has not yet been written whether the CSC is pending approval or approved. In the absence of an indication, “pending
approval” applies; the corresponding syntax is described in chapter 7.
Section 1 lists the errors (ERRORS), that is the constructs that the program recognises but that are written
incorrectly. In this case there are none.
Section 2 concerns the contractual lines, those that enter the contract when they are approved:
for now, the guarantees. For each one the degree is given, that is the way in which the guarantee is written: in
words (verbal, in the sense of “made of words”) or as a formula that a program can check
(formal). The two guarantees of the example are written in words.
Section 4 lists the guarantees pending approval, which the report lists under PENDING APPROVAL, NOT CONTRACT: a guarantee
pending approval, until it is approved, is not part of the contract. For now this is the
expected situation.
Section 5 lists the lines that the program has not recognised. Sections 3, 6 and 7 are described in the chapters in which they become relevant.
The last line is the outcome (outcome). The outcome no errors means that the file is written correctly, not that
the guarantees are correct: that assessment is up to whoever writes the CSC.
With the --strict option a single unrecognised line is enough for the check to have a negative outcome. Its
systematic use is recommended.
Summary
- A CSC is a
.cscfile: it begins withCSC Name VERSION numberand ends withEND. - It contains the purpose (
PURPOSE), what arrives (EVENT IN), what is observed with its initial value (STATE … INITIAL) and the guarantees in words (GUARANTEE … VERBAL). - Immediately below each guarantee is its verification:
VERIFY BY JUDGEMENTorVERIFY BY INSPECTION. - A CSC written entirely in words is already valid, but its guarantees remain pending approval.
bcdd check --strictchecks the form of the file without modifying it;no errorsdoes not mean that the guarantees are correct.
Special cases
Missing verification. If the VERIFY line below g2 is removed, the report shows:
1. ERRORS: 1
line 11: [E13] VERBAL without VERIFY: VERIFY BY JUDGEMENT or INSPECTION and a string are needed
This is an error, because a guarantee without verification is incomplete (chapter 1). The code in square
brackets, E13, makes it possible to look up the error in appendix B.
Missing purpose. The absence of the PURPOSE line is also an error:
1. ERRORS: 1
line 3: [E10] PURPOSE missing in CSC UsoLuce
Repeated short name. If the second guarantee is also called g1, the program reports it at the second one,
because a short name serves to cite a single guarantee:
1. ERRORS: 1
line 11: [E01] name already used at line 9: g1
Keyword in lower case. If guarantee g2: is written instead of GUARANTEE g2:, the program does not
report an error, because the line does not match any form of the language. The line is classified among the unrecognised
lines, and with it the verification line too, which is left without its guarantee:
5. UNRECOGNISED LINES: 2
line 11: guarantee g2: VERBAL "The light switches off by itself after a while"
line 12: VERIFY BY JUDGEMENT "a person with a watch"
Without --strict the report of the line appears in the outcome line: outcome: no errors; unrecognised lines: 2 (see section 5).
An unrecognised line is therefore always reported; with --strict the check has a negative outcome.
State without initial value. The line STATE accesa : Boolean, without INITIAL false, is not
recognised:
5. UNRECOGNISED LINES: 1
line 7: STATE accesa : Boolean
…
outcome: no errors; unrecognised lines: 1 (--strict)
A state always has a value, even at the first instant: for this reason the initial value is mandatory.
Guarantee written as a formula. A guarantee such as GUARANTEE g1: WHENEVER premuto THEN accesa AT ONCE
is not written in words but as a formula: bcdd reads it and checks its names. Formulas are described starting
from chapter 21; up to chapter 20 guarantees are written in words.

