<VCC notes > Inference operators, Mappings and quantifiers

Source: Internet
Author: User

Inference operator

The,==> symbol in VCC means the result of logical inference, that is, the implication relation in discrete mathematics. P==>q is equivalent to ((! P) | | (Q)). is a very commonly used operator.

Quantifier (quantifier)

As for quantifiers, this refers to the universal quantifier (Universal quantifier) and the existence quantifier (existential quantifier).

The description method of the universal quantifier in VCC is \forall T v; E, meaning "for any V of type T, the expression E is true."

For example:

_ (Assert x > 1 && \forall int i; 1 < i && i < x ==> x% i! = 0)

Assertion Test X is a prime number.

_ (Assert \forall int i; \forall int J; 0 <= i && i <= J && J < N ==> B[i] <= b[j])

Asserts that array B is ordered.

Similarly, the presence of quantifiers in VCC is expressed in \exists T v; E, meaning "V exists in the type T, so that expression E is set".

For example:

_ (Assert \exists int i; 0 <= i && i < N && B[i] = = 0)

Asserts that array B contains element 0.

Mapping (MAP)

VCC provides a mapping type, which is used a bit like an array, but their value is not necessarily a simple number or character, he is a mapping between two types of data. such as \integer x [int] is a mapping from the int type to the \integer type, x[-5] is the \integer value corresponding to 5 in X, but no one knows which \integer the 5 maps to because no mapping is given.

Note: \integer represents an integer in mathematical sense, while \natural is a natural number

For the creation of mappings, a lambda expression is generally used. such as \lambda T x; E, the expression will return a map from the x map of type T to the result after "x is computed by Expression E", and if the expression e evaluates to the type S, then the type of the mapping is s[t].

Cases:

_ (ghost int av[\natural] = \lambda \natural i;buf[i])

Ignore the previous ghost, and later, the following expression will create an AV map, from the natural number to the int type, mapped to Buf[i].

<VCC notes > Inference operators, Mappings and quantifiers

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.