Skip to content

Lean doesn't try unfolding when it could #1892

Closed

Description

@digama0
def OrderDual (α : Type u) : Type u := α

variable (α : Type u) [instLE : LE α] {a b : α}
instance : LE (OrderDual α) := ⟨fun x y : α => y ≤ x⟩

theorem foo : a ≤ b := sorry

example : a ≤ b := foo (OrderDual α) -- fails
-- synthesized type class instance is not definitionally equal to expression inferred by typing rules, synthesized
--   instLEOrderDual
-- inferred
--   instLE
example : a ≤ b := @foo (OrderDual α) _ b a -- works
example : a ≤ b := (foo (OrderDual α) :) -- works

Here we have a goal @LE.le.{u} α instLE a b which we want to match against @LE.le.{u} (OrderDual.{u} α) (@instLEOrderDual.{u} α instLE) ?a ?b, which is possible by unfolding instLEOrderDual and then assigning ?a := b, ?b := a. However lean seems to latch on the solution ?a := a, ?b := b and then complains that the instance argument does not match.

Activity

  1. gebner commented on Nov 28, 2022

    @gebner
    Member

    I don't think this has anything to do with unfolding (except for the superficial sense in that we have definitional reductions in Lean..). This seems to be a side effect of the new expected-type propagation procedure. In particular, we don't synthesize type class instances before propagating the expected type, allowing the unifier to assign them.

    Let me see if that's the issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions