Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
4/30/2010
1
Reduction of
inductive predicates
for shape analysis
of circular lists
Daniel Stutzman
April 27, 2010
circular lists
4/30/2010
2
shape analysis
of circular lists
inductive predicates
for shape analysis
of circular lists
4/30/2010
3
Reduction of
inductive predicates
for shape analysis
of circular lists
Let’s make a sorted linked list
struct ListNode {
int data;
struct ListNode* next;
struct ListNode* prev;
}
4/30/2010
4
Let’s make a sorted linked list
3
0
4 7
0
x
Run-time “checker” functions
boolean is_sll(ListNode* x) {
return (x->prev == NULL) && is_sll2(x);
}
boolean is_sll2(ListNode* x, int min_data) {
return (x->data >= min_data) &&
(x->next->prev == x) &&
is_sll2(x->next, x->data);
}
4/30/2010
5
Run-time “checker” functions
boolean is_sll(ListNode* x) {
return (x->prev == NULL) && is_sll2(x);
}
boolean is_sll2(ListNode* x) {
return (x->next->data >= x->data) &&
(x->next->prev == x) &&
is_sll2(x->next);
}
Run-time “checker” functions
boolean is_sll(ListNode* x) {
return (x->prev == NULL) && is_sll2(x);
}
boolean is_sll2(ListNode* x) {
return (x->next == NULL) ||
((x->next->data >= x->data) &&
(x->next->prev == x) &&
is_sll2(x->next));
}
4/30/2010
6
Static inductive predicates
is_sll(x) = null(x->prev) /\ is_sll2(x)
is_sll2(x) = null(x->next) V
((x->next->data >= x->data) /\
(x->next->prev == x) /\
is_sll2(x->next))
?
0
x
is_sll2
Example in a shape domain
4/30/2010
7
Unfolding
?
0
x
is_sll2
?
Unfolding
?
0
x
is_sll2
4/30/2010
8
Unfolding
?
0
0
x
Unfolding
?
0
x
is_sll2
?
?
0
0
x
V
4/30/2010
9
Let’s make a circular list
3
0
4 7
0
x
Let’s make a circular list
3
0
4 7
x
4/30/2010
10
Let’s make a circular list
3 4 7
x
Walking backwards
?
?
?
x
is_circular_list
4/30/2010
11
Walking backwards
?
?
?
x
is_circular_list
Walking backwards
?
?
?
x
is_circular_list
Error: Unable to find an
appropriate edge to unfold
4/30/2010
12
Reduction
? ?
x
is_list
Reduction
? ?
x
is_list
4/30/2010
13
Reduction
? ?
is_list
?
x
Two equivalent summaries
is_bounded_list
4/30/2010
14
Two equivalent summaries
is_bounded_list
Two equivalent summaries
is_bounded_list
4/30/2010
15
Two equivalent summaries
is_bounded_
list
Two equivalent summaries
is_
bound
ed_list
4/30/2010
16
Two equivalent summaries
Two equivalent summaries
is_list
4/30/2010
17
Two equivalent summaries
is_list
Two equivalent summaries
is_list
4/30/2010
18
Two equivalent summaries
is_list
Two equivalent summaries
4/30/2010
19
Other equivalent summaries
dll1NULL
Other equivalent summaries
dll1NULL
4/30/2010
20
Other equivalent summaries
dll1NULL
Other equivalent summaries
dll1NULL
4/30/2010
21
Other equivalent summaries
dll1NULL
Other equivalent summaries
NULLNULL
4/30/2010
22
Other equivalent summaries
dll2
NULLNULL
NULLNULL
Other equivalent summaries
dll2
NULLNULL
NULL
NULL
4/30/2010
23
Other equivalent summaries
dll2
NULLNULL
NULL
NULL
Other equivalent summaries
dll2
NULLNULL
NULL
NULL
4/30/2010
24
Other equivalent summaries
dll2
NULLNULL
NULL
NULL
Other equivalent summaries
NULLNULL
NULLNULL
4/30/2010
25