lean4-htt/tests/lean/run/grind_pow_inst_issue.lean
Leonardo de Moura 18cc1cec80
fix: grind instance normalization (#10179)
This PR fixes `grind` instance normalization procedure.
Some modules in grind use builtin instances defined directly in core
(e.g., `cutsat`), while others synthesize them using `synthInstance`
(e.g., `ring`). This inconsistency is problematic, as it may introduce
mismatches and result in two different representations for the same
term. This PR fixes the issue.
2025-08-30 02:24:26 +00:00

29 lines
878 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.

theorem square_mod_eight_eq (n : Nat) :
n ^ 2 % 8 = 0 n ^ 2 % 8 = 1 n ^ 2 % 8 = 4 := by
sorry
theorem test0 {n : Nat} (hn : n % 8 = 7) (a b c : Nat)
(hl' : a ^ 2 + b ^ 2 + c ^ 2 = n) :
False := by
grind [square_mod_eight_eq] -- works
class Monoid (M : Type u) extends Mul M, One M where
protected npow : Nat → M → M
instance Monoid.toNatPow {M : Type u} [Monoid M] : Pow M Nat :=
⟨fun x n ↦ Monoid.npow n x⟩
instance Int.instCommMonoid : Monoid Int where
npow n x := x ^ n
theorem test1 {n : Nat} (hn : n % 8 = 7) (a b c : Nat)
(hl' : a ^ 2 + b ^ 2 + c ^ 2 = n) :
False := by
grind [square_mod_eight_eq] -- should work
attribute [-instance] Lean.Grind.instCommRingInt in
theorem test2 {n : Nat} (hn : n % 8 = 7) (a b c : Nat)
(hl' : a ^ 2 + b ^ 2 + c ^ 2 = n) :
False := by
grind [square_mod_eight_eq] -- works