lean4-htt/tests/lean/run/grind_natCast_intCast.lean
Leonardo de Moura f8cdb03352
fix: add CommRing.Expr.intCast k and CommRing.Expr.natCast k (#9670)
This PR add constructors `.intCast k` and `.natCast k` to
`CommRing.Expr`. We need them because terms such as `Nat.cast (R := α)
1` and `(1 : α)` are not definitionally equal. This is pervaise in
Mathlib for the numerals `0` and `1`.

```lean
import Mathlib

example {α : Type} [AddMonoidWithOne α] : Nat.cast (R := α) 0 = (0 : α) := rfl -- not defeq
example {α : Type} [AddMonoidWithOne α] : Nat.cast (R := α) 1 = (1 : α) := rfl -- not defeq
example {α : Type} [AddMonoidWithOne α] : Nat.cast (R := α) 2 = (2 : α) := rfl -- defeq from here
-- Similarly for everything past `AddMonoidWithOne` in the Mathlib hierarchy, e.g. `Ring`.
```
2025-08-01 19:35:13 +00:00

15 lines
458 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

open Lean Grind
attribute [local instance] Semiring.natCast Ring.intCast
example [CommRing α] (a : α) : Int.cast (R := α) (-2) = a → a + 2 = 0 := by
grind
example [CommRing α] (a : α) : Nat.cast (R := α) 2 = a → a - 2 = 0 := by
grind
example [CommRing α] [IsCharP α 4] (a : α) : Int.cast (R := α) (-2) = a → a + 2 = 0 := by
grind
example [CommRing α] [IsCharP α 4] (a : α) : Nat.cast (R := α) 2 = a → a - 2 = 0 := by
grind