feat(frontends/lean/elaborator): restrict the number of places where coercions are considered

We do not consider coercions around meta-variables anymore.
This commit is contained in:
Leonardo de Moura 2015-11-11 12:37:19 -08:00
parent 296a4ab940
commit 5ceac83b6a
6 changed files with 45 additions and 13 deletions

View file

@ -50,7 +50,7 @@ namespace yoneda
end
definition yoneda_lemma_equiv [constructor] {C : Precategory} (c : C)
(F : Cᵒᵖ ⇒ cset) : hom (ɏ c) F ≃ lift (F c) :=
(F : Cᵒᵖ ⇒ cset) : hom (ɏ c) F ≃ lift (trunctype.carrier (to_fun_ob F c)) :=
begin
fapply equiv.MK,
{ intro η, exact up (η c id)},

View file

@ -360,10 +360,10 @@ definition of_num [coercion] [reducible] (n : num) : := num.to.rat n
protected definition prio := num.pred int.prio
definition rat_has_zero [reducible] [instance] [priority rat.prio] : has_zero rat :=
has_zero.mk (0:int)
has_zero.mk (of_int 0)
definition rat_has_one [reducible] [instance] [priority rat.prio] : has_one rat :=
has_one.mk (1:int)
has_one.mk (of_int 1)
theorem of_int_zero : of_int (0:int) = (0:rat) :=
rfl

View file

@ -1098,10 +1098,10 @@ definition of_nat [coercion] (n : ) : := nat.to.real n
definition of_num [coercion] [reducible] (n : num) : := of_rat (rat.of_num n)
definition real_has_zero [reducible] [instance] [priority real.prio] : has_zero real :=
has_zero.mk (0:rat)
has_zero.mk (of_rat 0)
definition real_has_one [reducible] [instance] [priority real.prio] : has_one real :=
has_one.mk (1:rat)
has_one.mk (of_rat 1)
theorem real_zero_eq_rat_zero : (0:real) = of_rat (0:rat) :=
rfl

View file

@ -616,7 +616,7 @@ pair<expr, constraint_seq> elaborator::mk_delayed_coercion(
pair<expr, constraint_seq> elaborator::ensure_has_type_core(
expr const & a, expr const & a_type, expr const & expected_type, bool use_expensive_coercions, justification const & j) {
bool lifted_coe = false;
if (m_ctx.m_coercions) {
if (m_ctx.m_coercions && !is_meta(a)) {
if (use_expensive_coercions &&
has_coercions_from(a_type, lifted_coe) && ((!lifted_coe && is_meta(expected_type)) || (lifted_coe && is_pi_meta(expected_type)))) {
return mk_delayed_coercion(a, a_type, expected_type, j);

View file

@ -0,0 +1,8 @@
import data.int data.real
open int real
example : (1 : ) * (1 : ) = (1 : ) :=
sorry
example : (1 : ) * 1 = 1 :=
sorry

View file

@ -0,0 +1,24 @@
import data.int data.real
open algebra nat int rat real
example : (1 : ) * (1 : ) = (1 : ) :=
sorry
example : (1 : ) * 1 = 1 :=
sorry
example : (1 : ) * (1 : ) = (1 : ) :=
sorry
example : (1 : ) * 1 = 1 :=
sorry
variable x :
variable a :
variable n :
example : x + a + n + 1 = 1 :=
sorry
example : x + 1 = 1 + x :=
sorry