Zulip Chat Archive

Stream: new members

Topic: Cast Int to Real


Tomaz Gomes (Nov 21 2023 at 12:22):

Hi, why isn't Real.intCast.intCast 0 definitionally equal to 0 : Real? For instance, if I do:

import Mathlib.Data.Real.Basic

example : (0 : ) = Rat.ofInt (Int.ofNat 0) := rfl -- ok

example : (0 : ) = Real.intCast.intCast 0 := rfl -- type mismatch on rfl

Is there another casting function that won't have this problem?

Kevin Buzzard (Nov 21 2023 at 13:22):

Why do you care about such implementation details? We have tactics which deal with all of this such as norm_cast.

Tomaz Gomes (Nov 21 2023 at 13:28):

I am implementing my own tactic, which involves casting variables from Int to Real. I will perform some operations on these variables, and I got some errors by assuming the equality I described. Also, I am curious about this :)

Eric Wieser (Nov 21 2023 at 13:41):

The reason they're not defeq is that we deliberately marked them as irreducible_def so that lean is not allowed to know that secretly they're defeq after all


Last updated: Dec 20 2023 at 11:08 UTC