Logo BCDDLogo CSC
BCDDBehavioural Contract-Driven Design
version 1.0-beta
ITEN

Chapter 27 — Extensions and profiles

The aim is to specify that the light, at switch-off, does not go off instantaneously but dims over two seconds. The keywords of chapters 21-23 are not enough. This chapter describes how a new form, the extension, is declared, with its meaning and the way to verify it. It then describes how the extensions of a field of use are collected in a profile, how a CSC imports it, and what trial words are.

A guarantee that keywords do not express

The states of a CSC have a value in every step, and the formula examines them one step at a time (chapter 21). “Within 2 seconds the light is off” is written with the keywords of chapter 22. “It dims without jumps”, by contrast, also concerns the values between one step and the next, which a formula does not examine: the brightness varies continuously over time.

A guarantee of this kind can be written in three ways.

In words. This is always possible:

  GUARANTEE g11: VERBAL "At switch-off the light does not go out abruptly: it dims over two seconds"
                 VERIFY BY JUDGEMENT "a person on the stairs who observes the switch-off"

With an extension already written, if a suitable one exists in a profile.

With a new extension, if none exists.

The extension

An extension is a new form of the language, declared in an EXTENSION Name … END block together with its meaning and the way to verify it; the term is not to be confused with the extension .csc of a file name. It has eight fields, one per line, in any order:

Field Mandatory Content
KIND yes where the form is used (following table)
LEVEL yes in which type of block the form is used, with the word that opens the block: CSC (CSC), entity (ENTITY), concrete forms (BINDING), verification plan (VERIFICATION); the field does not indicate the level of a detail (chapter 8)
PARAMS yes, even if empty the parameters of the form, in parentheses, each with a type or a category
FORM yes the form of use, in quotation marks: it begins with the name of the extension and contains each parameter once
MEANING yes the meaning, in words; if REDUCES TO is missing, it is the meaning that applies
REDUCES TO no the expanded form, written with the forms of the language
VERIFY yes the way of verification
SOURCE yes where the form comes from: the guarantee, the test or the decision that required it

The KIND field admits six values, written in upper case:

KIND The form is used
PATTERN as the form of a whole guarantee, in place of ALWAYS or of WHENEVER … THEN
SCOPE as a scope, in place of WHILE
FUNCTION inside a condition, like COUNT or PREV; after PARAMS the type of the result is written, PARAMS (…) : Type
DECLARATION as a line that declares an element, like STATE
RELATION as a relation, for example between the CSCs cited by an entity
SCENARIO-FORM inside a scenario

A parameter has a type, like the parameters of events, or a category, which indicates what is written in its place: Name (a declared name), Type (a type), Event (an event), Condition (a condition), Expression (an expression), Duration (a duration with a unit), Property (a whole property). In the FORM a word equal to the name of a parameter is the place of that parameter; every other element is fixed and is written as it is.

In the VERIFY field two codes are written. V1 indicates text verification and is followed by the codes of the checks that apply, from C1 to C8. C1 is the form check, C2 consistency, C3 scenarios, C4 coverage, C5 the rule “every used boundary is offered”, C6 entity guarantees, C7 realisability, which the specification does not provide (chapter 24), C8 details. V2, after a semicolon, indicates recording verification and is followed, in quotation marks, by what counts as observation. Alternatively the field contains BY JUDGEMENT or BY INSPECTION, like a verbal guarantee.

An extension respects the following rules:

bcdd checks the rules that concern the form:

The rules that concern the meaning are judged: the report lists them in section 14.

The profile

A profile is a collection of extensions for a field of use, with a name and a version:

PROFILE Name VERSION v
  PURPOSE "the field of use"
  STATUS HYPOTHESIS
  EXTENSION …
  END
  EXTENSION …
  END
END

The profile has a PURPOSE and a STATUS, in any order, and contains only extensions. For an extension written outside a profile bcdd reports error E32. A CSC uses a profile with the line IMPORT PROFILE Name VERSION v, in its header. For a CSC that does not import the profile, the extensions of the profile are not available, even if the profile is in the same file. A profile does not import other profiles. Whoever owns a profile maintains its versions, and an extension applies in the version of the profile that declares it: a CSC that imports another version of the profile uses another extension, even if the name is the same. An entity, a BINDING and a verification plan also import profiles, each independently.

The specification describes two profiles: Protocollo, for network protocols, and Segnale, for quantities that vary continuously. Segnale contains, among others, the extension SIGNAL, which declares a continuous quantity, that is a quantity defined at every instant and not only in the steps.

bcdd looks for the imported profile as it looks for a cited CSC (chapter 15): in the checked file, then in the file Segnale.csc of the same folder, then in the folders indicated with --dir. The profile is found only if it has the version written in the IMPORT PROFILE line.

The gradual dimming of the light

The profile Segnale does not contain a form for the dimming of the light. The new form is added to Segnale itself, in a new version, 0.3, by whoever owns the profile:

-- The profile Segnale: quantities that vary continuously.
-- VERSION 0.3: extension FADE added.

PROFILE Segnale VERSION 0.3
  PURPOSE "Quantities that vary continuously, measurements on samples, response over time"
  STATUS HYPOTHESIS

  EXTENSION SIGNAL
    KIND     DECLARATION
    LEVEL    CSC
    PARAMS   (nome: Name, T: Type)
    FORM     "SIGNAL nome : T"
    MEANING  "nome is a quantity of type T, defined at every instant and not only at the steps"
    VERIFY   V1 C1 ; V2 "continuous recording of the quantity"
    SOURCE   "the profile Segnale, version 0.1"
  END

  EXTENSION FADE
    KIND     PATTERN
    LEVEL    CSC
    PARAMS   (s: Expression, d: Duration)
    FORM     "FADE s WITHIN d"
    MEANING  "In every stretch of consecutive steps of the scope, s does not rise and does not jump, and is 0
              within d of the first step of the stretch; if s is greater than 0 at that step, it is not 0
              before 0.9 d"
    VERIFY   V1 C1 ; V2 "recording of s over time; the report declares the resolution of the recording instrument"
    SOURCE   "UsoLuce 0.4, guarantee g11"
  END
END

FADE is a guarantee form (KIND PATTERN) used in a CSC (LEVEL CSC). The parameter s is an expression, d a duration. The meaning is written in words and has no expanded form, because “does not jump” concerns the values between one step and the next.

The profile, checked on its own, has no errors:

$ bcdd check Segnale.csc
bcdd check Segnale.csc
lines: 29 (recognised 24, comments 2, blank 3, unrecognised 0)
blocks: 1
  line 4: PROFILE Segnale VERSION 0.3, STATUS HYPOTHESIS

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 0
  formal: 0
  declared extension: 0
  unrecognised: 0

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 2
  line 8: EXTENSION SIGNAL
  line 18: EXTENSION FADE

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

14. TO BE JUDGED: 4
  line 8: EXTENSION SIGNAL: the MEANING neither describes the implementation nor gives authority or precedence between parts
  line 8: EXTENSION SIGNAL: does not repeat a form that the language already has
  line 18: EXTENSION FADE: the MEANING neither describes the implementation nor gives authority or precedence between parts
  line 18: EXTENSION FADE: does not repeat a form that the language already has

outcome: no errors

The two extensions are pending approval, like the profile, and appear in section 4. Section 14 lists for each the rules to be judged: that the meaning does not describe the implementation, and that an extension without REDUCES TO does not repeat a form that the language already has.

The CSC UsoLuce moves to version 0.4, pending approval. It imports the profile, declares the brightness and adds guarantee g11:

CSC UsoLuce VERSION 0.4
  STATUS HYPOTHESIS
  IMPORT PROFILE Segnale VERSION 0.3
…
  STATE      modo : Modo INITIAL spenta
  STATE      luminosita : Real [0.0 .. 1.0] INITIAL 0.0
…
  -- g11: «At switch-off the light does not go out abruptly: it dims over two seconds»
  GUARANTEE g11: WHILE modo = spenta: FADE luminosita WITHIN 2 s

It reads: in every stretch in which the light is off, from the first step of the stretch the brightness falls without jumps and without rising again, and reaches 0 between 1.8 and 2 seconds later; if at the start of the stretch it is already 0, it remains 0. With the dimming the concrete forms of chapter 25 also change: modo = spenta holds from the moment the light begins to dim, and the brightness is the level of the light emitted by the lamp, from 0 (off) to 1 (full). The brightness is declared as a state; the special case “A quantity declared with SIGNAL” shows the declaration as a continuous quantity.

In the report the profile found appears under the line of the CSC, and g11 has a new degree:

$ bcdd check UsoLuce.csc
bcdd check UsoLuce.csc
lines: 69 (recognised 58, comments 6, blank 5, unrecognised 0)
blocks: 1
  line 4: CSC UsoLuce VERSION 0.4, STATUS HYPOTHESIS
    line 6: IMPORT PROFILE Segnale in Segnale.csc at line 4: VERSION 0.3, STATUS HYPOTHESIS, no errors

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
…
  line 42: GUARANTEE g10 formal
  line 49: GUARANTEE g11 declared extension
  line 50: ASSUME a1 verbal

bcdd recognises the use of FADE from its position, that of a guarantee form, and compares it with the FORM: luminosita occupies the place of s, 2 s that of d. For a use that does not respect the FORM, or that is in a position or in a block different from those declared by KIND and LEVEL, bcdd reports error E37.

The degree of a guarantee written with an extension

The degree of a guarantee written with an extension depends on the extension:

If the VERIFY declares an observation (V2), a guarantee of degree declared extension has, on recordings, outcomes of the same kind as those of formal guarantees, and the outcomes also show the name of the extension. If the VERIFY declares a judgement or an inspection, it has instead the outcomes of verbal guarantees. In the report of a verification the three degrees are in separate sections, and their outcomes are not added (chapter 24).

g11 has the degree declared extension, and the VERIFY of FADE declares an observation: the recording of the brightness over time. To observe it, the verification plan of chapter 26 must include an instrument that records the brightness, and not only whether the lamp is on or off.

Approval with a profile pending approval

A guarantee that uses an extension of a profile pending approval is pending approval, even in an approved CSC: the meaning of the extension has not yet been approved. bcdd ratify --all approves the CSC and leaves g11 pending approval, and reports it:

$ bcdd ratify UsoLuce.csc --all D-23
approved with D-23 in CSC UsoLuce: 6 lines
  line 5: CSC UsoLuce
  line 23: GUARANTEE g2a
  line 28: GUARANTEE g3a
  line 31: GUARANTEE g4a
  line 32: GUARANTEE g4b
  line 39: GUARANTEE g7a
contract: 17
lines still pending approval: 1
  line 49: GUARANTEE g11

The profile is approved as a whole, with its extensions, which have no status of their own:

$ bcdd ratify Segnale.csc D-24
approved PROFILE Segnale VERSION 0.3 (line 4) with D-24
extensions: 2

Once the profile is approved, g11 follows the status of the CSC, which is approved:

bcdd check UsoLuce.csc
lines: 69 (recognised 58, comments 6, blank 5, unrecognised 0)
blocks: 1
  line 4: CSC UsoLuce VERSION 0.4, STATUS RATIFIED BY D-23
    line 6: IMPORT PROFILE Segnale in Segnale.csc at line 4: VERSION 0.3, STATUS RATIFIED BY D-24, no errors
…
4. PENDING APPROVAL, NOT CONTRACT: 0

If the profile is in the same file as the CSC, the profile is chosen with --csc Segnale; without --csc, ratify chooses the CSC.

Trial words

Some keywords of the language are on trial: they are used like the others, but a future revision of the language may move them into a profile, as extensions with the same name, the same form and the same meaning. Among those described in this manual, the words on trial are TYPE (chapter 6), GIVEN (chapter 9), VARIANT (chapter 20), PREV (chapter 22) and CHANGED (chapter 23).

If a trial word moves into a profile, a CSC that uses it remains valid with the addition of the IMPORT PROFILE line of that profile. In an approved CSC the addition is a modification like the others and requires a new version (chapter 10). The word remains reserved even in the CSCs that do not import the profile: it cannot become the name of an element.

Conversely, a form used with the same meaning in several independent fields of use can enter the keywords of the language. The decision rests with whoever maintains the language.

Summary

Special cases

A quantity declared with SIGNAL. An extension of KIND DECLARATION is used as the first word of a line that declares a name. With the extension SIGNAL of the profile the brightness is declared as a continuous quantity:

  SIGNAL     luminosita : Real [0.0 .. 1.0]

The line declares the name luminosita, which enters the list of names of the CSC and is used in formulas like a state, without a type check. With this line in place of the STATE line, the report of version 0.4 is the following:

1. ERRORS: 0
…
5. UNRECOGNISED LINES: 0

Uses of extensions of KIND RELATION and KIND SCENARIO-FORM are not read by bcdd 1.0-beta: the line that contains them is unrecognised and appears in section 5; with --strict bcdd exits with code 3.

The profile in another version. If the folder contains only version 0.2 of Segnale, the imported profile is not found. Section 7 reports it, with the version found, and the guarantee that uses FADE is not recognised; the report gives the reason:

5. UNRECOGNISED LINES: 1
  line 49: GUARANTEE g11: WHILE modo = spenta: FADE luminosita WITHIN 2 s (profile Segnale VERSION 0.3 not found)
…
7. CSCs NAMED BUT NOT CHECKED: 1
  line 6: PROFILE Segnale (only VERSION 0.2 found in Segnale.csc)
…
outcome: no errors; unrecognised lines: 1 (see section 5)

It is not an error: the name FADE might be defined precisely in the missing version. With --strict bcdd exits with code 3.

The extension inside the CSC. An extension is declared in a profile. If it is written inside the CSC, bcdd reports error E32. Its lines, including the END line, are not recognised; that END line closes the extension and not the CSC. Without the IMPORT PROFILE line the guarantee that uses FADE is also unrecognised:

1. ERRORS: 1
  line 49: [E32] EXTENSION outside a PROFILE: an extension is declared in a profile
…
5. UNRECOGNISED LINES: 10
  line 48: GUARANTEE g11: WHILE modo = spenta: FADE luminosita WITHIN 2 s
  line 49: EXTENSION FADE
  line 50: KIND     PATTERN
  line 51: LEVEL    CSC
  line 52: PARAMS   (s: Expression, d: Duration)
  line 53: FORM     "FADE s WITHIN d"
  line 54: MEANING  "s falls without rising again and without jumps, and is 0 within d"
  line 55: VERIFY   V1 C1 ; V2 "recording of s over time"
  line 56: SOURCE   "UsoLuce 0.4, guarantee g11"
  line 57: END

A non-conforming field. The value of KIND is written in upper case, and SOURCE is mandatory:

1. ERRORS: 2
  line 18: [E33] field SOURCE is missing in EXTENSION FADE
  line 19: [E33] value of KIND not admitted: pattern

A use that does not respect the form. Without WITHIN 2 s the use GUARANTEE g11: WHILE modo = spenta: FADE luminosita does not respect the FORM:

1. ERRORS: 1
  line 49: [E37] use of FADE that does not respect FORM "FADE s WITHIN d"

A form that the language already expresses. Before writing an extension it is checked whether the guarantee can be expressed with the keywords of the language. An extension MAI with the meaning of NEVER (chapter 23) would give two names to the same thing and would not respect the second rule of extensions. If the extension has REDUCES TO, the check is automatic: the expanded form of MAI p is NEVER p, and bcdd reports it.

    REDUCES TO NEVER p
1. ERRORS: 1
  line 36: [E36] EXTENSION MAI repeats a form that the language already has: NEVER

If the extension does not declare REDUCES TO, the check rests with a person: it is an entry of section 14.

An extension that describes the implementation. A MEANING such as “when the relay opens a capacitor keeps the lamp on for 2 seconds” describes how the lamp is built, not what is observed, and does not respect the rules of extensions. bcdd does not read the meaning: the rule is an entry of section 14, which a person judges. The new form describes the brightness that the person on the stairs observes, like FADE; the way of obtaining it remains with whoever implements the lamp.

IMPORT PROFILE before STATUS. The lines STATUS, IMPORT PROFILE and PURPOSE follow the CSC line, before the body of the CSC, and can be written in any order. In a version with IMPORT PROFILE before STATUS RATIFIED BY D-20, the CSC turns out approved; still pending approval are the details without their own STATUS and g11, which uses the profile pending approval:

bcdd check UsoLuce.csc
lines: 69 (recognised 58, comments 6, blank 5, unrecognised 0)
blocks: 1
  line 4: CSC UsoLuce VERSION 0.4, STATUS RATIFIED BY D-20
    line 5: IMPORT PROFILE Segnale in Segnale.csc at line 4: VERSION 0.3, STATUS HYPOTHESIS, no errors
…
4. PENDING APPROVAL, NOT CONTRACT: 6
  line 23: GUARANTEE g2a
  line 28: GUARANTEE g3a
  line 31: GUARANTEE g4a
  line 32: GUARANTEE g4b
  line 39: GUARANTEE g7a
  line 49: GUARANTEE g11

For a second STATUS line in the header, by contrast, bcdd reports error E10, as for a second PURPOSE. With STATUS HYPOTHESIS immediately after the CSC line and STATUS RATIFIED BY D-20 after IMPORT PROFILE, the report flags the second as an error and keeps the first valid:

bcdd check UsoLuce.csc
lines: 70 (recognised 59, comments 6, blank 5, unrecognised 0)
blocks: 1
  line 4: CSC UsoLuce VERSION 0.4, STATUS HYPOTHESIS
    line 6: IMPORT PROFILE Segnale in Segnale.csc at line 4: VERSION 0.3, STATUS HYPOTHESIS, no errors

1. ERRORS: 1
  line 7: [E10] STATUS repeated: the first is at line 5