fix(library/normalize): bug in normalize

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-05-20 11:53:58 -07:00
parent fae07771ec
commit c5e8c10c9d
2 changed files with 17 additions and 1 deletions

View file

@ -23,6 +23,14 @@ class normalize_fn {
return update_binding(e, d, b);
}
expr normalize_app(expr const & e) {
buffer<expr> args;
expr f = get_app_rev_args(e, args);
for (expr & a : args)
a = normalize(a);
return mk_rev_app(f, args);
}
expr normalize(expr e) {
e = m_tc.whnf(e);
switch (e.kind()) {
@ -34,7 +42,7 @@ class normalize_fn {
case expr_kind::Lambda: case expr_kind::Pi:
return normalize_binding(e);
case expr_kind::App:
return update_app(e, app_fn(e), normalize(app_arg(e)));
return normalize_app(e);
}
lean_unreachable(); // LCOV_EXCL_LINE
}

8
tests/lua/expr10.lua Normal file
View file

@ -0,0 +1,8 @@
local env = environment()
local f = Local("f", mk_arrow(Bool, Bool, Bool))
local a = Local("a", Bool)
local b = Local("b", Bool)
local x = Local("x", Bool)
local t = Fun({f, a, b}, f(Fun(x, x)(b), a))
print(env:normalize(t))
assert(env:normalize(t) == Fun({f, a, b}, f(b, a)))