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

calc does not try to unify with expected type #2913

Closed
1 task done
collares opened this issue Nov 19, 2023 · 3 comments
Closed
1 task done

calc does not try to unify with expected type #2913

collares opened this issue Nov 19, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@collares
Copy link
Contributor

collares commented Nov 19, 2023

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Check that your issue is not already filed.
    • Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.

Description

Although example : 3 + 9 = 12 := rfl works, the following code

example : 3 + 9 = 12 :=
  calc
    3 + 9 = 12 := rfl

fails with

type mismatch
  rfl
has type
  3 + 9 = 3 + 9 : Prop
but is expected to have type
  3 + 9 = 12 : Prop

Replacing rfl with by rfl or by exact rfl above makes it work, but I think it shouldn't be necessary.

Context

Phil Wadler encountered this issue while porting his "Programming Language Foundations in Agda" book to Lean: https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Debugging.20an.20issue.20with.20calc.20mode

This is a regression pointed out by Wadler after upgrading from an old nightly. I bisected it and it works on the 2023-01-05 nightly and fails on the 2023-01-06 one. According to https://github.com/leanprover/lean4-nightly/releases/tag/nightly-2023-01-06 this points to fedf235, but see also 474f1a4 where this was worked around for the show tactic.

In particular, plfa/plfl@a4684b2 contains three more calc uses which now require type ascriptions (and didn't need them before fedf235).

Versions

Lean 4.3.0-rc2 on Linux

Impact

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

@collares collares added the bug Something isn't working label Nov 19, 2023
@collares collares changed the title calc problems with defeq terms calc does not try to unify with expected type Nov 20, 2023
@Kha
Copy link
Member

Kha commented Sep 27, 2024

Seems to have been fixed!

@Kha Kha closed this as completed Sep 27, 2024
@collares
Copy link
Contributor Author

Indeed, this fails on v4.10.0 but works on v4.11.0! Not sure which change fixed it, will bisect later.

(cc @wadler, since the ascriptions added in plfa/plfl@a4684b2 aren't needed since Lean v4.11.0)

@collares
Copy link
Contributor Author

Bisected to #4596:

commit 6080e3dd5cc76d9f8807de19d6575f517ee11899
Author: Leonardo de Moura <leomoura@amazon.com>
Date:   Tue Jul 2 15:42:47 2024 +0200

    fix: enforce `isDefEqStuckEx` at `unstuckMVar` procedure (#4596)
    
    Closes #2736
    
    See comment at `ExprDefEq.lean` for explanation.
    Side effects:
    - Improved error messages in two tests.
    - Had to improve `getSuccesses` procedure at `App.lean`. It now
      discards candidates that contain postponed elaboration problems.
      If it is too disruptive for Mathlib, we should try to discard the
      ones that have postponed metavariables.

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

No branches or pull requests

2 participants