Assisting Domain Modeling
   with Formal Analysis
                    Juan Cadavid
                   Benoit Baudry
                 Jean-Marc Jézéquel
       INRIA Bretagne - Atlantique, team Triskell




                           1
Domain Models
•   A conceptual
    model of a
    system which
    describes the
    various
    entities
    involved in that
    system and their
    relationships.
                           Domain Model for Insurance




                       2
Typical Domain
   Modeling
            Domain Model




          Raw Modeling Space


      3
Typical Domain
     Modeling
                     Incorrect
                     Instances




There is an intention not expressed
  by the metamodel on its own.
                 4
Precise Domain
   Modeling

          Limit the
          number of
          solutions to find
          the precise
          modeling space



      5
Precise Domain
           Modeling
            OCL
                        • Write constraints
                          along with the
                          domain model.
OCL
              OCL
                        • The most popular
                          language is OCL
            OCL           (Object Constraint
      OCL
                          Language)


                    6
Example: Metamodeling
   Feature Models

                   A




               B       B




          7
Example: Metamodeling
   Feature Models

                               A




                           B       B




     Two features cannot
     have the same name




                       7
Example: Metamodeling
   Feature Models




          8
Example: Metamodeling
   Feature Models



       There cannot be mutual
     exclusivity between a parent
       feature and its children.




                                8
Example: Metamodeling
   Feature Models

                A




                    B




          9
Example: Metamodeling
   Feature Models

                           A




                               B



       The or operator
      must have at least
        two operands




                       9
Precise Domain
           Modeling
                         • A given set of
            OCL
                           constraints could
                           include bad
                           instances, and leave
OCL                        out good instances.
              OCL

                         • How to find the
                           good set of
            OCL
      OCL                  constraints that
                           correctly
                           describes the
                           modeling space?
                    10
Exploring the Modeling
Space: Generating Instances
                                     Kermeta2Alloy
                  Metamodel                             Metamodel
                   in Ecore                              in Alloy
Pramana:
Generates
                       conforms to             AlloySolution
Metamodel
Instances using                      Solution2xmi        Instances
                  Instances
Alloy              in XMI
                                                          in Alloy
                                                            XML




                      11
Pramana Architecture




         12
Challenges with
         Pramana
• Robustness/Enough testing
• Alloy limitations
  • Small scope
  • Integer numbers
• Maximize distance between metamodel
  instances
• OCL2Alloy: A difficult transformation
                     13
Understanding the use
    of OCL (1)
• Study of 519 invariants from three OMG
  specifications: UML, OCL and CORBA
  Component Model
• Definition of Metrics
 • Size of Metamodel
 • Invariant complexity w.r.t. the metamodel
 • Invariant complexity w.r.t to OCL
                    14
Understanding the use
    of OCL (1I)
• 88% of invariants were written with 36%
  of the OCL language.
• Most invariants are defined over two or
  less domain elements (i.e. class
  attributes)
• Result: Catalog of recurring patterns in
  OCL invariants.

                    15
Automatic Invariant
      Derivation (I)
•   Prototype to match patterns from Catalog
•   Input: Metamodel, correct instances and incorrect
    instances.
•   Matching instances marked as incorrect by the user
    •   Incorrect motifs
    •   Derive OCL invariant from template
•   Test derived instances marked as correct by the
    user


                           16
Automatic Invariant
  Derivation (II)
            Pattern 1   Pattern 2 Pattern n
            Ecore+OCL   Ecore+OCL    Ecore+OCL




Metamodel

                        Automatic                Metamodel
 Correct                 Invariant                + OCL
Instances               Derivation


Incorrect
Instances



                          17
Strategies for Mining
       patterns
• Strings -> bio-inspired computing,
  bioinformatics
• Graphs -> graph grammars, mining graph
  bases
• Relational -> R, data mining algorithms
Algorithms
•   We need:
    •   Match existing patterns (from a predefined catalog)
    •   Find new patterns (mining correct/incorrect instances)
•   We could get them from:
    •   Bio-inspired computing, bioinformatics
    •   Graph grammars: structure learning, PEGG
    •   Relational data-mining
    •   Inductive-Logic programming
Protocol
List<OclExpression> mineInvs(List<Object> goodInst,
List<Object> badInst){

    #Encode instances

    #Match with existing patterns from catalog

    #Find new patterns

}

Point GEODES

  • 1.
    Assisting Domain Modeling with Formal Analysis Juan Cadavid Benoit Baudry Jean-Marc Jézéquel INRIA Bretagne - Atlantique, team Triskell 1
  • 2.
    Domain Models • A conceptual model of a system which describes the various entities involved in that system and their relationships. Domain Model for Insurance 2
  • 3.
    Typical Domain Modeling Domain Model Raw Modeling Space 3
  • 4.
    Typical Domain Modeling Incorrect Instances There is an intention not expressed by the metamodel on its own. 4
  • 5.
    Precise Domain Modeling Limit the number of solutions to find the precise modeling space 5
  • 6.
    Precise Domain Modeling OCL • Write constraints along with the domain model. OCL OCL • The most popular language is OCL OCL (Object Constraint OCL Language) 6
  • 7.
    Example: Metamodeling Feature Models A B B 7
  • 8.
    Example: Metamodeling Feature Models A B B Two features cannot have the same name 7
  • 9.
    Example: Metamodeling Feature Models 8
  • 10.
    Example: Metamodeling Feature Models There cannot be mutual exclusivity between a parent feature and its children. 8
  • 11.
    Example: Metamodeling Feature Models A B 9
  • 12.
    Example: Metamodeling Feature Models A B The or operator must have at least two operands 9
  • 13.
    Precise Domain Modeling • A given set of OCL constraints could include bad instances, and leave OCL out good instances. OCL • How to find the good set of OCL OCL constraints that correctly describes the modeling space? 10
  • 14.
    Exploring the Modeling Space:Generating Instances Kermeta2Alloy Metamodel Metamodel in Ecore in Alloy Pramana: Generates conforms to AlloySolution Metamodel Instances using Solution2xmi Instances Instances Alloy in XMI in Alloy XML 11
  • 15.
  • 16.
    Challenges with Pramana • Robustness/Enough testing • Alloy limitations • Small scope • Integer numbers • Maximize distance between metamodel instances • OCL2Alloy: A difficult transformation 13
  • 17.
    Understanding the use of OCL (1) • Study of 519 invariants from three OMG specifications: UML, OCL and CORBA Component Model • Definition of Metrics • Size of Metamodel • Invariant complexity w.r.t. the metamodel • Invariant complexity w.r.t to OCL 14
  • 18.
    Understanding the use of OCL (1I) • 88% of invariants were written with 36% of the OCL language. • Most invariants are defined over two or less domain elements (i.e. class attributes) • Result: Catalog of recurring patterns in OCL invariants. 15
  • 19.
    Automatic Invariant Derivation (I) • Prototype to match patterns from Catalog • Input: Metamodel, correct instances and incorrect instances. • Matching instances marked as incorrect by the user • Incorrect motifs • Derive OCL invariant from template • Test derived instances marked as correct by the user 16
  • 20.
    Automatic Invariant Derivation (II) Pattern 1 Pattern 2 Pattern n Ecore+OCL Ecore+OCL Ecore+OCL Metamodel Automatic Metamodel Correct Invariant + OCL Instances Derivation Incorrect Instances 17
  • 21.
    Strategies for Mining patterns • Strings -> bio-inspired computing, bioinformatics • Graphs -> graph grammars, mining graph bases • Relational -> R, data mining algorithms
  • 22.
    Algorithms • We need: • Match existing patterns (from a predefined catalog) • Find new patterns (mining correct/incorrect instances) • We could get them from: • Bio-inspired computing, bioinformatics • Graph grammars: structure learning, PEGG • Relational data-mining • Inductive-Logic programming
  • 23.
    Protocol List<OclExpression> mineInvs(List<Object> goodInst, List<Object>badInst){ #Encode instances #Match with existing patterns from catalog #Find new patterns }