Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
35c88576
Commit
35c88576
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[wp] added bsearch to gallery
parent
d2507dcc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/wp/tests/wp_gallery/bsearch.c
+35
-0
35 additions, 0 deletions
src/plugins/wp/tests/wp_gallery/bsearch.c
src/plugins/wp/tests/wp_gallery/oracle_qualif/bsearch.res.oracle
+40
-0
40 additions, 0 deletions
...gins/wp/tests/wp_gallery/oracle_qualif/bsearch.res.oracle
with
75 additions
and
0 deletions
src/plugins/wp/tests/wp_gallery/bsearch.c
0 → 100644
+
35
−
0
View file @
35c88576
/* run.config
DONTRUN:
*/
/* run.config_qualif
OPT: -wp-rte -wp-smoke-tests
*/
/*@
requires size >= 0;
requires \valid(t + (0 .. size-1));
requires ∀ integer i, integer j; 0 <= i <= j < size ==> t[i] <= t[j];
ensures Result: -1 <= \result < size;
ensures Found: \result >= 0 ==> t[\result] == key;
ensures NotFound: \result == -1 ==> ∀ integer i; 0 <= i < size ==> t[i] != key;
*/
int
binary_search
(
int
*
t
,
int
size
,
int
key
)
{
int
lo
,
hi
,
mid
;
lo
=
0
;
hi
=
size
-
1
;
/*@
loop assigns lo, hi, mid;
loop invariant Range: 0 <= lo && hi < size;
loop invariant Left: ∀ integer i; 0 <= i < lo ==> t[i] < key;
loop invariant Right: ∀ integer i; hi < i < size ==> t[i] > key;
loop variant hi - lo;
*/
while
(
lo
<=
hi
)
{
mid
=
lo
+
(
hi
-
lo
)
/
2
;
if
(
key
==
t
[
mid
])
return
mid
;
if
(
key
<
t
[
mid
])
hi
=
mid
-
1
;
else
lo
=
mid
+
1
;
}
return
-
1
;
}
This diff is collapsed.
Click to expand it.
src/plugins/wp/tests/wp_gallery/oracle_qualif/bsearch.res.oracle
0 → 100644
+
40
−
0
View file @
35c88576
# frama-c -wp -wp-rte [...]
[kernel] Parsing tests/wp_gallery/bsearch.c (with preprocessing)
[wp] Running WP plugin...
[rte] annotating function binary_search
[wp] 28 goals scheduled
[wp] [Passed] Smoke-test typed_binary_search_wp_smoke_default_requires
[wp] [Passed] Smoke-test typed_binary_search_wp_smoke_dead_loop_s3
[wp] [Passed] Smoke-test typed_binary_search_wp_smoke_dead_code_s8
[wp] [Passed] Smoke-test typed_binary_search_wp_smoke_dead_code_s12
[wp] [Passed] Smoke-test typed_binary_search_wp_smoke_dead_code_s16
[wp] [Passed] Smoke-test typed_binary_search_wp_smoke_dead_code_s17
[wp] [Passed] Smoke-test typed_binary_search_wp_smoke_dead_code_s18
[wp] [Alt-Ergo] Goal typed_binary_search_ensures_Result : Valid
[wp] [Qed] Goal typed_binary_search_ensures_Found : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_ensures_NotFound : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_signed_overflow : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_loop_invariant_Left_preserved : Valid
[wp] [Qed] Goal typed_binary_search_loop_invariant_Left_established : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_loop_invariant_Range_preserved : Valid
[wp] [Qed] Goal typed_binary_search_loop_invariant_Range_established : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_loop_invariant_Right_preserved : Valid
[wp] [Qed] Goal typed_binary_search_loop_invariant_Right_established : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_signed_overflow_2 : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_signed_overflow_3 : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_signed_overflow_4 : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_signed_overflow_5 : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_mem_access : Valid
[wp] [Qed] Goal typed_binary_search_assert_rte_mem_access_2 : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_signed_overflow_6 : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_assert_rte_signed_overflow_7 : Valid
[wp] [Qed] Goal typed_binary_search_loop_assigns : Valid
[wp] [Alt-Ergo] Goal typed_binary_search_loop_variant_decrease : Valid
[wp] [Qed] Goal typed_binary_search_loop_variant_positive : Valid
[wp] Proved goals: 28 / 28
Qed: 7
Alt-Ergo: 21
------------------------------------------------------------
Functions WP Alt-Ergo Total Success
binary_search 7 21 28 100%
------------------------------------------------------------
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment