Upcoming SlideShare
×

# Model Slicing

9,774 views

Published on

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
9,774
On SlideShare
0
From Embeds
0
Number of Embeds
7,868
Actions
Shares
0
12
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Model Slicing

1. 1. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionA General Model Based Slicing Framework Tony ClarkSchool of Engineering and Information Sciences, Middlesex University September 30, 2011 Tony Clark A General Model Based Slicing Framework
2. 2. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionContents 1 Program Slicing 2 Model Slicing 3 A General Slicing Framework GSF for Programs GSF for Models 4 Case Study 5 Conclusion Tony Clark A General Model Based Slicing Framework
3. 3. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionDeﬁnition and Use Cases What? Slicing is used to reduce the size of programs by removing those statements that do not contribute to the values of speciﬁed variables at a given program location. Why? Debugging; comprehension; veriﬁcation. How? Static (backwards,forwards); dynamic; conditioned; union. Tony Clark A General Model Based Slicing Framework
4. 4. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionBackward Slicing: Example1 Original Criterion Slice x = 42 d = 23 d d = 23 Tony Clark A General Model Based Slicing Framework
5. 5. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionBackward Slicing: Example2 Original Criterion Slice sum=0 prod=1 prod = 1 read(i) read(i) while(i<11) { while (i<11) { sum=sum+i prod=prod*i prod=prod*i i=i+1 i=i+1 } prod } Tony Clark A General Model Based Slicing Framework
6. 6. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionDynamic Slicing Original Criterion Slice sum=0 prod=1 prod = 1 read(i) read(i) while(i<11) { sum=sum+i prod=prod*i i=i+1 } prod, pos(next(input))=11 Tony Clark A General Model Based Slicing Framework
7. 7. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionConditioned Slicing Original Criterion Slice read(a) read(a) if(a<0) a=-a x=1/a x, +ve(next(input)) x=1/a Tony Clark A General Model Based Slicing Framework
8. 8. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionUnions Original Criterion Slice a = 42 a = 42 x = 2 b = 23 + a b = 23 + a y = 3 c = b + 2 c c = b + 2 a = 42 x = 2 b = 23 + a y = 3 y = 3 c = b + 2 y a = 42 a = 42 x = 2 b = 23 + a b = 23 + a y = 3 y = 3 c = b + 2 y and c c = b + 2 Tony Clark A General Model Based Slicing Framework
9. 9. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionContents 1 Program Slicing 2 Model Slicing 3 A General Slicing Framework GSF for Programs GSF for Models 4 Case Study 5 Conclusion Tony Clark A General Model Based Slicing Framework
10. 10. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionDeﬁnition and Use Cases What? erm - drop some bits? Why? Model management and comprehension; debugging transformations; debugging executable models; model veriﬁcation. How? State machines; class diagrams (syntax); speciﬁc technologies. Problem No general deﬁnition for model slicing. Tony Clark A General Model Based Slicing Framework
11. 11. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionDiﬀerences to Programs No starting point for execution. Static and dynamic slices. Multiple languages. DSLs, proﬁles, meta-models. Highly structured. Weak semantics. Links to model transformations; transformation combinations. Tony Clark A General Model Based Slicing Framework
12. 12. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionContents 1 Program Slicing 2 Model Slicing 3 A General Slicing Framework GSF for Programs GSF for Models 4 Case Study 5 Conclusion Tony Clark A General Model Based Slicing Framework
13. 13. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionA General Slicing Framework φ - σ:Σ γ:Γ p x q - - φ z- p γ :Γ - σ :Σ - q ω:Σ - q p y ? ? - γ :Γ - σ :Σ φ Γ Syntax domain. Σ Semantic domain. p, q Projections. φ Semantics. (x, ω) Slicing criterion. Tony Clark A General Model Based Slicing Framework
14. 14. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionKey Features To set up the framework for a particular domain you will need: syntax (Γ) The things you want to slice. semantics (Σ, φ) The meaning of the syntax deﬁned as a semantic domain and a semantic mapping. projections (p, q) Relationships that hold between syntactic and semantic elements and that remove items that are not of interest. criterion (x, ω) The things that remain invariant, deﬁned in terms of the semantic domain. products If the syntax and semantic domain also deﬁne products for elements and projections then there is scope for slicing composition. Tony Clark A General Model Based Slicing Framework
15. 15. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionSemantic Domain for Programs Tony Clark A General Model Based Slicing Framework
16. 16. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionGSF: Program Example1 Original Criterion Slice x = 42 d = 23 d d = 23 Semantics is σ = {[{x → 41; d → 23}]} The slice criterion requires that any trace in σ when projected onto the second step has a value for d, so ω = {{d → v } | v ∈ V } Therefore the smallest set of traces for which there exists a structural projection is σ = {[{d → v } | v ∈ V }]}. Tony Clark A General Model Based Slicing Framework
17. 17. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionGSF: Program Example2 Original Criterion Slice sum=0 prod=1 prod = 1 read(i) read(i) while(i11) { while (i11) { sum=sum+i prod=prod*i prod=prod*i i=i+1 i=i+1 } prod } Semantics is σ = {[{sum → 0}, {sum → 0; prod → 1}, {sum → 0; prod → 1; i → v }] + trace(v ) | v ∈ 0 . . . 10} ] where trace(0) = [] trace(v ) = trace(v − 1) + [{sum → i; prod →!v ; i → v }] i∈0...v Criterion requires that ω = {prod → v | v ∈ V } and x maps each trace onto the last maplet for prod. Tony Clark A General Model Based Slicing Framework
18. 18. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionModelling Language: Syntax Tony Clark A General Model Based Slicing Framework
19. 19. Program Slicing Model Slicing GSF for Programs A General Slicing Framework GSF for Models Case Study ConclusionModelling Language: Semantic Domain Tony Clark A General Model Based Slicing Framework
20. 20. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionContents 1 Program Slicing 2 Model Slicing 3 A General Slicing Framework GSF for Programs GSF for Models 4 Case Study 5 Conclusion Tony Clark A General Model Based Slicing Framework
21. 21. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionCase Study: Use Cases Tony Clark A General Model Based Slicing Framework
22. 22. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionCase Study: Class Model Tony Clark A General Model Based Slicing Framework
23. 23. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionOCL c o n t e x t Library :: borrow ( reader , book ) p r e not hasFine ( reader ) and p o s t borrows - includes ( b | b . reader = getReader ( reader ) and b . book = getBook ( book ) and b . date = date ()) Tony Clark A General Model Based Slicing Framework
24. 24. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionCase Study: State Machine Tony Clark A General Model Based Slicing Framework
25. 25. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionCase Study: Sequence Model Tony Clark A General Model Based Slicing Framework
26. 26. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionA Borrowing Step ( s1 , ok = 0 - borrow ( fred , b ) ,f , s6 ) where s1 = ({(0 ,* , Library )[ limit = l ] ,(1 ,* , Book )[ name =n , id =1] , (2 , initialized , Reader )[ name = fred , id =2]} ,{}) f = [( s1 , false = 0 - hasFine ( fred ) ,... , s1 ) , ( s1 ,2 = 0 - getReader ( fred ) ,... , s1 ) , ( s1 ,1 = 0 - getBook ( n ) ,... , s1 ) , ( s1 , d = 0 - getDate () ,... , s1 ) , ( s1 ,3 = 0 - new ( Borrows ) ,[] , s2 ) , ( s2 , ok = 3 - setReader (2) ,... , s4 ) , ....] s2 = ({(0 ,* , Library )[ limit = l ] ,(1 ,* , Book )[ name =n , id =1] , (2 , initialized , Reader )[ name = fred , id =2] , (3 ,* , Borrows )[]} ,{}) Tony Clark A General Model Based Slicing Framework
27. 27. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionSlicing Criterion B ={( s1 , v = l - borrow (r , b ) ,F , s2 ) | F - Filmstrip , s1 - Snapshot , s2 - Snapshot , v - Value , l - Id , r - Str , b - Str } Use ω = B ∗ as basis for slicing criterion. x1 projects a ﬁlmstrip to the sequence of borrow steps it contains. Tony Clark A General Model Based Slicing Framework
28. 28. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionSliced Model Tony Clark A General Model Based Slicing Framework
29. 29. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionReﬁning the Slice {[( s1 , v = l - borrow (r , b ) ,[] , s2 )] | s1 - Snapshot , s2 - Snapshot , v - Value , l - Id , r - Str , b - Str } The mapping part x2 is a reﬁnement of x1 that maps all nested ﬁlmstrips to []. Tony Clark A General Model Based Slicing Framework
30. 30. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionReﬁned Slice Tony Clark A General Model Based Slicing Framework
31. 31. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionContents 1 Program Slicing 2 Model Slicing 3 A General Slicing Framework GSF for Programs GSF for Models 4 Case Study 5 Conclusion Tony Clark A General Model Based Slicing Framework
32. 32. Program Slicing Model Slicing A General Slicing Framework Case Study ConclusionIssues and Problems Constructing slicing transformations: use of existing model transformation languages? New languages? Projection deﬁnition for OCL - requires theorem proving? Combination of slices? Consistency of slices? Slicing theories? Restricted forms of slicing: static, dynamic, conditioned? Tony Clark A General Model Based Slicing Framework