Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • F frama-c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 209
    • Issues 209
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • pub
  • frama-c
  • Issues
  • #2350

Closed
Open
Created Jul 08, 2010 by mantis-gitlab-migration@mantis-gitlab-migration

Loop variant which does not always decrease passed the verification

ID0000533: This issue was created automatically from Mantis Issue 533. Further discussion may take place here.


Id Project Category View Due Date Updated
ID0000533 Frama-C Plug-in > jessie public 2010-07-08 2010-09-29
Reporter logan Assigned To cmarche Resolution no change required
Priority normal Severity minor Reproducibility always
Platform - OS - OS Version -
Product Version Frama-C Boron-20100401 Target Version - Fixed in Version -

Description :

I have written an implementation of Binary Search and tried to verify it with Frama-C Jessie plug-in. My code passed the verification process but in some cases the loop won't stop. (These cases can be checked by both gcc and hand-calculation.)

There's the loop and its variant: (reference the attachment for the complete source code)

/*@ loop invariant \valid_range(array, left, right);
    loop invariant left <= right;
    loop invariant diff == right - left;
    loop invariant \forall integer i; 0 <= i <= left ==> array[i] != key ;
    loop invariant \forall integer i; right <= i < n ==> array[i] != key ;
    loop variant diff; // NOTICE HERE
*/
while (diff > 0) { // FIXME: This line is INCORRECT actually.
                   // Change to while (diff > 1) for correct version.

    unsigned int mid = left + (right - left) / 2;

    // FIXME: Since (right - left) / 2 will be rounded-off,
    // it is possible that the value of left and right will
    // NEVER be updated.

    if (array[mid] == key) { return mid; }
    else if (array[mid] < key) { left = mid; }
    else { right = mid; }

    diff = right - left;
}

REPRODUCE PROCEDURE:

  1. Download bisearch.c
  2. Start Frama-C/Jessie with: $ frama-c -jessie bisearch.c
  3. Click on "Alt-Ergo 0.91"
  4. All proof obligations are GREEN.

EXPECTED RESULT:

The proof obligations for "Function bsearch Safety > variant decreases" should result in either FALSE or Time Limit Exceed.

GOT RESULT:

Alt-Ergo 0.91 returns TRUE for such proof obligations.

Additional Information :

I am using the precompiled Frama-C executables from Debian/sid (i386) repository.

VERSION: Frama-C: Boron-20100401 (deb-version: 20100401+boron+dfsg-3) Why: 2.26 (deb-version: 2.26+dfsg-1+b1) Alt-Ergo: 0.91 (deb-version: 0.91-2)

Attachments

  • bisearch.c
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking