lecture 22 meta modelling
play

Lecture 22: Meta-Modelling Inheritance Meta-Modelling Idea - PowerPoint PPT Presentation

Content Inheritance Abstract syntax Software Design, Modelling and Analysis in UML Liskov Substitution Principle Well-typedness with inheritance Subset-semantics vs. uplink-semantics Lecture 22: Meta-Modelling Inheritance


  1. Content • Inheritance • Abstract syntax Software Design, Modelling and Analysis in UML • Liskov Substitution Principle • Well-typedness with inheritance • Subset-semantics vs. uplink-semantics Lecture 22: Meta-Modelling Inheritance • Meta-Modelling • Idea • Experiment : can we model classes ? • Revisit the UML 2.x standard 2017-02-07 (vs. experiment ) • Meta Object Facility (MOF) • The principle illustrated (once again) Prof. Dr. Andreas Podelski, Dr. Bernd Westphal • And That’s It! • The map – in hindsight. Albert-Ludwigs-Universität Freiburg, Germany – 22 – 2017-02-07 – Scontent – • Educational objectives – useful questions . – 22 – 2017-02-07 – main – – 22 – 2017-02-07 – main – • Any open questions? 2 /41 3 /41 Abstract Syntax Inheritance: Concrete Syntax Desired Semantics of Specialisation: Subtyping A signature with inheritance is a tuple Common graphical representations (of ⊳ = { ( C, D 1 ) , ( C, D 2 ) } ): There is a classical description of what one expects from sub-types , which is closely related to inheritance in object-oriented approaches: S = ( T , C , V, atr , E , F, mth , ⊳ ) C C C The principle of type substitutability : where Liskov Substitution Principle (LSP) Liskov (1988); Liskov and Wing (1994). • ( T , C , V, atr , E ) is a signature with signals and behavioural features D 1 D 2 D 1 D 2 D 1 D 2 ( F/ mth are methods, analogous to V/ atr attributes), and Mapping Concrete to Abstract Syntax by Example: • ⊳ ⊆ ( C × C ) ∪ ( E × E ) is an acyclic generalisation relation, i.e. C ⊳ + C for no C ∈ C . C 0 x : Int In the following (for simplicity), we assume that all attribute (method) names are of the form C :: v and C :: f for some C ∈ C ∪ E (“ fully qualified names ”). Read C ⊳ D as... D C 1 x : Int • D inherits from C , • C is a generalisation of D , • D is a specialisation of C , – 22 – 2017-02-07 – Ssyntax – – 22 – 2017-02-07 – Ssyntax – – 22 – 2017-02-07 – Slsp – • C is a super-class of D , C 2 • D is a sub-class of C , • ... Note : we can have multiple inheritance . 4 /41 5 /41 6 /41

  2. Desired Semantics of Specialisation: Subtyping Static Sub-Typing Session 0,1 FrontEnd itsSession dump () There is a classical description of what one expects from sub-types , which is closely related to inheritance in object-oriented approaches: VIPSession The principle of type substitutability : Liskov Substitution Principle (LSP) Liskov (1988); Liskov and Wing (1994). “If for each object o S of type S Domain Inclusion vs. Uplink Semantics In FrontEnd’s there is an object o T of type T state machine: such that for all programs P defined in terms of T the behavior of P is unchanged when o S is substituted for o T / itsSession := new Session s 0 then S is a subtype of T .” / itsSession . dump () s 2 s 3 In other words: Fischer and Wehrheim (2000) s 1 “An instance of the sub-type shall be usable / itsSession := new VIPSession whenever an instance of the supertype was expected, without a client being able to tell the difference .” – 22 – 2017-02-07 – Sinhessence – – 22 – 2017-02-07 – Sinhessence – – 22 – 2017-02-07 – Slsp – 6 /41 7 /41 8 /41 System States with Inheritance Inheritance and State-Machines: Example Inheritance and State-Machines: Example Wanted : a formal representation of “if C ⊳ ∗ D then D ‘ is a ’ C ”, that is, • • /n ! F /n ! F SM A : s 1 s 2 SM A : s 1 s 2 (i) D has the same attributes and behavioural features as C , and n � � signal � � n � signal � � � A C A C 0 , 1 E 0 , 1 E (ii) D objects (identities) can replace C objects. • • E/ E/ Two approaches to semantics: � � signal � � � � signal � � D SM D : s 1 s 2 D SM D : s 1 s 2 F F • Domain-inclusion Semantics (more theoretical ) u 1 : A u 1 : A u 1 : A u 1 : A u 1 : A st = s 1 st = s 2 st = s 1 st = s 2 st = s 2 stable = 0 stable = 1 stable = 0 stable = 1 stable = 1 n n n n n u 2 : D u 2 : D u 2 : D u 2 : D u 2 : D st = s 1 st = s 1 st = s 1 ( ∅ , { ( u 3 : F,u 2 ) } ) (? , ?) st = s 1 ( ∅ , { ( u 3 : F,u 2 ) } ) ( { F } , ∅ ) st = s 2 • Uplink Semantics (more technical ) − − − − − − − − − − → stable = 1 − − − → − − − − − − − − − − → stable = 1 − − − − − → stable = 1 stable = 1 stable = 1 u 1 ? u 1 u 2 u 3 : F u 3 : F – 22 – 2017-02-07 – Sinhessence – – 22 – 2017-02-07 – Sinhessence – – 22 – 2017-02-07 – Sinhessence – ε = ǫ ε = ( u 2 , u 3 : F ) ε = ǫ ε = ( u 2 , u 3 : F ) ε = ǫ 9 /41 10 /41 10 /41

  3. s Student 0 , 1 att : Int Recall: Subtyping Subtyping: Example Teacher t 0 , 1 (ii) Dispatch GenStWorker There is a classical description of what one expects from sub-types , which is closely related to workload : Int Genius Polite Clown ( cons , Snd ) ( � , � ) ( � � , � � ) � � � � � � � � inheritance in object-oriented approaches: u SM Teacher • • if s 1 /t ! Silence s 1 The principle of type substitutability : s : Student SM Student • u � dom( � ) � D ( C ) � � u E � D ( E ) : u E � ready ( � , u ) GoodAns / [ s. att > 0] /s ! Q : Teacher Q/ Liskov Substitution Principle (LSP) Liskov (1988); Liskov and Wing (1994). att = 3 t /t ! GoodAns s 2 s 2 • u is stable and in state machine state s , i.e. � ( u )( stable ) = 1 and � ( u )( st ) = s , /t ! WrongAns “If for each object o S of type S • • a transition is enabled , i.e. s 1 WrongAns / there is an object o T of type T s SM Genius � ( s, F, expr , act , s � ) �� ( SM C ) : F = E � I � expr � (˜ : Teacher : Genius � , u ) = 1 Q/ t such that for all programs P defined in terms of T /t ! GoodAns s 2 where ˜ � = � [ u. params E 7 � u E ] . the behavior of P is unchanged when o S is substituted for o T • /t ! Silence s 1 and then S is a subtype of T .” s SM Polite : Teacher : Polite Q/ • ( � � , � � ) results from applying t act to ( � , � ) and removing u E from the ether, i.e. t /t ! GoodAns s 2 In other words: Fischer and Wehrheim (2000) ( � �� , � � ) � t act [ u ](˜ � , � � u E ) , • � � = ( � �� [ u. st 7 � s � , u. stable 7 � b, u. params E 7 � � ]) | D ( C ) \{ u E } s 1 “An instance of the sub-type shall be usable s SM Clown : Teacher : Clown Q/ whenever an instance of the supertype was expected, t /t ! StupidJoke where b depends (see (i)) s 2 without a client being able to tell the difference .” – 12 – 2016-12-13 – Sstmrtc – • Consumption of u E and the side effects of the action are observed, i.e. • – 22 – 2017-02-07 – Sinhessence – – 22 – 2017-02-07 – Sinhessence – – 22 – 2017-02-07 – Sinhessence – • SM GenStWorker cons = { u E } , Snd = Obs t act [ u ](˜ � , � � u E ) . s 1 • s : Teacher : GenStWorker s 3 Q/ t /t ! GoodAns Task / s 2 21 /32 11 /41 12 /41 13 /41 Meta-Modelling: Why and What Meta-Modelling: Example • Meta-Modelling is one major prerequisite for understanding For example, let’s consider a class. • the standard documents OMG (2011a,b), and • A class has ( among others ) • the MDA ideas of the OMG. • a name , • any number of attributes , • The idea is somewhat simple : Meta-Modelling: Idea • any number of behavioural features . • if a modelling language is about modelling things , Each of the latter two has • and if UML models are things , • a name and • then why not describe (or: model ) the set of all UML models using a modelling language ? • a visibility . Behavioural features in addition have • a boolean attribute isQuery , • any number of parameters, • a return type. Can we model this (in UML, for a start)? – 22 – 2017-02-07 – Smm – – 22 – 2017-02-07 – Smm – – 22 – 2017-02-07 – main – 14 /41 15 /41 16 /41

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend