#include "Test/UnitTesting.hpp"
#include "Test/SyntaxSugar.hpp"
#include "Inferences/ALASCA/VIRAS.hpp"
#include "Inferences/ALASCA/VirasInterfacing.hpp"
#include "Test/SyntaxSugar.hpp"
#include "Test/GenerationTester.hpp"
#include "Test/AlascaTestUtils.hpp"
#include <viras.h>
#include <viras/test.h>
using namespace std;
using namespace Kernel;
using namespace Inferences;
using namespace Test;
using namespace Indexing;
using namespace Inferences::ALASCA;
#define SUGAR(Num) \
NUMBER_SUGAR(Num) \
DECL_DEFAULT_VARS \
DECL_FUNC(f, {Num}, Num) \
DECL_FUNC(g, {Num}, Num) \
DECL_FUNC(f2, {Num, Num}, Num) \
DECL_CONST(a, Num) \
DECL_CONST(b, Num) \
DECL_CONST(c, Num) \
DECL_CONST(d, Num) \
DECL_CONST(e, Num) \
DECL_PRED(R, {Num,Num}) \
DECL_PRED(P, {Num}) \
#define MY_SYNTAX_SUGAR SUGAR(Real)
REGISTER_GEN_TESTER(AlascaGenerationTester<VirasQuantifierElimination>())
TEST_GENERATION(ported_lra_test_basic01,
Generation::SymmetricTest()
.inputs ({ clause({x + a > 0, x + b > 0 }) })
.expected(exactly(
clause({})
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_basic02,
Generation::SymmetricTest()
.inputs ({ clause({x + a > 0, - x + b > 0 }) })
.expected(exactly(
clause({ a + b > 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_basic03,
Generation::SymmetricTest()
.inputs ({ clause({x + a > 0, - x + b > 0, f(y) + c > 0 }) })
.expected(exactly(
clause({a + b > 0, f(y) + c > 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_basic04,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, -x + b >= 0, x + c >= 0 }) })
.expected(exactly(
clause({ a + b >= 0, b + c >= 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_basic05_pos,
Generation::SymmetricTest()
.inputs ({ clause({ -x + a > 0, x + b >= 0, x - c >= 0 }) })
.expected(exactly(
clause({ a + b >= 0, a - c >= 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_basic05_neg,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, -x + b >= 0, - x - c >= 0 }) })
.expected(exactly(
clause({ (a + b) >= 0, (-b + -c) > 0 }),
clause({ (a + -c) >= 0, (b + c) > 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_shielded01,
Generation::SymmetricTest()
.inputs ({ clause({x + a > 0, - x + b > 0, f(x) + c > 0 }) })
.expected(exactly())
.premiseRedundant(false)
)
TEST_GENERATION(ported_lra_test_shielded02,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, - x + b > 0, P(x) }) })
.expected(exactly())
.premiseRedundant(false)
)
TEST_GENERATION(ported_lra_test_eq01a,
Generation::SymmetricTest()
.inputs ({ clause({ x + a >= 0, x - b == 0, P(y) }) })
.expected(exactly(
clause({ a + b >= 0, P(y) }),
clause({ P(y) }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_eq01b,
Generation::SymmetricTest()
.inputs ({ clause({ x + a >= 0, - x + b == 0, P(y) }) })
.expected(exactly(
clause({ a + b >= 0, P(y) }),
clause({ P(y) }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_eq02a,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, x - b == 0, P(y) }) })
.expected(exactly(
clause({ a + b >= 0, P(y) }),
clause({ P(y) }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_eq02b,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, - x + b == 0, P(y) }) })
.expected(exactly(
clause({ a + b >= 0, P(y) }),
clause({ P(y) }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_eq03a,
Generation::SymmetricTest()
.inputs ({ clause({ -x + a > 0, x - b == 0, P(y) }) })
.expected(exactly(
clause({ a - b == 0, P(y) })
, clause({ -b + a > 0, P(y) })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_eq03a_neg,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, -x + b == 0, P(y) }) })
.expected(exactly(
clause({ P(y) })
, clause({ b + a >= 0, P(y) }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_neq1a,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != x + a , 0 != x + b })})
.expected(exactly(
clause({ 0 != a - b })
, clause({ 0 != a - b }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_neq1b,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != -x - a , 0 != x + b })})
.expected(exactly(
clause({ 0 != a - b })
, clause({ 0 != a - b }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_neq1c,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != -x - a , 0 != -x - b })})
.expected(exactly(
clause({ 0 != a - b })
, clause({ 0 != a - b }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_neq1d,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != x + a , 0 != -x - b })})
.expected(exactly(
clause({ 0 != a - b })
, clause({ 0 != a - b }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_neq2,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != 2 * x + a , 0 != -x - b })})
.expected(exactly(
clause({ 0 != frac(1,2) * a - b })
, clause({ 0 != frac(1,2) * a - b }) ))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_misc02,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != 30 * x + f2(y,z) , 0 != 2 * x + y })})
.expected(exactly(
clause({ 0 != -15 * y + f2(y,z) }), clause({ 0 != 15 * y + -f2(y,z) })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_bug02a,
Generation::SymmetricTest()
.inputs ({ clause({ 0 == y + -1 , 0 != y + -c })})
.expected(exactly(
clause({ -c + 1 == 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_bug03,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != -1 + -x + -3 * f(x) + y
, 0 != 1 + x + 3 * f(x) - y })})
.expected(exactly(
clause({ })
))
.premiseRedundant(true)
)
TEST_GENERATION(ported_lra_test_bug04,
Generation::SymmetricTest()
.inputs ({ clause({ -x + y >= 0, x + -z >= 0, -f(y) + f(z) > 0 })})
.expected(exactly( clause({ y - z >= 0, f(z) - f(y) > 0}) ))
.premiseRedundant(true)
)
TEST_GENERATION(to_optimize_2,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != a - x, 0 != b - x })})
.expected(exactly(
clause({ 0 != b - a })
, clause({ 0 != a - b })
))
.premiseRedundant(true)
)
TEST_GENERATION(to_optimize_3,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != a - x, 0 != b - x, 0 != c - x })})
.expected(exactly(
clause({ 0 != b - a, 0 != c - a })
, clause({ 0 != a - b , 0 != c - b })
, clause({ 0 != a - c, 0 != b - c })
))
.premiseRedundant(true)
)
TEST_GENERATION(to_optimize_4,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != a - x, 0 != b - x, 0 != c - x, 0 != d - x })})
.expected(exactly(
clause({ 0 != b - a, 0 != c - a, 0 != d - a })
, clause({ 0 != a - b , 0 != c - b, 0 != d - b })
, clause({ 0 != a - c, 0 != b - c , 0 != d - c })
, clause({ 0 != a - d, 0 != b - d, 0 != c - d })
))
.premiseRedundant(true)
)
#define NOT_APPLICABLE_TEST(i, lit) \
TEST_GENERATION(not_applicable_ ## i, \
Generation::SymmetricTest() \
.inputs ({ clause({ x > 0, lit })}) \
.expected(exactly()) \
.premiseRedundant(false) \
) \
NOT_APPLICABLE_TEST(1, P(x))
NOT_APPLICABLE_TEST(2, f(x) + a > 0)
NOT_APPLICABLE_TEST(4, (x * y) > 0)
NOT_APPLICABLE_TEST(5, (x * x) > 0)
NOT_APPLICABLE_TEST(6, isInt(x))
TEST_GENERATION(lira_01,
Generation::SymmetricTest()
.inputs ({ clause({ floor(a) + frac(1,3) - x > 0, x - floor(a) - frac(2,3) > 0 , b - ceil(x) + x > 0 })})
.expected(exactly( clause({ b > frac(2,3) }) ))
.premiseRedundant(true)
)
TEST_GENERATION(lia_01_1,
Generation::SymmetricTest()
.inputs ({ clause({ 3 * floor(x) - 1 == 0 })})
.expected(withoutDuplicates(exactly( clause({ }) )))
.premiseRedundant(true)
)
TEST_GENERATION(lia_01_2,
Generation::SymmetricTest()
.inputs ({ clause({ 3 * floor(x) - 1 != 0 })})
.expected(withoutDuplicates(exactly()))
.premiseRedundant(true)
)
TEST_GENERATION(lia_02,
Generation::SymmetricTest()
.inputs ({ clause({ 3 * floor(x) - 1 != 0, x - floor(a) > 0, floor(b) - x > 0 })})
.expected(withoutDuplicates(exactly(
clause({ 3 * floor(b) - 1 != 0, floor(b) - floor(a) > 0 })
)))
.premiseRedundant(true)
)
#define liraQuot(l,r) floor((l) / (r))
#define liraRem(l,r) (l) - ((r) * liraQuot(l, r))
TEST_GENERATION(lia_03,
Generation::SymmetricTest()
.inputs ({ clause({ liraRem(x, 3) - 1 != 0, x - 3 * floor(a) > 0, 3 * floor(b) - x > 0 })})
.expected(withoutDuplicates(exactly(
clause({ 3 * floor(b) + 1 - 3 * floor(a) > 0 })
, clause({ 3 * floor(b) + 4 - 3 * floor(a) > 0 })
)))
.premiseRedundant(true)
)
TEST_GENERATION(test_misc_01,
Generation::SymmetricTest()
.inputs ({ clause({ x + f(a) > 0 })})
.expected(withoutDuplicates(exactly(
clause({ })
)))
.premiseRedundant(true)
)
TEST_GENERATION(test_misc_02,
Generation::SymmetricTest()
.inputs ({ clause({ x + f(x) > 0 })})
.expected(withoutDuplicates(exactly( )))
.premiseRedundant(false)
)
#define TEST_INTERNAL(Num) \
TEST_FUN(viras_internal_ ## Num) { \
auto conf = VampireVirasConfig<Num ## Traits>(); \
auto viras = viras::viras_test(conf); \
auto success = viras.auto_test(); \
ASS(success) \
} \
TEST_INTERNAL(Real)
TEST_INTERNAL(Rat)