Repository navigation
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
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
kmill commentedon Jul 28, 2025
More context: a workaround for this is
@[instance] theorem.I know that
theoremelaboration completes elaboration of the signature before proceeding, which is a natural point foromitto remove omitted parameters, and thatinstancedoesn't have such a point, but perhaps sinceinstancerequires a type, and it elaborates that type before proceeding to the body, it could still do the omission logic when the result is aProp?Or maybe it we could introduce an
instance theoremcommand?sgouezel commentedon Jul 28, 2025
Another possibility is to decide that
omitandincludeshould work for everyone (lemmas, defs, instances): if the user is writing this explicitely, isn't it to override the default choice anyway?fpvandoorn commentedon Oct 23, 2025
This suggestion is #5595 (and this issue is a special case of that one).