lean2/tests/lua/eta.lua
Leonardo de Moura 7b15e558a2 refactor(kernel/converter): implement eta in whnf instead of is_def_eq.
Without cumulativity, we do not have problems with Eta at whnf anymore.
When we had cumulativity, we could not not simply reduce
     (fun x : A, f x) ==> f
This step is correct only if domain(f) was definitionally equal to f.
Here is a problematic example for systems with cumulativity
Given, f : Type.{2} -> Bool
     (fun x : Type.{1}, f x)

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-12 17:49:53 -07:00

16 lines
666 B
Lua

local env = empty_environment()
env = add_decl(env, mk_var_decl("f", mk_arrow(Bool, mk_arrow(Bool, Bool))))
local f = Const("f")
local x = Const("x")
local y = Const("y")
local z = Const("z")
local tc = type_checker(env)
print(tc:whnf(Fun(x, Bool, f(x))))
print(tc:whnf(Fun(x, Bool, Fun(y, Bool, f(x, y)))))
print(tc:whnf(Fun(x, Bool, Fun(y, Bool, f(Const("a"), y)))))
print(tc:whnf(Fun(z, Bool, Fun(x, Bool, Fun(y, Bool, f(z, y))))))
assert(tc:is_def_eq(f, Fun(x, Bool, f(x))))
assert(tc:is_def_eq(f, Fun(x, Bool, Fun(y, Bool, f(x, y)))))
local a = Const("a")
local A = Const("A")
assert(tc:is_def_eq(Fun(a, A, a)(f), Fun(x, Bool, Fun(y, Bool, f(x, y)))))