feat(frontends/lean): coercion num -> int even when nat is not open, closes #219

I also had to mark the coercions as reducible.
Otherwise, given the constraint

          ?M (int.of_num 0) =?= (int.of_nat (nat.to_nat 0))

the unifier will not generate the solution

          ?M := fun x, x
This commit is contained in:
Leonardo de Moura 2014-10-01 11:09:10 -07:00
parent 966366e18e
commit 3657d4c3ab
2 changed files with 3 additions and 2 deletions

View file

@ -208,7 +208,8 @@ protected opaque definition has_decidable_eq [instance] : decidable_eq :=
_ _
irreducible int irreducible int
definition of_nat [coercion] (n : ) : := psub (pair n 0) definition of_nat [coercion] [reducible] (n : ) : := psub (pair n 0)
definition of_num [coercion] [reducible] (n : num) : := of_nat (nat.to_nat n)
theorem eq_zero_intro (n : ) : psub (pair n n) = 0 := theorem eq_zero_intro (n : ) : psub (pair n n) = 0 :=
have H : rel (pair n n) (pair 0 0), by simp, have H : rel (pair n n) (pair 0 0), by simp,

View file

@ -47,7 +47,7 @@ definition add (x y : ) : :=
nat.rec x (λ n r, succ r) y nat.rec x (λ n r, succ r) y
infixl `+` := add infixl `+` := add
definition to_nat [coercion] (n : num) : := definition to_nat [coercion] [reducible] (n : num) : :=
num.rec zero num.rec zero
(λ n, pos_num.rec (succ zero) (λ n r, r + r + (succ zero)) (λ n r, r + r) n) n (λ n, pos_num.rec (succ zero) (λ n r, r + r + (succ zero)) (λ n r, r + r) n) n