·Sami Dahoux

Why text-first, and why it is not SysML v2?#

Since the rise of SysML v2, text-based Model-Based Systems Engineering (MBSE) is becoming more and more popular. I see two reasons for that:

  • Having the same interoperable format for system description is the real way out of vendor lock-in

  • Being able to give a precise, machine-readable, meaning to concepts, rather than just representing diagrams

Benefits go even further when it comes to LLMs. Vendor representations are often hard to parse, bloated database (hello DOORS), obscure XML… On the other hand, text is fast to process and easier to verify and translate.

Studies of LLMs point the same way: current models struggle to directly generate valid XMI models (4% valid for GPT-4o), while, as Stein et al. note, the textual notation of SysML v2 makes it more accessible to LLM-based generation than purely graphical modelling languages. My guess is that a syntax made of generic symbols, which looks like XML, is more likely to be interpreted loosely than one with tokens made for the domain it describes.

Text is also versionable out of the box. Free and battle-tested solutions such as git can deal with configurations, baselines and releases with no licence fee: Eclipse S-CORE, for instance, creates its baselines with GitHub tags.

The twist with SysML v2#

Every language designer would defend the above-mentioned arguments; this is uncontroversial. However, in the case of SysML v2, there is a tradeoff to make, compared to a brand-new language. The tradeoff is articulated around two points:

SysML v2 answers the first point with KerML, whose semantics are formal. But formal here means declarative, not executable: the model execution annex is informative and only covers the basic patterns needed to aid development of a complete execution procedure.

It answers the second point by keeping the concepts of v1, written as text: one academic analysis sees it as a textual enhancement of the graphical v1. This transforms the text-first proposal of SysML into graphics as text, mimicking languages like Mermaid in a sense. It gets worse when the evolution of the language leads to considering putting graphical layout-related information within the specification.

SysML v2 is text, but it is still a modeling language written as text: the model comes first.

This is where req diverges from SysML. Being text-first in the case of req means writing statements about a system that can be verified. The formalism and structure of the statements lead to the diagrams, not the opposite.

The req language is made to provide guarantees out of the box, and each statement offers the maximum amount of testability, while being human-friendly. This is because at the end of the day stakeholders want to verify requirements, not models.

req is not incompatible with SysML. SysML is great to communicate and learn about a system, but deploying a verification setup around it, with tools like Rhapsody or SysML-to-code bridges, costs a lot and is hard to maintain. The two can work together as long as SysML is mainly there to generate diagrams, is versioned in the same repository as the req sources, and leaves the verifiable statements to req.

A tiny example#

Take a sentence that a stakeholder could write about an engine: “The engine shall generate torque as a function of RPM as shown in Table 1.” Here is how the SysML v2 training material writes this requirement, trimmed to the essentials:

SysML v2, adapted from the official training material#
package 'Engine Requirements' {
  action def GenerateTorque;

  part def Engine {
    perform action generateTorque: GenerateTorque;
  }

  requirement def TorqueGeneration {
    doc /* The engine shall generate torque as a function of RPM as shown in Table 1. */
    subject generateTorque: GenerateTorque;
  }

  requirement engineSpecification {
    subject engine : Engine;

    requirement torqueGeneration : TorqueGeneration {
      subject = engine.generateTorque;
    }
  }
}

In this example, the textual information is relegated to a documentation comment. The word “engine” in that comment is plain text (the standard defines the body of a comment as a String): nothing links it to the part.

The very thing that stakeholders will write and want to be traced is just a comment. This shows that the process envisioned behind SysML is to build the model first, and to hang the requirement on one of its elements. Before the sentence can exist, we need an action definition, a part that performs it, a requirement definition and a typed subject: in SysML, you are ultimately drawing elements.

A stakeholder, technical or not, is unlikely to write this, especially once reuse, inheritance and complex semantics get involved. So the sentence ends up written twice, once by the stakeholder and once in the model, which doubles the work and creates authoring drift.

In req, the order is reversed: the stakeholder’s sentence comes first, and the model follows from it, if you need one.

The same sentence, as a requirement#
package Powertrain
  part Engine
  part

  requirement Torque_generation top bottom
    on Engine
  is
    @@
      The [[Engine]] shall generate torque as a function of RPM as shown in Table 1.
    @@
  requirement
package

The sentence is the requirement, as the stakeholder wrote it, and the only thing it needs is a glossary term: Engine. Nothing was drawn.

The sentence is copied into the req file too, but there it is the specification itself, not a comment hanging on a model: the stakeholder can read it as written, the model grows from this text instead of being built beside it, and the req file can become the one place where the sentence lives.

If you need more, the sentence leads the way: its nouns become attributes, and a first formal reading refines it, without leaving the specification.

The sentence, then a first formal reading#
package Powertrain
  part Engine
    let torque in real \ N*m \
  part

  requirement Torque_generation top
    on Engine
  is
    @@
      The [[Engine]] shall generate torque as a function of RPM as shown in Table 1.
    @@
  requirement

  requirement Positive_torque bottom
    on Engine::torque
    refines Torque_generation
  is
    Engine::torque > 0
  requirement
package

Because the text is the specification, a tool can read it all and tell you when a statement makes no sense. Replace 0 with false and reqtool check objects right away:

reqtool check, after replacing 0 with false#
Powertrain::Positive_torque
17:4         expected type Number got Boolean
Engine::torque > false
found 1 issue(s)

Nothing was drawn to find this mistake, and nothing needs to be: a diagram, if you want one, can be derived from these statements.