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:
parent
966366e18e
commit
3657d4c3ab
2 changed files with 3 additions and 2 deletions
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue