Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use option -wp-gen in Frama-C 20 ? #31

Open
jensgerlach opened this issue Dec 1, 2019 · 3 comments
Open

How to use option -wp-gen in Frama-C 20 ? #31

jensgerlach opened this issue Dec 1, 2019 · 3 comments

Comments

@jensgerlach
Copy link

How does the option -wp-gen work in Frama-C 20?
Specifically, I would like to obtain the proof obligations for cvc4 (or the other supported provers) of the example find.c below.
I tried

frama-c -wp -wp-rte -wp-gen -wp-prover cvc4 -wp-out find.wp find.c

but the directory find.wp is empty except for the empty subdirectory typed.

find.c

/*@
  requires   \valid_read(a + (0..n-1));
  assigns    \nothing;
  ensures    0 <= \result <= n;

  behavior some:
    assumes  \exists integer i; 0 <= i < n && a[i] == val;
    assigns  \nothing;
    ensures  0 <= \result < n;
    ensures  a[\result] == val;
    ensures  \forall integer i; 0 <= i < \result ==> a[i] != val;

  behavior none:
    assumes  \forall integer i; 0 <= i < n ==> a[i] != val;
    assigns  \nothing;
    ensures  \result == n;

  complete behaviors;
  disjoint behaviors;
*/
unsigned int
find(const int* a, unsigned int n, int val)
{
  /*@
    loop invariant 0 <= i <= n;
    loop invariant \forall integer k; 0 <= k < i ==> a[k] != val;
    loop assigns i;
    loop variant n-i;
   */
  for (unsigned int i = 0u; i < n; i++) {
    if (a[i] == val) {
      return i;
    }
  }

  return n;
}
@anonymous3444
Copy link

Hi..iam a university student..we're learning frama-c can u help me doing loop pgms?

@jensgerlach
Copy link
Author

Probably not.

https://stackoverflow.com/help/how-to-ask

@correnson
Copy link
Member

Option -wp-gen is not currently working (it was designed for -wp-prover native:* outputs only).
There is a trick : when using cache, digests are computed by pretty-printing the Why3 task for each prover, which is indeed very closed to what is actually sent to solvers, but in pseudo-why3 syntax. These preprints are generated in temporary directory but you can reveal them by using -wp-out <dir>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants