2013-09-21 05:01:40 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include <iostream>
|
|
|
|
#include "util/test.h"
|
|
|
|
#include "kernel/abstract.h"
|
2014-01-03 04:03:42 +00:00
|
|
|
#include "kernel/max_sharing.h"
|
2014-01-02 21:37:50 +00:00
|
|
|
#include "library/printer.h"
|
2013-09-21 05:01:40 +00:00
|
|
|
using namespace lean;
|
|
|
|
|
|
|
|
static void tst1() {
|
|
|
|
max_sharing_fn max_fn;
|
|
|
|
expr a1 = Const("a");
|
|
|
|
expr a2 = Const("a");
|
2014-01-10 02:09:53 +00:00
|
|
|
expr F1 = HEq(a1, a2);
|
|
|
|
lean_assert(!is_eqp(heq_lhs(F1), heq_rhs(F1)));
|
2013-09-21 05:01:40 +00:00
|
|
|
expr F2 = max_fn(F1);
|
2014-01-10 02:09:53 +00:00
|
|
|
lean_assert(is_eqp(heq_lhs(F2), heq_rhs(F2)));
|
2013-09-21 05:01:40 +00:00
|
|
|
expr x = Const("x");
|
|
|
|
expr y = Const("y");
|
|
|
|
expr f = Const("f");
|
|
|
|
expr N = Const("N");
|
|
|
|
F1 = f(Fun({x, N}, f(x, x)), Fun({y, N}, f(y, y)));
|
|
|
|
lean_assert(!is_eqp(arg(F1, 1), arg(F1, 2)));
|
|
|
|
F2 = max_fn(F1);
|
|
|
|
std::cout << F2 << "\n";
|
|
|
|
lean_assert(is_eqp(arg(F2, 1), arg(F2, 2)));
|
|
|
|
max_fn.clear();
|
2013-09-27 01:24:45 +00:00
|
|
|
local_context lctx{mk_lift(1, 1), mk_inst(0, a1)};
|
2013-10-02 00:25:17 +00:00
|
|
|
expr m1 = mk_metavar("m1", lctx);
|
|
|
|
expr m2 = mk_metavar("m1", lctx);
|
2013-09-21 05:01:40 +00:00
|
|
|
F1 = f(m1, m2);
|
|
|
|
lean_assert(!is_eqp(arg(F1, 1), arg(F1, 2)));
|
|
|
|
F2 = max_fn(F1);
|
|
|
|
std::cout << F2 << "\n";
|
|
|
|
lean_assert(is_eqp(arg(F2, 1), arg(F2, 2)));
|
|
|
|
F1 = f(Let({x, f(a1)}, f(x, x)), Let({y, f(a1)}, f(y, y)));
|
|
|
|
lean_assert(!is_eqp(arg(F1, 1), arg(F1, 2)));
|
|
|
|
F2 = max_fn(F1);
|
|
|
|
std::cout << F2 << "\n";
|
|
|
|
lean_assert(is_eqp(arg(F2, 1), arg(F2, 2)));
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2013-12-07 22:59:21 +00:00
|
|
|
save_stack_info();
|
2013-09-21 05:01:40 +00:00
|
|
|
tst1();
|
|
|
|
return has_violations() ? 1 : 0;
|
|
|
|
}
|