<VCC Notes > Assumption

Source: Internet
Author: User

Next is the second type of comment statement, Assumption. Syntax _ (assume E), this expression is to let VCC in the next amount of reasoning, ignoring the expression E, directly recognize the expression E.

Cases:

int x, y;

_ (assume X! = 0)

y = 100/x;

Before the assumption, VCC will definitely not pass validation, because x may be 0. However, after adding assumption, VCC chose to abandon the treatment and add x!=0 to its own database. But it doesn't do you any good to fool vcc with assumption, because when the code is actually running, no one will take care of that heap of annotations, and when x happens to be 0, the program will be crash. So in general, if you want your verification to be reliable, assumption can only be a temporary product in the verification process, and eventually it will be eliminated as much as possible.

Sounds assumption is not a good thing, in fact, he also has a lot of effect.

1. When your code is complex, VCC is difficult to verify, you can use assumption first skip, assumption is also a mark, and then to verify him.

2. When you debug those comments, you can use assumption to narrow down the error range and help locate the error.

3. For complex programs, VCC verification takes a long time, and using assumption allows VCC to discard the treatment and quickly pass that code to improve the efficiency of writing debug annotations.

4. You can use the assumption simulator to run the environment.

Even when VCC itself validates the program, it is secretly using assumption.

int x;

_ (Assert x = = 1)

_ (Assert x > 0)

In the example above, the first assertion will be an error, but the second will not. Since VCC gave the first assertion an error, he wrote a _ (assume x==1) in order to continue to find more errors.

Cases:

int x, y;

_ (Assert x > 5)

_ (Assert x > 3)

_ (Assert x < 2)

_ (Assert y < 3)

Results

_ (Assert x > 5)//Fails

_ (Assert x > 3)//succeeds

_ (Assert x < 2)//Fails

_ (Assert y < 3)//Fails

<VCC Notes > Assumption

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.