Fix bug in max_sharing
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
dd74284fdc
commit
f00d8c4683
2 changed files with 15 additions and 2 deletions
|
@ -25,13 +25,15 @@ class max_sharing_functor {
|
|||
public:
|
||||
|
||||
expr apply(expr const & a) {
|
||||
if (a.raw()->max_shared())
|
||||
return a;
|
||||
auto r = m_cache.find(a);
|
||||
if (r != m_cache.end()) {
|
||||
lean_assert((*r).raw()->max_shared());
|
||||
return *r;
|
||||
}
|
||||
if (a.raw()->max_shared()) {
|
||||
m_cache.insert(a);
|
||||
return a;
|
||||
}
|
||||
switch (a.kind()) {
|
||||
case expr_kind::Var: case expr_kind::Constant: case expr_kind::Prop: case expr_kind::Type: case expr_kind::Numeral:
|
||||
cache(a);
|
||||
|
|
|
@ -187,6 +187,16 @@ void tst6() {
|
|||
}
|
||||
}
|
||||
|
||||
void tst7() {
|
||||
expr f = constant(name("f"));
|
||||
expr v = var(0);
|
||||
expr a1 = max_sharing(app(f, v, v));
|
||||
expr a2 = max_sharing(app(f, v, v));
|
||||
lean_assert(!eqp(a1, a2));
|
||||
expr b = max_sharing(app(f, a1, a2));
|
||||
lean_assert(eqp(get_arg(b, 1), get_arg(b, 2)));
|
||||
}
|
||||
|
||||
int main() {
|
||||
continue_on_violation(true);
|
||||
std::cout << "sizeof(expr): " << sizeof(expr) << "\n";
|
||||
|
@ -197,6 +207,7 @@ int main() {
|
|||
tst4();
|
||||
tst5();
|
||||
tst6();
|
||||
tst7();
|
||||
std::cout << "done" << "\n";
|
||||
return has_violations() ? 1 : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue