Zulip Chat Archive

Stream: lean4

Topic: Synthesization order


Peter Nelson (Nov 25 2023 at 00:53):

What is wrong with this?

import Mathlib.Tactic

class P1 (n : ) : Prop where
  (p : 37 < n)

class P2 (m n : ) : Prop where
  (p : 37 < n)
  (q : n < m)

instance foo (m n : ) [h : P2 m n] : P1 n :=
  h.p

/-
cannot find synthesization order for instance foo with type
  ∀ (m n : ℕ) [h : P2 m n], P1 n
all remaining arguments have metavariables:
  P2 ?m n
  -/

foo works fine as a theorem, but can't be an instance apparently. What is the reason typeclass search can't find something like that?

Kyle Miller (Nov 25 2023 at 01:57):

I think it would work if m were an out_param on P2. The problem is that you need to figure out a value of m from n somehow in the foo instance, and P2 does not determine m from n.


Last updated: Dec 20 2023 at 11:08 UTC