math-comp / algebra-tactics

Ring, field, lra, nra, and psatz tactics for Mathematical Components
29 stars 1 forks source link

Coq's ring tactic works with semi-ring where mc.a-t doesn't #68

Closed SnarkBoojum closed 1 year ago

SnarkBoojum commented 1 year ago

I was experimenting with the limitations of automatic tactics when I found an example where Coq's ring tactic could solve a goal and algebra-tactics' couldn't.

I could extract a simpler example from my proof script:

From mathcomp Require Import ssreflect ssrnat.

Lemma foo n: n * n.+1 * n.*2.+1 + 6 * n.+1 ^ 2 = n.+1 * n.+2 * (n.+1).*2.+1.
Proof.
Fail ring.
rewrite -!muln2.
ring.
Qed.

From mathcomp.algebra_tactics Require Import ring.

Lemma foo_bis n: n * n.+1 * n.*2.+1 + 6 * n.+1 ^ 2 = n.+1 * n.+2 * (n.+1).*2.+1.
Proof.
Fail ring.
rewrite -!muln2.
Fail ring.
Admitted.
SnarkBoojum commented 1 year ago

Now I find the time to dig a little more: the issue here is that natural numbers don't form a ring.

But they form what is called a semi-ring, so perhaps it's possible to do something about them.

pi8027 commented 1 year ago

Duplicate of #40

I would suggest using lia instead.