2 * Q.h - support for ForAll, ThereExists, Count and Sum (i.e. quantifiers).
4 * Portability: this file uses the GNU C Statement Expression extension and
5 * so requires GCC/C++ with extensions enabled (this is checked by the
8 * Copyright (c) 1997 Phil Maker
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * Id: Q.h,v 1.1.1.1 1997/11/23 11:45:50 pjm Exp
45 #ifndef __GNUC__ /* not compiling with GCC/G++ extensions */
47 This file requires the GNU C
/C
++ "statement expression" extension
;
48 so use GCC
/G
++ with extensions enabled
. If you have
not got GCC then
49 misery follows though we may be able to
do something about it
54 * A(i,c,n,a) - true iff a is true for all values generated by for(i;c;n)
56 * Note: local variables can be introduced in this statement even in C.
59 #define A(i,c,n,a) /* ForAll */ \
74 * E(i,c,n,a) - true iff exists any true a for values generated by for(i;c;n)
77 #define E(i,c,n,a) /* Exists */ \
92 * C(i,c,n,a) - count the number of times a is true over the values
93 * generated by for(i;c;n)
96 #define C(i,c,n,a) /* Count */ \
110 * E1(i,c,n,a) - exists a single value generated by for(i;c;n)
111 * suchthat i is true.
114 #define E1(i,c,n,a) (C(i,c,n,a) == 1) /* There Exists 1 */
117 * S(i,c,n,v) - sum of v over the values generated by for(i;c;n)
123 typeof(v) _S_result = 0; \
132 * P(i,c,n,v) - product of v over the values generated by for(i;c;n)
138 typeof(v) _P_result = 1; \
146 #else /* defined(WITHOUT_NANA) */
149 * we don't produce any empty stubs for Q.h when compiling without nana
150 * since calls to A(...), etc should only occur in stubbed out code such
154 #endif /* !defined(WITHOUT_NANA) */