Skip to content

omit not working for Prop-valued instances #9597

Open

Description

@sgouezel

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

Currently, lemmas only use variables in the context that are referred to in the statement, while definitions use variables that are refereed to in the statement and in the body. I would expect that Prop-valued instances behave like lemmas, and data-carrying instances behave like definitions, but this is not the case: omit does not work for Prop-valued instances.

Context

This issue is a minimization of an issue showing up in mathlib, see discussion at #mathlib4 > Is `omit` broken? @ 💬

Steps to Reproduce

Run the following code:

class A (α : Type) : Prop where
class B (α : Type) : Prop where
class C (α : Type) : Prop where

instance BtoC (α : Type) [B α] : C α := {}
instance AtoC (α : Type) [A α] : C α := {}

variable (α : Type) [h : A α]

omit h in
instance myinst [B α] : C α := by
  infer_instance

#check myinst -- myinst (α : Type) [h : A α] [B α] : C α

Expected behavior: Since myinst is a Prop-valued instance, I expect the line omit h to work, and the infer_instance line to use BtoC, as there should be no assumption [A α] in the context.

Actual behavior: h is not omitted, so [A α] is available in the proof of myinst, and is used in the infer_instance line. In the end, myinst requires both [A α] and [B α].

Versions

Lean 4.23.0-nightly-2025-07-28
Target: x86_64-unknown-linux-gnu

Additional Information

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Activity

  1. added
    bug
    on Jul 28, 2025
  2. kmill commented on Jul 28, 2025

    @kmill
    Collaborator

    More context: a workaround for this is @[instance] theorem.

    I know that theorem elaboration completes elaboration of the signature before proceeding, which is a natural point for omit to remove omitted parameters, and that instance doesn't have such a point, but perhaps since instance requires a type, and it elaborates that type before proceeding to the body, it could still do the omission logic when the result is a Prop?

    Or maybe it we could introduce an instance theorem command?

  3. sgouezel commented on Jul 28, 2025

    @sgouezel
    ContributorAuthor

    Another possibility is to decide that omit and include should work for everyone (lemmas, defs, instances): if the user is writing this explicitely, isn't it to override the default choice anyway?

  4. added
    P-medium
    on Aug 8, 2025
  5. fpvandoorn commented on Oct 23, 2025

    @fpvandoorn
    Contributor

    Another possibility is to decide that omit and include should work for everyone (lemmas, defs, instances): if the user is writing this explicitely, isn't it to override the default choice anyway?

    This suggestion is #5595 (and this issue is a special case of that one).

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

    P-mediumbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions