isDefEq fails in presence of unassignable metavariable
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Description
In the unification problem ?a =?= (fun x => ?a) b, when ?a is not assignable then unification fails.
Context
Zulip discussion, reported by Jovan Gerbscheid.
Steps to Reproduce
Expected behavior: the following test returns true. Actual behavior: it returns false.
import Lean
open Lean Meta
elab "foo" : term => do
let a ← mkFreshExprSyntheticOpaqueMVar (mkConst ``Nat)
let c := mkApp (mkLambda `x .default (mkConst ``Nat) a) (mkConst ``Nat.zero)
return toExpr <| ← isExprDefEq a c
set_option trace.Meta.isDefEq true
#check foo
This can be triggered with metacontext depth as well:
elab "foo" : term => do
let a ← mkFreshExprMVar (mkConst ``Nat)
let c := mkApp (mkLambda `x .default (mkConst ``Nat) a) (mkConst ``Nat.zero)
return toExpr <| ← withNewMCtxDepth do isExprDefEq a c
Additional information
The following test helps localize the issue to isDefEqQuickOther returning LBool.false.
import Lean
open Lean Meta
elab "foo" : term => do
let a ← mkFreshExprSyntheticOpaqueMVar (mkConst ``Nat)
let c := mkApp (mkLambda `x .default (mkConst ``Nat) a) (mkConst ``Nat.zero)
withTheReader Meta.Context (fun c => {c with config := {c.config with isDefEqStuckEx := true}}) do
return toExpr <| ← isExprDefEq a c
set_option trace.Meta.isDefEq true
set_option trace.Meta.isDefEq.stuck true
#check foo
-- ...
-- [] ?m.654 [nonassignable] =?= (fun x ↦ ?m.654) Nat.zero [nonassignable]
-- [stuck] ?m.654 =?= (fun x ↦ ?m.654) Nat.zero
Versions
#eval Lean.versionString
-- "4.6.0-rc1"
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided reproducer using isExprDefEq and the trace output, then inspect the isDefEqQuickOther path identified in the issue. Confirm the behavior for an unassignable metavariable in both examples and verify that the expected equality result is returned.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100