Yifan Dai
Yifan Dai

Reputation: 9

Is there a way to define a function that converts a value between same types?

i.e. Is it possible to define

example {α β : Type} (hab : α = β) (x : α) : β := sorry

From what I understand Eq.subst a b has type ∀ {α : Sort u} {motive : α → Prop} {a b : α}, a = b → motive a → motive b, but the restriction that motive must return Prop seems an unnecessary restriction and hence does not suit my need very well.

Upvotes: 0

Views: 109

Answers (2)

Sebastian Ullrich
Sebastian Ullrich

Reputation: 1230

This is Eq.cast in Lean 4.

Eq.cast : {α β : Sort u_1} → α = β → α → β

Upvotes: 0

Yury Kudryashov
Yury Kudryashov

Reputation: 146

In Lean 3 it is called eq.rec/eq.rec_on. I guess, in Lean 4 it is called Eq.rec/Eq.rec_on.

Upvotes: 2

Related Questions