2014-06-02 22:09:24 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include "library/update_declaration.h"
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
static declaration update_declaration(declaration d, optional<level_param_names> const & ps,
|
|
|
|
optional<expr> const & type, optional<expr> const & value) {
|
2014-06-02 23:20:34 +00:00
|
|
|
level_param_names _ps = ps ? *ps : d.get_univ_params();
|
2014-06-02 22:09:24 +00:00
|
|
|
expr _type = type ? *type : d.get_type();
|
|
|
|
expr _value;
|
|
|
|
if (d.is_definition()) {
|
|
|
|
_value = value ? *value : d.get_value();
|
|
|
|
} else {
|
|
|
|
lean_assert(!value);
|
|
|
|
}
|
2014-10-02 23:54:56 +00:00
|
|
|
if (d.is_constant_assumption()) {
|
2014-06-02 23:20:34 +00:00
|
|
|
if (is_eqp(d.get_type(), _type) && is_eqp(d.get_univ_params(), _ps))
|
2014-06-02 22:09:24 +00:00
|
|
|
return d;
|
|
|
|
if (d.is_axiom())
|
|
|
|
return mk_axiom(d.get_name(), _ps, _type);
|
|
|
|
else
|
2014-10-02 23:54:56 +00:00
|
|
|
return mk_constant_assumption(d.get_name(), _ps, _type);
|
2014-06-02 22:09:24 +00:00
|
|
|
} else {
|
2014-06-02 23:20:34 +00:00
|
|
|
if (is_eqp(d.get_type(), _type) && is_eqp(d.get_value(), _value) && is_eqp(d.get_univ_params(), _ps))
|
2014-06-02 22:09:24 +00:00
|
|
|
return d;
|
|
|
|
if (d.is_theorem())
|
2015-06-30 19:11:13 +00:00
|
|
|
return mk_theorem(d.get_name(), _ps, _type, _value, d.get_height());
|
2014-06-02 22:09:24 +00:00
|
|
|
else
|
2015-05-08 22:42:42 +00:00
|
|
|
return mk_definition(d.get_name(), _ps, _type, _value,
|
2015-06-30 19:11:13 +00:00
|
|
|
d.get_height(), d.use_conv_opt());
|
2014-06-02 22:09:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
declaration update_declaration_univ_params(declaration const & d, level_param_names const & ps) {
|
|
|
|
return update_declaration(d, optional<level_param_names>(ps), none_expr(), none_expr());
|
|
|
|
}
|
|
|
|
|
|
|
|
declaration update_declaration_type(declaration const & d, expr const & type) {
|
|
|
|
return update_declaration(d, optional<level_param_names>(), some_expr(type), none_expr());
|
|
|
|
}
|
|
|
|
|
|
|
|
declaration update_declaration_value(declaration const & d, expr const & value) {
|
|
|
|
return update_declaration(d, optional<level_param_names>(), none_expr(), some_expr(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
declaration update_declaration(declaration const & d, level_param_names const & ps, expr const & type, expr const & value) {
|
|
|
|
return update_declaration(d, optional<level_param_names>(ps), some_expr(type), some_expr(value));
|
|
|
|
}
|
|
|
|
declaration update_declaration(declaration const & d, level_param_names const & ps, expr const & type) {
|
|
|
|
return update_declaration(d, optional<level_param_names>(ps), some_expr(type), none_expr());
|
|
|
|
}
|
|
|
|
}
|