specifications in jml
Download
Skip this Video
Download Presentation
Specifications in JML

Loading in 2 Seconds...

play fullscreen
1 / 5

Specifications in JML - PowerPoint PPT Presentation


  • 100 Views
  • Uploaded on

Specifications in JML. Example: Linear Search: Environment: var N : int; b : array [0.. N ) of int; i, x : int; Frame: i : [ N >0  x  b [0.. N ), 0  i < N  (  j | 0  j < i : x  b [ j ])  x = b [ i ]]. In JML public static int[] b= {2,3,1,2,4, 3,4};

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Specifications in JML' - chantale-irwin


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
specifications in jml
Specifications in JML
  • Example: Linear Search:
    • Environment:

varN: int; b:array [0..N) of int; i, x: int;

    • Frame:i: [N>0 xb[0..N), 0 i <N (j| 0 j < i: xb[j]) x=b[i]]
  • In JML
    • public static int[] b= {2,3,1,2,4, 3,4};
    • /*@ requires (\exists int j; 0<=j && j<b.length;x==b[j]);
    • @ ensures b[\result]==x;
    • @ ensures (\forall int j;0<=j && j<\result; b[j]!=x);
    • @*/
    • public static int search1(int x){---}

UCN T&B: JML-1

specifications in jml1
Specifications in JML

public static int search1(int x){

int i= 0;

boolean found= false;

while(i<b.length && !found){

if(x==b[i])

found= true;

else

i++;

}

return i;

}

public static void main(String[] args){

System.out.println(search1(3));

}

public static int[] b= {2,3,1,2,4, 3,4};

UCN T&B: JML-1

specifications in jml2
Specifications in JML

public static int search1(int x){

int i= 0;

boolean found= false;

while(i<b.length && !found){

if(x==b[i])

found= true;

else

i++;

}

return i;

}

public static void main(String[] args){

System.out.println(search1(13));

}

Precondition!

UCN T&B: JML-1

specifications in jml3
Specifications in JML

public static int search1(int x){

int i= 0;

boolean found= false;

while(i<b.length && !found){

if(x==b[i])

found= true;

else

i++;

}

return i+1;

}

public static void main(String[] args){

System.out.println(search1(3));

}

Postcondition!

UCN T&B: JML-1

exercise
Exercise
  • Implement and test a few of the examples or exercises in Java and JML.

UCN T&B: JML-1

ad