fix(kernel/converter): relax is_def_eq test, for example is_def_eq(f(?m1), a) should generate a constraint instead of returning an error
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
2cc8172d61
commit
5c17411a86
2 changed files with 39 additions and 12 deletions
|
@ -413,19 +413,19 @@ struct default_converter : public converter {
|
|||
|
||||
// At this point, t_n and s_n are in weak head normal form (modulo meta-variables and proof irrelevance)
|
||||
if (is_app(t_n) && is_app(s_n)) {
|
||||
expr it1 = t_n;
|
||||
expr it2 = s_n;
|
||||
bool ok = true;
|
||||
do {
|
||||
if (!is_def_eq(app_arg(it1), app_arg(it2), c, jst)) {
|
||||
ok = false;
|
||||
break;
|
||||
buffer<expr> t_args;
|
||||
buffer<expr> s_args;
|
||||
expr t_fn = get_app_args(t_n, t_args);
|
||||
expr s_fn = get_app_args(s_n, s_args);
|
||||
if (is_def_eq(t_fn, s_fn, c, jst) && t_args.size() == s_args.size()) {
|
||||
unsigned i = 0;
|
||||
for (; i < t_args.size(); i++) {
|
||||
if (!is_def_eq(t_args[i], s_args[i], c, jst))
|
||||
break;
|
||||
}
|
||||
it1 = app_fn(it1);
|
||||
it2 = app_fn(it2);
|
||||
} while (is_app(it1) && is_app(it2));
|
||||
if (ok && is_def_eq(it1, it2, c, jst))
|
||||
return true;
|
||||
if (i == t_args.size())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_env.prop_proof_irrel()) {
|
||||
|
@ -445,6 +445,11 @@ struct default_converter : public converter {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (has_metavar(t_n) || has_metavar(s_n)) {
|
||||
c.add_cnstr(mk_eq_cnstr(t_n, s_n, jst.get()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
22
tests/lua/tc7.lua
Normal file
22
tests/lua/tc7.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
local env = environment()
|
||||
env = add_decl(env, mk_var_decl("N", Type))
|
||||
local N = Const("N")
|
||||
env = add_decl(env, mk_var_decl("f", mk_arrow(N, N)))
|
||||
env = add_decl(env, mk_var_decl("g", mk_arrow(N, N)))
|
||||
env = add_decl(env, mk_var_decl("a", N))
|
||||
local f = Const("f")
|
||||
local g = Const("g")
|
||||
local x = Local("x", N)
|
||||
env = add_decl(env, mk_definition("h", mk_arrow(N, N), Fun(x, f(x)), {opaque=false}))
|
||||
local h = Const("h")
|
||||
local a = Const("a")
|
||||
local m1 = mk_metavar("m1", N)
|
||||
local cs = {}
|
||||
local ngen = name_generator("tst")
|
||||
local tc = type_checker(env, ngen, constraint_handler(function (c) print(c); cs[#cs+1] = c end))
|
||||
assert(tc:is_def_eq(f(m1), g(a)))
|
||||
assert(tc:is_def_eq(f(m1), a))
|
||||
assert(not tc:is_def_eq(f(a), a))
|
||||
assert(tc:is_def_eq(mk_lambda("x", N, Var(0)), h(m1)))
|
||||
assert(tc:is_def_eq(h(a), f(a)))
|
||||
assert(tc:is_def_eq(h(a), f(m1)))
|
Loading…
Add table
Reference in a new issue