-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20d2e5c
commit 0993a93
Showing
4 changed files
with
99 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <owi.h> | ||
|
||
struct IntPair { | ||
int x, y; | ||
int mean1() const { return (x & y) + ((x ^ y) >> 1); } | ||
int mean2() const { return (x + y) / 2; } | ||
}; | ||
|
||
int main() { | ||
IntPair p{owi_i32(), owi_i32()}; | ||
owi_assert(p.mean1() == p.mean2()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
#include <owi.h> | ||
|
||
class Poly { | ||
public: | ||
int poly; | ||
Poly(int a, int b, int c, int d) { | ||
int x = owi_i32(); | ||
int x2 = x * x; | ||
int x3 = x * x * x; | ||
poly = a * x3 + b * x2 + c * x + d; | ||
} | ||
int getPoly() { | ||
return this->poly; | ||
} | ||
private: | ||
int poly; | ||
public: | ||
Poly(int a, int b, int c, int d) { | ||
int x = owi_i32(); | ||
int x2 = x * x; | ||
int x3 = x2 * x; | ||
poly = a*x3 + b*x2 + c*x + d; | ||
} | ||
|
||
int hasRoot() const { return poly == 0; } | ||
}; | ||
|
||
int main() { | ||
Poly p(1, -7, 14, -8); | ||
|
||
owi_assert(p.getPoly() != 0); | ||
|
||
return 0; | ||
owi_assert(not(p.hasRoot())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
#include <owi.h> | ||
|
||
class Poly { | ||
public: | ||
int poly; | ||
Poly(int a, int b, int c, int d) { | ||
int x = owi_i32(); | ||
int x2 = x * x; | ||
int x3 = x * x * x; | ||
poly = a * x3 + b * x2 + c * x + d; | ||
owi_assume(x != 1); | ||
owi_assume(x != 2); | ||
// Make model output deterministic | ||
owi_assume(x > -2147483646); | ||
owi_assume(x != 4); | ||
} | ||
int getPoly() { | ||
return this->poly; | ||
} | ||
private: | ||
int poly; | ||
public: | ||
Poly(int a, int b, int c, int d) { | ||
int x = owi_i32(); | ||
int x2 = x * x; | ||
int x3 = x2 * x; | ||
owi_assume(x != 1); | ||
owi_assume(x != 2); | ||
// make model output deterministic | ||
owi_assume(x > -2147483646); | ||
owi_assume(x != 4); | ||
poly = a*x3 + b*x2 + c*x + d; | ||
} | ||
|
||
int hasRoot() const { return poly == 0; } | ||
}; | ||
|
||
int main() { | ||
Poly p(1, -7, 14, -8); | ||
|
||
owi_assert(p.getPoly() != 0); | ||
|
||
return 0; | ||
owi_assert(not(p.hasRoot())); | ||
} |