jml model fields
play

JML Model Fields Christian Engel ITI, Universit at Karlsruhe 08. - PowerPoint PPT Presentation

JML What are model fields? Translation to JavaDL Demo JML Model Fields Christian Engel ITI, Universit at Karlsruhe 08. Juni 2005 Christian Engel JML Model Fields JML What are model fields? Translation to JavaDL Demo Outline JML 1


  1. JML What are model fields? Translation to JavaDL Demo JML Model Fields Christian Engel ITI, Universit¨ at Karlsruhe 08. Juni 2005 Christian Engel JML Model Fields

  2. JML What are model fields? Translation to JavaDL Demo Outline JML 1 What are model fields? 2 Translation to JavaDL 3 Axiomatic approach Interpretation as model methods/queries Demo 4 Christian Engel JML Model Fields

  3. JML What are model fields? Translation to JavaDL Demo JML JML . . . . . . is a specification language tailored to Java. Christian Engel JML Model Fields

  4. JML What are model fields? Translation to JavaDL Demo JML JML . . . . . . is a specification language tailored to Java. . . . serves as an input language for KeY. Christian Engel JML Model Fields

  5. JML What are model fields? Translation to JavaDL Demo JML JML . . . . . . is a specification language tailored to Java. . . . serves as an input language for KeY. . . . can be used for specifying method contracts and loop invariants. Christian Engel JML Model Fields

  6. JML What are model fields? Translation to JavaDL Demo JML JML . . . . . . is a specification language tailored to Java. . . . serves as an input language for KeY. . . . can be used for specifying method contracts and loop invariants. . . . allows declaring model methods and model fields. Christian Engel JML Model Fields

  7. JML What are model fields? Translation to JavaDL Demo Model fields Model fields are only visible on the level of specification. Christian Engel JML Model Fields

  8. JML What are model fields? Translation to JavaDL Demo Model fields Model fields are only visible on the level of specification. Example: //@ public model int a; Christian Engel JML Model Fields

  9. JML What are model fields? Translation to JavaDL Demo Model fields Model fields are only visible on the level of specification. Example: //@ public model int a; The represents clause defines, how the value of a model field is related to the implementation. Christian Engel JML Model Fields

  10. JML What are model fields? Translation to JavaDL Demo Model fields Model fields are only visible on the level of specification. Example: //@ public model int a; The represents clause defines, how the value of a model field is related to the implementation. /*@ public represents a \ such that 0<=a && a<size(); @*/ Christian Engel JML Model Fields

  11. JML What are model fields? Translation to JavaDL Demo The represents clause The represents clause defines a relation R ( x , ~ q ) between a model field x and a vector ~ q , consisting of fields and methods. //@ model t x; //@ represents x \ such that R(x,~ q); Christian Engel JML Model Fields

  12. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo The axiomatic approach – a first attempt A first attempt: We interpret R ( x , ˜ q ) as an axiom that holds in every state of the program. Christian Engel JML Model Fields

  13. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo The axiomatic approach – a first attempt A first attempt: We interpret R ( x , ˜ q ) as an axiom that holds in every state of the program. But: This is not possible, since there can be a state s , in which R ( x , ˜ q ) is equivalent to false . Christian Engel JML Model Fields

  14. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo The axiomatic approach – a first attempt A first attempt: We interpret R ( x , ˜ q ) as an axiom that holds in every state of the program. But: This is not possible, since there can be a state s , in which R ( x , ˜ q ) is equivalent to false . Solution: The axiom we have to use is: ( ∃ a : t ( R ( a , ˜ q ))) → R ( x , ˜ q ) Christian Engel JML Model Fields

  15. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo The axiomatic approach expressed in JavaDL Let φ ( x ) be a first order formula with occurences of x . Christian Engel JML Model Fields

  16. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo The axiomatic approach expressed in JavaDL Let φ ( x ) be a first order formula with occurences of x . x is the result of the translation of a model field x of type t . Christian Engel JML Model Fields

  17. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo The axiomatic approach expressed in JavaDL Let φ ( x ) be a first order formula with occurences of x . x is the result of the translation of a model field x of type t . R ( x , ˜ q ) is the formula provided by the represents clause. Christian Engel JML Model Fields

  18. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo The axiomatic approach expressed in JavaDL Let φ ( x ) be a first order formula with occurences of x . x is the result of the translation of a model field x of type t . R ( x , ˜ q ) is the formula provided by the represents clause. Then we get the formula: ∀ x ′ : t ( { x := x ′ } ( A ( x ) → φ ( x ))) with A ( x ) := ( ∃ a : t ( R ( a , ˜ q ))) → R ( x , ˜ q ) Christian Engel JML Model Fields

  19. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Drawbacks of the axiomatic approach bigger, less readable formulas Christian Engel JML Model Fields

  20. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Drawbacks of the axiomatic approach bigger, less readable formulas not applicable for recursively defined represents clauses Christian Engel JML Model Fields

  21. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Drawbacks of the axiomatic approach bigger, less readable formulas not applicable for recursively defined represents clauses One possible solution: Use Taclets Γ ⊢ φ ( x ()) , ∆ Christian Engel JML Model Fields

  22. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Drawbacks of the axiomatic approach bigger, less readable formulas not applicable for recursively defined represents clauses One possible solution: Use Taclets Γ ⊢ φ ( x ()) , ∃ x ′ : t ( R ( x ′ , ˜ q )) , ∆ Γ ⊢ φ ( x ()) , ∆ Christian Engel JML Model Fields

  23. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Drawbacks of the axiomatic approach bigger, less readable formulas not applicable for recursively defined represents clauses One possible solution: Use Taclets Γ ⊢ φ ( x ()) , ∃ x ′ : t ( R ( x ′ , ˜ q )) , ∆ Γ , R ( x () , ˜ q ) ⊢ φ ( x ()) , ∆ Γ ⊢ φ ( x ()) , ∆ Christian Engel JML Model Fields

  24. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Representing model fields by model methods Another approach: Model fields are represented by model method that are free of side effects and have a “suitable” specification. Christian Engel JML Model Fields

  25. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Representing model fields by model methods Another approach: Model fields are represented by model method that are free of side effects and have a “suitable” specification. Let φ ( x ) and R(x, � q) be defined as on the previous slides. We get the formula: φ ( m ()) where m () is the model method associated with R(x, � q) . Christian Engel JML Model Fields

  26. JML What are model fields? Axiomatic approach Translation to JavaDL Interpretation as model methods/queries Demo Representing model fields by model methods The specification of m (): /*@ public normal_behavior @ requires (\exists t x; R(x,q)); @ assignable \nothing; @ ensures R(\result, q); @*/ Christian Engel JML Model Fields

  27. JML What are model fields? Translation to JavaDL Demo Demo Christian Engel JML Model Fields

  28. JML What are model fields? Translation to JavaDL Demo The interface LimitedIntContainer public interface LimitedIntContainer{ /*@ @ public model int value; @ public model boolean regularState; @*/ /*@ public normal_behavior @ ensures regularState ==> \result == value; @*/ int /*@ pure @*/ available(); } Christian Engel JML Model Fields

  29. JML What are model fields? Translation to JavaDL Demo The class PayCard public class PayCard implements LimitedIntContainer{ /*@ public represents value <- balance; @ public represents regularState <- @ (unsuccessfulOperations <= 3); @*/ public /*@pure@*/ int available() { if (unsuccessfulOperations<=3) return balance; return 0; } ... } Christian Engel JML Model Fields

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