Zulip Chat Archive
Stream: general
Topic: Implicitly coerce Fin n to Fin m, where n
Konstantin Weitz (Jul 24 2025 at 18:18):
I'm struggling to implement this, since Coe seems to require all implicit parameters to be deliverable from the source type
Yakov Pechersky (Jul 24 2025 at 18:23):
Coercion here is working through the typeclass synthesis system. That system needs access to all facts to synthesize. On the fly, it can't prove n < m and use that for its synthesis, unless you have an explicit [Fact (n < m)] for your specific n and m available.
Yakov Pechersky (Jul 24 2025 at 18:24):
Do you really need implicit coercion, or could you do an at-site-of-call lift? Via CanLift and the lift tactic.
Robin Arnez (Jul 24 2025 at 19:19):
Something like
class Decide (p : Prop) [Decidable p] where
out (p) : p
instance : @Decide p (Decidable.isTrue h) := @Decide.mk _ (_) h
local instance [Decide (n ≤ m)] : CoeDep (Fin n) x (Fin m) := ⟨x.castLE (Decide.out (n ≤ m))⟩
variable (x : Fin 3)
#check (x : Fin 5)
should work
Violeta Hernández (Jul 26 2025 at 01:06):
Or you know, you could simply do the coercion explicitly as ⟨x.1, by decide⟩
Last updated: Dec 20 2025 at 21:32 UTC