Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isDefEq creates type-incorrect terms when applying isDefEqSingleton rule #6420

Open
3 tasks done
kmill opened this issue Dec 20, 2024 · 0 comments · May be fixed by #6421
Open
3 tasks done

isDefEq creates type-incorrect terms when applying isDefEqSingleton rule #6420

kmill opened this issue Dec 20, 2024 · 0 comments · May be fixed by #6421
Labels
bug Something isn't working

Comments

@kmill
Copy link
Collaborator

kmill commented Dec 20, 2024

Prerequisites

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

Description

Given a projection of a metavariable for a one-field structure that's unified with a term of the wrong type, the result is a type-incorrect term assigned to the metavariable.

Context

[Broader context that the issue occurred in. If there was any prior discussion on the Lean Zulip, link it here as well.]

Steps to Reproduce

Consider the following code:

import Lean

open Lean

structure foo where
  bar : Nat

#eval show MetaM Unit from do
  let lhs := Expr.const ``foo []
  let m ← Meta.mkFreshExprMVar lhs
  let rhs := Expr.app (.const ``foo.bar []) m
  let defeq? ← Meta.isDefEq lhs rhs
  let m ← instantiateMVars m
  logInfo m!"unifiable? {defeq?}"
  logInfo m!"m is{indentExpr m}"
  logInfo m!"m is type correct? {← Meta.isTypeCorrect m}"

Expected behavior: We should see unifiable? false in the output.

Actual behavior: Instead this outputs

unifiable? true
m is
  { bar := foo }
m is type correct? false

Versions

Lean 4.16.0-nightly-2024-12-19
Target: x86_64-unknown-linux-gnu

Additional Information

Changing the structure to have more than one field causes the unification to correctly fail.

Reported on Zulip

Impact

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

@kmill kmill added the bug Something isn't working label Dec 20, 2024
kmill added a commit to kmill/lean4 that referenced this issue Dec 20, 2024
This PR fixes an issue where the `isDefEqSingleton` rule could apply in inappropriate situations. In particular, if `S` is a one-field structure with field `f`, then `S.f ?m =?= v` was being reduced to `?m =?= { f := v }` even if `{ f := v }` was type-incorrect.

Closes leanprover#6420
@kmill kmill linked a pull request Dec 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant