#include "Test/SyntaxSugar.hpp"
#include "Inferences/ALASCA/VariableElimination.hpp"
#include "Test/SyntaxSugar.hpp"
#include "Test/AlascaTestUtils.hpp"
#include "Test/GenerationTester.hpp"
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(Rat)
REGISTER_GEN_TESTER(AlascaGenerationTester<VariableElimination>())
TEST_GENERATION(basic01,
Generation::SymmetricTest()
.inputs ({ clause({x + a > 0, x + b > 0 }) })
.expected(exactly(
clause({})
))
.premiseRedundant(true)
)
TEST_GENERATION(basic02,
Generation::SymmetricTest()
.inputs ({ clause({x + a > 0, - x + b > 0 }) })
.expected(exactly(
clause({ a + b > 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(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(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(basic05,
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(shielded01,
Generation::SymmetricTest()
.inputs ({ clause({x + a > 0, - x + b > 0, f(x) + c > 0 }) })
.expected(exactly())
.premiseRedundant(false)
)
TEST_GENERATION(shielded02,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, - x + b > 0, P(x) }) })
.expected(exactly())
.premiseRedundant(false)
)
TEST_GENERATION(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(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(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(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(eq03a,
Generation::SymmetricTest()
.inputs ({ clause({ -x + a > 0, x - b == 0, P(y) }) })
.expected(exactly(
clause({ P(y) }), clause({ a - b >= 0, P(y) })
))
.premiseRedundant(true)
)
TEST_GENERATION(eq03b,
Generation::SymmetricTest()
.inputs ({ clause({ -x + a > 0, - x + b == 0, P(y) }) })
.expected(exactly(
clause({ P(y) }), clause({ a - b >= 0, P(y) })
))
.premiseRedundant(true)
)
TEST_GENERATION(eq04a,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, -x + b >= 0, - x - c == 0 }) })
.expected(exactly(
clause({ a + b >= 0, a - c >= 0 }),
clause({ a + b >= 0, b + c >= 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(eq04b,
Generation::SymmetricTest()
.inputs ({ clause({ x + a > 0, -x + b >= 0, x + c == 0 }) })
.expected(exactly(
clause({ a + b >= 0, a - c >= 0 }),
clause({ a + b >= 0, b + c >= 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(neq1a,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != x + a , 0 != x + b })})
.expected(exactly(
clause({ 0 != a - b })
))
.premiseRedundant(true)
)
TEST_GENERATION(neq1b,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != -x - a , 0 != x + b })})
.expected(exactly(
clause({ 0 != a - b })
))
.premiseRedundant(true)
)
TEST_GENERATION(neq1c,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != -x - a , 0 != -x - b })})
.expected(exactly(
clause({ 0 != a - b })
))
.premiseRedundant(true)
)
TEST_GENERATION(neq1d,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != x + a , 0 != -x - b })})
.expected(exactly(
clause({ 0 != a - b })
))
.premiseRedundant(true)
)
TEST_GENERATION(neq2,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != 2 * x + a , 0 != -x - b })})
.expected(exactly(
clause({ 0 != frac(1,2) * a - b })
))
.premiseRedundant(true)
)
TEST_GENERATION(misc01,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != -3 * x + f2(y,z) , 0 != x + -10 * z })})
.expected(exactly(anyOf(
clause({ 0 != 10 * z + frac(-1, 3) * f2(y,z) }),
clause({ 0 != -10 * z + frac( 1, 3) * f2(y,z) })
)))
.premiseRedundant(true)
)
TEST_GENERATION(misc02,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != 30 * x + f2(y,z) , 0 != 2 * x + y })})
.expected(exactly(anyOf(
clause({ 0 != frac(-1,2) * y + frac(1,30) * f2(y,z) })
)))
.premiseRedundant(true)
)
TEST_GENERATION(bug02a,
Generation::SymmetricTest()
.inputs ({ clause({ 0 == y + -1 , 0 != y + -c })})
.expected(exactly(
clause({ c + -1 >= 0 }), clause({ 1 + -c >= 0 })
))
.premiseRedundant(true)
)
TEST_GENERATION(bug03,
Generation::SymmetricTest()
.inputs ({ clause({ 0 != -1 + -x + -3 * f(x) + y , 0 != 1 + x + 3 * f(x) - y })})
.expected(exactly(
clause({ 0 != 1 + 3 * f(x) + x + -1 - x + -3 * f(x) })
))
.premiseRedundant(true)
)
TEST_GENERATION(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(bug05,
Generation::SymmetricTest()
.inputs({clause({
-5 * x + e + -4 * f(z) + -7 * b >= 0,
-4 * x + -19 * g(z) + - c * y + - (d * f(z)) >= 0,
15 + 15 * x + 6 * y + -17 * b >= 0,
})
})
.expected(exactly( clause({
1 + frac(6,15) * y + frac(-17,15) * b + frac(1,5) * e + frac(-4,5) * f(z) + frac(-7,5) * b >= 0,
1 + frac(6,15) * y + frac(-17,15) * b + frac(-19,4) * g(z) + frac(-1,4) * c * y + frac(-1,4) * (d * f(z)) >= 0,
}) ))
.premiseRedundant(true)
)