main
|
Last change
on this file was 05a4f7e, checked in by Stephen Siegel <siegel@…>, 38 hours ago |
|
Added support for "floor", which is now supported by SMT-LIB2.
Fixed simple bug in transformation: in MPI transformer, math.h was being
moved to file scope, but not math.cvl. Now it is, and the one MPI prime
test that was failing now passes.
|
-
Property mode
set to
100644
|
|
File size:
707 bytes
|
| Rev | Line | |
|---|
| [ef04a5c] | 1 | #include <complex.h>
|
|---|
| 2 |
|
|---|
| 3 | $input int N = 3;
|
|---|
| 4 |
|
|---|
| 5 | double _Complex mypow(double _Complex a, int n) {
|
|---|
| 6 | double _Complex result = 1.0;
|
|---|
| 7 | for (int i=0; i<n; i++)
|
|---|
| 8 | result *= a;
|
|---|
| 9 | return result;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | int main(void) {
|
|---|
| 14 | // Assume x is an n-th root of 1 but not 1...
|
|---|
| 15 | double _Complex x;
|
|---|
| 16 | $havoc(&x);
|
|---|
| 17 | $assume(mypow(x, N) == 1.0);
|
|---|
| 18 | $assume(x != 1.0);
|
|---|
| 19 |
|
|---|
| 20 | double _Complex y = 0.0;
|
|---|
| 21 | for (int i=0; i<N; i++) {
|
|---|
| 22 | y += mypow(x, i);
|
|---|
| 23 | }
|
|---|
| [05a4f7e] | 24 | $print("y = ", y, "\n");
|
|---|
| [ef04a5c] | 25 | $assert(y*(x-1) == 0.0); // ok for N<=10
|
|---|
| 26 | $assert(y == 0.0); // ok for N<=4
|
|---|
| 27 | }
|
|---|
| [05a4f7e] | 28 |
|
|---|
| 29 | // (1+x+x^2+x^3+ .... + x^{n-1} + x^{n-1}) * (1-x)
|
|---|
| 30 | // = 1+x+x^2+x^3+ .... + x^{n-1} + x^{n-1} +
|
|---|
| 31 | // -x-x^2-x^3 ......................... -x^n
|
|---|
| 32 | // = 1 - x^n = 1 - 1 = 0
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.