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

linter.unusedVariables false positive when used in induction #2873

Open
sven-manthe opened this issue Nov 14, 2023 · 5 comments
Open

linter.unusedVariables false positive when used in induction #2873

sven-manthe opened this issue Nov 14, 2023 · 5 comments
Labels
bug Something isn't working server Affects the Lean server code

Comments

@sven-manthe
Copy link

Prerequisites

  • [X ] 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

In some cases, the linter.unusedVariables yields false positives for variables used only in inductions.

Context

This was discussed in https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Possible.20linter.2EunusedVariables.20bug

Steps to Reproduce

example (P : Unit → Prop) (H : P () → True) (x : Unit) (h : P x) : True := by
  let h' := h
  cases x
  exact H h'

Expected behavior: No warning occurs.

Actual behavior: The message "unused variable h' [linter.unusedVariables]" is shown.

Versions

Lean (version 4.3.0-rc1, commit baa4b68, Release)
Manjaro Linux 23.0

@sven-manthe sven-manthe added the bug Something isn't working label Nov 14, 2023
@Kha Kha added the server Affects the Lean server code label Nov 14, 2023
@Kha
Copy link
Member

Kha commented Nov 14, 2023

Must be a general info tree issue
image

@Kha
Copy link
Member

Kha commented Nov 14, 2023

I think we're still missing a tactic version of #1396

@Seasawher
Copy link
Contributor

Seasawher commented Nov 18, 2023

I have encountered a similar false positive warning.

This is the MWE to reproduce the bug.

variable (α : Type)

def sample (n : Nat) : Nat :=
  match h : n with
  | 0 => 0
  | m + 1 => m + sample (m / 2)
  decreasing_by
    simp [h]
    simp_wf
    exact Nat.lt_of_le_of_lt (Nat.div_le_self _ _) (Nat.lt_succ_self _)

related : https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/False.20Positive.20Warning.3A.20.60linter.2EunusedVariables.60

@semorrison
Copy link
Collaborator

@Seasawher, I think this is an independent issue, that nothing is checking for usages in a decreasing_by clause. Could you open your example as a separate issue?

@Seasawher
Copy link
Contributor

done #2920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server Affects the Lean server code
Projects
None yet
Development

No branches or pull requests

4 participants