Skip to content

grind often fails on goals containing (...#usize : Nat) #1035

Open

Description

@abentkamp

I've noticed that grind often fails on goals containing (...#usize : Nat). Here is a small example demonstrating this:

example (x : Nat) : (5 : Nat) ∣ (5 : Nat) * x := by grind --works
example (x : Nat) : (5#usize : Nat) ∣ (5#usize : Nat) * x := by grind -- fails

A solution could be to add grind norm attributes to the following lemmas:

attribute [grind norm] UScalar.ofNatCore_val_eq
attribute [grind norm] IScalar.ofInt_val_eq

I don't fully understand the issue, but I believe grind is attempting to use its linear arithmetic solver on these kinds of goals and fails when numbers are wrapped in (...#usize : Nat).

Activity

  1. sonmarcho commented on May 18, 2026

    @sonmarcho
    Member

    I think the treatment of coercions to Nat is hardcoded in grind. But I'm surprised by grind norm: isn't norm the simpset used internally by grind to normalize expressions fed into the egraph (shouldn't we never touch it)? If yes to both it's probably worth creating an MWE and opening an issue for Lean.

  2. abentkamp commented on May 19, 2026

    @abentkamp
    CollaboratorAuthor

    You're right, we shouldn't use grind norm for this.

    But I just remembered this:

    I'd guess that this would probably solve the issue.

  3. sonmarcho commented on May 20, 2026

    @sonmarcho
    Member

    I'm not sure that's the best solution? It looks more like we need some preprocessing step like what I'm doing here (I discussed the fact we need proper support for this in grind with Leo during the hackathon):

    let (simpResult, _) ← Lean.Meta.simp type simpCtx simprocs

    Also, I really think it's worth minimizing the issue and opening an issue on the Lean github: it looks very much like a bug with grind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions