Automated Verification with HIP and SLEEK

1 / 12

# Automated Verification with HIP and SLEEK - PowerPoint PPT Presentation

Automated Verification with HIP and SLEEK. Asankhaya Sharma. Recall the List length Example. int length( struct node* p) /*@ requires p::list<n,B> ensures p::list<n,B> & res=n; */ { if(p == NULL) return 0; else return 1 + length(p->next); }. Memory Safety. Length of the List.

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

## PowerPoint Slideshow about 'Automated Verification with HIP and SLEEK' - annot

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

### Automated Verification withHIP and SLEEK

Asankhaya Sharma

Recall the List length Example

int length(struct node* p)/*@requires p::list<n,B>ensures p::list<n,B> & res=n;*/{ if(p == NULL) return 0; else return 1 + length(p->next);}

Memory Safety

Length of the List

Bag of Values

With Immutability

int length(struct node* p)/*@requires p::list<>@I ensures res=n;*/{ if(p == NULL) return 0; else return 1 + length(p->next);}

With Immutability Annotation

More concise and precise specification

Recall the List Append Example

void append(node* x, node* y)requires x::list<n> & x != null & x = yensures

requires x::list<n> & x != null ensures{ if(x->next==NULL) x->next=y; else append(x->next,y);}

x::clist<n>

x::lseg<y,n>

With Immutability

void append(node* x, node* y)requires x::lseg<p>@I * p::node<a,null>ensures p::node<a,y>{ if(x->next==NULL) x->next=y; else append(x->next,y);}

Immutable List Segment

Cut point preservation

Aliasing Example

int foo(cell x, cell y)requires x::cell<a> * y::cell<b> ensures x::cell<a> * y::cell<b> & res = a+b

requires x::cell<a> & x = yensures x::cell<a> & res = 2*a;{

return x.val + y.val;}

Heap Sharing with Immutability

int foo(cell x, cell y)requires x::cell<a>@I &y::cell<b>@Iensures res = a+b{

return x.val + y.val;}

Allows Aliasing

Immutable Specifications
• Many programs do not change their input
• Use immutable specifications, where possible
• More concise (for multiple pre/post)
• More accurate (as cut points are preserved)
• More efficient (as less folding is needed)
• More control (don’t modify data)
Verification of Concurrent Programs
• Fork/join concurrency + (mutex) locks + barriers
• Properties
• Functional correctness
• Data-race freedom
• Permission-based heaps, e.g.

x::cell(0.5)<1> * y::cell(0.5)<2>

data cell { intval;}

• void thread1 (cell x) requires x::cell<0> * y::cell<0>ensures x::cell<1> * y::cell<2> ;
• { x.val = x.val + 1;
• y.val = y.val + 2;}
• void thread2 (thrd t1, cell y) requires t1::thrd<y::cell<2>>ensures y::cell<4> ;{ join(t1);
• y.val = y.val + 2;}

void main()

requires true ensure true;

{

cell x = new cell(0);

• cell y = new cell(0);
• //{t1::thrd<x::cell<1> * y::cell<2>>}
• //{t1::thrd<x::cell<1>>
• join(t1);
• x.val = x.val + 1;
• join(t2);
• assert( x::cell<2> * y::cell<4> );

}

Example

main

x,y

x,y

t1

t1

t1,t2

x

y

join(t1);

join(t1);

multi-join

t2,x

y

join(t2);

x,y