lean4-htt/tests/lean/1298.lean
Joe Hendrix 1d9074c524
chore: upstream NatCast and IntCast (#3347)
This upstreams NatCast and IntCast alone independent of norm_cast in
#3322.

This will allow more efficiently upstreaming parts of Std.Data.Int
relevant for omega.

---------

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
2024-02-16 00:54:22 +00:00

15 lines
430 B
Text

class Semiring (R : Type u) extends Add R, HPow R Nat R, Mul R where
zero : R
instance [Semiring R] : OfNat R n where
ofNat := Semiring.zero
def Nat.castTest [Semiring R] (n : Nat) : R := let _ := n = n; Semiring.zero
@[default_instance high] instance [Semiring R] : HPow R Nat R := inferInstance
instance [Semiring R] : CoeTail Nat R where
coe n := n.castTest
variable (R) [Semiring R]
#check (8 + 2 ^ 2 * 3 : R) = 20