lean4-htt/tests/lean/run/grind_11515.lean
Leonardo de Moura b0a12cb49f
feat: mark Nat power and divisibility theorems for grind (#11519)
This PR marks `Nat` power and divisibility theorems for `grind`. We use
the new `grind_pattern` constraints to control theorem instantiation.
Examples:

```lean
example {x m n : Nat} (h : x = 4 ^ (m + 1) * n) : x % 4 = 0 := by
  grind

example (a m n o p : Nat) : a ∣ n → a ∣ m * n * o * p := by
  grind

example {a b x m n : Nat}
    : n > 0 → x = b * 4^m * a → a = 9^n → m > 0 → x % 6 = 0 := by
  grind

example {a n : Nat}
    : m > 4 → a = 2^(m^n) → a % 2 = 0 := by
  grind
```

Closes #11515

Remark: We are adding support for installing extra theorems to `lia`
(aka `cutsat`). The example at #11515 can already be solved by `grind`
with this PR, but we still need to add the new theorems to the set for
`lia`.

cc @kim-em
2025-12-05 03:49:01 +00:00

66 lines
1.8 KiB
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.

example {x m n : Nat} (h : x = 4 ^ (m + 1) * n) : x % 4 = 0 := by
grind
/--
info: Try these:
[apply] grind only [usr Nat.div_pow_of_pos, usr Nat.dvd_mul_right_of_dvd]
[apply] grind =>
instantiate only [usr Nat.div_pow_of_pos]
instantiate only [usr Nat.dvd_mul_right_of_dvd]
lia
-/
#guard_msgs in
example {x m n : Nat} (h : x = 4 ^ (m + 1) * n) : x % 4 = 0 := by
grind?
example {x m n : Nat} (h : x = 4 ^ (m + 1) * n) : x % 4 = 0 := by
grind only [usr Nat.div_pow_of_pos, usr Nat.dvd_mul_right_of_dvd]
example {x m n : Nat} (h : x = 4 ^ (m + 1) * n) : x % 4 = 0 := by
grind =>
instantiate only [usr Nat.div_pow_of_pos]
instantiate only [usr Nat.dvd_mul_right_of_dvd]
lia
example {x m n : Nat} (h₁ : x = 4 ^ (m + 1) * n) : x % 4 = 0 := by
grind
example {x m n : Nat} (h₁ : x = 4 ^ m * n) : m > 0 → x % 4 = 0 := by
grind
example {x m n : Nat} (h₁ : x = n * 4 ^ (m + 1) * n) : x % 4 = 0 := by
grind
example {a b x m n : Nat} (h₁ : x = b * a * 4 ^ (m + 1) * n) : x % 4 = 0 := by
grind
example {a b x m n : Nat} (h₁ : x = b * 4 ^ m * a * 3 ^ n) : n > 0 → m > 0 → x % 12 = 0 := by
grind
example {a b x m n : Nat} (h₁ : x = b * 4 ^ m * a * 3 ^ n) : n > 0 → m > 0 → x % 6 = 0 := by
grind
example (m n : Nat) (h : 4 m) : 4 m * n := by
grind
example (a m n : Nat) (h : a m) : a m * n := by
grind
example (a m n o p : Nat) : a m → a m * n * o * p := by
grind
example {a b x m n : Nat}
: x = b * 4 ^ m * a → a = 3^n → n > 0 → m > 0 → x % 12 = 0 := by
grind
example {a b x m n : Nat}
: n > 0 → x = b * 4^m * a → a = 9^n → m > 0 → x % 6 = 0 := by
grind
example {a n : Nat}
: a = 2^(3^n) → a % 2 = 0 := by
grind
example {a n : Nat}
: m > 4 → a = 2^(m^n) → a % 2 = 0 := by
grind