leanprover-community / leanprover-community/mathlib4

possible bug revealed by failure to apply simple `rel`, warning/error is confusing

Open
#20,232 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #20234 by @Command-Master — closed without merging
Dominant language
Lean
Stars
4.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Prerequisites

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

Description

The following is an MWE reproducing an issue I found working on a wider exercise.

import Mathlib.Tactic

example {n: ℕ} (h: 5 ≤ n): 2^n ≥ 30 := by
  calc
    2^n ≥ 2^5 := by rel [h] -- < -- fails ---
    _ ≥ 30 := by norm_num

The rel [h] fails.

The error message is confusing:

rel failed, cannot prove goal by 'substituting' the listed relationships. The steps which could not be automatically justified were:
1 ≤ 2

The code and error message have been verified on the online environment:
https://live.lean-lang.org/#codez=JYWwDg9gTgLgBAWQIYwBYBtgCMB0AVJAYxmEICgyBTADyXHUrgG8A7ALjkFRCAXzgApUHAKxxAJkRwWASg4AmAHos4gUyI4AZgAMcNgF44WAJ5k4cQknTljx+YpXyROvfrhRK6OAG1UAXTgBaX3AAPH4BAGZIwOgAziG+RpYA+spqmg4GEtAgCSwAriBkQA

Context

The issue was mentioned on the lean zulipchat and it was recommended a bug report was raised (forgive me if I misunderstood that bit)

https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/can't.20apply.20simple.20inequality.20by.20.60rel.60

Steps to Reproduce
  1. use the MWE above
  2. or use the linked example on the online environment

Expected behavior: [Clear and concise description of what you expect to happen]

It is expected that the rel [h] succeeds with no error or warning.

There may be some discussion about (0.5)^n ≥ (0.5)^5 but the MWE above only uses natural numbers, not reals or irrationals, not even integers.

Actual behavior: [Clear and concise description of what actually happens]

The rel [h] fails.

The error message is confusing:

rel failed, cannot prove goal by 'substituting' the listed relationships. The steps which could not be automatically justified were:
1 ≤ 2
Additional

Adding an explicit hypothesis g: 1 ≤ 2 in response to the error message is also fails.
Even if it worked, this should not be considered a satisfactory solution.

import Mathlib.Tactic

example {n: ℕ} (h: 5 ≤ n): 2^n ≥ 30 := by
  have g: 1 ≤ 2 := by norm_num -- < -- shouldn't ne necessary, still fails
  calc
    2^n ≥ 2^5 := by rel [h] -- < -- fails ---
    _ ≥ 30 := by norm_num
Versions

using macOS 15.2 VSC 1.96.2 the lean version is "4.3.0"
using live.lean-lang.org "4.15.0-rc1"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproducible example in the issue and the rel tactic entry point; reproduce the failure in the linked Lean environment. Done means the natural-number example behaves as expected and the reported diagnostic is no longer confusing, with relevant tests passing.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.