Abstract
This paper introduces Example-Driven Modeling (EDM), a methodology supported by the Clafer modeling language. By unifying abstract rules and concrete examples within a single syntax, Clafer bridges the semantic gap between domain experts and software modelers. The approach allows for early error detection through automated reasoning and facilitates a more collaborative modeling process.
Introduction
In traditional software engineering, a significant "semantic gap" often exists between domain experts and technical modelers. Domain experts typically communicate through concrete examples (e.g., "Alice booked Room C"), while modelers operate in abstractions (e.g., "a Meeting must have exactly one Room"). Standard tools like UML exacerbate this by separating these concepts into distinct diagrams, making it difficult to maintain synchronization or validate rules against reality. This often results in models that are either too rigid or insufficiently constrained. Example-Driven Modeling (EDM) aims to make examples first-class citizens in the modeling process to resolve these discrepancies.
Methodology: The Clafer Language
The authors propose the Clafer language and its associated instance generator, ClaferIG, as the technical foundation for EDM. Clafer is a lightweight modeling language that treats types, attributes, and instances as a single concept: the "clafer."
Key methodological components include:
- Unified Syntax: Unlike UML, Clafer allows a model to contain both abstract rules and concrete examples in one place.
- Redefinition: This feature allows modelers to define an example as a specialized version of an abstraction. A specific instance inherits the structure of the general rule while providing specific details.
- Constraint Reasoning: Clafer supports first-order logic constraints. For example, a rule might state that if a meeting has online participants, the assigned room must have audio-conferencing equipment. The reasoner can then automatically check if specific examples violate these constraints.
The EDM Workflow and the Role of Examples
The EDM process is iterative, involving abstraction inference (creating rules from examples) and example derivation (generating new examples from rules to test the model).
A critical insight of this work is the value of negative examples. While positive examples ground the model in reality, negative examples—scenarios that should be impossible—are vital for defining the boundaries of the system and refining constraints. Clafer also supports "partial examples," where the system uses the Closed World Assumption (CWA) to fill in missing information during reasoning, allowing stakeholders to focus on specific details of interest.
Key Results
The paper validates the EDM approach through a Room Booking System scenario, testing six core hypotheses (H1-H6). Key findings include:
- Improved Comprehension: Explicit examples help non-technical stakeholders identify logic errors more easily.
- Efficiency: The unified syntax allows for rapid model evolution with minimal effort, as modelers can easily transition between examples and abstractions.
- Automated Validation: Using ClaferIG, modelers can automatically generate "near-miss" examples—scenarios that almost satisfy the model but fail—which are essential for debugging complex logic.
Conclusion and Future Work
While Clafer and EDM significantly improve structural modeling, the authors acknowledge limitations. Current efforts focus on data and relationships, leaving behavioral modeling (system changes over time) as a subject for future work. Additionally, as models grow, the scalability of example generation becomes a challenge, necessitating better tools for filtering and visualizing the generated example space. Future research will also aim to identify the optimal variety and quantity of examples needed for different modeling tasks.
Summary updated