Frama-C-discuss mailing list archives

This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] Proving a simple property on bitshift with WP


  • Subject: [Frama-c-discuss] Proving a simple property on bitshift with WP
  • From: Dillon.Pariente at dassault-aviation.com (Pariente Dillon)
  • Date: Thu, 29 Aug 2013 14:13:12 +0000
  • In-reply-to: <CAC3Lx=b2ngvaheSxzLr=5ZZi_R1T4fym7uYOW1yV3ARg0QRY-w@mail.gmail.com>
  • References: <CAC3Lx=YN+ofoawh_vint2WumaAd6=akQaLccmrg8BV6wBOphmA@mail.gmail.com> <CA+yPOVj2PgA5gtp-OhSgeNumhmvOmmtM78KNBcVTtBXdzJeAZg@mail.gmail.com> <CAC3Lx=b2ngvaheSxzLr=5ZZi_R1T4fym7uYOW1yV3ARg0QRY-w@mail.gmail.com>

Hi,

Coupling Value and WP to the extensive annotations below (discharged by Value) also allows to discharge the last assert by WP.
(This is a very verbose solution, indeed, but might be still readable)
HTH,
D.

frama-c-gui -val -wp -wp-rte bits.c

//-----------------------------------------------

static unsigned char m[] = { (1 << 7), (1 << 6), (1 << 5), (1 << 4), (1 << 3), (1 << 2), (1 << 1), (1 << 0) };

/*@ requires n >= 0;  */
int main(int n)
{
  int size, bit;

  size = 8;
  bit = n%size;
  //@ assert 0 <= bit <= 7;

  //@ assert m[0] == ((unsigned char)(1 << 7));
  //@ assert m[1] == ((unsigned char)(1 << 7-(1%8)));
  //@ assert m[2] == ((unsigned char)(1 << 7-(2%8)));
  //@ assert m[3] == ((unsigned char)(1 << 7-(3%8)));
  //@ assert m[4] == ((unsigned char)(1 << 7-(4%8)));
  //@ assert m[5] == ((unsigned char)(1 << 7-(5%8)));
  //@ assert m[6] == ((unsigned char)(1 << 7-(6%8)));
  //@ assert m[7] == ((unsigned char)(1 << 7-(7%8)));
  //@ assert m[bit] == ((unsigned char)1 << (7-(n%8)));

  return 0;
}

> -----Message d'origine-----
> De?: frama-c-discuss-bounces at lists.gforge.inria.fr [mailto:frama-c-
> discuss-bounces at lists.gforge.inria.fr] De la part de David MENTRE
> Envoy??: jeudi 29 ao?t 2013 15:48
> ??: Frama-C public discussion
> Objet?: Re: [Frama-c-discuss] Proving a simple property on bitshift
> with WP