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

Unification not working on simple expected case. #2051

Open
1 task done
ericrbg opened this issue Jan 20, 2023 · 3 comments
Open
1 task done

Unification not working on simple expected case. #2051

ericrbg opened this issue Jan 20, 2023 · 3 comments

Comments

@ericrbg
Copy link
Contributor

ericrbg commented Jan 20, 2023

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

example (a b c : Nat) : a = b → a * c = b * c := congrArg _ --fails, works with (· * c) requires you to explicitly spell out the function. In lean3, this is not required, and often used in mathlib.

Expected behavior: Success.

Actual behavior:

type mismatch
  congrArg ?m.56535
has type
  ?m.56533 = ?m.56534 → ?m.56535 ?m.56533 = ?m.56535 ?m.56534 : Prop
but is expected to have type
  a = b → a * c = b * c : Prop

Reproduces how often: 100%

Versions

Lean (version 4.0.0-nightly-2023-01-16, commit 5349a08, Release)
OSX Ventura 13.1, M1 Mac

@ericrbg
Copy link
Contributor Author

ericrbg commented Oct 26, 2023

Just want to confirm that this is still an issue on new Lean4 releases.

@semorrison
Copy link
Collaborator

@leodemoura, do we know what exactly changed in Lean4 that resulted in this change in behaviour? I don't know here whether to say this is an unavoidable regression due to some deeper change, or something that could potentially be addressed.

@Kha
Copy link
Member

Kha commented Nov 2, 2023

@semorrison I believe this is

In Lean3 and Lean 4, we used to use the quasi-pattern approximation during elaboration.

Indeed, carefully arranging the proof of a similar example such that Lean is sure that a may be used in the hole but b/c may not (making it a regular pattern unification problem) makes it work.

example : ∀ (a b c : Nat), b = c → b * a = c * a :=
  fun a =>
    let f := _
    fun b c => congrArg f  -- replace `f` with `_` to break it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants