This PR implements support for (commutative) semirings in `grind`. It
uses the Grothendieck completion to construct a (commutative) ring
`Lean.Grind.Ring.OfSemiring.Q α` from a (commutative) semiring `α`. This
construction is mostly useful for semirings that implement
`AddRightCancel α`. Otherwise, the function `toQ` is not injective.
Examples:
```lean
example (x y : Nat) : x^2*y = 1 → x*y^2 = y → y*x = 1 := by
grind
example [CommSemiring α] [AddRightCancel α] (x y : α) : x^2*y = 1 → x*y^2 = y → y*x = 1 := by
grind
example (a b : Nat) : 3 * a * b = a * b * 3 := by grind
example (k z : Nat) : k * (z * 2 * (z * 2 + 1)) = z * (k * (2 * (z * 2 + 1))) := by grind
example [CommSemiring α] [AddRightCancel α] [IsCharP α 0] (x y : α)
: x^2*y = 1 → x*y^2 = y → x + y = 1 → False := by
grind
```
30 lines
1 KiB
Text
30 lines
1 KiB
Text
example (n t : Nat) : 1 ^ (n / 3) * 2 ^ t = 2 ^ t := by grind
|
||
|
||
example (n t : Nat) : (1 : Int) ^ (n / 3) * 2 ^ t = 2 ^ t := by grind
|
||
|
||
open Lean Grind
|
||
|
||
example (x y : Nat) : x + y = 1 → y + x = 1 := by
|
||
grind -cutsat -linarith
|
||
|
||
example (x y : Nat) : x^2*y = 1 → x*y^2 = y → y*x = 1 := by
|
||
grind -cutsat -linarith
|
||
|
||
example (x y : Nat) : x + y = 1 → x + z + y = 2 → z = 0 → False := by
|
||
grind -cutsat -linarith
|
||
|
||
example [CommSemiring α] [AddRightCancel α] [IsCharP α 0] (x y z : α)
|
||
: x + y = 1 → x + z + y = 2 → z = 0 → False := by
|
||
grind -cutsat -linarith
|
||
|
||
example (x y : Nat) : x^2*y = 1 → x*y^2 = y → y*x = 1 := by
|
||
grind
|
||
|
||
example [CommSemiring α] [AddRightCancel α] (x y : α) : x^2*y = 1 → x*y^2 = y → y*x = 1 := by
|
||
grind -cutsat -linarith
|
||
|
||
example [CommSemiring α] [AddRightCancel α] (x y : α) : x^2*y = 1 → x*y^2 = y → y*x = 1 := by
|
||
grind
|
||
|
||
example [CommSemiring α] [AddRightCancel α] [IsCharP α 0] (x y : α) : x^2*y = 1 → x*y^2 = y → x + y = 1 → False := by
|
||
grind
|