leanprover / leanprover/lean4

grind: normalization of `UInt16.toNat 0` gets in the way

Open
#11,990 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Description

Goals around UInt16.toNat can sometimes fail because grind normalizes UInt16.toNat 0 too eagerly.

Context

Discussion here:
#general > grind confused by `UInt.toNat`?

Steps to Reproduce
example (b : UInt16) (h : b = 0) : UInt16.toNat b = 0 := by grind [UInt16.toNat_zero]

Expected behavior: grind should be able to prove this

Actual behavior: grind fails

Versions

4.28.0-nightly-2026-01-12 on live.lean-lang.org

Workaround

For the concrete example above, this is a possible workaround, but it feels like this should not be necessary:

@[grind gen]
theorem UInt16.toNat_of_eq_zero (h : b = 0) : UInt16.toNat b = 0 := by subst h; rfl

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 by reproducing the example from the issue with Lean 4.28.0-nightly-2026-01-12 and compare it with the supplied workaround theorem. Trace how grind normalizes UInt16.toNat 0; the work is done when the original example is proved without requiring that workaround.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.