Conversation
|
Thanks for opening the new PR, and for addressing the points from #586. The feature is valuable: finding out whether a class diagram and its OCL have any valid instance, and getting a sample object diagram, is something BESSER can't do today. We'd like to merge it. A good part of it already works. The branch merges cleanly into the current Must fix before merge
Smaller fixes
Structure (to align with the rest of the codebase)
Happy to do another round once these are in. Points 1 to 3 matter most, since they decide whether users can trust the answer. |
|
Two additions to my review above: Unsupported features don't have to be implemented now. For points 1 and 3, full support isn't required for this PR. When the model uses something the translation doesn't cover yet (multiple inheritance, association classes, Please add a complete example to the docs. The Alloy page currently shows only the generation step and a single invariant. It would really help to have one full walkthrough:
|
|
You say :" the translator should work on the typed OCL tree from parse_ocl (besser/BUML/metamodel/ocl) instead of re-tokenising and parsing strings a second time. That avoids a third OCL implementation in the codebase." Not sure this is longer term instead of something to be addressed now. Is there a technical reason for not using the parsed tree we already have? And what is the other OCL implemeentation???? (you say this would be three meaning we have 2) |
|
You're right on both points. I was imprecise. The “other” OCL implementation: Why don't use the parsed tree: Most of the mistranslations I found come from that second parser, including:
A visitor that generates Alloy based on each OCL node type and explicitly reports anything it does not support would also provide the “inform the user” behaviour we want. The date and string handling, as well as the solver-related parts, can mostly remain as they are. Only the OCL front end needs to be rewritten. I will update my comments |
What
An implementation of SAT-based semantic checking for BUML class diagrams with OCL constraints, as well as automated generation of logically consistent object diagrams. The semantic check of class diagrams and OCL constraints is based on a characterization of these modeling elements into the Alloy formal notation, and the use of SAT solving (via Alloy Analyzer) for consistency checking. Alloy Analyzer is used to produce semantically compliant instances, which are translated back into BESSER as object diagrams.
Why
This is a new feature of BESSER. Semantic checking goes beyond just checking correct syntax of a model: it allows developers to check for logical consistency of model constraints, and thus to identify overlooked contradictions and inconsistencies in constraints. Moreover, this implementation is able to produce object diagrams that are not only syntactically consistent with a class diagram, but also semantically consistent with cardinality constraints and OCL constraints present in the model.
How
The implementation involves some minor fixes and additions to BESSER, as well as two major new functionalities:
A new translation from BUML class diagrams + OCL constraints into the Alloy notation, implemented by the AlloyGenerator class (documented in docs/source/generators/alloy.rst, see below).
Automated generation of BUML object diagrams, implemented by the AlloySolver class (documented in docs/source/generators/object_diagram.rst).
We added documentation in the following files explaining the new features:
As the AlloySolver employs the Alloy Analyzer as a backend, it depends on the following software:
Also, the following environment variables must be set for consistency checks/object diagram generation:
We updated Dockerfile to automatically download and install these dependencies, and set the environment variables. We also added a THIRD_PARTY_LICENSES.md disclosing the use of the Alloy Analyzer (which has an Open Source MIT License).
The minor fixes and additions are, basically, syntactic support for OCL operators that were not supported in BESSER (e.g., closure).
Testing
Further Unit tests were added/updated, specifically targeting the new functionality:
Manual checks were also performed on newly devised BESSER case studies, that incorporate complex OCL constraints: