lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

`grind`: Application type mismatch on `cpop` of a `let`-bound `BitVec`

Open luigirinaldi opened this issue 2 months ago • 0 comments

Prerequisites

  • [x] Check that your issue is not already filed: https://github.com/leanprover/lean4/issues
  • [x] Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to Mathlib or Batteries.
  • [x] Test your test case against the latest nightly release, for example on https://live.lean-lang.org/#project=lean-nightly (You can also use the settings there to switch to “Lean nightly”)

Description

grind fails with an internal Application type mismatch when a hypothesis mentions cpop of a let-bound BitVec literal. The same goal with the literal stated as a separate hypothesis passes. grind -hom solves the issue.

Context

This issue arose when developing some automation for BitVec solving. #15261 is possibly related.

Steps to Reproduce

-- Passes, m equated to literal as a hypothesis
example (m b : BitVec 2) (h : m = 1#2) : b = m.cpop → b = 1 := by
  intro hb
  grind

-- Fails, m defined using a let binding
example (b : BitVec 2) : let m : BitVec 2 := 1#2; b = m.cpop → b = 1 := by
  intro m h
  grind

-- Fails, equate b to the cpop of a let bound variable using sorry
example (b : BitVec 2) : True := by
  let m : BitVec 2 := 1#2
  have h : b = m.cpop := sorry
  grind

-- Passes, disabling homomorphism module
example (b : BitVec 2) : let m : BitVec 2 := 1#2; b = m.cpop → b = 1 := by
  intro m h
  grind -hom

Error message in both cases:

Application type mismatch: The argument
  h
has type
  b = m.cpop
but is expected to have type
  b = 1
in the application
  Eq.mp (Eq.trans (fun {n} {x y} => propext BitVec.toNat_eq) (congrArg (Eq b.toNat) (Eq.refl 1))) h

https://live.lean-lang.org/?from=lean#project=lean-nightly&codez=LTAEAUEMGdoU2gGlAW1HAjgV0gFzgCai4D2oANgJb4BOk5oMjoAFgJ4AOJuLCl0AKDgAPSCg7k4oABRoARqABcoAELUAanADGoAEwBKGSyWpQAXlABGAMQGTCiygB0Wrh1CAkwlAOrSi3LYBUFBKADtcGjIWOSDQAHMaMIIBARBQADFISnIkUwI4ADMwwlAsaDC45klcbySKoVFxSRkFZTVcTR07ZWrTNo1tPT8rWwBub3NUFzdPCYtLYYDYsIiyNBZYhKSUtMzs3MwcfAnSYl5QVxJ3EgKquBq5EixQogA3SETIOWayitBoEg0GiBERiCRSaStVQDLqGZQAFRoWCkin8gWCvTQ%2FQ6g10wxsuliLEgrykxmUPmcl3cqP%2BgOBm0SLx2YCgsAQyAI%2FC%2BVFClRYJBQgsBHBY%2FDQQoIWEkDTBzUhJnanT0cIo9z60JxXXxYzmU2psx8C1pS2CK0ipg2wS2L1AwAFKBS1lJNHKJFCQA

Versions

Lean 4.36.0-nightly-2026-09-27
Target: x86_64-unknown-linux-gnu Linux

luigirinaldi avatar Sep 28 '26 16:09 luigirinaldi