Clafer: Lightweight Modeling of Structure, Behaviour, and Variability

Paulius Juodisius, Atrisha Sarkar, Raghava Rao Mukkamala, Michal Antkiewicz, Krzysztof Czarnecki, Andrzej Wasowski

Introduction

Modern embedded systems are characterized by a complex interplay between architecture and control logic. To design these systems effectively, engineers must manage three distinct facets: structure (how components connect), behavior (how the system reacts over time), and variability (how different product variants differ). Traditionally, this has required "heavyweight" modeling languages like SysML or AADL, which force engineers to juggle multiple disparate notations and diagram types. This compartmentalization increases cognitive load and often leads to inconsistencies between models.

The authors propose Clafer, a minimalistic modeling language designed to unify these three facets into a single, human-readable syntax. By providing a unified framework, Clafer aims to reduce the "ballast" of traditional modeling and provide a more cohesive view of complex systems.

Unifying Structure and Variability

At its core, Clafer is a structural modeling language. However, its design allows it to naturally represent variability. Instead of using separate feature models and class diagrams, Clafer uses a single primitive—the "clafer"—to represent both.

Structural Modeling

In Clafer, structure is defined through nested hierarchies and constraints. This approach mirrors the information found in UML class diagrams but in a more concise, textual format.

Clafer syntax vs. UML class diagram for structural modeling.

As shown in the figure above, Clafer can represent components, ports, and commands with clear cardinalities, effectively replacing the need for visual UML diagrams while maintaining the same level of structural detail.

Modeling Variability

Variability is integrated directly into the structural core. Feature models, often represented using FODA (Feature-Oriented Domain Analysis) notation, are mapped directly to Clafer hierarchies.

Clafer syntax vs. FODA notation for feature modeling.

This integration allows for "presence conditions," where the existence of a structural component can be tied directly to a feature selection. For example, a "Pinch Protection" component can be constrained to exist only if the "Express Up" feature is selected in the variability model.

Behavioral Modeling via LTL

The key innovation presented in this work is the extension of Clafer to handle behavior without introducing complex new entities like "States" or "Transitions." Instead, the authors extend Clafer’s constraint language with Linear Temporal Logic (LTL) operators such as next, always, and until.

A Clafer model is interpreted through trace-based semantics, where the system's evolution is viewed as a sequence of snapshots. Behavior is defined as a set of constraints on how these snapshots can change over time. To maintain readability, the authors use modeling patterns and "syntactic sugar" (e.g., --> for transitions) to represent state machines and common behavioral properties.

Evaluation: The Power Window Case Study

The language was evaluated using a realistic automotive subsystem: the Power Window. The authors compared Clafer against established standards like SysML, AADL, and Temporal OCL.

Key results from this qualitative evaluation include:

  • Conciseness: Clafer models are significantly more terse. While SysML might require six different models to capture variants and behavior, Clafer can express them in one unified model.
  • Expressiveness: Clafer directly captures complex interactions, such as "alphabet variability" (where features enable or disable specific events) and "transition variability" (where features alter state transitions).
  • Tooling: A compiler was developed to "desugar" high-level Clafer patterns into LTL, which are then analyzed using the Alloy Analyzer for trace generation and bounded constraint checking.

Conclusion and Future Work

Clafer demonstrates that a minimalistic approach can be more powerful than complex, multi-notation standards. By treating behavior as constraints on structural snapshots and integrating variability into the core syntax, Clafer provides a unified perspective on system design.

While the constraint-based approach can sometimes hide relationships in logic rather than making them visually explicit, the benefits in conciseness and consistency are substantial. Future work includes expanding support for sequence diagrams, exploring Petri-net-like models for concurrent states, and generating properties for real-time monitoring.

Summary updated

Abstract

Embedded software is growing fast in size and complexity, leading to intimate mixture of complex architectures and complex control. Consequently, software specification requires modeling both structures and behaviour of systems. Unfortunately, existing languages do not integrate these aspects well, usually prioritizing one of them. It is common to develop a separate language for each of these facets. In this paper, we contribute Clafer: a small language that attempts to tackle this challenge. It combines rich structural modeling with state of the art behavioural formalisms. We are not aware of any other modeling language that seamlessly combines these facets common to system and software modeling. We show how Clafer, in a single unified syntax and semantics, allows capturing feature models (variability), component models, discrete control models (automata) and variability encompassing all these aspects. The language is built on top of first order logic with quantifiers over basic entities (for modeling structures) combined with linear temporal logic (for modeling behaviour). On top of this semantic foundation we build a simple but expressive syntax, enriched with carefully selected syntactic expansions that cover hierarchical modeling, associations, automata, scenarios, and Dwyer's property patterns. We evaluate Clafer using a power window case study, and comparing it against other notations that substantially overlap with its scope (SysML, AADL, Temporal OCL and Live Sequence Charts), discussing benefits and perils of using a single notation for the purpose.
BibTeX
@article{juodisius2019clafer,
  author = {Paulius Juodisius and Atrisha Sarkar and Raghava Rao Mukkamala and Michal Antkiewicz and Krzysztof Czarnecki and Andrzej Wasowski},
  title = {{Clafer: Lightweight Modeling of Structure, Behaviour, and Variability}},
  journal = {Art Sci. Eng. Program.},
  year = {2019},
  doi = {10.22152/programming-journal.org/2019/3/2},
}
Figure